
<script type="text/javascript" language="Javascript">
function submitForm(){
    document.frmOne.submit();
    document.frmOne.method='post';
}
var util = { };

document.addEventListener('keydown', function(e){

    var key = util.key[e.which];
    if( key ){
        e.preventDefault();
    }
  if( key === 'F1' ){        
      $("#id").focus();
    }
    if( key === 'F2' ){        
      $("#qty").focus();
	   $("#qty").focus().value = "";
	  document.getElementById("qty").value = "";
    }
	 if( key === 'F3' ){        
      $("#cash").focus();
    }
	
	

	 if( key === 'enter' ){        
return true;
    }
	
})


  
util.key = { 
  9: "tab",
  //13: "enter",
  16: "shift",
  18: "alt",
  27: "esc",
  33: "rePag",
  34: "avPag",
  35: "end",
  36: "home",
  37: "left",
  38: "up",
  39: "right",
  40: "down",
  112: "F1",
  113: "F2",
  114: "F3",
  115: "F4",
  116: "F5",
  117: "F6",
  118: "F7",
  119: "F8",
  120: "F9",
  121: "F10",
  122: "F11",
  123: "F12"
}
	var finaltotal=0;
		//price = document.sales.total.value;
	//document.sales.discountedtotal.value = price;
    function OnChangediscount(value){
		
		total = document.sales.total.value;
		discount = document.sales.maindiscount.value;
        finaltotal = total-discount;
		
		document.sales.discountedtotal.value = finaltotal;
    }
</script>

	 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script> 
 <div class="row" style="padding:1; margin:1px">
  <script type="text/javascript" language="Javascript">
	var sum=0;
	price = document.sales.discountedtotal.value;
	document.sales.change.value = price;
    function OnChange(value){
		
		payable = document.sales.discountedtotal.value;
		cash = document.sales.cash.value;
        sum = cash - payable;
		
		document.sales.change.value = sum;
    }
	
</script>
 
<script type="text/javascript">
  
	
			
	   $(document).on("click", "#editbtn", function()
        {
          var productid = $(this).data('id');
		  $("#productid").val(productid); 
		     var expdate = $(this).data('expdate');
		   $("#expdate").val(expdate); 
		    var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description").val(description); 
		 
		     var qty = $(this).data('qty');
		   $("#qty1").val(qty);


		     var code = $(this).data('code');
		   $("#code").val(code); 	

		     var reorderevel = $(this).data('reorderevel');
		   $("#reorderevel").val(reorderevel); 	
 var category = $(this).data('category');
		   $("#category").val(category); 		
	
		   
 var 	supplier = $(this).data('supplier');
		   $("#supplier").val(supplier); 		
 var buyingprice = $(this).data('buyingprice');
		   $("#buyingprice").val(buyingprice); 		
 var sellingprice = $(this).data('sellingprice');
		   $("#sellingprice").val(sellingprice); 		
 var promoprice = $(this).data('promoprice');
		   $("#promoprice").val(promoprice); 	

 var wholesaleprice = $(this).data('wholesaleprice');
		   $("#wholesaleprice").val(wholesaleprice);
		   
		   
		    var store = $(this).data('store');
		   $("#store").val(store);
		    var tax_included = $(this).data('tax_included');
		   $("#tax_included").val(tax_included);
		   
		      var orderamount = $(this).data('orderamount');
		   $("#orderamount").val(orderamount);
		   
		   
		   
		   
        });
		
		
    </script>
<style>
#big{
	font-style: normal;font-size: 1.8em;
	
}
#cash{
	font-style: normal;font-size: 1em;
	 line-height: 50%;
	padding:5px;
	
}
#discountedtotal{
	font-style: normal;font-size: 1em;
	 line-height: 50%;
	padding:5px;
	
}

#maindiscount{
	font-style: normal;font-size: 1em;
	 line-height: 50%;
	padding:5px;
	
}
#change{
		font-style: normal;font-size: 1em;
	 line-height: 50%;
	padding:5px;
	
}
</style>
	<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">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>

				                        <a  id="more" target="blank" class="btn btn-primary" href="<?php echo base_url();?>user/viewpurchases">back  </a>

            	</div>
            </div>
			<div class="panel-body">

				<div class="widget-content nopadding table_holder table-responsive"  >		
	
		
	
					
					
				
					<div class="table-responsive">
						<table id="register" class="table table-bordered " width="100%" >
						<thead>
							<tr>
								<th colspan="2" width="50%">Receivings:</th>
							
								
								<th width="20%">Qty Purchased</th>
								<th width="10%" >Moving to? </th>
																<th width="30%" colspan="7">VAT </th>

								
							</tr>
								<tr>
								<th colspan="2">
										<?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;
					}
	 $session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	  $addproductaction=$this->usermodel->populatuserpermissionsdataarray('purchases','add',$userid);

	 $updateaction=$this->usermodel->populatuserpermissionsdataarray('purchases','update',$userid);
  $updatebuyingpriceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updatebuyingprice',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('purchases','delete',$userid);
  $updatesellingpriceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updatesellingprice',$userid);
    $updateclosedinvoiceaction=$this->usermodel->populatuserpermissionsdataarray('purchases','updateclosedinvoice',$userid);
	 
	 
	 
	 
	 
      $invoicestatus=$this->usermodel->populateallarray('purchaseorder','invoice',$salesid);
$myinvoice=$invoicestatus[0]["transactionstatus"];



   echo $this->session->flashdata('msg'); 
                 echo form_open('user/addreceivings' , 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="salesid" value="<?php echo set_value('type',$salesid); ?>" class="form-control" required placeholder="Enter invoice">
<?php
if(($invoicestatus!=false) && ($myinvoice=="open")){
	?>
			  		<input type="text" name="code" id="id" autofocus value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter code or name">

	<?php
	
}else  if ( $updateclosedinvoiceaction==true){
	 ?>
			  		<input type="text" name="code" id="id" autofocus value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter code or name">


	 	<?php	

 }else if(($invoicestatus!=false) && ($myinvoice=="progress")){
  	?>
			  		<input type="text" name="code" id="id" autofocus value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter code or name">

	<?php
 
}
	?>	

		 
								</th>
								
								
								
								
								
								
								
								
								
					
					
								
								
								
								<th>
								

								
		  		<input type="text" name="qty" id="qty" value="<?php echo set_value('qty','1'); ?>" class="form-control" required placeholder="Qty" >
								
								</th>
									<th>
 






    
	
	<select class="form-control" name="to" required>
	
	<option value=""  >---Moving products to?---</option>
	<option value="Main"  >Main Store</option>

	
	<?php 
					 

					 $branch= $this->usermodel->populateall('branch','companyid',$companyid);



if(is_array($branch)) {

   foreach($branch as $branchrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected"  value="<?=  $branchrow->id;   ?>"><?=  $branchrow->name; ?></option>



	<?php

}} else {
    echo 'No branch available.';
}
	
?>
</select>
		

		

  












					
								</th>
								
								<th>
 






    
	
	<select class="form-control" name="tax" >
	
	<option value="VATABLE" select  >VATABLE</option>
			<option value="ZERO RATED"  >ZERO RATED</option>
				<option value="ZERO RATED"  >EXEMPTED</option>
				<option value=""  >N/A</option>

	
</select>
		

		

  












					
								</th>
								<th colspan="4">

								
								<button type="submit"  value="sale" name="btn_addsale" class="btn btn-primary"> Click to add product   </button>

 
  					<?php echo form_close();?>
								
								</th>
								
							</tr>
								<tr>
								<th>Code</th>
								<th width="40%">Item Name</th>
								
								<th>Qty</th>
								<th>B Price </th>
								<th>S Price</th>
								<th>Total</th>
								<th>To?</th>
								<th>Get Avg</th>
								<th>VAT</th>

								<th></th>
									<th></th>	
							</tr>
						</thead>
						<?php
					
 if(!is_array($viewreceivings)) {
	  echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    echo"There is no product under this invoice number..";
    echo "</td>";
   echo "</tr>";

			 }else{
 
 $totalcost=0;
  $finaltotal=0;
  	foreach ($viewreceivings as $row){
		
	
 $itemid=$row->item_id;
  $myid=$row->id;
   $productid=$row->id;
		 		$recaiving= $this->usermodel->populateall('products', 'code',$itemid);
				
			
 if(is_array($recaiving)){
	 
	 foreach ($recaiving as $c){
 
   $c->code;

             ?>
				                    <tbody >
									
										 
										<?php
					
		
                 echo form_open('user/editreceivedproducts' , 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;?>								
											<tr>
									<td><?php ; 
														
   $customer=$c->code;
   if($customer!=""){
	  
      $productname = $this->usermodel->populateallarray('products','code',$itemid);
  
?>

											
																			<?php	

if($myinvoice=="closed"){
 echo $customer;
}else{
	?>
			
				<a  id="more" target="_blank"class="btn btn-default" href="<?php echo base_url();?>user/viewserials?randomitemidentifier=<?php   {echo  $salesid;}  ?>&mycode=<?php   {echo  $row->item_id;}  ?>&myqty=<?php   {echo  $row->total;}  ?>&myid=<?php   {echo  $row->id;}  ?>&status=create"> <?php echo  $customer; ?></a>
					
	
		<?php
}
	?>	

	

<?php
	
   }else{
	    echo "No Product";  
   }

  
  ?></td>
  								
													    <td><?php ; 
						 $receiptdescription=$configuration[0]['receiptdescription'];
									
   $customer=$c->code;
   if($customer!=""){
	  
     // $productname = $this->usermodel->geteproductbyid($customer);
  
     echo "<b>";
     $name=$productname[0]['name']; if($receiptdescription=="yes"){ echo"-".$description=$productname[0]['description'];}
	 ?>
 <a class="btn default editbtn" id="editbtn"data-tax_included='<?php echo  $productname[0]['tax_included'];?>' data-expdate='<?php echo  $productname[0]['expdate'];?>'data-store='<?php echo  $productname[0]['store'];?>' 	 data-orderamount='<?php echo  $productname[0]['orderamount'];?>' data-supplier='<?php echo  $productname[0]['supplier'];?>'  data-category='<?php echo  $productname[0]['category'];?>'  data-buyingprice='<?php echo  $productname[0]['buyingprice'];?>' data-sellingprice='<?php echo  $productname[0]['sellingprice'];?>'data-promoprice='<?php echo  $productname[0]['promoprice'];?>'  data-wholesaleprice='<?php echo  $productname[0]['wholesaleprice'];?>' data-code='<?php echo  $productname[0]['code'];?>' data-qty='<?php echo  $productname[0]['qty'];?>'	data-description='<?php echo  $productname[0]['description'];?>' data-name='<?php echo  $productname[0]['name'];?>'	data-reorderevel='<?php echo  $productname[0]['reorderevel'];?>'  data-id='<?php echo  $productname[0]['id'];?>' data-toggle='modal' data-target='#editProductModel'> <?php echo $productname[0]['name'] ; ?> </a>	 

<?php
	
	  echo "</b>";

	
   }else{
	    echo "No Product";  
   }

  
  ?></td>
									
												
													<td>
												<input type="hidden" name="salesid" id="salesid" value="<?php echo set_value('salesid',$salesid); ?>" class="form-control" required placeholder="salesid" >
											<input type="hidden" name="itemid" id="itemid" value="<?php echo set_value('itemid',$row->item_id); ?>" class="form-control" required placeholder="itemid" >

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

											
											
																			<?php	

if(($updateclosedinvoiceaction==false) && ($myinvoice=="closed")){
  	?>

	<?php
 echo $row->total;
}else{
	?>
			
																		  		<input type="text" name="myqty" id="myqty" value="<?php echo set_value('myqty',$row->total); ?>" class="form-control" required placeholder="Qty" >
					
	
		<?php
}
	?>	
											
											
											
											
											
											
											
											
											
											
											
</td>
													<td>
													
													
														<?php

	if(($updateclosedinvoiceaction==false) && ($myinvoice=="closed")){
		echo $row->buyingprice;
	}
 else if(($updatebuyingpriceaction==true) && ($myinvoice!="closed")){
	 ?>

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

	 	<?php	

 } else if(($updateclosedinvoiceaction==true) && ($updatebuyingpriceaction==true)){
  ?>

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

	 	<?php	
 
 } else{
	echo $row->buyingprice;
 }
  ?>
		
													
													</td>
										 	 <td>
											 
											 
											 
																	
														<?php

	if(($updateclosedinvoiceaction==false) && ($myinvoice=="closed")){
	echo $c->sellingprice;
	}
 else if(($updatesellingpriceaction==true) && ($myinvoice!="closed")){
	 ?>

					<input type="text" name="sellingprice" id="sellingprice" value="<?php echo set_value('sellingprice',$c->sellingprice); ?>" class="form-control" required placeholder="selling price" >

	 	<?php	

 } else if(($updateclosedinvoiceaction==true) && ($updatesellingpriceaction==true)){
  ?>

					<input type="text" name="sellingprice" id="sellingprice" value="<?php echo set_value('sellingprice',$c->sellingprice); ?>" class="form-control" required placeholder="selling price" >

	 	<?php	
 
 } else{
	echo $c->sellingprice;
 }
  ?>						 

											 </td>
											 
											 
											 
											 
											 
											 
											 
											 
											 	 <td><?php 
												 $totalqty=1;
												 if($row->total !=""){
													 
													 $totalqty=$row->total;
												 }
												echo $totalcost=(($totalqty)*($row->buyingprice)) ;
												 $finaltotal=$finaltotal+$totalcost;
												 ?></td>
				  <td>
																		<input type="hidden" name="branch" id="branch" value="<?php echo set_value('branch',$branch=$row->type); ?>" class="form-control" required placeholder="branch" >
							 
	<?php 
					// $branch="";
					 $branch=$row->type;

					 $branch= $this->usermodel->populateall('branch','id',$branch);



if(is_array($branch)) {

   foreach($branch as $branchrow){

   echo $branchrow->name;
 
 
}} else {
    echo 'Store.';
}
	
?>
												 
												 
												 
												 
												 
												 
												 
												 
												 
												 
											  </td>
											  
											  
											  
							  <td>					  
											  	
	<select class="form-contro1" name="compare" required>
	
	<option value="Yes"  >Yes</option>
	<option value="No" selected="selected"  >No</option>

	

</select>
		

			  </td>									  
						  <td>					  
							<?php
$tax=$row->tax;
							?>							
	<select class="form-contro1" name="tax" required>
		<option value="<?php echo $tax;   ?>" selected="selected"  ><?php echo $tax;   ?></option>

		<option value="VATABLE" select  >VATABLE</option>
			<option value="ZERO RATED"  >ZERO RATED</option>
				<option value="ZERO RATED"  >EXEMPTED</option>
				<option value=""  >N/A</option>

	

</select>
		

			  </td>								  
											  
											  
											  
											  
											  
											  
											  
												 	<td  style='color:green'> 
				<?php

	
 if( $deleteaction==true){
	 ?>
		                              <a  id="more" class="btn btn-danger" href="<?php echo base_url();?>user/deletereceivedproducts?randomitemidentifier=<?php   {echo  $salesid;}  ?>&transactionid=<?php   {echo  $productid;}  ?>&itemid=<?php   {echo  $itemid;}  ?>"> <span class="glyphicon glyphicon-trash"></span> </a>

	 
	 	<?php	

 }else{
	
 }
  ?>
		                              </td> <td>
									  
									  
																		<?php

	if(($updateclosedinvoiceaction==false) && ($myinvoice=="closed")){

	}
 else if(($updateaction==true) && ($myinvoice!="closed")){
	 ?>

<button type="submit"  value="myedit" name="btn_editreceivedproduct" class="btn btn-default"> <span class="glyphicon glyphicon-pencil"></span> </a>   </button>

	 	<?php	

 } else if(($updateclosedinvoiceaction==true) && ($updateaction==true)){
  ?>

<button type="submit"  value="myedit" name="btn_editreceivedproduct" class="btn btn-default"> <span class="glyphicon glyphicon-pencil"></span> </a>   </button>

	 	<?php	
 
 } else{

	}
  ?>						  
				

	<div class="btn-group">
                                    <button type="button" class="btn btn-default btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
								
								
                                    <ul class="dropdown-menu dropdown-default pull-right" role="menu">
                                        <li>
										
		<?php
										if($myinvoice=="closed"){
 echo "This invoice is closed   </br>";
}else{
	?>
			
				<a  id="more" target="_blank"class="btn btn-default" href="<?php echo base_url();?>user/viewserials?randomitemidentifier=<?php   {echo  $salesid;}  ?>&mycode=<?php   {echo  $row->item_id;}  ?>&myqty=<?php   {echo  $row->total;}  ?>&myid=<?php   {echo  $row->id;}  ?>&status=create"> 
					<i class="glyphicon glyphicon-pencil"></i>
															Record	 Serial No
																
                                                </a>
	
		<?php
}
	?>	

	
	
	


                                                
                                                        </li>
														                                        <li class="divider"></li>

											  <li> 
				<a  id="more" target="_blank"class="btn btn-default" href="<?php echo base_url();?>user/viewoldserials?randomitemidentifier=<?php   {echo  $salesid;}  ?>&mycode=<?php   {echo  $row->item_id;}  ?>&myqty=<?php   {echo  $row->total;}  ?>&myid=<?php   {echo  $row->id;}  ?>&status=create"> 


                                                <i class="glyphicon glyphicon-pencil"></i>
															View	 Serial No
                                                </a>
                                                        </li>
											 <li class="divider"></li>

									  <li> 
				<a  id="more" target="_blank"class="btn btn-default" href="<?php echo base_url();?>user/printserialcodes?randomitemidentifier=<?php   {echo  $salesid;}  ?>&mycode=<?php   {echo  $row->item_id;}  ?>&myqty=<?php   {echo  $row->total;}  ?>&myid=<?php   {echo  $row->id;}  ?>&status=create"> 


                                                <i class="glyphicon glyphicon-pencil"></i>
															Print	Barcode
                                                </a>
                                                        </li>
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
										
								</div>
 <?php echo form_close();?>	
  					

 </td>
 </tr>
 <?php 
	 }?>
				<?php }?>							
	<?php }} ?>

              <?php ?>	

								<tr>
									<th colspan="4"></b>Invoice Number:	</b><?php echo$salesid?>   : 
							
								<?php	

if(($updateclosedinvoiceaction==false) && ($myinvoice=="closed")){
  	?>

	<?php
 
}else{
	?>
	<a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printgrn?invoice=<?php   if(isset($salesid)) {echo $salesid; } ?>&type=receiving">  Print Good Receive Note   </a>

				<a  id="more"  class="btn btn-warning" href="<?php echo base_url();?>user/updatereceivedeals?randomitemidentifier=<?php   {echo  $salesid;}  ?>&status=suspended"> Suspend</a>

								
								
			 								<a  id="more"  class="btn btn-info" href="<?php echo base_url();?>user/updatereceivedeals?randomitemidentifier=<?php   {echo  $salesid;}  ?>&status=progress"> Work in progress</a>

								
	
		<?php
}
	?>	
							
			 								<a  id="more"  class="btn btn-success" href="<?php echo base_url();?>user/updatereceivedeals?randomitemidentifier=<?php   {echo  $salesid;}  ?>&status=closed"> Complete/Close</a>

								
								</th>
								<th colspan="4"><h3>Total:<?php if(isset($finaltotal)) {echo formatMoney($finaltotal, true); }?></h3>
							</th>
							
							</tr>
				
									</tbody>
									
									
					</table>
				</div>	
			</div>
					
					
					
					
					
					
		
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>

	
			
			
				
			<div id="editProductModel" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Update Product</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
//$session_data = $this->session->userdata('logged_in');
$imgid = rand(100, 990000).time();


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updatesaleproduct' , 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="myview" value="user/viewsales" class="form-control" required placeholder="Enter view">

<input type="hidden" name="productid" value=""id="productid" class="form-control" required placeholder="Enter productid">
		<!--<input type="hidden" name="page" value="<?php echo $page ?>"id="page" class="form-control" required placeholder="Enter bookid">
-->
	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">	 Code</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="code" id="code" value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter Product Code">
		 
				
		<span class="text-danger"> <?php echo form_error('code'); ?>
		
		</span>
	</div>
  </div>

	<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	 Name</label>
    <div class="col-sm-10">
		
				<input type="text" name="name"   id="name" value="<?php echo set_value('name') ;?>"  class="form-control" required placeholder="Enter  product name">

		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

     <div class="form-group">
    <label for="inputcategory" class="col-sm-2 control-label">Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="category" id="category"required>
	
	<option value="" selected></option>
		<option value=""  >---Select Category---</option>

	<?php 
					 
			$mycategory = $this->usermodel->populateproductcategory();
	


if(is_array($mycategory)) {

   foreach($mycategory as $mycategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $mycategoryrow->id;   ?>"><?=  $mycategoryrow->name; ?></option>



	<?php

}} else {
    echo 'No category available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('category'); ?>

	</div>
  </div>
  	


  

  
     <div class="form-group">
    <label for="inputsupplier" class="col-sm-2 control-label">supplier?</label>
    <div class="col-sm-10">
	<select class="form-control" name="supplier" id="supplier" required>
	
	<option value=""  >---Select supplier---</option>

	
	<?php 
					 
			$suppliers = $this->usermodel->populatesupplier();
	


if(is_array($suppliers)) {

   foreach($suppliers as $suppliersrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $suppliersrow->id;   ?>"><?=  $suppliersrow->company ."(". $suppliersrow->firstname ." ".$suppliersrow->lastname.")"; ?></option>



	<?php

}} else {
    echo 'No supplier available.';
}
	
?>
</select>
		
						<span class="text-danger"><?php echo form_error('supplier'); ?>

	</div>
  </div>
  
  
  
  
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputbuyingprice" class="col-sm-2 control-label">	B Price</label>
    <div class="col-sm-10">

				<input type="text" id="buyingprice" required name="buyingprice" value="<?php echo set_value('buyingprice'); ?>"  class="form-control"  placeholder="Enter buying price">
			
		<span class="text-danger"> <?php echo form_error('buyingprice'); ?>
		
		</span>
	</div>
  </div>
  	
	<div class="form-group">
    <label for="inputsellingprice" class="col-sm-2 control-label">	S Price</label>
    <div class="col-sm-10">

				<input type="text" id="sellingprice" name="sellingprice" required value="<?php echo set_value('sellingprice'); ?>"  class="form-control"  placeholder="Enter selling price">
			
		<span class="text-danger"> <?php echo form_error('sellingprice'); ?>
		
		</span>
	</div>
  </div>
	
		<div class="form-group">
    <label for="inputwholesaleprice" class="col-sm-2 control-label">	H Price</label>
    <div class="col-sm-10">

				<input type="text"  name="wholesaleprice" value="<?php echo set_value('wholesaleprice'); ?>"  id="wholesaleprice" class="form-control"  placeholder="Enter whole sale price">
			
		<span class="text-danger"> <?php echo form_error('wholesaleprice'); ?>
		
		</span>
	</div>
  </div>
	
	
			<div class="form-group">
    <label for="inputpromoprice" class="col-sm-2 control-label">	Promo Price</label>
    <div class="col-sm-10">

				<input type="text" id="promoprice" name="promoprice" value="<?php echo set_value('promoprice'); ?>"  class="form-control"  placeholder="Enter Promotion  price">
			
		<span class="text-danger"> <?php echo form_error('promoprice'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	
	<div class="form-group">
    <label for="inputqty" class="col-sm-2 control-label">	Quantity</label>
    <div class="col-sm-10">

				<input type="text" name="qty" id="qty1" value="<?php echo set_value('qty'); ?>"  class="form-control" required  placeholder="Enter quantity in stock">
			
		<span class="text-danger"> <?php echo form_error('qty'); ?>
		
		</span>
	</div>
  </div>
  	
	
		
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Description</label>
    <div class="col-sm-10">

				<textarea name="description"  id="description"  value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter description"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	
	<div class="form-group">
    <label for="inputreorderevel" class="col-sm-2 control-label">	Reorder Level</label>
    <div class="col-sm-10">

				<input type="text" required  id="reorderevel"  name="reorderevel" value="<?php echo set_value('reorderevel'); ?>"  class="form-control"  placeholder="Enter Reorder Level e.g 10">
			
		<span class="text-danger"> <?php echo form_error('reorderevel'); ?>
		
		</span>
	</div>
  </div>
	
	
		
			<div class="form-group">
    <label for="inputorderamount" class="col-sm-2 control-label">	Quantity to order</label>
    <div class="col-sm-10">

				<input type="text" 
				name="orderamount" value="<?php echo set_value('orderamount'); ?>"  id="orderamount" class="form-control"  placeholder="Enter  quantity to Reorder">
			
		<span class="text-danger"> <?php echo form_error('orderamount'); ?>
		
		</span>
	</div>
  </div>
	

	<div class="form-group">
    <label for="inputtax_included" class="col-sm-2 control-label">	Tax included (%)</label>
    <div class="col-sm-10">

				<input type="text"   id="tax_included" name="tax_included" value="<?php echo set_value('tax_included'); ?>"  class="form-control"   placeholder="Enter tax if any">
			
		<span class="text-danger"> Enter tax to be included if any<?php echo form_error('tax_included'); ?>
		
		</span>
	</div>
  </div>
  	
		<div class="form-group">
    <label for="inputstore" class="col-sm-2 control-label">	Rack /Store Name</label>
    <div class="col-sm-10">

				<input type="text"  id="store" name="store" value="<?php echo set_value('store'); ?>"  class="form-control"   placeholder="Enter store / rack name">
			
		<span class="text-danger"> Enter the name where the product is stored<?php echo form_error('store'); ?>
		
		</span>
	</div>
  </div>
	
	<div class="form-group">
    <label for="inputexpdate" class="col-sm-2 control-label">	Expiry date</label>
    <div class="col-sm-10">

				<input type="text"   id="expdate" name="expdate" value="<?php echo set_value('expdate'); ?>"  class="form-control"   placeholder="Enter expiry date">
			
		<span class="text-danger"> Enter expiry date  if any<?php echo form_error('expdate'); ?>
		
		</span>
	</div>
  </div>
	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="product" name="btn_updateproduct" class="btn btn-primary"> Update Product   </button>

    </div>
  </div>
  					<?php echo form_close();?>
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

		</div>
	    </div>
    </div>
			
			
			<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Delete</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to delete this transaction ? </h3>
      </div>
      <div class="modal-footer">
	  	

     
		<?PHP
				$session_data = $this->session->userdata('logged_in');
 echo $this->session->flashdata('deletemsg'); 

		
                 echo form_open('user/deletesoldeproducts' , array('class' => 'form-horizontal ', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>
 <input type="text" id="transactionid"name="transactionid" class="transactionid" placeholder="transactionid" value=""><br>
				<input type="hidden" name="mysalesid" value="<?php echo set_value('mysalesid',$salesid); ?>" id="mysalesid" class="form-control" required placeholder="Enter salesid">
 <input type="text" id="myid"name="myid" class="myid" placeholder="myid" value=""><br>

 <button type="button" class="btn btn-success" data-dismiss="modal">Don't Delete</button>
 		  	         <button type="submit" name="btn_delete" value="delete" class="btn btn-danger"> Delete  </button>

	<?php echo form_close();?>
      </div>
    </div>

  </div>

  </div>







  </div>

















