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

  
  ?>
		<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"> </span>
	  
				 	  				 <a href="<?php echo base_url();?>user/paybill" class="btn btn-info"> Back </a>
DAILY BILLS
				 
            	</div>
            </div>
			<div class="panel-body">


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

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


		
                 echo form_open('user/addbill' , array('class' => 'form-inline form-groups-bordered validate', 'enctype' => 'multipart/form-data'));
				 if(validation_errors()):
				 $salesid=$main[0]['invoice']

				 ?>
<div class='alert alert-danger text-center'><?php echo validation_errors(); ?></div>
<?php endif;?>

 </div>
	<div class="col-md-12">
									<input type="hidden" name="view" value="user/editbill?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">
								<input type="hidden" name="action" value="update" class="form-control" required placeholder="Enter invoiceno">

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

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


   <?php
 $countryid= $main[0]['supplier'];
 		$mysupplier= $this->usermodel->populateall('people','id',$countryid);



if(is_array($mysupplier)) {

   foreach($mysupplier as $mysupplierrow){

    ?>
					<option selected="selected" value="<?=  $mysupplierrow->id;   ?>"><?=  $mysupplierrow->company ."(". $mysupplierrow->firstname ." ".$mysupplierrow->lastname.")"; ?></option>

   
    <?php

}} else {
 ?>
<option value=""  >---Select supplier/customer---</option>

		<?php 
}


	
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


if(is_array($mycustomer)) {

   foreach($mycustomer as $mycustomerrow){

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




	<?php

}} else {
    echo 'No supplier available.';
}
	
?>
</select>		
		  		
				
		<span class="text-danger"> 	<?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>	
		
			  <div class="form-group">
    <label for="inputdatespent" class="col-sm-2 control-label">Bill  Date </label>
    <div class="col-sm-4">

	<input type="text"   name="datespent" value="<?php echo set_value('datespent',$main[0]['datespent']); ?>"id="datespent" class="form-control" required placeholder="Enter Bill date  ">
			<span class="text-danger"> <?php echo form_error('datespent'); ?>
		
		</span>
	</div>
  </div>	
  	
	 
	   </div>
		<div class="col-md-12">

		
		
				
			  <div class="form-group">
    <label for="inputorderdate" class="col-sm-2 control-label">Date captured </label>
    <div class="col-sm-4">

	<input type="text" readonly  name="dateposted" value="<?php echo set_value('dateposted',$main[0]['dateposted']); ?>"id="dateposted" class="form-control" required placeholder="Enter date  ">
			<span class="text-danger"> <?php echo form_error('dateposted'); ?>
		
		</span>
	</div>
  </div>		
			
		
					  <div class="form-group">
    <label for="inputduedate" class="col-sm-2 control-label">Due Date </label>
    <div class="col-sm-4">

	<input type="text" name="duedate" value="<?php echo set_value('duedate',$main[0]['duedate']); ?>"id="duedate" class="form-control" required placeholder="Enter due date ">
			<span class="text-danger"> <?php echo form_error('duedate'); ?>
		
		</span>
	</div>
  </div>		
		
		   </div>
	


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

			  <div class="form-group">
    <label for="inputinvoice" class="col-sm-2 control-label">Bill No</label>
    <div class="col-sm-4">
<input type="text" readonly name="id" value="<?php echo set_value('id',$main[0]['id']); ?>" class="form-control" required placeholder="Enter bill no">
			<span class="text-danger"> <?php echo form_error('id'); ?>
		
		</span>
	</div>
	 
  </div>
 
 
				  <div class="form-group">
    <label for="inputinvoice" class="col-sm-2 control-label">Ref NO </label>
    <div class="col-sm-4">
<input type="text" readonly name="invoice" value="<?php echo set_value('invoice',$main[0]['invoice']); ?>" class="form-control" required placeholder="Enter invoiceno">
			<span class="text-danger"> <?php echo form_error('invoice'); ?>
		
		</span>
	</div>

  </div>
 
  	  

				
  		
  
  
  

  
</div>

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

			<div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label"> Amount   </label>
    <div class="col-sm-4">
		
				<input type="text"  name="amount" value="<?php echo set_value('amount',$main[0]['amount']) ;?>" id="dob" class="form-control" required  placeholder="Please enter amount ">

				
		</span>
	</div>
  </div>
  	  
 <div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">Invoice /Purchase Order No</label>
    <div class="col-sm-4">

	<input type="text"   name="idno" value="<?php echo set_value('idno',$main[0]['idno']); ?>"id="dateposted" class="form-control"  placeholder="Enter Invoice or Purchase Order Number if any ">
			<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>	
			
  
  

  
</div>

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

  	
				  <div class="form-group">
    <label for="inputuser" class="col-sm-2 control-label">Contact Person? </label>
    <div class="col-sm-4">

	<input type="text" name="user" value="<?php echo set_value('user',$main[0]['user']); ?>"id="contact" class="form-control" required placeholder="Enter Contact Person">
			<span class="text-danger"> <?php echo form_error('user'); ?>
		
		</span>
	</div>
  </div>
  	  <div class="form-group">
    <label for="inputcontroller" class="col-sm-2 control-label">Approved by? </label>
    <div class="col-sm-4">
<input type="text"  name="controller" value="<?php echo set_value('controller',$main[0]['controller']); ?>" class="form-control" required placeholder="Enter controller">
			<span class="text-danger"> <?php echo form_error('controller'); ?>
		
		</span>
	</div>
  </div>
  </div>
		

	
				
  	<div class="col-md-12">		
<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">Description/Note</label>
    <div class="col-sm-4">

	<textarea name="description" class="form-control" placeholder="Bussines/comments/note"><?php echo set_value('description',$main[0]['description']); ?></textarea> 
			
	</div>
  </div>
 	
  		<div class="form-group">
    <label for="inputterms" class="col-sm-2 control-label"> Terms of Payment   </label>
    <div class="col-sm-4">
		
				<input type="text"  name="terms" value="<?php echo set_value('terms',$main[0]['terms']) ;?>" id="dob" class="form-control"   placeholder="Please enter payment terms ">

				
		</span>
	</div>
  </div>
  	
  
	<div class="form-group">	
    <label for="inputterms" class="col-sm-2 control-label"> </label>

    <div class="col-sm-4">
	
     
	         <button type="submit"  name="btn_addbill"  value="bill"  class="btn btn-primary"> Update Bill</button>
<a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printmybill?invoice=<?php   if(isset($main[0]['invoice'])) {echo $main[0]['invoice']; } ?>">  Print Bill   </a>

    </div>
  </div>
  
  
  	 
  
						
			
				 
  	
		
  
  

	
  					<?php echo form_close();?>
					
		 </div>			
			  </div>		
			
				<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>Account:</th>
							
								<th colspan="2">Description:</th>
								<th>Ref No:</th>

								
								<th>Total</th>
								<th>Customer</th>
						<th>Save</th>

									<th></th>	
								
							</tr>
								<tr>
								
										<?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',$finalsalesid);
$myinvoice=$invoicestatus[0]["status"];
  
   echo $this->session->flashdata('productmsg'); 
                 echo form_open('user/addnewbill' , 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="invoice" value="<?php echo set_value('invoice',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoice">

									<input type="hidden" name="view" value="user/editbill?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">


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

									<input type="hidden" name="myid" id="myid" value="" class="form-control" required placeholder="myid" >
	<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter insert">


								
								
									<th>
								

	<select class="chzn-select" name="bankname" required>
	
	<option value=""  >Select Account</option>
	
	<?php 
	$session_data = $this->session->userdata('logged_in');

  
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
		 $data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
					 
										$banking= $this->usermodel->populatealldatanoarray('glaccounts','companyid',$companyid,'description','5');


	
if(is_array($banking)) {

   foreach($banking as $bankingrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $bankingrow->number;   ?>"><?=  $bankingrow->accountname; ?></option>



	<?php

}} else {
    echo 'No bank available.';
}
	
?>
</select>
		
	
								
								
								</th>
								
								
									
								
								
								
						<th colspan="2">
								

								
		  		<input type="text" name="description" id="description" value="<?php echo set_value('description'); ?>" class="form-control"  placeholder="Enter description" >
								
								</th>
								
					
							<th>
								

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

								
		  		<input type="text" name="amount" id="amount" value="<?php echo set_value('amount','0'); ?>" class="form-control" required placeholder="amount" >
								
								</th>
							<th>
								<select class="form-control"name="supplier" id="supplier" style="display:none" >
	
	<option value=""  selected="selected">---Select Customer/supplier/vender---</option>




		<?php 



	
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


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 supplier available.';
}
	
?>
</select>	

	
	<select class="form-control" name="tax" >
	
							<option value="VATABLE"   >VATABLE</option>

			<option value="ZERO RATED"  >ZERO RATED</option>
					  				<option value="EXEMPTED"  selected >EXEMPTED</option>

	
</select>
		
							
							</th>
								<th>
																			  		<input type="text" name="code" id="code" style="width:55%" value="<?php echo set_value('code',0); ?>" class="form-control2"  placeholder="Ente Vat %" >

									Vat
									</th>
								
								<th >

								
								<button type="submit"  value="statement" name="btn_statment" class="btn btn-primary"> Post Bill  </button>

 
  					<?php echo form_close();?>
								
								</th>
								
							</tr>
								
						</thead>
						<?php
					 $finaltotal=0;
  $totalfinaltotal=0;
 if(!is_array($submain)) {
	  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 ($submain as $c){
		
$itemid=$c->id;
$total=$c->amount;
$finaltotal=$finaltotal+$total;
             ?>
				                    <tbody >
									
										 
										<?php
					
		
                 echo form_open('user/addnewbill' , 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>
		



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

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

													<input type="hidden" name="action" value="update" class="form-control" required placeholder="Enter insert">
		<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="view" value="user/editbill?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">

											
											
											
			<td>
			
				 <?php  $accountid= $c->account ;
	 $myaccount = $this->usermodel->populateallarray('glaccounts','number', $accountid);

   echo $myaccount[0]['accountname'];

  ?>
			
			</td>
			
			<td colspan="2"><?php echo $c->description; ?></td>

	<td><?php echo $c->refno; ?></td>
					<td><?php echo $c->amount; ?></td>

							  
											<td >
			
			
			
				
	<select class="form-control" name="tax" >

								<option  selected="selected" value="<?php echo $c->tax ?>"   ><?php echo $c->tax; ?></option>

							<option value="VATABLE"   >VATABLE</option>

			<option value="ZERO RATED"  >ZERO RATED</option>
					  				<option value="EXEMPTED"   >EXEMPTED</option>

	
</select>
		
			
			
			
			
			
			
			</td>

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


				
				</td>					
											 
		
				  									 
								<td >
				

										  		<input type="text" name="code" id="code" style="width:25%" value="<?php echo set_value('code',$c->code); ?>" class="form-control2"  placeholder="Ente Vat %" >

				
				</td>					
												 
											 
											 
											 
											 
											 
												  
											  
											  
											  
											  
											  <td>   <!--
								<button type="submit"  value="statement" name="btn_statment" class="btn btn-primary"> Update Bill  </button>
-->
											  </td>
											  
											  
												 	<td  style='color:green'> 
				<?php

	
 if( $deleteaction==true){
	 
	 ?>
		   		                              <a  id="more" class="btn btn-danger" href="<?php echo base_url();?>user/deletepurchasedproducts?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&itemid=<?php   {echo  $c->id;}  ?>&view=user/editbill?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&deltetable=statement&maintable=expenses"> <span class="glyphicon glyphicon-trash"></span> </a>

	 
	 	<?php	

 }else{
	
 }
  ?>
		                              </td> 
		  					<?php echo form_close();?>
					
 </tr>
 <?php 
	 }?>
				<?php }?>		
				
	<tr style="display:none" >
								<td><b>Item Name/Code:</b></td>
									<td><b>Qty:</b></td>
								<td><b>Description:</b></td>
								<td><b>Rate:</b></td>
									<td><b>Total:</b></td>
										<td><b>Customer:<b></td>
									
							<td></td>
								
							</tr>
	<tr style="display:none" >
														

								<td colspan="1">
										<?php
	 $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'];	
	   
   //echo $this->session->flashdata('productmsg'); 
                 echo form_open('user/addexpenses' , 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="invoice" value="<?php echo set_value('invoice',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoice">
									<input type="hidden" name="view" value="user/editbill?randomitemidentifier=<?php echo $main[0]['invoice']; ?>" class="form-control" required placeholder="Enter invoiceno">

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

		 
								</td>
								
								<td>
								

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

								
		  		<input type="text" name="description" id="description" value="<?php echo set_value('description'); ?>" class="form-control"  placeholder="description" >
								
								</td>
								
								
								
								<td>
							</td>
								
							<td>
					
								<select class="form-control"name="customer" id="customer" >
	
	<option value=""  >---Select Customer/supplier/vender---</option>




		<?php 



	
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


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 supplier available.';
}
	
?>
</select>	
							
					
							
							</td>
								
							
								
								<td colspan="2">

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

 
  					<?php echo form_close();?>
								
								</td>
							
							
							
							
							
							
							</tr>
							
							
						
						<?php
					
						 $totalcost=0;
  $myfinaltotal=0;
 if(!is_array($mysubmain)) {
	  echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='5'>";
  //  echo"There is no data found..";
    echo "</td>";
   echo "</tr>";
												$totalfinaltotal= $finaltotal;

			 }else{
 

  	foreach ($mysubmain as $row){
		
	
 $itemid=$row->code;
  $myid=$row->id;
   $productid=$row->id;
		 		$recaiving= $this->usermodel->populateall('products', 'code',$itemid);
				
			
 if(is_array($recaiving)){
	 
	 foreach ($recaiving as $c){
 
   $c->code;

             ?>	<tr>
									
										 
										<?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 ; 
						 $receiptdescription=$configuration[0]['receiptdescription'];
							      $productname = $this->usermodel->populateallarray('products','code',$itemid);
		
   $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="hidden" name="finalsalesid" id="finalsalesid" value="<?php echo set_value('finalsalesid',$finalsalesid); ?>" class="form-control" required placeholder="finalsalesid" >
											<input type="hidden" name="itemid" id="itemid" value="<?php echo set_value('itemid',$row->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" >

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

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

		
													
													</td>
										 
											 
											 
											 
											 
											 
											 
											 
											 
											 	 <td><?php 
												
												echo $totalcost=(($row->qty)*($row->bprice)) ;
												 $myfinaltotal=$myfinaltotal+$totalcost;
												$totalfinaltotal= $myfinaltotal+ $finaltotal;
												 ?></td>
				  
												  
											  
											  
											  
											  
											  <th>
									
											  <select class="form-control"name="customer" id="customer" >
	


   <?php
  $supplierid=$row->customer;
 		$mysupplier= $this->usermodel->populateall('people','id',$supplierid);



if(is_array($mysupplier)) {

   foreach($mysupplier as $mysupplierrow){

    ?>
					<option selected="selected" value="<?=  $mysupplierrow->id;   ?>"><?=  $mysupplierrow->idno ."". $mysupplierrow->firstname ." ".$mysupplierrow->lastname.""; ?></option>

   
    <?php

}} else {
 ?>
<option value=""  >---Select supplier/customer---</option>

		<?php 
}


	
					 
			$mycustomer= $this->usermodel->populateviewcustomers('people','firstname','ASC','companyid', $companyid);
	     // $mycustomer=$this->usermodel->populatealldatawhere('products','bulk',$userid);


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 supplier available.';
}
	
?>
</select>		
											  
								
							</th>
											  
											  
												 	<td  style='color:green'> 
		
		                              <a  id="more" class="btn btn-danger" href="<?php echo base_url();?>user/deletepurchasedproducts?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&itemid=<?php   {echo  $productid;}  ?>&view=user/editbill?randomitemidentifier=<?php   {echo  $finalsalesid;}  ?>&deltetable=purchaseorderlist&maintable=expenses"> <span class="glyphicon glyphicon-trash"></span> </a>

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

									  </td>
						
						

 <?php echo form_close();?>	
  					

 </tr>   

 <?php 
	 }?>
	 
				<?php }?>							
	<?php }} ?>

								
	
<tr>
			<td colspan="4"><h3 style="padding:0; margin:0;">
			TOTAL MONEY SPENT:
			</h3>
				</td>
			
								<td colspan="4"><h3 style="padding:0; margin:0;">Total:<?php if(isset($totalfinaltotal)) {echo formatMoney($totalfinaltotal, true); }?></h3></td>
			
				
			
			</tr>
							
							
         
								
				
									</tbody>
									
									
					</table>
					
					
				</div>	
			</div>			
					
					
					
					
					
					
					
					
					
			</div>							   
				
									
							
								
			<div class="modal-footer">

    

				</div>

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

 
</div>


















