<?php    include_once('../config/db.php');  include_once('../config/check.php'); 



if (filter_has_var(INPUT_POST, "delete")) 
 try{
       
         
   } catch(Exception $e) { echo 'Message: ' .$e->getMessage();}



?>

<!DOCTYPE html>
<html>
<head>
 
<?php include_once('../inc/slink.php');   ?>  
 
</head>


<body <?php include_once('../inc/snav.php');  ?>>
<div class="wrapper">

  <!-- Main Header -->
    <header class="main-header">

    <!-- Logo -->
       <?php include_once('../inc/sbrand.php');   ?>

    <!-- Header Navbar -->
    <?php include_once('../inc/snavbar.php');   ?>

  </header>
 
  <!-- Left side column. contains the logo and sidebar -->
    <aside class="main-sidebar">

    <!-- sidebar: style can be found in sidebar.less -->
     <?php include_once('../inc/smenu.php');   ?>
    <!-- /.sidebar -->
  </aside>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
   

  <section class="content-header">
    <div class="col-md-12 ">
      <div class="col-md-3">
      <p style="color:green; font-size:20px ;font-weight:bold; " > <i class="fa fa-file" ></i> Lead Activities  </p>
      
               
      </div>
           
      <div class="col-md-3  " class="mybtn" id="mybtn"  >
      </div>  
      <div class="col-md-6 pull-right"   >
            
        <div class="col-sm-12 row"> 
            <div class="col-md-6" id="mysearchbox">
              
            </div>               
            <div class="col-md-3">
                <input type="text" id="min" name="min" placeholder="start date" class="form-control" >
            </div>               
            <div class="col-md-3">
                  <input type="text" id="max" name="max"  placeholder="End date" class="form-control" >
            </div>               
                          
                                                                    
        </div> 
    </div>
   </section>


  
  <!-- Main content -->
  <section class="content container-fluid">
    <div class="row">        
        <div class="col-md-12">
        <div class="box box-default box-xs">
          <div class="box-body">
                            
                <!-- Filter END -->
            <div class="col-xs-12">
         

            <table id="customer_data" width="100%" class="table table-condensed  table-small table-responsive ">
                
                <thead class="bg-primary">
                    <th >  </th>
                    <th >  </th>
                    <th >  </th>
                    <th > Date </th>
                    <th > Name   </th>
                    <th > Description </th>
                                    
                  </thead>
                  <tbody></tbody>
       
            </table>
                
            </div>
          </div>
        </div>
         
        </div>
        <!-- /.col -->
      </div>
  </section>
  
</div>
  <!-- /.content-wrapper -->
  
  <!-- Main Footer -->
  <footer class="main-footer">
    <?php  include_once('../inc/footer.php'); ?>
  </footer>
  
</div>
                         
<!-- ./wrapper -->

<!-- REQUIRED JS SCRIPTS -->
<?php  include_once('../inc/slinkjs.php') ?>


</body>
</html>

<!-- dynamic rows start here -->
<!-- DYANAMIC ROWS LISTING HERE --->
<script type="text/javascript" language="javascript" ></script>

<script>

var minDate, maxDate;
 
// Custom filtering function which will search data in column four between two values
$.fn.dataTable.ext.search.push(
    function( settings, data, dataIndex ) {
        var min = minDate.val();
        var max = maxDate.val();
        var date = new Date( data[3] );
 
        if (
            ( min === null && max === null ) ||
            ( min === null && date <= max ) ||
            ( min <= date   && max === null ) ||
            ( min <= date   && date <= max )
        ) {
            return true;
        }
        return false;
    }
);
 
$(document).ready(function() {
    // Create date inputs
    minDate = new DateTime($('#min'), {
        format: 'MMMM Do YYYY'
    });
    maxDate = new DateTime($('#max'), {
        format: 'MMMM Do YYYY'
    });
 
    // DataTables initialisation
       var table= $('#customer_data').DataTable( { 
                    "scrollX": true,
 
                    "language": {
                      searchPlaceholder: "Search here",
                      search: "" },
                    "pageLength": 10,
                    "dom": '<"top"f>rt<"bottom"ilp><"clear">',
                     ajax: {
                           url: 'filter/crm_leadsource.php'
                     },
                     footerCallback: function (row, data, start, end, display) {
                          var api = this.api();
              
                          // Remove the formatting to get integer data for summation
                          var intVal = function (i) {
                              return typeof i === 'string' ? i.replace(/[\$,]/g, '') * 1 : typeof i === 'number' ? i : 0;
                          };
              
                          // Total over all pages
                          // Total over this page
                          // Update footer                      
                         
                      }

       
                 } );

                 // start btn
                      
                 codeListTable = $("#customer_data").DataTable();
                        new $.fn.dataTable.Buttons( codeListTable, {
                            buttons: [
                          
                                {
                                extend:    'excel',
                                footer: true,
                                text:      '<i class="fa fa-files-o"></i> Excel',
                                titleAttr: 'Excel',
                                className: 'btn btn-default btn-sm',
                                exportOptions: {
                                    footer: true,
                                    columns: ':visible'
                                }
                                },
                                {
                                extend:    'pdf',
                                text:      '<i class="fa fa-file-pdf-o"></i> PDF',
                                titleAttr: 'PDF',
                                className: 'btn btn-default btn-sm',
                                exportOptions: {
                                    columns: ':visible'
                                }
                                },               
                                {
                                extend:    'print',
                                text:      '<i class="fa fa-print"></i> Print',
                                titleAttr: 'Print',
                                className: 'btn btn-default btn-sm',
                                exportOptions: {
                                    columns: ':visible'
                                }
                                },  
                            ]
                        } );
                        codeListTable.buttons().container().appendTo('#mybtn');  
                         $(".dataTables_filter").detach().appendTo("#mysearchbox");
                          

                      // end btn 

 
    // Refilter the table
    $('#min, #max').on('change', function () {
        table.draw();
    });


});


</script>
