<!-- begin:: Subheader -->
<div class="kt-subheader   kt-grid__item" id="kt_subheader">
<div class="kt-container  kt-container--fluid ">
    <div class="kt-subheader__main">
        <div class="kt-subheader__breadcrumbs">
            <a class="kt-subheader__breadcrumbs-link">
                Reports </a>
            <span class="kt-subheader__breadcrumbs-separator"></span>
            <a  class="kt-subheader__breadcrumbs-link">
            Leads Distribution Analysis </a>
            <span class="kt-subheader__breadcrumbs-separator"></span>
            
        </div>
    </div>
    <div class="kt-subheader__toolbar">        
       <!--  <a href="<?=base_url();?>reports/export_lead_report?center_name=0&year=<?=(isset($_GET['year']) && $_GET['year'] !=''? $_GET['year']:CURRENT_SESSION);?>" class="btn btn-label-brand btn-bold">
            <i class="flaticon-download"></i> Export to Excel</a>-->
    </div>                                        
</div>
</div>
<!-- end:: Subheader -->
<!-- begin:: Content -->
<div class="kt-container  kt-container--fluid  kt-grid__item kt-grid__item--fluid">
   <div class="kt-portlet">
      <div class="kt-portlet__body kt-portlet__body--fit">
       <div class="kt-portlet__body">
            <form name="filter" method="get">          
                <div class="row justify-content-between">
                    <div class="col-sm-3" style="margin-bottom: 10px;">
                       <?php if(isset($_GET['cdate_from']) && $_GET['cdate_from']!=''){
                           echo $_GET['cdate_from'] .' - ';
                        }else{
                            echo '1st ' .date('M').' - ';
                        }
                        ?>
                        <?php if(isset($_GET['cdate_to']) && $_GET['cdate_to']!=''){
                           echo $_GET['cdate_to'];
                        }else{
                            echo date('t').'th '.date('M');
                        }
                        ?>
                        Reports
                    </div>                
                    <div class="col-sm-3" style="margin-bottom: 10px;">
                        <input type="text" name="cdate_from" class="form-control" placeholder="Sales Date From" aria-controls="kt_table_1" id="datepicker" value="<?=(isset($_GET['cdate_from']) && $_GET['cdate_from']!='' ? $_GET['cdate_from']:'');?>"autocomplete="off" >
                    </div>
                    <div class="col-sm-3" style="margin-bottom: 10px;">
                        <input type="text" name="cdate_to" class="form-control" placeholder="Sales Date To" aria-controls="kt_table_1" id="datepicker1" value="<?=(isset($_GET['cdate_to']) && $_GET['cdate_to']!='' ? $_GET['cdate_to']:'');?>" autocomplete="off">
                    </div>                    
                    <div class="col-sm-3" style="margin-bottom: 10px;">
                        <button type="submit" class="btn btn-info" style="width: 100%;">Apply</button>
                    </div>
                </div>
            </form>
            <div class="row">
                <div class="col-sm-12 table-scrollable">
                    <!--begin: Datatable -->
                    <table class="table table-striped- table-bordered table-hover table-checkable" id="kt_table_1">
                        <thead>
                            <tr>                                           
                                <th> Owner Name </th>   
                                <th> Prospect Stage </th>                                  
                                <?php $lead_source = get_lead_source_list();?>  
                                <?php foreach($lead_source as $value){ ?>
                                    <th> <?=$value['name'];?> </th>
                                <?php } ?>  
                                <th> Total Lead </th>                                                               
                            </tr>
                        </thead>
                        <tbody>
                        <?php
                            if(empty($report_data) ===FALSE){
                                foreach ($report_data as $key){
                                ?>
                                    <tr>                        
                                        <td>
                                        <?php if($key->user_id == '1'){ ?>
                                          Admin
                                        <?php }else{ ?>
                                        <?php $center_details = get_center_by_id($key->user_id); ?>
                                            <?=ucfirst($center_details[0]['user_name']);?>
                                        <?php } ?>
                                        </td>  
                                        <td><?php
                                        if(isset($key->activity_type) && $key->activity_type!=''){
                                         $stage = get_disposition_by_id($key->activity_type);
                                           echo $stage['name'];
                                        }else{
                                            echo 'Fresh';
                                        }
                                        ?></td>                                     
                                       <?php foreach($lead_source as $value){ ?>
                                        <td> <?=(isset($key->lead_source) && $key->lead_source == $value['name']) ? $value['name'] : '';?></td>
                                        <?php } ?> 
                                        <td><?=$key->total;?></td>               
                                    </tr>
                            <?php  }}else{ ?>
                                <tr class="odd"><td valign="top" colspan="13" style="color: #595d6e;text-align: center;">No matching records found.</td></tr>
                            <?php } ?>                                        
                        </tbody>
                    </table>
                </div>
            </div>

            <!--end: Datatable -->
        </div>
      </div>
   </div>
</div>
