<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"> SWAP YOUR PRODUCTS</span>	
                        <a  id="more" class="btn btn-info"  href="searchinvoice?code=<?php echo $invoice ;?>">Back to Sales order </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">SWAP / EXCHANGE PRODUCTS</h4>
      </div>
      <div class="modal-body">
      
	  	

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



		
                 echo form_open('user/swapstock' , 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="myview" value="user/searchinvoice?code=<?php echo $invoice ;?>"id="view" class="form-control" required placeholder="Enter view">

				<input type="hidden" name="view" value="user/viewswapping?randomitemidentifier=<?php echo $itemid;?>&page=<?php echo $page;?>&code=<?php echo $code ?>&invoice=<?php echo $invoice ?>" 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"> Product to swap to?</label>
    <div class="col-sm-10">
	

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

	
	<?php 
	
$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 sold</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('description'); ?>
		
		</span>
	</div>
  </div>


			<div class="form-group">
    <label for="inputtotal" class="col-sm-2 control-label">	Selling Price</label>
    <div class="col-sm-10">
	
		 
						  		<input type="text"   readonly name="sellingprice" value="<?php echo set_value('sellingprice',$viewdistribution[0]["sprice"]); ?>"id="qty3" class="form-control" required placeholder="Enter sellingprice">

		<span class="text-danger"> <?php echo form_error('sellingprice'); ?>
		
		</span>
	</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',$viewproducts[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">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="swap" name="btn_swaptock" class="btn btn-primary"> SWAP PRODUCT   </button>

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

    

				</div>

		</div>
	 
  







							
</div>	

	
					

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

 
</div>



















