<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 type="text/javascript">
      $(this).ready( function() {  
            $("#searchterm").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>/Systemusers/storeproductlookup",  
                        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 itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		   $(document).on("click", "#managebtn", function()
        {
          var productid = $(this).data('id');
		  $("#productid1").val(productid); 
		  
		    var name = $(this).data('name');
		   $("#name1").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description1").val(description); 
		 
		     var qty = $(this).data('qty');
		   $("#qty1").val(qty);


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

		     var reorderevel = $(this).data('reorderevel');
		   $("#reorderevel1").val(reorderevel); 			   
        });
		
		
     $(document).on("click", "#manageorderbtn", function()
        {
          var productid = $(this).data('id');
		  $("#productid2").val(productid); 
		  
		    var name = $(this).data('name');
		   $("#name2").val(name); 
		   
		     var description = $(this).data('description');
		   $("#description2").val(description); 
		 
		     var qty = $(this).data('qty');
		   $("#qty2").val(qty);


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

		     var reorderevel2 = $(this).data('reorderevel');
		   $("#reorderevel2").val(reorderevel2); 			   
        });
		
	
			
	   $(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');
		   $("#qty").val(qty);


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

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

 var wholesaleprice = $(this).data('wholesaleprice');
		   $("#wholesaleprice").val(wholesaleprice);
		   
		   
		    var store = $(this).data('store');
		   $("#store").val(store);
		    var tax_included = $(this).data('tax_included');
		   $("#tax_included").val(tax_included);
		   
		       var orderamount = $(this).data('orderamount');
		   $("#orderamount").val(orderamount);
		   
		          var shortname = $(this).data('shortname');
		   $("#shortname").val(shortname);
		   
        });
		
		
    </script>
 
 <div class="row">
  <?php
  echo $this->session->flashdata('deletemsg'); 
 
				echo $this->session->flashdata('msg'); 
   $session_data = $this->session->userdata('logged_in');

   
 	$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('store','add',$userid);
	      $bulkaction=$this->usermodel->populatuserpermissionsdataarray('store','bulk',$userid);

		   $updateaction=$this->usermodel->populatuserpermissionsdataarray('store','update',$userid);
  $addstockaction=$this->usermodel->populatuserpermissionsdataarray('store','addstock',$userid);
  $deleteaction=$this->usermodel->populatuserpermissionsdataarray('store','delete',$userid);
  $moreaction=$this->usermodel->populatuserpermissionsdataarray('store','more',$userid);
  $removestockaction=$this->usermodel->populatuserpermissionsdataarray('store','removestock',$userid);
  $removeallstockaction=$this->usermodel->populatuserpermissionsdataarray('store','removeallstock',$userid);
  $deleteorder=$this->usermodel->populatuserpermissionsdataarray('store','deleteorder',$userid);



  ?>
   	

   	<div class="col-md-12">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
							<?php

	
 if( $addproductaction==true){
	 ?>
												                     <a data-toggle='modal' data-target='#addModal' class="btn btn-primary">Add product </a>

	 
	 	<?php	

 }else{
	
 }
  ?>
	<?php

	
 if( $bulkaction==true){
	 ?>
												 													                     <a data-toggle='modal' data-target='#uploadModal' class="btn btn-primary">Product upload  </a>

	 
	 	<?php	

 }else{
	
 }
  ?>


 <a href="<?php echo base_url();?>downloads/products.csv" class="btn btn-success"> download  bulk products template </a>	

 <a href="<?php echo base_url();?>user/downloadstore" class="btn btn-success"> Download  store products   </a>	 

	 		<?php

	
 if( $removestockaction==true){
	 ?>

				 <a href="<?php echo base_url();?>user/viewmyorder" class="btn btn-primary"> My order </a>

	 	<?php	

 }else{
	
 }
  ?>

	 		<?php

	
 if( $removeallstockaction==true){
	 ?>

				 <a href="<?php echo base_url();?>user/viewallorder" class="btn btn-primary"> All order </a>

	 	<?php	

 }else{
	
 }
  ?>

 

				                  <span class="pull-right"> View Store Products</span>
            	</div>
            </div>
			
			<div class="panel-body">
			
	<div class="widget-content nopadding table_holder table-responsive" >				
	<div class="col-md-12">
        <?php 
		
        $attr = array("class" => "form-horizontal", "role" => "form", "id" => "search", "name" => "search");
        echo form_open("user/searchallstore", $attr);?>
            <div class="form-group">
			
                <div class="col-md-5">
                    <input class="form-control" id="searchterm" name="searchterm" placeholder="Search for product by name, code,description.." type="text" value="<?php echo set_value('searchterm'); ?>" />
                </div>
                <div class="col-md-4">
                    <input id="btn_search" name="btn_search" type="submit" class="btn btn-success" value="Search" />
                    <a href="<?php echo base_url(). "user/viewstore"; ?>" class="btn btn-primary">Refresh</a>
                </div>
				 
            </div>
        <?php echo form_close(); ?>

        </div>
			
						
					<div class="row">
					<?PHP

 
								?>
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
         <tr>
     <th>Code</th>
     <th>Product Name</th>
    <th>Short Name</th>
	     <th>Category</th>

	 
		   <th>B.price</th> 
		   <th>S.price</th> 
		<th>H.price</th>

<th>Qty</th>
<th>Shop</th>
<th>Edit</th>
<th>stock</th>
<th>Order</th>
<th>More</th>
              

<th>Delete</th>

			  </tr>
             </thead>
<?php



 if(!is_array($viewproducts)) {
				    echo '<div class="alert alert-danger text-center">There was no products found in the system</div>';

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

 {


   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 
  
  	foreach ($viewproducts as $c): 

		


             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>

              
  <td><?php echo $c->code ; ?></td>
    <td><?php echo $c->name."-".$c->description ; ?></td>
		    <td><?php echo $c->shortname ; ?></td>

    <td><?php 
	$category=$c->category;
	
	$mycategory = $this->usermodel->populatecategorybyowner($category);
	


if(is_array($mycategory)) {

   foreach($mycategory as $mycategoryrow){
		echo $mycategoryrow->name;


}} else {
    echo 'No Category .';
}
	$qty1=$c->qty ;
	$reorder=$c->reorderevel; 
	  $userids= $c->supplier ;

$myuser=$this->usermodel->geteuser($userids);
   //echo $myname=$myuser[0]['firstname'];
$c->expdate ;
?>
</td>

  <td><?php echo $c->buyingprice ; ?></td>
          <td><?php echo $c->sellingprice ; ?></td> 
      <td><?php echo $c->wholesaleprice ; ?></td>  
  
	<td><b>
			<?php 
			
			if($qty1>$reorder){
			
			?>
			<div style="background-color:green">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			}else if($qty1<=$reorder){
		?>
			<div style="background-color:orange">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			
			}else if($qty1==0){
			?>
			<div style="background-color:red">
			<?php  echo $c->qty ; 	?>
			</div>
			<?php
			}
			
		
			?>
			
		</b></td>
		<td><b>
			<?php 
			$mycode=$c->code;
			$mystock=$this->usermodel->populateallarray('products','code', $mycode);
			$myreorder=$mystock[0]['reorderevel'];
			$myqty1=$mystock[0]['qty']; 			
	 
			if($myqty1>$myreorder){
			
			?>
			<div style="background-color:green">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			}else if($myqty1<=$myreorder){
		?>
			<div style="background-color:orange">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			
			}else if($myqty1==0){
			?>
			<div style="background-color:red">
			<?php  echo $myqty1 ; 	?>
			</div>
			<?php
			}
			
		
			?>
			
		</b></td>
              <td>
			  
			<?php

	
 if( $updateaction==true){
	 ?>
		 <a class="btn btn-primary editbtn" id="editbtn"data-tax_included='<?php echo  $c->tax_included;?>'  data-shortname='<?php echo  $c->shortname;?>'  data-orderamount='<?php echo  $c->orderamount;?>'    data-expdate='<?php echo  $c->expdate;?>'data-store='<?php echo  $c->store;?>' 	data-supplier='<?php echo  $c->supplier;?>'  data-category='<?php echo  $c->category;?>'  data-buyingprice='<?php echo  $c->buyingprice;?>' data-sellingprice='<?php echo  $c->sellingprice;?>'data-promoprice='<?php echo  $c->promoprice;?>'  data-wholesaleprice='<?php echo  $c->wholesaleprice;?>' data-code='<?php echo  $c->code;?>' data-qty='<?php echo  $c->qty;?>'	data-description='<?php echo  $c->description;?>' data-name='<?php echo  $c->name;?>'	data-reorderevel='<?php echo  $c->reorderevel;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> Edit </a>	 

	 	<?php	

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

	
 if( $addstockaction==true){
	 ?>

	 	 <a class="btn btn-primary managebtn" id="managebtn"	data-code='<?php echo  $c->code;?>' data-qty='<?php echo  $c->qty;?>'	data-description='<?php echo  $c->description;?>' data-name='<?php echo  $c->name;?>'	data-reorderevel='<?php echo  $c->reorderevel;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editModal'> stock </a>	 

	 	<?php	

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

	
 if( $removestockaction==true){
	 ?>

	 	 <a class="btn btn-info manageorderbtn" id="manageorderbtn"	data-code='<?php echo  $c->code;?>' data-qty='<?php echo  $c->qty;?>'	data-description='<?php echo  $c->description;?>' data-name='<?php echo  $c->name;?>'	data-reorderevel='<?php echo  $c->reorderevel;?>'  data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editorderModal'> Order </a>	 

	 	<?php	

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

	
 if( $moreaction==true){
	 ?>

	 	 <a  id="more" class="btn btn-primary" href="<?php echo base_url();?>user/viewmorestockstore?randomitemidentifier=<?php   {echo  $id;}  ?>">More  </a>

	 	<?php	

 }else{
	
 }
  ?>



		 </td>	
		 
		 	 <td> 

 
 
					<div class="btn-group">
                                    <button type="button" class="btn btn-primary btn-sm dropdown-toggle" data-toggle="dropdown">
                                        Delete <span class="caret"></span>
                                    </button>
									<?php
										 if( $deleteaction==true){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#myDelete<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										}
										?>
                                </div>
</td>
             </tr>

	<?php endforeach;} ?>

              <?php }?>

        </table>
  <div class="col-md-12 text-center">    <?php echo $links; ?>
					   		<span style="color:red; font-size:20px"><?php  echo $total_rows. "   Products in the store. " ;?>    </span>

        
        </div>
									
									
									
					</div>				
							


			<div id="myDelete" 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="store">
<input type="hidden" name="type" value="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"id="view" class="form-control" required placeholder="Enter view">
 
 
 
 
 <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="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 Product</h4>
      </div>
      <div class="modal-body">
      
	  	

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

   
 	$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('msg'); 
		
                 echo form_open('user/addproduct' , 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="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"id="view" class="form-control" required placeholder="Enter view">

				  	<input type="hidden" name="branch" value="no"id="branch" class="form-control" required placeholder="Enter branch">

	<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" 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" 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="inputshortname" class="col-sm-2 control-label">	Short Name</label>
    <div class="col-sm-10">
		
				<input type="text" name="shortname" value="<?php echo set_value('shortname') ;?>"  class="form-control"  placeholder="Enter  Short  name">

		<span class="text-danger"> <?php echo form_error('shortname'); ?>
		
		</span>
	</div>
  </div>
  
  
    
  <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=""  >---Select Status---</option>
		<option value="active" selected="selected"  >Active</option>
		<option value="inactive"  >Inactive</option>
		<option value="global"  >Global</option>

	

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

	</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" required>
	
	<option value=""  >---Select Category---</option>

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


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" required>
	
	<option value=""  >---Select supplier---</option>

	
	<?php 
					 
			$allsuppliers =  $this->usermodel->populatemysupplier($companyid);
	

	
if(is_array($allsuppliers)) {

   foreach($allsuppliers 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">
    <label for="inputbuyingprice" class="col-sm-2 control-label">	B Price</label>
    <div class="col-sm-10">

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

				<input type="text" name="orderamount" value="0"  class="form-control"  placeholder="Enter  quantity to Reorder">
			
		<span class="text-danger"> <?php echo form_error('orderamount'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	
	
		<div class="form-group">
    <label for="inputtax_included" class="col-sm-2 control-label">	Tax included (%)</label>
    <div class="col-sm-10">

				<input type="text" 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" 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="expdate1" 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">
    <label for="inputphoto" class="col-sm-2 control-label">	Upload Image</label>
    <div class="col-sm-10">
	<input type="hidden" name="imgid"   value="<?php if(isset($imgid)) {echo $imgid; }?>"  class="form-control">


	<input type="file" name="photo" value="<?php echo set_value('photo'); ?>"id="photo" class="form-control"  placeholder="Please upload image if any">
			<span class="text-danger"> <?php echo form_error('photo'); ?>
		
		</span>
	</div>
	
	
	 <div class="form-group">

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

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

    

				</div>

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

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

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

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

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


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/updateproduct' , 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="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"id="view" 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="inputshortname" class="col-sm-2 control-label">	Short Name</label>
    <div class="col-sm-10">
		
				<input type="text" name="shortname" value="<?php echo set_value('shortname') ;?>"  id="shortname" class="form-control"  placeholder="Enter  Short  name">

		<span class="text-danger"> <?php echo form_error('shortname'); ?>
		
		</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->populateproductcategorybyid($companyid);
		 
	


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->populatemysupplier($companyid);



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="qty" value="<?php echo set_value('qty'); ?>"  class="form-control" required  placeholder="Enter quantity in stock">
			
		<span class="text-danger"> <?php echo form_error('qty'); ?>
		
		</span>
	</div>
  </div>
  	
	
		
	<div class="form-group">
    <label for="inputdescription" class="col-sm-2 control-label">	Description</label>
    <div class="col-sm-10">

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

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

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

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

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

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

				<input type="text"   id="expdate" name="expdate" value="<?php echo set_value('expdate'); ?>"  class="form-control"   placeholder="Enter expiry date">
			
		<span class="text-danger"> Enter expiry date  if any<?php echo form_error('expdate'); ?>
		
		</span>
	</div>
  </div>
	<div class="form-group">
    <label for="inputphoto" class="col-sm-2 control-label">	Upload Image</label>
    <div class="col-sm-10">

	

	<input type="file" name="photo" value="<?php echo set_value('photo'); ?>"id="photo" class="form-control"  placeholder="Please upload image if any">
			<span class="text-danger"> <?php echo form_error('photo'); ?>
		
		</span>
	</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>
						<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">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadproducts' , 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="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"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="products" name="btn_uploaduploadproducts" class="btn btn-primary">Upload products  </button>

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

    

				</div>

		</div>
	    </div>
    </div>
			<div id="editModal" 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 stock (<?PHP

 $postedtime = date('Y-m-d');
		$currenttime = date('h:i sa');
 		echo$dateposted =  ($postedtime)." ".$currenttime ;?>)</h4>
      </div>
      <div class="modal-body">
      
	  	

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



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

<input type="hidden" name="type" value="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"id="view" class="form-control" required placeholder="Enter view">
		<input type="hidden" name="productid" value=""id="productid1" 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="inputtotal" class="col-sm-2 control-label">	Total items to Add </label>
    <div class="col-sm-10">
	
		  		<input type="text"   name="total" value="<?php echo set_value('total'); ?>"id="total1" class="form-control" required placeholder="Enter total">
		 
				
		<span class="text-danger"> 	How many items do you want to add?<?php echo form_error('total'); ?>
		
		</span>
	</div>
  </div>
  
  
  
	
  
  
  <div class="form-group">
    <label for="inputfrom" class="col-sm-2 control-label">From?</label>
    <div class="col-sm-10">
	<select class="form-control" name="from" required>
	
	<option value=""  >--Where are you adding product from?---</option>

	
	<option value="external"  > from supplier</option>
	<option value="internal"  > from within</option>


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

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

		<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Product Name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>"id="name1" class="form-control" readonly required placeholder="Enter  Product name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
	
		<div class="form-group">
    <label for="inputqty" class="col-sm-2 control-label">	Total Remaining items </label>
    <div class="col-sm-10">
	
		  		<input type="text"  readonly name="qty" value="<?php echo set_value('qty'); ?>"id="qty1" class="form-control" required placeholder="Enter qty">
		 
				
		<span class="text-danger"> <?php echo form_error('qty'); ?>
		
		</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"  readonly  name="reorderevel" value="<?php echo set_value('reorderevel'); ?>"id="reorderevel1" class="form-control" required placeholder="Enter reorder level">
		 
				
		<span class="text-danger"> <?php echo form_error('reorderevel'); ?>
		
		</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" readonly id="description1"class="form-control"><?php echo set_value('description'); ?></textarea>		
		<span class="text-danger"> Enter description if any<?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		

  
  
  
  
  
  
  
  
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="store" name="btn_updatestore" class="btn btn-primary"> Update Stock   </button>

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

    

				</div>

		</div>
	    </div>
    </div>	
	
	
	
	
	
	
	
	
	
	
	
	
					<div id="editorderModal" 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">Order products (<?PHP

 $postedtime = date('Y-m-d');
		$currenttime = date('h:i sa');
 		echo$dateposted =  ($postedtime)." ".$currenttime ;?>)</h4>
      </div>
      <div class="modal-body">
      
	  	

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



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

<input type="hidden" name="type" value="store"id="type" class="form-control" required placeholder="Enter type">
				<input type="hidden" name="view" value="user/viewstore"id="view" class="form-control" required placeholder="Enter view">
		<input type="hidden" name="productid" value=""id="productid2" 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">	Product code</label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="code" value="<?php echo set_value('code'); ?>"id="code2" class="form-control" required placeholder="Enter  code">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>	

		<div class="form-group">
    <label for="inputname" class="col-sm-2 control-label">	Product Name</label>
    <div class="col-sm-10">
	
		  		<input type="text" name="name" value="<?php echo set_value('name'); ?>"id="name2" class="form-control" readonly required placeholder="Enter  Product name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>
	
		<div class="form-group">
    <label for="inputqty" class="col-sm-2 control-label">	Total Remaining items </label>
    <div class="col-sm-10">
	
		  		<input type="text"  readonly name="qty" value="<?php echo set_value('qty'); ?>"id="qty2" class="form-control" required placeholder="Enter qty">
		 
				
		<span class="text-danger"> <?php echo form_error('qty'); ?>
		
		</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"  readonly  name="reorderevel" value="<?php echo set_value('reorderevel'); ?>"id="reorderevel2" class="form-control" required placeholder="Enter reorder level">
		 
				
		<span class="text-danger"> <?php echo form_error('reorderevel'); ?>
		
		</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" readonly id="description2"class="form-control"><?php echo set_value('description'); ?></textarea>		
		<span class="text-danger"> Enter description if any<?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>
		
	
	
		<div class="form-group">
    <label for="inputtotal" class="col-sm-2 control-label">	Total items to Remove </label>
    <div class="col-sm-10">
	
		  		<input type="text"   name="total" value="<?php echo set_value('total'); ?>"id="total2" class="form-control" required placeholder="Enter total">
		 
				
		<span class="text-danger"> 	How many items do you want to remove?<?php echo form_error('total'); ?>
		
		</span>
	</div>
  </div>
  
  
  
	
  
  

  
  <div class="form-group">
    <label for="inputcomments" class="col-sm-2 control-label">	 Comments</label>
    <div class="col-sm-10">

<textarea name="comments"  id="comments"class="form-control" placeholder="Enter description/comments if any "><?php echo set_value('comments'); ?></textarea>		
		<span class="text-danger"> Enter description/comments if any<?php echo form_error('comments'); ?>
		
		</span>
	</div>
  </div>
		
  
  
  
  
  
  
    <div class="form-group">
    <label for="inputfrom" class="col-sm-2 control-label">From?</label>
    <div class="col-sm-10">
	<select class="form-control" name="from" required>
	
	<option value=""  >--Where are you adding product from?---</option>

	
	<option value="store to kitchen" selected > from store to kitchen</option>


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

	</div>
  </div>
  
  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="stock" name="btn_uaddstock" class="btn btn-primary">Move Stock   </button>

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

    

				</div>

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

 
</div>


</div>


</div>












