<!-- 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">
                All Conversion Analysis </a>
            <span class="kt-subheader__breadcrumbs-separator"></span>
            
        </div>
    </div>
    <div class="kt-subheader__toolbar">        
        
    </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> Admission/Registration Done </th>                                  
                                <?php $lead_source = get_lead_source_list();?>  
                                <?php foreach($lead_source as $value){ ?>
                                    <th> <?=$value['name'];?> </th>
                                <?php } ?>  
                                <th> Total Lead </th>   
                                <th>Conversion Ratio</th>                                 
                            </tr>
                        </thead>
                        <tbody>
                        <?php //print_r($report_data);
                            if(empty($report_data) ===FALSE){
                                foreach ($report_data as $key=>$value){                                    
                                ?>
                                    <tr>                      
                                        <td>
                                        <?php if($value['user_id'] == '1'){ ?>
                                          Admin
                                        <?php }else{ ?>
                                        <?php $center_details = get_center_by_id($value['user_id']); ?>
                                            <?=ucfirst($center_details[0]['user_name']);?>
                                        <?php } ?>
                                        </td>  
                                        <td><?php
                                        if(isset($value['sales_status']) && $value['sales_status']!=''){
                                          echo $value['sales_status'];
                                        }
                                        ?></td>
                                       <?php foreach($lead_source as $ls){ ?>
                                        <td><?=(isset($value['lead_source'][$ls['name']]) && $value['lead_source'][$ls['name']]!='' ? $value['lead_source'][$ls['name']]:'');?></td>
                                      <?php } ?>
                                       <td><?=$value['total_leads'];?></td>             
                                        <td>
                                        <?php
                                        if(isset($value['sales_status']) && $value['sales_status']!=''){
                                          echo $value['sales_status']/$value['total_leads'];
                                        }
                                        ?>   
                                        </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>
