<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">
	

 


	 <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>

				   

				   
	
        <script>
        $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
	
            $(document).ready(function() { 
				$("#name").hide();
               $("#due").hide();
               $("#accountno").hide();   
					});
          
		              $(function () {
        $("#type").change(function () {
            if ($(this).val() == "Cash") {
             $("#due").hide();
		   $("#accountno").hide();
              

            } else  if ($(this).val() == "Credit") {
           
				             $("#accountno").hide();      
				$("#due").show();
            }else  if ($(this).val() == "Invoice") {
              $("#accountno").hide();
				                
				$("#due").show();
            }
            else {
               $("#accountno").show();

               $("#due").hide();
            }
        });
    });
	
	              $(function () {
        $("#customer").change(function () {
            if ($(this).val() == "directly") {
            
			$("#name").show();
		 
              

            }  else {
                 $("#name").hide();

            
			
            }
        });
    });
	
	
	
        </script>
 



<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 === 'right' ){        
      $("#btn_dontprint").focus();
    }
		 if( key === 'left' ){        
      $("#btn_savesales").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>

 
 <div class="row" style="padding:1; margin:1px">
  <script type="text/javascript" language="Javascript">
	var sum=0;
	price = document.sales.total.value;
	document.sales.change.value = price;
    function OnChange(value){
		
		payable = document.sales.total.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);
		   
		   
		   
		   
        });
		
		
    </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>


 
            
        <script type="text/javascript">  
        $(this).ready( function() {  
            $("#id").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
					    url: "<?php echo base_url(); ?>Systemusers/branchlookup",  

                       // url: "<?php echo base_url(); ?>/Systemusers/wholesalelookup",  
                        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); 
		   
		   
        });
		
        </script>  
		 
 <div class="row">
   	<div class="col-md-9">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>

				
            	</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"  border="1" width="100%" >
						<thead>
						
								<tr>
								<th colspan="2">
										<?php
										 $mydate=date("Y-m-d H:i:s");
										 $mydates=date("Y-m-d 00:00:00");

																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');
 $dateposted=date("Y-m-d H:i:s");

 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 $data['usertype'] = $session_data['usertype'];
	 $usertype = $data['usertype'];	
	$updateaction=$this->usermodel->populatuserpermissionsdataarray('products','update',$userid);
            	$viewreport=$this->usermodel->populatuserpermissionsdataarray('openclose','viewreport',$userid);
 


			 echo form_open('user/addwholesalereading' , 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="mydate" value="<?php echo set_value('date',$dateposted); ?>" class="form-control" required placeholder="Enter  date">

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

			  		<input type="hidden" name="type" value="<?php echo set_value('type','Cash'); ?>" class="form-control" required placeholder="Enter type">
			  		<input type="hidden" name="salestype" value="wholesale" class="form-control" required placeholder="Enter sales type">

		  		<input type="text" name="code" id="id" autofocus value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter code or name">
		 
								</th>
										<th>
		  		<input type="text" name="start" id="start" value="<?php echo set_value('start'); ?>" class="form-control" required placeholder="Enter start qty" >
									

									

									
								</th>
								
								
										  		<input type="hidden" name="discount" value="<?php echo set_value('discount','0'); ?>" class="form-control" required placeholder="Enter Discount">

								
								
								<th>
	<select class="form-control" name="mode" required>
	
	<option value="Start"  >Start</option>
	<option value="End"  >End</option>
		
</select>								
								</th>
								<th colspan="4">
								<button type="submit"  value="sale" name="btn_addsale" class="btn btn-primary"> Add Readings   </button>

 
  					<?php echo form_close();?>
								
								</th>
							
								
							</tr>
							
						</thead>   <tr>
						<?php
					
 if(!is_array($viewwholesales)) {
	 

			 }else{
 if(!is_array($viewwholesales)) 

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
    
    echo "</td>";
   echo "</tr>";
    }else {
 $totalcost=0;
  
  	foreach ($viewwholesales as $c): 

		 

             ?>
				                 
												
									
										 
										<?php
					
		
                 echo form_open('user/editsalereading' , 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;?>								
																						
																							    <td><?php ; 
														
   $customer=$c->code;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
  
		
 if( $updateaction==true){

?>
 <a class="btn primary 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]['code'] ; ?> </a>	 

<?php
 }else{
echo $productname[0]['code'] ;	
 }


   }else{
	    echo "No Product";  
   }

  
  ?></td>
  
		 <td><?php ; 
						 $receiptdescription=$configuration[0]['receiptdescription'];
									
   $customer=$c->code;
   if($customer!=""){
	  
      $productname = $this->usermodel->geteproductbyid($customer);
  
     echo "<b>";
     echo$name=$productname[0]['name']; if($receiptdescription=="yes"){ echo"-".$description=$productname[0]['description'];}
	 
	 
	  echo "</b>";

	
   }else{
	    echo "No Product";  
   }

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

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

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

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


</td>







												
										 	 <td><?php echo $c->sprice ; ?></td>
											 	 <td><?php echo $c->amount ; 
												 $totalcost=$totalcost+$c->amount ;
												 ?></td>
												 
												 	<td  style='color:green'> 
		<?php
		$myid=  $c->id ;
		?>
		                              <a  id="more" class="btn btn-danger" href="<?php echo base_url();?>user/deletesoldeproducts?randomitemidentifier=<?php   {echo  $salesid;}  ?>&transactionid=<?php   {echo  $myid;}  ?>&type=wholesale"> <span class="glyphicon glyphicon-trash"></span> </a>
		                             
							
<button type="submit"  value="sale" name="btn_editsales" class="btn btn-primary"> <span class="glyphicon glyphicon-pencil"></span> </a>   </button>

 
  					

 </td>
				<?php echo form_close();?>							</tr>
										<?php endforeach;} ?>
									<tr>
							<td colspan="4"><h3>Total</h3></td>

							
								<td colspan="4"><H1><?php if(isset($totalcost)) {echo $totalcost; }?></h1></td>
							
							</tr>
					
										

              <?php }?>	
			 
								
								
									
									
					</table>
				</div>	
			</div>
					
					
					
					
					
					
		
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>
	<div class="col-md-3">
	
	
	<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
										  
<?php 	echo $this->session->flashdata('msg'); ?>
				
            	</div>
            </div>
			<div class="table table-responsive" >
                        <a  id="non-printable"  class="btn btn-primary" href="<?php echo base_url();?>user/openorders">Orders  </a>

		<?php
 if( $viewreport==true){

?>
	  <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Daily Report </a>
		  <a data-toggle='modal' data-target='#addgroupModal' class="btn btn-success">Group Report </a>
		<?php
 }

?>
	

<table class="table table-responsive" >



	<tr>
							<form name = "sales" id="sales"action="savesalesreading" method="post">

<?php
						echo $this->session->flashdata('salestmsg');
						echo $this->session->flashdata('updatemsg'); 
						
		echo $this->session->flashdata('deletemsg'); 
                 //echo form_open('user/addsale' , array('id'=>'sales','name'=>'','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="salestype" value="wholesale" class="form-control" required placeholder="Enter sales type">
<input type="hidden" name="myview" value="user/openclose" class="form-control" required placeholder="Enter view">

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

								<td >
																	<select name="type" id="type" class="form-control">

<option value="Cash" selected="selected">Cash</option>
<option value="Credit">Credit</option>
<option value="Invoice">Invoice</option>
<option value="Mpesa">Mpesa</option>
<option value="Bank">Bank</option>
</select>										</td>
			
								
								</td>
								<td>
<div class="form-group">

	<select class="chzn-select" name="customer" id="customer">
	
	<option value=""  >---Select Customer/Waiter---</option>
		<option value="directly"  >---Enter Name Directly---</option>

	
	<?php 
					 
			//$mycustomer= $this->usermodel->populateviewcustomers();
				$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);



if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

   //echo $courserow->coursename;
   ?>
					<option value="<?=  $mycustomerrow->id;   ?>"><?=  $mycustomerrow->idno ." ". $mycustomerrow->firstname ." ".$mycustomerrow->lastname." "; ?></option>




	<?php

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

  </td>
							</tr>



<tr>
								<td>
								
											  			  <a class="btn btn-warning" href="<?php echo base_url(); ?>user/suspendsales?randomitemidentifier=<?php   {echo  $salesid;}  ?>&view=user/viewwholesales">Suspend Sales </a>

		

  </td>
  <td>
																<input type="text" name="accountno" id="accountno" placeholder="Payment code" style="margin-bottom:0: "value="" class="form-control" /><br>

								<input type="text" name="due" id="due" placeholder="Due Date(Credit only)"  value="<?php echo$dateposted ;?>" class="tcal" /><br>


								
								
  </td>
								
							</tr>
						
							
							<tr>
								<td id="big">TOTAL</td>
								<td id="big">
										  		<input type="text"   readonly name="discountedtotal" value="<?php if(isset($totalcost)) {echo $totalcost; }?>" id="discountedtotal"class="form-control" required placeholder="total">
														<input type="text" name="name" id="name" placeholder="Customer Name(Optional)" style="margin-bottom:0: "value="" class="form-control" />

								</td>
							</tr>
						
										<?php 
						$maindiscount=$configuration[0]['maindiscount']; 
						if(($maindiscount=="yes")&&($maindiscount!="")){
						
						?>
							
							<tr>
								<td id="big"> Discount</td>
								<td id="big">

								
								<input type="text"  class="form-control" name="maindiscount" value="0" id="maindiscount"  placeholder="discount" onkeyup='OnChangediscount(this.value)' onkeypress="return isNumberKey(event)" autocomplete="off"  ="required"/>
																
							
								
								
								</td>
							</tr>
							
							
											<?php 
						
						}
						?>
							
							
							
							
							
							
							
							
							
								<tr>
								<tr>
								<td id="big">TENDERED</td>
								<td id="big">
		<input type="hidden" name="total"   placeholder="Cash" value="<?php if(isset($totalcost)) {echo $totalcost; }?>" />

								<input type="text"  class="form-control" name="cash" value="<?php if(isset($totalcost)) {echo $totalcost; }?>" id="cash"  placeholder="cash" onkeyup='OnChange(this.value)' onkeypress="return isNumberKey(event)" autocomplete="off"  required="required"/>
																
							
								
								
								</td>
							</tr>
								<tr>
								<td id="big">CHANGE</td>
								<td id="big">
		  		<input type="text"   readonly name="change" value="" id="change"class="form-control" required placeholder="Change">
								
								</td>
							</tr>
							
							<tr>
								
								<td colspan="2">	
						 <button type="submit"  value="sales" name="btn_savesales" id="btn_savesales"  class="btn btn-primary"><h4> Close/Print Receipt  </h4>  </button>
	         <button type="submit"  value="noreceipt" name="btn_savesales" id="btn_dontprint"  class="btn btn-warning"><h4> Close/ No Print  </h4>  </button>


  					<?php echo form_close();?>
				</td>
							</tr>
</table>




		</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/viewwholesales" 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="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="addgroupModal" 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">Group Sales Report</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewgroupsalesreportreading' , 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;?>

	
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$mydates); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$mydate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  
    
	
  
  
	
	
	
	
	
	
     <div class="form-group">
    <label for="inputtype" class="col-sm-2 control-label">Sales type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	<option selected="selected" value="all"  >---All/Any type--</option>
	<option value="Cash" >Cash</option>
<option value="Credit">Credit</option>
<option value="Invoice">Invoice</option>
<option value="Mpesa">Mpesa</option>
<option value="Bank">Bank</option>
	
</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
   

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-primary"> View group Sales  </button>

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

    

				</div>

		</div>
	    </div>
    </div>			
			
<div id="addModal" 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">Sales Report</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewsalesreportreading' , 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;?>

	
  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">From Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$mydates); ?>" class="form-control" required placeholder="Enter start date">
		 
				
		<span class="text-danger"> <?php echo form_error('fromdate'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputtodate" class="col-sm-2 control-label">	To Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="todate" value="<?php echo set_value('todate',$mydate); ?>" class="form-control" required placeholder="Enter End date">
		 
				
		<span class="text-danger"> <?php echo form_error('todate'); ?>
		
		</span>
	</div>
  </div>
  

  <div class="form-group" style="display:none">
    <label for="inputviewmaincategory" class="col-sm-2 control-label">Product Category?</label>
    <div class="col-sm-10">
	<select class="form-control" name="maincategory"  id="maincategory" required>
	
	<option selected="selected" value="all"  >---All/Any Category--</option>

	
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('maincategory','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

	</div>
  </div>

  
    
     <div class="form-group" style="display:none">
    <label for="inputtype" class="col-sm-2 control-label">Sales type?</label>
    <div class="col-sm-10">
	<select class="form-control" name="type" required>
	<option selected="selected" value="all"  >---All/Any type--</option>
	<option value="Cash" >Cash</option>
<option value="Credit">Credit</option>
<option value="Invoice">Invoice</option>
<option value="Mpesa">Mpesa</option>
<option value="Bank">Bank</option>
	
</select>
		
						<span class="text-danger"><?php echo form_error('type'); ?>

	</div>
  </div>
   

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="event" name="btn_addevent" class="btn btn-primary"> View Sales  </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>

















