<?php
$msg = '';

include("include/settings.php");
include("checksession.php");



$usermaster=$mysqli->prepare("select *,(select count(*) from rishta_leadmaster where source='website') as website_count 
,(select count(*) from rishta_leadmaster where source='walk-in') as walk
,(select count(*) from rishta_leadmaster where source='social_media') as social
,(select count(*) from rishta_leadmaster where source='events') as events
,(select count(*) from rishta_leadmaster where source='530 AM Punjabi Lehran Navi Sidhu Canada') as Punjabi
,(select count(*) from rishta_leadmaster where source='530 AM Des Pardes Tajinder Sidhu Canada') as sidhu
,(select count(*) from rishta_leadmaster where source='1610 AM Gaunda Punjab Joginder Bassi Canada') as Gaunda
,(select count(*) from rishta_leadmaster where source='1320 AM Fulkari Raj &amp; Harjot Canada') as Fulkari
,(select count(*) from rishta_leadmaster where source='1320 AM Parvasi Rajinder Saini Canada') as Parvasi
,(select count(*) from rishta_leadmaster where source='810 AM Radio Dhamaal Bhupinder Toor Canada') as Dhamaal
,(select count(*) from rishta_leadmaster where source='Channel Y TV Yudhvir Jaiswal Canada') as Jaiswal
,(select count(*) from rishta_leadmaster where source='Red FM Vancouver Canada') as Red
,(select count(*) from rishta_leadmaster where source='1550 AM Vancouver Canada') as Vancouver
,(select count(*) from rishta_leadmaster where source='101.3 FM Asian Connections Ranbir Chuhan Canada') as Asian
,(select count(*) from rishta_leadmaster where source='101.7 World FM Edmonton Canada') as Edmonton
,(select count(*) from rishta_leadmaster where source='Desh Punjab Radio Edmonton Canada') as Radio
,(select count(*) from rishta_leadmaster where source='1610 AM Radio Humsafar Montreal Canada') as Humsafar
,(select count(*) from rishta_leadmaster where source='Radio Awaz Winnipeg Canada') as Awaz
,(select count(*) from rishta_leadmaster where source='Red FM Calgary Canada') as Calgary
,(select count(*) from rishta_leadmaster where source='Radio Punjab USA') as Punjab
,(select count(*) from rishta_leadmaster where source='Panjab Radio UK') as UK
,(select count(*) from rishta_leadmaster where source='Raaj FM UK') as Raaj
,(select count(*) from rishta_leadmaster where source='Kohinoor Radio UK') as Kohinoor
,(select count(*) from rishta_leadmaster where source='Haanji Radio Australia') as Haanji
,(select count(*) from rishta_leadmaster where source='Lesiter Radio') as Lesiter
,(select count(*) from rishta_leadmaster where source='Hayes Mela') as Hayes
,(select count(*) from rishta_leadmaster where source='Zee London Mela') as Mela
,(select count(*) from rishta_leadmaster where source='Tehalka TV') as TV
,(select count(*) from rishta_leadmaster where source='Tehalka Radio') as Tehalka
,(select count(*) from rishta_leadmaster where source='Jus Punjab') as Jus
,(select count(*) from rishta_leadmaster where source='Prime Asia Tv') as Prime
,(select count(*) from rishta_leadmaster where source='PTC Punjabi') as PTC
,(select count(*) from rishta_leadmaster where source='Sign Board') as Sign
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Amritsar') as Amritsar
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Jalandhar') as Jalandhar
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Chandigarh') as Chandigarh

from rishta_leadmaster where lead_type='rishta_lead'");
$usermaster->execute();
$userresult=$usermaster->get_result();
$userrow=mysqli_fetch_object($userresult);




$usermasters=$mysqli->prepare("select *,(select count(*) from rishta_leadmaster where source='website' AND disposition='Fully Paid') as website_count 
,(select count(*) from rishta_leadmaster where source='walk-in' AND disposition='Fully Paid') as walk
,(select count(*) from rishta_leadmaster where source='social_media' AND disposition='Fully Paid') as social
,(select count(*) from rishta_leadmaster where source='events' AND disposition='Fully Paid') as events
,(select count(*) from rishta_leadmaster where source='530 AM Punjabi Lehran Navi Sidhu Canada' AND disposition='Fully Paid') as Punjabi
,(select count(*) from rishta_leadmaster where source='530 AM Des Pardes Tajinder Sidhu Canada' AND disposition='Fully Paid') as sidhu
,(select count(*) from rishta_leadmaster where source='1610 AM Gaunda Punjab Joginder Bassi Canada' AND disposition='Fully Paid') as Gaunda
,(select count(*) from rishta_leadmaster where source='1320 AM Fulkari Raj &amp; Harjot Canada' AND disposition='Fully Paid') as Fulkari
,(select count(*) from rishta_leadmaster where source='1320 AM Parvasi Rajinder Saini Canada' AND disposition='Fully Paid') as Parvasi
,(select count(*) from rishta_leadmaster where source='810 AM Radio Dhamaal Bhupinder Toor Canada' AND disposition='Fully Paid') as Dhamaal
,(select count(*) from rishta_leadmaster where source='Channel Y TV Yudhvir Jaiswal Canada' AND disposition='Fully Paid') as Jaiswal
,(select count(*) from rishta_leadmaster where source='Red FM Vancouver Canada' AND disposition='Fully Paid') as Red
,(select count(*) from rishta_leadmaster where source='1550 AM Vancouver Canada' AND disposition='Fully Paid') as Vancouver
,(select count(*) from rishta_leadmaster where source='101.3 FM Asian Connections Ranbir Chuhan Canada' AND disposition='Fully Paid') as Asian
,(select count(*) from rishta_leadmaster where source='101.7 World FM Edmonton Canada' AND disposition='Fully Paid') as Edmonton
,(select count(*) from rishta_leadmaster where source='Desh Punjab Radio Edmonton Canada' AND disposition='Fully Paid') as Radio
,(select count(*) from rishta_leadmaster where source='1610 AM Radio Humsafar Montreal Canada' AND disposition='Fully Paid') as Humsafar
,(select count(*) from rishta_leadmaster where source='Radio Awaz Winnipeg Canada' AND disposition='Fully Paid') as Awaz
,(select count(*) from rishta_leadmaster where source='Red FM Calgary Canada' AND disposition='Fully Paid') as Calgary
,(select count(*) from rishta_leadmaster where source='Radio Punjab USA' AND disposition='Fully Paid') as Punjab
,(select count(*) from rishta_leadmaster where source='Panjab Radio UK' AND disposition='Fully Paid') as UK
,(select count(*) from rishta_leadmaster where source='Raaj FM UK' AND disposition='Fully Paid') as Raaj
,(select count(*) from rishta_leadmaster where source='Kohinoor Radio UK' AND disposition='Fully Paid') as Kohinoor
,(select count(*) from rishta_leadmaster where source='Haanji Radio Australia' AND disposition='Fully Paid') as Haanji
,(select count(*) from rishta_leadmaster where source='Lesiter Radio' AND disposition='Fully Paid') as Lesiter
,(select count(*) from rishta_leadmaster where source='Hayes Mela' AND disposition='Fully Paid') as Hayes
,(select count(*) from rishta_leadmaster where source='Zee London Mela' AND disposition='Fully Paid') as Mela
,(select count(*) from rishta_leadmaster where source='Tehalka TV' AND disposition='Fully Paid') as TV
,(select count(*) from rishta_leadmaster where source='Tehalka Radio' AND disposition='Fully Paid') as Radio
,(select count(*) from rishta_leadmaster where source='Jus Punjab' AND disposition='Fully Paid') as Jus
,(select count(*) from rishta_leadmaster where source='Prime Asia Tv' AND disposition='Fully Paid') as Prime
,(select count(*) from rishta_leadmaster where source='PTC Punjabi' AND disposition='Fully Paid') as PTC
,(select count(*) from rishta_leadmaster where source='Sign Board' AND disposition='Fully Paid') as Sign
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Amritsar' AND disposition='Fully Paid') as Amritsar
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Jalandhar' AND disposition='Fully Paid') as Jalandhar
,(select count(*) from rishta_leadmaster where source='94.3 MY FM Chandigarh' AND disposition='Fully Paid') as Chandigarh

from rishta_leadmaster where lead_type='rishta_lead'");
$usermasters->execute();
$userresults=$usermasters->get_result();
$userrows=mysqli_fetch_object($userresults);


?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Sales Status Report - Rishta Depot</title>
  
		
<?php include('./include/meta.php'); ?>
  
</head>

	
<?php include('./include/header.php'); ?>
  
  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
	  <div class="container-full">
		<!-- Content Header (Page header) -->
		<div class="content-header">
			<div class="d-flex align-items-center">
				<div class="me-auto">
					<h4 class="page-title">Reports</h4>
					<div class="d-inline-block align-items-center">
						<nav>
							<ol class="breadcrumb">
								<li class="breadcrumb-item"><a href="#"><i class="mdi mdi-home-outline"></i></a></li>
								<li class="breadcrumb-item" aria-current="page">Sales Status Report</li>
								<li class="breadcrumb-item active" aria-current="page">Reports</li>
							</ol>
						</nav>
					</div>
				</div>
				
			</div>
		</div>

		<!-- Main content -->
		<section class="content">
		  <div class="row">
			<div class="col-12">

			 <div class="box">
				<div class="box-header with-border">
				  <h3 class="box-title">Sales Status Report</h3>
				</div>
			<form action="#" method="post" enctype="multipart/form-data">
					<div class="box-body">
					         <?php
                    if (trim($msg) != null) {
                        ?>
                        <div class='row'>
                            <div class='col-md-12'>
                                <div class="alert alert-success errormessage" id="errormessage">
                                    <strong><?php echo $msg ?></strong>
                                </div>
                            </div>
                        </div>
                        <?php
                    }
                    ?>
						
						<div class="row">
						  <div class="col-md-4">
							<div class="form-group">
							  <input placeholder='Start Date' type="date" id="txtFromDate" name="txtFromDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
                    </div>
						  </div>
						  <div class="col-md-4">
							<div class="form-group">
							 <input placeholder='End Date' type="date" id="txtToDate" name="txtToDate" class="form-control" autocomplete='off' onchange="getLeads()"/>
                    </div>
						  </div>
						</div>
					</div>
				</form>
				<!-- /.box-header -->
				<div class="box-body"  id="ajaxcoursedata">
					<div class="table-responsive">
					  <table  class="table table-bordered table-striped">
						<thead>
							<tr>
							
								<th>Lead Source</th>
								<th>Total</th>
								<th>Conversion Count</th>
							</tr>
						</thead>
								<tbody>
											        
													
													                 <tr class="text-center"> <td>Website</td>
													                 <td><?php echo $userrow->website_count ?></td>
													                 <td><?php echo $userrows->website_count ?></td>
													                 </tr>
													                  <tr class="text-center"> <td>Walk-In</td>
													                 <td><?php echo $userrow->walk ?></td>
													              <td><?php echo $userrows->walk ?></td>
													                 </tr>
													                   <tr class="text-center"> <td>Social Media</td>
													                 <td><?php echo $userrow->social ?></td>
													                 <td><?php echo $userrows->social ?></td>
													                 </tr>
													                   <tr class="text-center"> <td>Events</td>
													                 <td><?php echo $userrow->events ?></td>
													                      <td><?php echo $userrows->events ?></td>
													                 </tr>
													                   <tr class="text-center"> <td>530 AM Punjabi Lehran Navi Sidhu Canada</td>
													                 <td><?php echo $userrow->Punjabi ?></td>
													                <td><?php echo $userrows->Punjabi ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>530 AM Des Pardes Tajinder Sidhu Canada</td>
													                 <td><?php echo $userrow->sidhu ?></td>
													                <td><?php echo $userrows->sidhu ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>1610 AM Gaunda Punjab Joginder Bassi Canada</td>
													                 <td><?php echo $userrow->Gaunda ?></td>
													                <td><?php echo $userrows->Gaunda ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>1320 AM Fulkari Raj &amp; Harjot Canada</td>
													                 <td><?php echo $userrow->Fulkari ?></td>
													                <td><?php echo $userrows->Fulkari ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>1320 AM Parvasi Rajinder Saini Canada</td>
													                 <td><?php echo $userrow->Parvasi ?></td>
													                <td><?php echo $userrows->Parvasi ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>810 AM Radio Dhamaal Bhupinder Toor Canada</td>
													                 <td><?php echo $userrow->Dhamaal ?></td>
													                <td><?php echo $userrows->Dhamaal ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Channel Y TV Yudhvir Jaiswal Canada</td>
													                 <td><?php echo $userrow->Jaiswal ?></td>
													                <td><?php echo $userrows->Jaiswal ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Red FM Vancouver Canada</td>
													                 <td><?php echo $userrow->Red ?></td>
													                <td><?php echo $userrows->Red ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>1550 AM Vancouver Canada</td>
													                 <td><?php echo $userrow->Vancouver ?></td>
													                <td><?php echo $userrows->Vancouver ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>101.3 FM Asian Connections Ranbir Chuhan Canada</td>
													                 <td><?php echo $userrow->Asian ?></td>
													                <td><?php echo $userrows->Asian ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>101.7 World FM Edmonton Canada</td>
													                 <td><?php echo $userrow->Edmonton ?></td>
													                <td><?php echo $userrows->Edmonton ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Desh Punjab Radio Edmonton Canada</td>
													                 <td><?php echo $userrow->Radio ?></td>
													                <td><?php echo $userrows->Radio ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>1610 AM Radio Humsafar Montreal Canada</td>
													                 <td><?php echo $userrow->Humsafar ?></td>
													                <td><?php echo $userrows->Humsafar ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Radio Awaz Winnipeg Canada</td>
													                 <td><?php echo $userrow->Awaz ?></td>
													                <td><?php echo $userrows->Awaz ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Red FM Calgary Canada</td>
													                 <td><?php echo $userrow->Calgary ?></td>
													                <td><?php echo $userrows->Calgary ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Radio Punjab USA</td>
													                 <td><?php echo $userrow->Punjab ?></td>
													                <td><?php echo $userrows->Punjab ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Panjab Radio UK</td>
													                 <td><?php echo $userrow->UK ?></td>
													                <td><?php echo $userrows->UK ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Raaj FM UK</td>
													                 <td><?php echo $userrow->Raaj ?></td>
													                <td><?php echo $userrows->Raaj ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Kohinoor Radio UK</td>
													                 <td><?php echo $userrow->Kohinoor ?></td>
													                <td><?php echo $userrows->Kohinoor ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Haanji Radio Australia</td>
													                 <td><?php echo $userrow->Haanji ?></td>
													                <td><?php echo $userrows->Haanji ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Lesiter Radio</td>
													                 <td><?php echo $userrow->Lesiter ?></td>
													                <td><?php echo $userrows->Lesiter ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Hayes Mela</td>
													                 <td><?php echo $userrow->Hayes ?></td>
													                <td><?php echo $userrows->Hayes ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Zee London Mela</td>
													                 <td><?php echo $userrow->Mela ?></td>
													                <td><?php echo $userrows->Mela ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Tehalka TV</td>
													                 <td><?php echo $userrow->TV ?></td>
													                <td><?php echo $userrows->TV ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Tehalka Radio</td>
													                 <td><?php echo $userrow->Tehalka ?></td>
													                <td><?php echo $userrows->Tehalka ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Jus Punjab</td>
													                 <td><?php echo $userrow->Jus ?></td>
													                <td><?php echo $userrows->Jus ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Prime Asia Tv</td>
													                 <td><?php echo $userrow->Prime ?></td>
													                <td><?php echo $userrows->Prime ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>PTC Punjabi</td>
													                 <td><?php echo $userrow->PTC ?></td>
													                <td><?php echo $userrows->PTC ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>Sign Board</td>
													                 <td><?php echo $userrow->Sign ?></td>
													                <td><?php echo $userrows->Sign ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>94.3 MY FM Amritsar</td>
													                 <td><?php echo $userrow->Amritsar ?></td>
													                <td><?php echo $userrows->Amritsar ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>94.3 MY FM Jalandhar</td>
													                 <td><?php echo $userrow->Jalandhar ?></td>
													                <td><?php echo $userrows->Jalandhar ?></td>
													                 </tr>
													                 <tr class="text-center"> <td>94.3 MY FM Chandigarh</td>
													                 <td><?php echo $userrow->Chandigarh ?></td>
													                <td><?php echo $userrows->Chandigarh ?></td>
													                 </tr>
													                 
             
														
												</tbody>
				
					  </table>
					</div>
				</div>
				<!-- /.box-body -->
			  </div>
			  <!-- /.box -->


			  <!-- /.box -->          
			</div>
			<!-- /.col -->
		  </div>
		  <!-- /.row -->
		</section>
		<!-- /.content -->
	  
	  </div>
  </div>
  <!-- /.content-wrapper -->
  <script>
    function getLeads() {

        var txtFromDate = $('#txtFromDate').val();
        var txtToDate = $('#txtToDate').val();
        var txtSearch = $('#txtSearch').val();

        var ddlUserId = $('#ddlUserId').val();

    


        $('#loading').css('display', '');
        $.ajax({
            url: 'sale_status_ajax.php',
            type: 'post',
            data: {
                ddlUserId: ddlUserId,

            
                txtFromDate: txtFromDate,
                txtToDate: txtToDate,
                txtSearch: txtSearch,
      
            },
            datatype: 'html',
            success: function (rsp) {
                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');
            }
        });
    }
    
    
 function getLeadsPagination(page_skip) {
        var txtFromDate = $('#txtFromDate').val();
        var txtToDate = $('#txtToDate').val();
        var txtSearch = $('#txtSearch').val();
       
        var ddlUserId = $('#ddlUserId').val();

        $('#loading').css('display', '');
        $.ajax({
            url: 'sale_status_ajax.php',
            type: 'post',
            data: {"ddlUserId": ddlUserId, "txtFromDate": txtFromDate, "txtToDate": txtToDate, "txtSearch": txtSearch, "page_skip": page_skip},
            datatype: 'html',
            success: function (rsp) {
                $('#ajaxcoursedata').html(rsp);
                $('#loading').css('display', 'none');
            }
        });
    }


    function changeLeadAllocation(executive_id, lead_id) {
        $('#loading').css('display', '');
        $.ajax({
            url: 'allocate_lead.php',
            type: 'post',
            data: {"executive_id": executive_id, "lead_id": lead_id},
            datatype: 'html',
            success: function (rsp) {
                $('#loading').css('display', 'none');
            }
        });
    }

  

    $(document).ready(function () {
        $("#txtFromDate,#txtToDate").datepicker({
            dateFormat: 'yy-mm-dd',
			//dateFormat: 'mm/dd/yy'
            // minDate: 0, // 0 days offset = today
        });
    });
</script>
	    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<?php include('./include/footer.php'); ?>
