<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	 <script src="<?php echo base_url(); ?>assets/autocomplete/jquery.min.js"></script>
    <script src="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.min.js"></script>


 
            
        <script type="text/javascript">  
        $(this).ready( function() {  
            $("#id").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/lookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });  
		
		
			
		 $(document).on("click", "#managebtndelete", function()
        {
          var transactionid = $(this).data('id');
		  $("#transactionid").val(transactionid); 
   var myid = $(this).data('myid');
		  $("#myid").val(myid); 
		   
		   
        });
		  $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
        </script>
	   	
 
 <div class="row">
  
   	

   	<div class="col-md-12">

  <?php

			function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}
 
				echo $this->session->flashdata('msg'); 
   $session_data = $this->session->userdata('logged_in');

      $mydate=date("Y-m-d H:i:s");
 $date = Date('Y-m-d') ;
		 	 $year = Date('Y') ;
		  $month = Date('m') ;
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
    $deletebank=$this->usermodel->populatuserpermissionsdataarray('accounting','deletebank',$userid);

     echo $this->session->flashdata('productmsg'); 

	 
	
	
	 
	 
	 
	 

	 
	 
	 
  ?>

  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
				 <span class="pull-center"> Update products </span>
	  
				 	  				 <a href="<?php echo base_url();?>user/viewproductlist?randomitemidentifier=<?php echo $mycode; ?>" class="btn btn-info"> Back </a>

				 
            	</div>
            </div>
			<div class="panel-body">
								
								
								
														<table id="register" class="table table-bordered " width="100%" >

								
			<thead>
								<tr>
								<th>#</th>

								<th>Code</th>
								<th>Item Name</th>
									<th>B Price</th>
									<th>S Price</th>

								<th> Qty </th>

								<th>Main Serial</th>
								<th>Other serial</th>
								<th>Status</th>

								</tr>
								
								
								
								
							
							
								
								
					<tr>
					<td>#</td>
					<td colspan="8">
					<CENTER>UPDATE PRODUCTS</CENTER>
					</td>
</tr>					
								
								
								

						</thead>
						    <tbody >
													
								
 						<?php
					
		
		
                 echo form_open('user/bulkproductsmissings' , array('class' => 'form-horizontal form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>		

 		<input type="hidden" name="mainview" value="<?php echo base_url();?>user/viewmissingserials?branch=<?php   {echo  $mybranch;}  ?>&mycode=<?php   {echo  $mycode;}  ?>&startdate=<?php   {echo  $startdate ;}  ?>" class="form-control" required placeholder="Enter invoiceno">

 
						<?php
									$ttsprice=0;

				$ttbprice=0;
				$i=0;
 if(!is_array($viewserials)) {
	  echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    echo"There is no data found..";
    echo "</td>";
   echo "</tr>";

			 }else{

  	foreach ($viewserials as $c){
	
					$availableserials= $this->usermodel->viewmissingserial($startdate,$companyid,$c->branch,$c->code,$c->serial);
if($availableserials==false){
			$i++;

	      ?>
				                
									
										 
										
											<tr>
											 <td>
											 
											 <input type="hidden" name="finalid" id="myid" value="<?php echo set_value('myid',$c->id); ?>" class="form-control" required placeholder="myid" >

  		<input type="hidden" name="myqty" id="myqty" value="<?php echo set_value('myqty',$c->qty); ?>" class="form-control" required placeholder="myqty" >

											
	 <?php
	  		echo 	$i;				
	   	$ttbprice=	$ttbprice+$c->buyingprice;
		 	$ttsprice=	$ttsprice+$c->sellingprice;
	   ?>
	    </td> <td>
  	<input type="text" readonly name="code[]" id="code" value="<?php echo set_value('code',$c->code); ?>" class="form-control"  placeholder="code" >
  </td>
			 <td>
			 

   	<input type="text" required readonly name="name[]" id="name" value="<?php echo set_value('name',$c->name); ?>" class="form-control"  placeholder="eneter product code" >


  
  	      	<input type="hidden" required readonly name="description[]" id="description" value="<?php echo set_value('description',$c->description); ?>" class="form-control"  placeholder="enter product code" >

  </td>
  								
													    
  
  <td>
  	<input type="text"  name="buyingprice[]" id="buyingprice" value="<?php echo set_value('buyingprice',$c->buyingprice); ?>" class="form-control"  placeholder="buying price" >
  </td>
												
						<td>


		<input type="hidden" name="myid[]" id="myid" value="<?php echo set_value('myid',$c->itemid); ?>" class="form-control" required placeholder="myid" >
		<input type="hidden" name="branch[]" id="branch" value="<?php echo set_value('branch',$c->branch); ?>" class="form-control" required placeholder="branch" >

		<input type="hidden" name="mydate[]" id="mydate" value="<?php echo set_value('mydate',$c->createdate); ?>" class="form-control" required placeholder="entry date" >

<input type="hidden" name="batchno[]" id="batchno" value="<?php echo set_value('batchno',$c->batchno); ?>" class="form-control" required placeholder="batch" >

			<input type="hidden" name="id[]" id="id" value="<?php echo set_value('id',$c->id); ?>" class="form-control" required placeholder="id" >

					
	
									
											
											
											
						  	<input type="text"  name="sellingprice[]" id="sellingprice" value="<?php echo set_value('sellingprice',$c->sellingprice); ?>" class="form-control"  placeholder="sprice" >
					
											
											
											
											
											
</td>














													<td>
													
													
													


					<input type="text" readonly name="qty[]" id="qty" value="<?php echo set_value('qty',$c->qty); ?>" class="form-control" required placeholder="Qty" >

													
													</td>
			
			<td>
		
		<input type="text" name="serial[]" id="serial" value="<?php echo set_value('serial',$c->serial); ?>" class="form-control" required placeholder="serial" >


		
</td>	
<td>
		
		<input type="text" name="otherserial[]" id="otherserial" value="<?php echo set_value('otherserial',$c->otherserial); ?>" class="form-control"  placeholder="other serial" >


		
</td>		

<td>
		

<select class="form-control2"name="status[]" id="status" style="width:50%" >
	
	<option value=""  >---Select Status---</option>

  

   <option value="new" >New</option>
   <option value="used"  >Used</option>
   <option value="damaged"  >Damaged</option>
      <option value="return"  >Returned</option>
     <option value="Missing" selected="selected" >Missing</option>

   

</select>	
<?php echo set_value('status',$c->status); ?>
		
</td>		

		

 </tr>
 <?php 
 			  
			
			
 		
 
 
 
 
}
 
										 }?>
										

         

								<tr>
								<th></th>
									<th> 
									<h4><?php if(isset($i)) {echo formatMoney($i); }?> Items</H4>

	
				</th>	
				
				
				<th>	
				
					</th>
					<th>
								<h4>Total B.PRICE: <?php if(isset($ttbprice)) {echo formatMoney($ttbprice, true); }?></H4>
							</th>
								<th>
								<h4>Total S.PRICE:   <?php if(isset($ttsprice)) {echo formatMoney($ttsprice, true); }?></H4>
							</th>
				
				
				
				
				
				<th colspan="3">			

								
								</th>
							
							
							</tr>
							
							<tr>
									
									
				<td></td>
				
				<th colspan="8">			
<button type="submit"  value="bulkupdatemissing" name="btn_bulkproductsreceiving" class="btn btn-primary"> Receive these products in bulk  </button>

								
								</th>
							
							
							</tr>
				 <?php echo form_close();?>	
				 
				 <?php }?>	
									</tbody>
									
									
					</table>
				</div>	
			</div>			
					
					
					
					
					
					
					
					
					
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    
			
			
		</div>
	    </div>
		
  

 
</div>


















