	<?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" style="float: none">

								<?php $form_data=array('name'=>'dispense_manage','id'=>'dispense_manage','class'=>'form-horizontal','autocomplete'=>'off','onsubmit' => 'return validate_dispenser_details()','enctype'=>'multipart/form-data'); 
								echo form_open($form_action,$form_data); ?>	
								
 								 <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="col-sm-6">
                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required">Customer Name:</label>
                              <div class="col-sm-7">
                                 <label><?php echo $customer_name;?></label>              
                              </div>	
                            </div>
                          </div>

                           <div class="col-sm-6">
                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required">Sales Person Name:</label>
                              <div class="col-sm-7">
                                <label><?php echo $first_name;?> <?php echo $last_name;?></label>             
                              </div>	
                            </div>
                          </div>

                          <div class="col-sm-6">
                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required">Dispenser Name:</label>
                              <div class="col-sm-7">
                               <label><?php echo $dispenser_name;?></label>            
                              </div>	
                            </div>
                          </div>

                          <div class="col-sm-6">
                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required">Dispenser Quantity:</label>
                              <div class="col-sm-7">
                               <label><?php echo $dispenser_quantity;?></label>            
                              </div>	
                            </div>
                          </div>

                           <div class="col-sm-6">
                           <div class="form-group">
                            <label for="client_code" class="col-sm-5 control-label required">Installation/Sale Date:</label>
                              <div class="col-sm-7">
                               <label><?php echo $installation_date;?></label>            
                              </div>	
                            </div>
                          </div>
                       
                            
                         <!-- </div> -->
                         <!-- main col-sm-12  close-->
                       </div> <!-- blank close -->
        </div><!-- blank close -->
      </div>   <!-- panel body close -->
    </section> <!-- section close -->
     <section class="panel panel-default">
                 				 <header class="panel-heading bg-info lt font-bold"><?php echo $this->_page_data['tb_heading']; ?></header>
                                    <div class="table-responsive">
									<table id="simple-table" class="table  table-bordered table-hover">
											<thead>
												<tr>
													<th>Sr No</th>
													<th>Tracking Numbers</th>
													<th>Refill Name</th>
													<th>Programming Duration Days</th>
													<th>Quantity</th>
													<th>UOM</th>
													<th>Refill Date</th>
													<th>Refill Location</th>
													<th>comments</th>
												
													<!-- <th>Return Dispenser</th> -->
													<th id="action">Action</th>
													
													
												</tr>
											</thead>

											<tbody><div class="form-holder-append">
										     <td>1</td>
										      <td> 

										      	<?php
														echo $tracking_numbers_name;
												?>
											   
												<input type="hidden" name="tracking_no" id="tracking_no" value="<?php echo $tracking_numbers;?>">
												<br><span class="red" id="tracking_no_1_error"></span>
                                              </td>
                                             <td>                                         	
												 <?php
												 
													$refill_array_data=$refill_array;
													$js1 = 'id="refill_product_id_1" class="form-control"';
													echo $refill_select=form_dropdown('refill_product_id', $refill_array_data, $refill_id, $js1);
												?>
												<br><span class="red" id="refill_product_id_1_error"></span>
                                             </td>
                                             <td>
                                              	
											    <select  style="width:218px;" name="programming_days" id="programming_days_1" >
													<option value="">Select Programming Duration Days<?php echo $duration_days; ?></option>
												    <option value="7" <?php if($duration_days=="7"){?> selected <?php }?>>7</option>
												    <option value="10" <?php if($duration_days=="10"){?> selected <?php }?>>10</option>
												    <option value="15" <?php if($duration_days=="15"){?> selected <?php }?>>15</option>
													<option value="30" <?php if($duration_days=="30"){?> selected <?php }?>>30</option>
													<option value="45" <?php if($duration_days=="45"){?> selected <?php }?>>45</option>
													<option value="60" <?php if($duration_days=="60"){?> selected <?php }?>>60</option>
												</select>
												<br><span class="red" id="programming_days_1_error"></span>
                                             </td>

                                             <td>
                                             	<input type='text' name='refill_quantity' id="refill_quantity_1" value="<?php echo $quantity;?>" placeholder='' style="width: 63px;" maxlength="3" readonly>
												<br><span class="red" id="refill_quantity_1_error"></span>
                                             </td>
											<td>
											    <select  style="width:50px;" name="uom" id="uom_1" >													
													<option value="PCs" <?php if($unit_of_measurment=="PCs"){?> selected <?php }?>>PCs</option>
													<option value="ML" <?php if($unit_of_measurment=="ML"){?> selected <?php }?>>ML</option>
												    <option value="KG" <?php if($unit_of_measurment=="KG"){?> selected <?php }?>>KG</option>
													<option value="GM" <?php if($unit_of_measurment=="GM"){?> selected <?php }?>>GM</option>
												</select>
												<br><span class="red" id="uom_1_error"></span>
                                             </td>
                                             <td>
                                               
                                             	<div class="input-group" style="width:183px;">
                                                    <input name="refill_date" id="refill_date_1" value="<?php echo $refill_date;?>"  type="text" class="form-control" />
                                                </div>
												<br><span class="red" id="refill_date_1_error"></span>
                                             </td>

                                              <td>
                                             	<div class="form-group">  
															<div class="col-sm-7 control-label" for="form-field-2">	
																<?php	
																	$admin_type_name_data=array('name'=>'refill_location',
																		'id'=>'refill_location_1',
																		'placeholder'=>'Enter Refill Location',
																		'value'=> $refill_location,

																		);
																echo form_input($admin_type_name_data,'');
																echo form_error('admin_type_name');
											                    ?>
										                   </div>
									            </div>
                                             </td>
                                             <td>
                                               
                                             	<div class="input-group" style="width:183px;">
                                                    <input name="refill_comments" id="refill_comments" value=""  type="text" class="form-control" />
                                                </div>
												<br><span class="red" id="refill_date_1_error"></span>
                                             </td>
                                            <!--  <td></td> -->
											

											</tbody>   
                                             
                                    </table>
                                 </div>
                              </section>
							
									<input type="hidden" name="details_no" id="details_no" value="1">
									<input type="hidden" name="dispenser_sales_id" id="dispenser_sales_id" value="<?php echo $dispenser_sales_id;?>">
									<input type="hidden" name="dispenser_refill_details_id" id="dispenser_refill_details_id" value="<?php echo $dispenser_refill_details_id;?>">
									<input type="hidden" name="customer_id" id="customer_id" value="<?php echo $customer_id;?>">
									<input type="hidden" name="company_branch_id" id="company_branch_id" value="<?php echo $company_branch_id;?>">
											 </div>								                                  							      
														       
         		               
								</div> <!-- col 12 -->
								<div class="col-md-offset-5 col-md-5">
									<button class="btn btn-info" type="button" onclick="javascript:window.history.back();">
										Back
									</button>									
									<button type="submit" name="btn_confirm" value="btn_confirm" class="btn btn-info left-icon mr-10">Submit</button>
								</div>
								
							</div><!-- row -->
						</div><!-- widget main -->
					</div> <!-- widget body -->	
				</div><!-- widget light box -->
				
                              
			</div> <!-- main col 12 close -->
 
                                 <!-- </div> -->
                                  
		</div> <!-- blank -->
		<!-- /.col -->
	<!-- </div> -->
	<div class="clearfix form-actions">
		
	</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>
function hide()
{
	document.getElementById("admin_type_code").style.display="none";
}
function show()
{
	document.getElementById("admin_type_code").style.display="";
}
</script>
<script type="text/javascript">
$(document).ready(function() {
    $('form:first *:input[type!=hidden]:first').focus();
});
</script>	
<script type="text/javascript">
$('#refill_date_1').datepicker({dateFormat: 'dd-mm-yy'});
</script>

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

	  	  $(".select2").select2();  
			$(".select2").prop("multiple", "");

	  	  });
</script>


<script>
function checkIfArrayIsUnique(myArray) 
    {
        for (var i = 0; i < myArray.length; i++) 
        {
            for (var j = i+1; j < myArray.length; j++) 
            {                  
                    if (myArray[i] == myArray[j]) 
                    {
                        return true; // means there are duplicate values
                    }

            }
        }
        return false; // means there are no duplicate values.
    }
function validate_dispenser_details()
{
	var error=false;
	var details_no_cnt=$('#details_no').val();
	var tracking_no1 = new Array(); 
	var newlist = new Array(); 
	for(i=1;i<=details_no_cnt;i++)
	{
		
		
		
		
		
		var refill_product_id=$("#refill_product_id_"+i).val();	
		if(refill_product_id=="" || refill_product_id==null)
		{
			$("#refill_product_id_"+i+"_error").html("Please Select Refill Name");
			error=true;	
		}
		else
		{
			if(document.getElementById("#refill_product_id_"+i+"_error"))
			{
				document.getElementById("#refill_product_id_"+i+"_error").innerHTML="";
			}	
		}
		
		var programming_days=$("#programming_days_"+i).val();	
		
		if(programming_days=="" || programming_days==null)
		{
			$("#programming_days_"+i+"_error").html("Please Select Programming Days");
			error=true;	
		}
		else
		{
			if(document.getElementById("#programming_days_"+i+"_error"))
			{
				document.getElementById("#programming_days_"+i+"_error").innerHTML="";
			}	
		}
		
		var refill_quantity=$("#refill_quantity_"+i).val();	
		if(refill_quantity=="" || refill_quantity==null)
		{
			$("#refill_quantity_"+i+"_error").html("Please Enter Quantity");
			error=true;	
		}
		else
		{
			if(document.getElementById("#refill_quantity_"+i+"_error"))
			{
				document.getElementById("#refill_quantity_"+i+"_error").innerHTML="";
			}	
		}
		
		var next_refill_date=$("#refill_date_"+i).val();	
		if(next_refill_date=="" || next_refill_date==null)
		{
			$("#refill_date_"+i+"_error").html("Please Enter Refill Date");
			error=true;	
		}
		else
		{
			if(document.getElementById("#refill_date_"+i+"_error"))
			{
				document.getElementById("#refill_date_"+i+"_error").innerHTML="";
			}	
		}
		
	}
	
	var is_dupliate=checkIfArrayIsUnique(newlist);
	console.log(is_dupliate);
	if(is_dupliate==true)
	{
		$("#tracking_no_1_error").html("Please Select Unique Tracking Number");
		error=true;	
	}
	else
	{
		$("#tracking_no_1_error").html("");
		
	}
	
	
	if(error==true)
	{
		return false;
	}
	else
	{
		return true;
	}
}
/* var itemIndex = 2;
var x = 22;
$("#addrefill").click(function (e) { //on add input button click
    e.preventDefault();
    
        x++; //text box increment
          $("table tbody").append('<div class="clonedInput"><input id="data_item_'+ itemIndex++ +'"  type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
    
}); */

	function SomeDeleteRowFunction(btndel) {
    if (typeof(btndel) == "object") {
        $(btndel).closest("tr").remove();
    } else {
        return false;
    }
}
</script>
