<link href="<?php echo base_url(); ?>assets/autocomplete/jquery-ui.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/ui.theme.css" rel="stylesheet">
    <link href="<?php echo base_url(); ?>assets/autocomplete/autocomplete.css" rel="stylesheet">
	
 <link href="<?php echo base_url(); ?>assets/select/chosen.min.css" rel="stylesheet" media="screen">
	
		   
		   		   <script src="<?php echo base_url(); ?>assets/select/chosen.jquery.min.js"></script>


 

<script type="text/javascript">
  
	 $(document).on("click", "#managebtndelete", function()
        {
          var itemid2 = $(this).data('id');
		  $("#itemid2").val(itemid2); 
		  
		  
		   
        });
				    $(function() {
<!--             $(".datepicker").datepicker(); -->
<!--             $(".uniform_on").uniform() -->;
            $(".chzn-select").chosen();
   <!--          $('.textarea').wysihtml5(); -->

        });
	
		
		
		
		 $(this).ready( function() {  
            $("#newproduct").autocomplete({  
 
                minLength: 1,  
                source:   
                function(req, add){  
                    $.ajax({  
                        url: "<?php echo base_url(); ?>Systemusers/productlistlookup",  
                        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">
	
  
		<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"> Move/distribute/break products</span>	
                        <a  id="more" class="btn btn-info" href="<?php echo base_url();?>Systemusers/viewproductlist/<?php   {echo  $page;}  ?>">Back to Products </a>


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

	  <?php
  echo $this->session->flashdata('deletemsg'); 
   echo $this->session->flashdata('msg'); 

				echo $this->session->flashdata('updatemsg'); 
   $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'];	
  
  



  ?>
										
		
							
	<div class="widget-content nopadding table_holder table-responsive" >				
	
							
		


    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Transfer/Move/Distribute stock (Eg Breaking Tots,packets etc)</h4>
      </div>
      <div class="modal-body">
      
	  	

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



		
                 echo form_open('user/movetock' , 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="code" value="<?php echo $code ?>"id="page" class="form-control" required placeholder="Enter bookid">

				<input type="hidden" name="view" value="user/viewdistribution?randomitemidentifier=<?php echo $itemid;?>&page=<?php echo $page;?>&code=<?php echo $code ?>" id="view" class="form-control" required placeholder="Enter view">
		<input type="hidden" name="productid" value="<?php echo $itemid;?>"id="productid3" 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">
<input type="hidden" name="mytype" value="shop"id="mytype" class="form-control" required placeholder="Enter type">


  

  	<div class="form-group">
    <label for="inputnewproduct" class="col-sm-2 control-label">Next Product Code</label>
    <div class="col-sm-10">
	

		
		
		<select class="chzn-select" name="newproduct" width="100%" required>
	
	<option value=""   >---Select child product-</option>

	
	<?php 
				$child  = $this->usermodel->populatealldatanoarray('uomproducts','code', $code,'status',"child" );

					 


							


if(is_array($child)) {

   foreach($child as $childrow){
											// $myproducts = $this->usermodel->populateallarray('productlist','code', $childrow->code);
										 $myproducts = $this->usermodel->populatealldataarray('productlist','code', $childrow->code,'branch', $branchid);
	$myname=$myproducts[0]['name'];
		$mysellingprice=$myproducts[0]['sellingprice'];
   //echo $courserow->coursename;
    ?>
					<option selected="selected" value="<?=  $childrow->code;   ?>"><?= $childrow->code." ". $myname. "  ".$mysellingprice; ?></option>



	<?php

}} else {
	

	
}

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

if(is_array($main)) {

   foreach($main as $mainrow){
											// $myproducts = $this->usermodel->populateallarray('productlist','code', $childrow->code);

   //echo $courserow->coursename;
    ?>
					<option  value="<?=  $mainrow->code;   ?>"><?= $mainrow->code." ".  $mainrow->name."  ".$mainrow->sellingprice;  ?></option>



	<?php

}} else {
	

	
}





	
?>
</select>
		
		
		
		
		
	</div>
  </div>
	
		<div class="form-group">
    <label for="inputtotal" class="col-sm-2 control-label">	Total items to deduct </label>
    <div class="col-sm-10">
	
		  		<input type="text"   name="description" value="1" id="description" class="form-control" required placeholder="Enter total no to deduct">
		 
				
		<span class="text-danger"> 	How many items do you want to deduct?<?php echo form_error('description'); ?>
		
		</span>
	</div>
  </div>

  	<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',0); ?>"id="total3" class="form-control" required placeholder="Enter total/Factor">
		 
				
		<span class="text-danger"> 	How many items do you want to add(Factor/Equivalent No)?<?php echo form_error('total'); ?>
		
		</span>
	</div>
  </div>
	
	
       
  <div class="form-group">
    <label for="inputtobranch" class="col-sm-2 control-label">To?</label>
    <div class="col-sm-10">
	<select class="form-control" name="tobranch" required>
	
	<option value=""  >---Where do you want to transfer product to?---</option>

	
	<?php 
					 

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



if(is_array($branch)) {

   foreach($branch as $branchrow){

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



	<?php

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


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

	</div>
  </div>
  	



<div class="form-group">
    <label for="inputbranch" class="col-sm-2 control-label">Branch(From)</label>
    <div class="col-sm-10">
	<select class="form-control" name="branch"  readonly id="branch3" required >

	
	

	
	<?php 
					$mybranch= $viewdistribution[0]["branch"];

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



if(is_array($branch)) {

   foreach($branch as $branchrow){

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



	<?php

}} else {
    echo 'No branch available.';
}
	
?>
</select>
		
						<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',$viewdistribution[0]["code"]); ?>"id="code3" 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',$viewdistribution[0]["name"]); ?>"id="name3" 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',$viewdistribution[0]["qty"]); ?>"id="qty3" 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',$viewdistribution[0]["reorderevel"]); ?>"id="reorderevel3" class="form-control" required placeholder="Enter reorder level">
		 
				
		<span class="text-danger"> <?php echo form_error('reorderevel'); ?>
		
		</span>
	</div>
  </div>
	
	
	
	
	

		
		
		
	
  
  
  
  
  
  
  
  
  
  

  
  
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="move" name="btn_movestock" 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>



















