<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-ui.min.js"></script>
	

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		 $(document).on("click", "#approvebtn", function()
        {
          var aprrovalid = $(this).data('id');
		  $("#aprrovalid").val(aprrovalid); 
		   var aprrovalinvoice = $(this).data('invoice');
		  $("#aprrovalinvoice").val(aprrovalinvoice); 
		  
		  
		   
        });
		
			
		$(this).ready( function() {  
            $("#mysupplier").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
					//  url: "<?php echo base_url(); ?>Systemusers/customerSaleslookup",  

                       url: "<?php echo base_url(); ?>Systemusers/customerlookup",  
                        dataType: 'json',  
                        type: 'POST',  
                        data: req,  
                        success:      
                        function(data){  
                            if(data.response =="true"){  
                                add(data.message);  
                                console.log(data);
                            }  
                        },  
                    });  
                },  
                     
            });  
        });
		
    </script> 

 
 <div class="row">
  
   	

   	<div class="col-md-12">
			<?PHP
 echo $this->session->flashdata('deletemsg'); 
	 $session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
        
		 $userid = $data['id'];
$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
	 $data['branchid'] = $session_data['branchid'];
	 $branchid = $data['branchid'];
	 
		 $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);
    $approverequest=$this->usermodel->populatuserpermissionsdataarray('purchases','approve',$userid);
    $viewdirectpurchases=$this->usermodel->populatuserpermissionsdataarray('purchases','viewdirectpurchases',$userid);
	   	      $viewserials=$this->usermodel->populatuserpermissionsdataarray('purchases','viewserials',$userid);

	   $viewquotation=$this->usermodel->populatuserpermissionsdataarray('purchases','viewquotation',$userid);
  $viewpurchase=$this->usermodel->populatuserpermissionsdataarray('purchases','viewpurchase',$userid);
   $salesorder=$this->usermodel->populatuserpermissionsdataarray('purchases','salesorder',$userid);

  $budget=$this->usermodel->populatuserpermissionsdataarray('purchases','budget',$userid);
    $addpeople=$this->usermodel->populatuserpermissionsdataarray('members','add',$userid);
	   $viewallaction=$this->usermodel->populatuserpermissionsdataarray('reports','viewall',$userid);

  
$viewdebtors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewdebtors',$userid);
 	  	 $smsconfig = $this->usermodel->populateallarray('smsconfig','id',$companyid);
		 	  $tax1rate=$smsconfig[0]['tax1rate'];	

 $viewcreditors=$this->usermodel->populatuserpermissionsdataarray('incomeexpenses','viewcreditors',$userid);
function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}
				echo $this->session->flashdata('msg'); 
								?>	
  
		<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-right"> View Purchase Order</span>
	  <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Create New L.P.0 </a>
				 				 	  <a data-toggle='modal' data-target='#purchaseModal' class="btn btn-primary">Search for Purchases Order</a>
 
  <a data-toggle='modal' data-target='#uploadMasterModal' class="btn btn-default">Upload purchased Master </a>

 <a data-toggle='modal' data-target='#uploadModal' class="btn btn-default">Upload LPO Items   </a>

 <div class="collapse navbar-collapse" id="app-navbar-collapse">
             <ul class="nav navbar-nav">
				 <?php

 if( $viewserials==true){
 ?>
				   <li><a href="<?php echo base_url(); ?>user/viewserialnumbers">View Serials </a></li>

 
<?php	
}
  ?>
  
   <?php

 if( $viewdirectpurchases==true){
 ?>
                    <li><a href="<?php echo base_url(); ?>user/viewpurchases">View Purchase</a></li>

 
<?php	
}
  ?>
 <?php

 if( $viewquotation==true){
 ?>
                    <li><a href="<?php echo base_url(); ?>user/allquatation">View Quotation</a></li>

 
<?php	
}
  ?>
	  <?php

 if( $salesorder==true){
 ?>
 	  	  				 	  	                    <li> <a href="<?php echo base_url(); ?>user/salesorder"> Sales order</a>	</li>


 
<?php	
}
  ?>
  
  
  
   <?php

 if( $viewpurchase==true){
 ?>
 	  	  				 	  	  			                   <li> <a href="<?php echo base_url(); ?>user/allpurchaseorder">Purchases order</a>	</li>


 
<?php	
}
  ?>
  
  
  
    
   <?php

 if( $budget==true){
 ?>
 	  	  				 	  	  			                   <li> <a href="<?php echo base_url(); ?>user/viewbudget"> Budget</a>	</li>

 
<?php	
}
  ?>
  
  
  
	
	  <?php

 if( $addpeople==true){
 ?>
                         <a data-toggle='modal' data-target='#addsupplierModal' class="btn btn-default">Add Campany </a>

 
<?php	
}
  ?>
	  		


  <?php

 if( $viewdebtors==true){
 ?>
 	  	  				 <a href="<?php echo base_url();?>user/allcreditors" class="btn btn-default"> All Debtors</a>

 
<?php	
}
  ?>
	  <?php

 if( $viewcreditors==true){
 ?>
 						 	  	  				 <a href="<?php echo base_url();?>user/viewallcreditors" class="btn btn-default"> All Creditors</a>

 
<?php	
}
  ?>			

				  
				 
                </ul>
					
                <!-- Right Side Of Navbar -->

            </div>

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

			
	<div class="widget-content nopadding table_holder table-responsive" >				
	
					<div class="row">
						<div class="col-md-12">
							<div class="row">
						<div class="col-md-12">
							<center> <b style="color:red">Welcome to Purchase Order(L.P.O) Window </b></center>
<?php 
			 				echo $this->session->flashdata('deletemsg'); 

		// echo $this->session->flashdata('msg'); 
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallmysalesorder", $attr);?>
	

            				<input type="hidden" name="view" value="userdata/allpurchaseorder" id="view" class="form-control" required placeholder="Enter status">

			
                <div class="col-md-9">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="General search.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                  <div class="col-md-3">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/allpurchaseorder"; ?>" class="btn btn-primary">Refresh</a>
              
			
        <?php echo form_close(); ?>
		  </div>
			 </div>	
                 </div>
							<div class="panel-body">
		
								
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
  <th> View </th>
    <th> P.O No </th>
			<th> Amount </th>
					<th> P.Order Date </th>
			<th> Expiry Date </th>
				<th> Delivery Date </th>

			<th> Supplier </th>
			<th> Remarks </th>
				<th> status </th>
								<th> Approval  </th>
																<th> Staff </th>

																<th> Approver</th>

																<th> Branch</th>

					<th>More</th>

		


                 </tr>
             </thead>
<?php
 if(!is_array($viewpurchases)) {
				    echo '<div class="alert alert-danger text-center">There was no purchase found in the system</div>';

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

 {


   echo "<tr  style='margin-bottom:0px;margin-top:0px;' '>";
      echo "<td colspan='1'>";
    
       echo '<div class="alert alert-warning text-center">There no records found..</div>';
    echo "</td>";
   echo "</tr>";
    }else {
?>
    
             <?php 
  $totalamount=0;
  	foreach ($viewpurchases as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;
$invoice_number=$c->invoice;
$totalamount=$totalamount+$c->amount ; 
?>

              
  <td><?php 
  if($invoice_number==""){
	  echo $c->invoice ; 
	  
  }else{
	  
	  ?>
	  	  	  	 <a  id="more" class="btn btn-default"  href="<?php echo base_url();?>user/viewnewpurchaseorder?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">View </br> </a><?php echo $c->ordernumber ; ?>
	  	  	  	 <a  id="more" class="btn btn-info"  href="<?php echo base_url();?>user/viewreceivedproducts?randomitemidentifier=<?php   {echo  $invoice_number;}  ?>">Add Item(LPO) </a>

  

	  
	 <?php  

  }
  ?>
  

  
  
  
  </td>
  
    <td><?php echo $c->id ; ?></td>
  <td><?php echo $c->amount ; ?></td>
     <td><?php echo $c->fromdate ; ?></td>
    <td><?php echo $c->paiddate ; ?></td>

       <td><?php echo $c->deliverydate ; ?></td>

	 

	 <td>
	 
	 <a  href="<?php echo base_url();?>user/editmember?randomitemidentifier=<?php   {echo  $c->supplier ;}  ?>">

	
	 <?php  $userids= $c->supplier ;

$myuser=$this->usermodel->getpeople($userids);
    $myname=$myuser[0]['company'];
     $firstname=$myuser[0]['firstname'];
   if($myname!=""){
	   echo $myname;
	   
   }else{
	   
	   echo $firstname; 
	   
   }

  ?>
  </a>
  
  </td>
	  
	  
	  <td><?php echo $c->description ;
if($c->deliverymethod !=""){
	echo "<br>".$c->deliverymethod;
	
}


	  ?></td>
	   <td><?php echo $c->transactionstatus ; ?></td>
	   
	   	   <td style="color:blue"><?php echo $c->approvalstatus ; ?></td>
		   
		   	
		   		   <td><?php  $c->orderedby ; ?>
				   
				   	 <?php  $orderedby= $c->orderedby ;

$MYorderedby=$this->usermodel->getpeople($orderedby);
    $myname=$MYorderedby[0]['company'];
     $firstname=$MYorderedby[0]['firstname'];
   if($myname!=""){
	   echo $myname;
	   
   }else{
	      if($firstname!=""){
			  echo $firstname;   
		  }else{
			  echo $c->orderedby ;
		  }
	 
	   
   }

  ?>
				   
				   
				   
				   
				   
				   
				   
				   </td>

	   
		    <td>
	 

	
	 <?php  $controller= $c->controller ;

$controller=$this->usermodel->getpeople($controller);
    
     $firstname=$controller[0]['firstname'];
 
	   echo $firstname; 
	   
   

  ?>
</td>

       <td><?php

 	$branchss = $this->usermodel->populateallarray('branch','id',$c->branchid);

    echo$branchss[0]["name"];
 ?></td>
 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        More <span class="caret"></span>
                                    </button>
									                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">

									<?php
										if($usertype=="admin"){
											
											?>
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										<!--
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#deleteModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									    <li class="divider"></li>
										
										-->
										
										  
										<?php
										}
										if($approverequest==TRUE){
											
											?>
											
                                     	  <li> 

	 <a class="btn btn-default approvebtn" id="approvebtn" data-invoice='<?php echo  $c->invoice;?>'   data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#approveModal'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Approve / Reject
                                                </a>
                                                        </li>
															<?php
										}
										?>
										
										
										
										
										
										
										
										
                                  
                                        
                                       	
                                        <li class="divider"></li>
                                        <li> 
<a  id="more" class=" btn-success"  href="<?php echo base_url();?>user/viewmyexpense?pono=<?php   {echo  $c->ordernumber;}  ?>&finaltotal=<?php   {echo  $c->ordernumber;}  ?>">
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Expenses
                                                </a>
																		
										</li>
										
										<?PHP
	$APPROVALSTATUS= $c->approvalstatus;
    if($APPROVALSTATUS=="Approved") {
		?>
										
										  <li class="divider"></li>
                                        <li> 
<a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printpurchaseorder?invoice=<?php   if(isset($c->invoice)) {echo $c->invoice; } ?>&type=lpo"> 
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Print LPO
                                                </a>
																		
										</li>
										
									  <li class="divider"></li>
                                        <li> 
	 <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printgrn?invoice=<?php     if(isset($c->invoice)) {echo $c->invoice; } ?>&type=purchaseorder">  
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Print GRN
                                                </a>
																		
										</li>
											
												  <li class="divider"></li>
                                        <li> 
<a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/printinternalinvoice?invoice=<?php   if(isset($c->invoice)) {echo $c->invoice; } ?>&type=purchaseorder""> 
								 
																							 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Print Internal Invoice
                                                </a>
																		
										</li>
										
	<?PHP
	}
?>
										
										
										
                                        
                                    </ul>
											<?php
										
										?>
                                </div>
</td>
                  
             </tr>

	<?php endforeach;} ?>

              <?php }?>
 								<tr border="1" background="green">
									<td colspan="2"><b>Total amount</b></td>

									<td><input type="text" name="total" style="background:#999999 ; width:100px" readonly="true"  value="<?php if(isset($totalamount)) {echo formatMoney($totalamount, true);   }?>" class="form-field"/> </td>
</td>
	<td colspan="7"></td>								
</tr>
	
        </table>
		<div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Purchases (s) in the system. " ;?>    </span>

        
        </div>
	</div>

	
	
	
	<div id="approveModal" 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">Approval</h4>
      </div>
      <div class="modal-body">
        <h3>Are you sure you want to process this application? </h3>
      </div>
      <div class="modal-footer">
	  	

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

		
                 echo form_open('user/approveporequest' , 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="hidden" id="table"name="table" class="table" placeholder="view" value="purchaseorder">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/allpurchaseorder">

 
 
 
   
   	<div class="form-group">
    <label for="inputstatus" class="col-sm-2 control-label">Status	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="status" required >
	
	<option value=""  selected="selected">---Select Status---</option>
	<option value="Approved"  >Final Approved</option>
		<option value="Temporary Approved"  >Temporary Approved</option>

		<option value="Rejected"  >Rejected</option>
				<option value="Progress"  >Progress</option>
								<option value="Active"  >Active</option>

								<option value="Returned"  >Returned</option>

	</select>		 
				
		<span class="text-danger"> <?php echo form_error('status'); ?>
		
		</span>
	</div>
  </div>
  
  
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Comments</label>
    <div class="col-sm-10">

				<textarea name="description" value="<?php echo set_value('description'); ?>"  class="form-control"  placeholder="Enter any comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		
 
 
 <div class="form-group">
    <label for="inputapprovedby" class="col-sm-2 control-label">Approved  By?</label>
    <div class="col-sm-10">
	<select class="form-control" name="approvedby" required>
	
	<option value=""  >---Approved By?--</option>

		
	<?php 
				
				
	
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
   // echo 'No user available.';
}
	
?>

	<?php 
				
				
		if($usertype=="admin"){
			$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
		}
?>

</select>





		

	</div>
  </div>
  

 
 
 
 
 <input type="hidden" id="aprrovalid"name="aprrovalid" class="aprrovalid" placeholder="aprrovalid" value=""><br>
  <input type="hidden" id="aprrovalinvoice"name="aprrovalinvoice" class="aprrovalinvoice" placeholder="aprrovalinvoice" value=""><br>

 <button type="button" class="btn btn-warning" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_updatepoapproval" value="approval" class="btn btn-default"> YES  </button>

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

  </div>

  </div>

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

				<?PHP
//$session_data = $this->session->userdata('logged_in');
					 // $mydate=date("Y-m-d 00:00:00");
					 $mydate = date('Y-m-d H:i:s');

					  $todates=date("Y-m-d 23:59:59");

				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/viewpurchaseorderreport' , 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="inputbranchname" class="col-sm-2 control-label">Counter</label>
    <div class="col-sm-10">
	<select class="form-control" name="branchname"  id="branchname" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>
<?php
									 if( $viewallaction==true){
										 ?>
					<option value="all"  >All branches/Counters</option>
									<?php
									
							
				 
					 		$maincategory = $this->usermodel->populateall('branch','companyid',$companyid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

}} else {
    echo 'No main counter available.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

		
	</div>
  </div>
	
	
	
	
	
  <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',$mydate); ?>" 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',$todates); ?>" 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="inputsupplier" class="col-sm-2 control-label">supplier?</label>
    <div class="col-sm-10">
	<select class="form-control" name="supplier" required>
	
	<option value=""  >---Select supplier---</option>

		<option value="all" selected="selected" >--I want view all/any supplier---</option>
	<?php 
					 
			$mysuppliers =  $this->usermodel->populatemysupplier($companyid);
	

	
if(is_array($mysuppliers)) {

   foreach($mysuppliers as $suppliersrow){

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



	<?php

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

	</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 Purchases  </button>

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

    

				</div>

		</div>
	    </div>
    </div>	
	
	
	
	
	
	
	
				<div id="addsupplierModal" 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">Add new  Campany/Customer</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addmember' , 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="status" value="1"id="status" class="form-control" required placeholder="Enter status">

<input type="hidden" name="view" value="user/allpurchaseorder"id="view" class="form-control" required placeholder="Enter status">


	
		  		<input type="hidden" name="category" readonly     value="<?php echo set_value('category','supplier'); ?>" class="form-control"  placeholder="Enter ocategory">
		 
				
				
						
						
					<div class="form-group">
    <label for="inputcompany" class="col-sm-2 control-label">	Company Name </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="company" required value="<?php echo set_value('company'); ?>" class="form-control"  placeholder="Enter company name if any">
		 
				
		<span class="text-danger"> <?php echo form_error('company'); ?>
		
		</span>
	</div>
  </div>	
						
						
						
						
						
						
						
	<div class="form-group">
    <label for="inputfirstname" class="col-sm-2 control-label"> Contact	Names<span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="firstname" value="<?php echo set_value('firstname'); ?>" class="form-control" required placeholder="Enter first and last name">
		 
				
		<span class="text-danger"> <?php echo form_error('firstname'); ?>
		
		</span>
	</div>
  </div>

  
  	<div class="form-group">
    <label for="inputphone" class="col-sm-2 control-label">	Phone <span style="color:red;">*</span></label>
    <div class="col-sm-10">
	
		  		<input type="text" name="phone" value="<?php echo set_value('phone'); ?>" class="form-control" required placeholder="Enter phone e.g 254712345678">
		 
				
		<span class="text-danger"> e.g 254712345678 <?php echo form_error('phone'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphoneaddress_1" class="col-sm-2 control-label">Phone 2	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="address_1" value="<?php echo set_value('address_1'); ?>" class="form-control"  placeholder="Enter other line e.g 254712345678">
		 
				
		<span class="text-danger">Other Number e.g 254712345678 <?php echo form_error('address_1'); ?>
		
		</span>
	</div>
  </div>
  
   	<div class="form-group">
    <label for="inputphonegender" class="col-sm-2 control-label">Contact	Gender	 </label>
    <div class="col-sm-10">
	
	<select class="form-control" name="gender" >
	
	<option value=""  >---Select Gender---</option>
	<option value="female"  >female</option>
		<option value="male"  >male</option>
	</select>		 
				
		<span class="text-danger"> <?php echo form_error('gender'); ?>
		
		</span>
	</div>
  </div>
   <div class="form-group">
    <label for="inputcountry" class="col-sm-2 control-label">Country?</label>
    <div class="col-sm-10">
	<select class="form-control" name="country" >
	


	
	<?php 
					 
			$mycountry = $this->nationmodel->populatenation();
	


if(is_array($mycountry)) {

   foreach($mycountry as $mycountryrow){

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



	<?php

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

	</div>
  </div>
  
  
  
  
    	<div class="form-group">
    <label for="inputemail" class="col-sm-2 control-label">	Email </label>
    <div class="col-sm-10">
	
		  		<input type="email" name="email" value="<?php echo set_value('email'); ?>" class="form-control"  placeholder="Enter Your email">
		 
				
		<span class="text-danger"> <?php echo form_error('email'); ?>
		
		</span>
	</div>
  </div>
  
  	
 
  	<div class="form-group">
    <label for="inputidno" class="col-sm-2 control-label">	ID Number	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idno" value="<?php echo set_value('idno'); ?>" class="form-control"  placeholder="Enter idno if any ">
		 
				
		<span class="text-danger"> <?php echo form_error('idno'); ?>
		
		</span>
	</div>
  </div>
  
  
  
     
   	<div class="form-group">
    <label for="inputidnumber" class="col-sm-2 control-label">	PIN  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="idnumber" value="<?php echo set_value('idnumber'); ?>" class="form-control"  placeholder="Enter Campany Pin">
		 
				
		<span class="text-danger"> <?php echo form_error('idnumber'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
  
     
  
  
  
  
    
  	<div class="form-group">
    <label for="inputcity" class="col-sm-2 control-label">	City 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="city" value="<?php echo set_value('city'); ?>" class="form-control"  placeholder="Enter City or town">
		 
				
		<span class="text-danger"> <?php echo form_error('city'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  	<div class="form-group">
    <label for="inputzip" class="col-sm-2 control-label">	Zip Code 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="zip" value="<?php echo set_value('zip'); ?>" class="form-control"  placeholder="Enter Zip Code">
		 
				
		<span class="text-danger"> <?php echo form_error('zip'); ?>
		
		</span>
	</div>
  </div>
  
  
  
 
  
  	
 
  
    	<div class="form-group">
    <label for="inputwebsite" class="col-sm-2 control-label">		Website/Link 	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="website" value="<?php echo set_value('website'); ?>" class="form-control"  placeholder="Enter website if any">
		 
				
		<span class="text-danger"> <?php echo form_error('website'); ?>
		
		</span>
	</div>
  </div>
  
  	<div class="form-group">
    <label for="inputentrydate" class="col-sm-2 control-label">	Entry date  	 </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="entrydate" value="<?php echo set_value('entrydate'); ?>" class="form-control"  placeholder="Enter Entry date">
		 
				
		<span class="text-danger"> <?php echo form_error('entrydate'); ?>
		
		</span>
	</div>
  </div>
  
  
  
  
	<div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	Description</label>
    <div class="col-sm-10">

				<textarea name="comments" value="<?php echo set_value('comments'); ?>"  class="form-control"  placeholder="Enter comments"></textarea>
			
		<span class="text-danger"> <?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		

	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="member" name="btn_addmember" class="btn btn-primary"> Add Campany   </button>

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

    

				</div>

		</div>
	    </div>
    </div>						
			
			
	
	
	
	
	<div id="deleteModal" 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 item? </h3>
      </div>
      <div class="modal-footer">
	  	

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

		
                 echo form_open('user/deletebyid' , 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="hidden" id="table"name="table" class="table" placeholder="view" value="purchaseorder">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/allpurchaseorder">
 <input type="hidden" id="itemid1"name="itemid" class="itemid" placeholder="itemid" value=""><br>
 <button type="button" class="btn btn-success" data-dismiss="modal">No</button>
 		  	         <button type="submit" name="btn_delete" value="deletebyid" class="btn btn-danger"> Delete  </button>

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

  </div>

  </div>		
  
  
  
  
  
	
	
						<div id="uploadopeningbalancesModal" 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">Please Upload Correct Opening balances  data(CSV)</h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/supplierbalance.xlsx" class="btn btn-info">Download   opening balance template </a>	 

	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadsupplierinvoice' , 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="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewpurchases"id="view" class="form-control" required placeholder="Enter view">
	
	  <div class="form-group">
    <label for="inputfromdate" class="col-sm-2 control-label">Balance Date </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="fromdate" value="<?php echo set_value('fromdate',$new_date); ?>" 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="inputfiscalyear" class="col-sm-2 control-label">	Current fiscal year?</label>
    <div class="col-sm-10">
	<select class="form-control" name="fiscalyear"  id="fiscalyear" required>
	
	<option selected="selected" value="all"  >--Current fiscal year--</option>

	
	<?php 

					 		$productcategory = $this->usermodel->populatealldatawhere('fiscalyear','id','desc','companyid',$companyid);

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


							


if(is_array($productcategory)) {

   foreach($productcategory as $productcategoryrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $productcategoryrow->id;   ?>"><?=  $productcategoryrow->name." (From ".$productcategoryrow->startdate." to ". $productcategoryrow->enddate.")"; ?></option>



	<?php

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

	</div>
  </div>

	
	
	
  
  
  
  
  
  
  
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="uploadpurchases" name="btn_uploadsupplierinvoice" class="btn btn-default">Upload new Opening Balance  </button>

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

    

				</div>

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

						<div id="uploadMasterModal" 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">Please Upload Purchase Master(CSV)</h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/purchasemaster.xlsx" class="btn btn-info">Download   purchases template </a>	 

	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadpurchasesmaster' , 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="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewpurchases"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
		 <div class="form-group">
    <label for="inputpaymenttype" class="col-sm-2 control-label">Purchase type</label>
    <div class="col-sm-10">
	<select class="form-control" id="paymenttype" name="paymenttype" required required>
	
	<option value=""  >---Select Purchase type---</option>
			<option value="purchases" >Final Purchases</option>

		<option value="p.o"  selected="selected"  >LPO Purchases(Raw)</option>

		

</select>
		

	</div>
  </div>
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="uploadpurchases" name="btn_uploadpurchasesmaster" class="btn btn-default">Upload new purchases master </button>

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

    

				</div>

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

						<div id="uploadModal" 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">Please Upload Correct Products data(CSV)</h4>
		
      </div>
      <div class="modal-body">
        <a href="<?php echo base_url();?>downloads/purchasestock.csv" class="btn btn-info">Download   purchases template </a>	 

	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadlpo' , 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="type" value="product"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/allpurchaseorder"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="uploadpurchases" name="btn_uploadpurchases" class="btn btn-default">Upload new purchases  </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">Add new Purchase Order</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addpurchaseorder' , 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('invoiceno',$finalsalesid); ?>" class="form-control" required placeholder="Enter invoiceno">
<input type="hidden" name="view" value="user/viewnewpurchaseorder?randomitemidentifier=" class="form-control" required placeholder="Enter invoiceno">
								<input type="hidden" name="action" value="insert" class="form-control" required placeholder="Enter invoiceno">
								<input type="hidden" name="status" value="p.o" class="form-control" required placeholder="Enter sales">
								<input type="hidden" name="mytable" value="333" class="form-control" required placeholder="Enter remarks">
								<input type="hidden" name="paymentmethodes" value="" class="form-control" required placeholder="Enter invoiceno">
										<input type="hidden" name="branchid" value="<?php echo set_value('branchid',$branchid); ?>" class="form-control" required placeholder="Enter invoiceno">

  <center>  <b>LPO  No: <?php echo set_value('ordernumber',$ordernumber); ?> </b> </center>








					  <div class="form-group" style="display:none">
    <label for="inputsupplier" class="col-sm-3 control-label">Posting Branch/Counter</label>
    <div class="col-sm-9">
				
	
		
		
		
				
				<select class="form-control" name="branchidss"  id="branchid" required>
	
	
	<option value=""  >---Select Branch/Counter Name--</option>

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


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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



  <div class="form-group">
    <label for="inputbranchname" class="col-sm-3 control-label">Receiving Branch/Counter</label>
    <div class="col-sm-9">
	<select class="form-control" name="branchto"  id="branchto" required>
	
	
	<option value=""  selected="selected" >---Select Branch/Counter Name--</option>
	
		<option value="Main"  >Main Store</option>
<?php
									 if( $viewallaction==true){
										 ?>
				
									<?php
									
							
				 
					 		$maincategory = $this->usermodel->populateall('branch','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 counter available.';
}
 }else{
?>
	<?php 
					 
					 		$maincategory = $this->usermodel->populateall('branch','id',$branchid);


							


if(is_array($maincategory)) {

   foreach($maincategory as $maincategoryrow){

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



	<?php

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

		
	</div>
  </div>
	





			

 		<div class="form-group">
    <label for="inputordernumber" class="col-sm-3 control-label">LPO/Invoice  No:  </label>
    <div class="col-sm-9">
	
		<input type="text"  name="ordernumber" value="<?php echo set_value('ordernumber',$ordernumber); ?>" class="form-control"  placeholder="Enter  Invoice No if any  ">
		 
				
		<span class="text-danger"> <?php echo form_error('ordernumber'); ?>
		
		</span>
	</div>
  </div>


  
			
					  <div class="form-group">
    <label for="inputsupplier" class="col-sm-3 control-label">Supplier name</label>
    <div class="col-sm-9">
	
		  		<input type="text" name="supplier" id="mysupplier" autofocus value="<?php echo set_value('supplier'); ?>" class="form-control" required placeholder="Enter supplier name">
		 
				
		<span class="text-danger"> <?php echo form_error('supplier'); ?>
		
		</span>
	</div>
  </div>
				
				
				




  	
		
				
			  <div class="form-group">
    <label for="inputorderdate" class="col-sm-3 control-label">P.Order Date </label>
    <div class="col-sm-9">

	<input type="text" name="orderdate" value="<?php echo set_value('orderdate',$mydate); ?>"id="orderdate" class="form-control" required placeholder="Enter specific order date  (dd-mm-YYY) ">
			<span class="text-danger"> <?php echo form_error('orderdate'); ?>
		
		</span>
	</div>
  </div>		
			
		
					  <div class="form-group">
    <label for="inputcanceldate" class="col-sm-3 control-label">Exp Expiry Date </label>
    <div class="col-sm-9">

	<input type="text" name="canceldate" value="<?php echo set_value('canceldate',$mydate); ?>"id="canceldate" class="form-control" required placeholder="Enter Exp Expiry Date order date  (dd-mm-YYY) ">
			<span class="text-danger"> <?php echo form_error('canceldate'); ?>
		
		</span>
	</div>
  </div>		
		
	
		 
		<div class="form-group">
    <label for="inputorderedby" class="col-sm-3 control-label">	Ordered by: </label>
    <div class="col-sm-9">
	
		 <select class="form-control" name="orderedby" required>
	
	<option value=""  >---Prepared By?--</option>

		
	<?php 
				
				
	
			$allusers = $this->usermodel->populatealldatanoarray('people', 'id',$userid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
   // echo 'No user available.';
}
	
?>

	<?php 
				
				
		if($usertype=="admin"){
			$allusers = $this->usermodel->populatealldatanoarray('people', 'companyid',$companyid,'id >',0);

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){

   //echo $courserow->coursename;
    ?>
					<option value="<?=  $userrow->id;   ?>"><?=  $userrow->firstname ."- ".$userrow->surname ."(". $userrow->email.")"; ?></option>



	<?php

}} else {
    echo 'No user available.';
}
		}
?>

</select>

				
		<span class="text-danger"> <?php echo form_error('orderedby'); ?>
		
		</span>
	</div>
  </div>
	
			
	     	<div class="form-group" style="display:none">
    <label for="inputpin" class="col-sm-2 control-label">	VAT Rate  </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="vatrate" value="<?php     if(isset($tax1rate)) {echo $tax1rate; } ?>" class="form-control"  placeholder="Enter vat rate (%)">
		 
				
		<span class="text-danger"> <?php echo form_error('vatrate'); ?>
		
		</span>
	</div>
  </div>
						
			  <div class="form-group">
    <label for="inputterms" class="col-sm-3 control-label">Terms of payment </label>
    <div class="col-sm-9">

	<input type="text" name="terms" value="<?php echo set_value('terms',"On Delivery"); ?>"id="terms" class="form-control" required placeholder="Enter Terms of payment  ">
			<span class="text-danger"> <?php echo form_error('terms'); ?>
		
		</span>
	</div>
  </div>		
				
			  <div class="form-group">
    <label for="inputfob" class="col-sm-3 control-label">Freight On Board </label>
    <div class="col-sm-9">

	<input type="text" name="fob" value="<?php echo set_value('fob'); ?>"id="fob" class="form-control"  placeholder="Enter Freight On Board   ">
			<span class="text-danger"> <?php echo form_error('fob'); ?>
		
		</span>
	</div>
  </div>		
		
		
		
		
		
		
	

			    <div class="form-group">
    <label for="inputamount" class="col-sm-3 control-label">Total Amount   </label>
    <div class="col-sm-9">
		
				<input type="text" name="amount" readonly value="<?php echo set_value('0') ;?>" id="amount" class="form-control"   placeholder="Please total amount ">

				
		</span>
	</div>
  </div>
	
 
  	    <div class="form-group">
    <label for="inputdeliverymethod" class="col-sm-3 control-label"> Delivery Method:   </label>
    <div class="col-sm-9">
		
				<input type="text" name="deliverymethod" value="<?php echo set_value('deliverymethod',"Road") ;?>" id="dob" class="form-control"   placeholder="Please provide delivery method ">

				
		
	</div>
  </div>
  	

				
  
  
  
  <div class="form-group">
    <label for="inputshippingto" class="col-sm-3 control-label">Shipping to details..</label>
    <div class="col-sm-9">

	<textarea name="shippingto" class="form-control" placeholder="Shipping to details."><b>Please supply the following:</b></textarea> 			
	</div>
  </div>
<div class="form-group">
    <label for="inputdescription" class="col-sm-3 control-label">Note/Message</label>
    <div class="col-sm-9">

	<textarea name="description" class="form-control" placeholder="Bussines/comments/note"><?php echo set_value('description'); ?></textarea> 
			
	</div>
  </div>
  







 <div class="form-group">
    <label for="inputapprovedby" class="col-sm-3 control-label">Approver?</label>
    <div class="col-sm-9">
	<select class="form-control" name="controller" >
	
	<option value=""  >---Approver?--</option>

		
	
	<?php 
				
					$allusers = $this->usermodel->populatealldatanoarraythree('supervisor', 'companyid',$companyid,'status',"active",'id >',0);

	

	
if(is_array($allusers)) {

   foreach($allusers as $userrow){
	   
	   $biodata= $this->usermodel->populateallarray('people','id',$userrow->employeeno);
		
$name=$biodata[0]['firstname'] ."  "  .$biodata[0]['surname'];

$email=$biodata[0]['email'] ;

    ?>
						<option value="<?=  $userrow->employeeno;   ?>"><?=  $name ."(". $email.")"; ?></option>




	<?php

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





		

	</div>
  </div>
  









  	
  
<div class="form-group">
    <label for="inputsms" class="col-sm-3 control-label">Send SMS?</label>
    <div class="col-sm-9">
	<select class="form-control" name="sms" required>
	
	<option value=""  >---Do you want send sms to approver---</option>

		<option value="no" selected="selected" >No</option>

			<option value="yes" >Yes</option>

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

	</div>
  </div>
  
  

	
	 <div class="form-group">

    <div class="col-sm-10">
     
	         <button type="submit"  name="btn_purchaseorder"  value="mysalesorder"  class="btn btn-primary"> NEXT >> </button>

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

    

				</div>
				</div>
	

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

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

 
</div>


















