 <script src="<?php echo base_url();?>assets/choosen.js"></script>
<link rel="stylesheet" href="<?php echo base_url();?>assets/style.css">

 <div class="row">

                    <div class="col-12">
            
                           
                          <div class="col-xl-12 col-xxl-12 col-sm-12">
                             <div class="card">
    
                                <div class="card-body">
                                 
                   
                                   <div class="row">

                                       <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Material:</label>
                                                      <select name="material_id" id="material_id" class="form-control material_id" tabindex="-98">
                                                      <option value="">Select Material</option>
                                                      <?php foreach ($get_materials as $get_materials) { ?>
                                                          
                                                           <option value="<?php echo $get_materials['id']; ?>"><?php echo $get_materials['name']; ?></option>

                                                      <?php } ?>
                                                     
                                                      
                                                      </select>
                                                 </div>
                                                </div>

                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Machine:</label>
                                                    <select name="machine_id" id="machine_id" class="form-control machine_id" tabindex="-98">
                                                      <option value="">Select Machine</option>
                                                      <?php foreach ($get_machine as $get_machines) { ?>
                                                          
                                                           <option value="<?php echo $get_machines['id']; ?>"><?php echo $get_machines['machine_name']; ?></option>

                                                      <?php } ?>
                                                     
                                                      
                                                      </select>
                                                 </div>
                                                </div>


                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Products:</label>
                                                     <select name="product_id" id="product_id" class="form-control product_id" tabindex="-98">
                                                     <option value="">Select Products</option>
                                                      <?php foreach ($get_products1 as $get_products) { ?>
                                                          
                                                           <option value="<?php echo $get_products['id']; ?>"><?php echo $get_products['name']; ?></option>

                                                      <?php } ?>
                                                     
                                                      
                                                      </select>
                                                 </div>
                                                </div>

                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Operator:</label>
                                                      <select name="empolyee_id" id="empolyee_id" class="form-control empolyee_id" tabindex="-98">
                                                     <option value="">Select Operator</option>
                                                      <?php foreach ($operators as $operatorss) { ?>
                                                          
                                                           <option value="<?php echo $operatorss['id']; ?>"><?php echo $operatorss['fullname']; ?></option>

                                                      <?php } ?>
                                                     
                                                      
                                                      </select>
                                                 </div>
                                                </div>
                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                <div class="form-group">
                                                    <label class="form-label">Start Date:</label>
                                                     <input type="date" id="start_date" name="start_date"   class="form-control insert_date">
                                                 </div>
                                                </div>

                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                     			 <div class="form-group">
                                                    <label class="form-label">End Date:</label>
                                                     <input type="date" id="end_date" name="end_date"   class="form-control insert_date">
                                                 </div>
                                                </div>


                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Job#:</label>
                                                     <input type="number" id="job" name="job"   class="form-control insert_date">
                                                 </div>
                                                </div>


                                                <div class="col-lg-3 col-md-6 col-sm-12">
                                                 <div class="form-group">
                                                    <label class="form-label">Shift:</label>
                                                      <select name="shift" id="shift" class="form-control" tabindex="-98">
                                                     <option value="">Select Shift</option>
                                                    
                                                           <option value="1">Day</option>
                                                           <option value="2">Night</option>
                                                      </select>
                                                 </div>
                                                </div>
                                               
                                       <button type="button" id="filter"  class="btn btn-primary">Filter <i class="icon-arrow-right14 position-right"></i></button>
                                        </div>
                         
                              
                                    </div>
                              </div></div></div></div>

                              <div class="row">
                                   <div class="col-lg-12">
                                          <div class="card-body">
                                         <div id='party_danger' class='alert alert-danger solid' style='display:none;width: 25%;'></div>

                                      <div class="table-responsive">
                                         
                                          <div id="filter_datas">
                                              
                                      </div>

                                     </div>
                                  </div>    

                                 </div>
                              </div>
 
<script>

 $(".material_id").chosen();
 
  $(".product_id").chosen();
  
   $(".machine_id").chosen();

   
   $("#filter").click(function () {
    var start_date = $('#start_date').val();
    var end_date = $('#end_date').val();
    var material_id = $('#material_id').val();
    var machine_id = $('#machine_id').val();
    var product_id = $('#product_id').val();
    var empolyee_id = $('#empolyee_id').val();
    var job_no = $('#job').val();
    var shift = $('#shift').val();

    var conditions = [];

    if (material_id != '') {
        conditions.push("machine_daily_report.material_id = '" + material_id + "'");
    }

    if (machine_id != '') {
        conditions.push("machine_daily_report.machine_id = '" + machine_id + "'");
    }

    if (product_id != '') {
        conditions.push("machine_daily_report.product_id = '" + product_id + "'");
    }

    if (empolyee_id != '') {
        conditions.push("machine_daily_report.emp_id = '" + empolyee_id + "'");
    }

    if (job_no != '') {
        conditions.push("machine_daily_report.job = '" + job_no + "'");
    }

    if (shift != '') {
        conditions.push("qc_machine.day_night = '" + shift + "'");
    }

    if (start_date != '') {
        conditions.push("machine_daily_report.insert_date >= '" + start_date + "'");
    }

    if (end_date != '') {
        conditions.push("machine_daily_report.insert_date <= '" + end_date + "'");
    }

    var array_val = conditions.join(" AND ");

    $.ajax({
        type: 'POST',
        url: '<?php echo base_url('Admin/filter_summary_report'); ?>',
        data: { array_val: array_val },
        dataType: 'json',
        success: function (data) {
            $('#filter_datas').show().html(data.html);
        },
        error: function (data) {
            console.log(data.responseText);
        }
    });
});

 
</script>
                   
           