<?php
	include('common/header.php'); 
?>
	<div class="">
		<div class="col-xm-12">
			<div class="widget-box light-border">
				
				<div class="widget-body">
					<div class="widget-main">
						<div class="row">
							<div class="col-sm-12">
								<form class="form-horizontal" role="form" method="post" name="module_form" id="module_form" action="<?php echo base_url();?>index.php/<?php echo DISPENSER_SALES_DATA;?>return_dispenser" onsubmit="return validateForm()">

                
                <input type="hidden" value="" id="dispenser_sales_id" name="dispenser_sales_id">
							<!-- 	<input type="hidden" value="<?php echo $this->_page_data['product_id']; ?>" name="product_id">

                <input type="hidden" value="<?php echo $this->_page_data['tracking_numbers_id'];?>" name="tracking_numbers_id">
                <input type="hidden" value="<?php echo $this->_page_data['company_branch_id']; ?>" name="company_branch_id"> -->
                 <!-- <input type="hidden" value="<?php echo $this->_page_data['tracking_number']; ?>" name="tracking_number"> -->

               <input type="hidden" value=" <?php echo $customer_id ?>" name="customer_id"> 

 								 <section class="panel panel-default">
                 				 <header class="panel-heading bg-info lt font-bold">Dispenser Details</header>
                  <!-- panel body start -->
                  <div class="panel-body bs-example form-horizontal">
                    <div class="">
                     <div class="hr hr12 dotted"></div>
                       <div class="">
                        <!-- main col-sm-12 -->
                  <div class="col-sm-12"> 
                          <div class="table-header">
      
                          </div>
                                    
                      <div class="table-responsive">

                       
                        <table id="example" cellspacing="0" width="100%" class="table table-bordered table-condensed">
                          <thead>
                            <tr>
                              <th class="text-center">Action</th>
                              <th class="text-center">Sr no</th>
                              <th class="text-center">Customer Name</th>
                              <th class="text-center">Dispenser Name</th>
                              <th class="text-center">Sale Type</th>
                              <th class="text-center">Branch Name</th>
                              <th class="text-center">Sale Person Name</th>
                              <th class="text-center">Refill Date</th>
                              <th class="text-center">Next Refill Date</th>
                              <!--<th class="text-center">Comments</th>-->
                              <th class="text-center">Tracking Number</th>
                              <th class="text-center">Returned</th>
                            </tr>   
                          </thead>
                          <tbody>
                            <?php 
                            $srno=1;
                            $count=count($return);
                            
                            if (!empty($return)) {
                            foreach ($return as $value) {?>        
                             <tr>
                              <td class="text-center"><input type="checkbox" name="check_action[]" onclick="get_check_value();" value="<?php echo $value['tracking_details_id'] ?>"></td>
                               <td class="text-center"><?php echo $srno; ?></td>
                               <td class="text-center"><?php echo $value['customer_name'];?></td>
                               
                               <td class="text-center"><?php echo $value['dispenser'];?></td>
                               <td class="text-center"><?php echo $value['sales_type'];?></td>
                               <td class="text-center"><?php echo $value['company_branch_name'];?></td>
                               <td class="text-center"><?php echo $value['first_name']." ".$value['last_name'];?></td>
                                <td>
                                   <?php 
                                if ($value['refill_date']=='0000-00-00') {?>
                                <label><?php echo $value['refill_date']; ?></label><?php }else{?>
                                <label><?php echo get_date_dmy_format_wo_time($value['refill_date']); ?></label>
                                <?php } ?>
                              </td>
                              <td>
                                  <?php 
                                 if ($value['next_refill_date']=='0000-00-00') {?>
                                 <label><?php echo $value['next_refill_date']; ?></label><?php }else{?>
                                 <label><?php echo get_date_dmy_format_wo_time($value['next_refill_date']); ?></label>
                                <?php } ?>
                              </td>
                             <!-- <td class="text-center"><?php echo $value['comments'];?></td>-->
                              <td class="text-center"><?php echo $value['tracking_number'];?></td>
                              <td class="text-center"><?php echo $value['is_returned'];?></td>
                             </tr> 
                              <?php 
                               $srno=$srno+1;
                            }
                            }
                             ?>
                          </tbody>
                        </table>
                      </div>
                         <span id="disp_comments1" class="text-danger font-weight-bold"></span>
                      <div class="hr hr12 dotted"></div>
                        <label class="col-sm-5 control-label" for="form-field-2" >Comment<font style="color:red">*</font></label>
                        <textarea name="return_comments" id="return_comments"></textarea>
                        <span id="return_comments1" class="text-danger font-weight-bold"></span>
                  </div>
                            
                         <!-- </div> -->
                         <!-- main col-sm-12  close-->
                       </div> <!-- blank close -->
        </div><!-- blank close -->
      </div>   <!-- panel body close -->
    </section> <!-- section close -->

  <div class="clearfix form-actions">
    <div class="col-md-offset-5 col-md-5"> 
    <button class="btn btn-info" type="button" onclick="javascript:window.location='<?php echo base_url();?>index.php/gc/dispenser_sale_data/search_return_dispenser'">
         Back
      </button> 
      <button class="btn btn-info" type="submit">
         Return Dispenser
      </button>
      <button class="btn btn-info" type="button" onclick="javascript:window.location='<?php echo base_url();?>index.php/gc/dispenser_sale_data/return_dispenser_list/<?php echo $customer_id?>/export'">
         Export to Excel
      </button>
      
    </div>
  </div>
																	                                  							      
								                           							      
								</div> 
								
								</form>	
							</div>
						</div>
					</div>	
				</div>
			</div>
		</div>
		<!-- /.col -->
	</div>

	
	<div class="space-4"></div>
		<!-- /.page-row -->
        <!-- /.page-content --> 
    </div>
    <!-- /.main-content --> 
	</div>
    <!-- /#ace-settings-container --> 
	</div>
	<!-- /.main-container-inner --> 
<?php
	include('common/footer.php');
?>
<!-- <script type="text/javascript">
$(document).ready(function() {
    $('form:first *:input[type!=hidden]:first').focus();
});
</script>  -->
<!-- <script type="text/javascript">
 $('#date-timepicker2').datepicker({dateFormat: 'dd-mm-yy'});
                 //format: 'MM/DD/YYYY h:mm:ss A',//use this option to display seconds
</script> -->

<script type="text/javascript">
    $(document).ready(function(){
       // $("#simple-table").hide();
        $("#action").hide();

        });
    function get_check_value(){
    var fav = [];
    $("input[name='check_action[]']:checked").each(function(){
       fav.push($(this).val());
    });
    document.getElementById("dispenser_sales_id").value = fav;
    // console.log(fav);
  }
</script>
<script type="text/javascript">
  
function validateForm(){
  var error=false;  
  
  var dispenser_sales_id=$("#dispenser_sales_id").val(); 
if(dispenser_sales_id=='')
  {
    $("#disp_comments1").html("Please Select atleast one dispenser");
    error=true; 
  }else{
    $('#disp_comments1').html("");
  }  
  var return_comments=$("#return_comments").val();  
  if(return_comments=='')
  {
    $("#return_comments1").html("Please Enter Comment");
    error=true; 
  }else{
    $('#return_comments1').html("");
  }
  if(error==true)
  {
    return false;
  }
  else
  {
    return true;   
  }


}
</script>

<!-- <script>
  $(document).ready(function(){
        $("#addrefill").click(function(){
          $("#simple-table").show();
      
       $("#action").show();
      //var id_count = 1;
            // var Dispenser_type = "<td><select name='customer_type' id='customer_type'><option>Select Product Name of Type dispenser</option><option>Dispenser1</option><option>Dispenser2</option><option>Dispenser3</option></select></td>";

            // var dispenser_quantity = "<td><input type='text' name='dispenser_quantity' placeholder='1'></td>";

            var srno= 2 ;


            var srno="<td>"+ srno +"</td>";

            var refill_name = "<td><select name='rname' id='rname'><option>Select Refill name</option><option>soap</option><option>paper</option><option>Watertreatment</option></select></td>"; 

          var programming_days = "<td><select name='rname' id='rname'><option>Select Programming Duration Days</option><option>15</option><option>30</option><option>45</option><option>60</option></select></td>"; 

                                                        
            var refill_quantity ="<td><input type='text' name='refill_quantity' style='width: 63px;' maxlength='3'></td>"; 



            var refill_duration = "<td><div class='input-group'style='width:183px;'><input id='date-timepicker3' type='text' class='form-control' style='width:144px;''></div></td>"; 

          var location ="<td><input type='text' name='location' placeholder='Enter Refill Location'></td>"; 
                                                            
                                                                                                                                                                                                 
            var tracking_no = "</thead><td><select name='tracking_no' style='width:218px;' multiple><option>JDU-123</option><option>JDU-124</option><option>JDU-125</option><option>JDU-130</option></select></td>";

            // var comments = "<td><div class='col-sm-7'><div class='form-group'><textarea class='form-control' id='comment' style='width:234px; height:45px;'></textarea></div></div></td>";                                   
                
            // var markup ="<tr><td><input type='checkbox' name='record'></td>" + Dispenser_type + dispenser_quantity + refill_name + refill_quantity + refill_expiry + "</tr>";
            var markup ="<tr></td>" + srno + tracking_no +refill_name + programming_days + refill_quantity + refill_duration + location + "<td class='center'><label class='pos-rel'><button type='button'  class='btn btn-danger' name='record' onclick='SomeDeleteRowFunction(this)'>Delete</button></label</tr>";

            $("table tbody").append(markup);

            $('#date-timepicker3').datepicker({dateFormat: 'dd-mm-yy'});

        }); 
    });    
</script>
<script>
  function SomeDeleteRowFunction(btndel) {
    if (typeof(btndel) == "object") {
        $(btndel).closest("tr").remove();
    } else {
        return false;
    }
}
</script>
<script type="text/javascript">
 $('#date-timepicker2').datepicker({dateFormat: 'dd-mm-yy'});
                 //format: 'MM/DD/YYYY h:mm:ss A',//use this option to display seconds
</script>
<script type="text/javascript">
 $('#date-timepicker3').datepicker({dateFormat: 'dd-mm-yy'});
                 //format: 'MM/DD/YYYY h:mm:ss A',//use this option to display seconds
</script>
   -->
<script type="text/javascript">
$(document).ready(function() {
    $('#example').DataTable( {
    destroy: true,
    searching: true,
    "lengthMenu": [20, 40, 60, 80, 100],
    "pageLength": 20,
    "order": [],
    "columnDefs": [
      { "orderable": false, "targets":  [] }
      ]
  } );
});
</script> 
												
						
					
