

         <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
		  
		   
        });
		
		
		
    </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"> Stock history</span>	
                        <a  id="more"  class="btn btn-primary" href="<?php echo base_url();?>user/viewproducts">back  </a>
						 

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

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


				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
				<table class="tablesorter table table-bordered  table-hover" id="sortable_table">			

             <thead>
			  <tr>
			 <th colspan="19"><center>
			 <?php  if(isset($configuration[0]['businessname'])) {echo   $configuration[0]['businessname']; }
			   $TIMEOFREPORT=date("d/m/Y H:i:s a");
			 ?>

			 <B><?PHP if(isset($reporttype)) {echo   $reporttype; } ?><BR> 
				Stock Movement  report  <?php  if(isset($finalfromdate)) {echo   date("d/m/Y H:i:s", strtotime($finalfromdate)); }?>    <?php  if(isset($finaltodate)) {echo     date("d/m/Y H:i:s", strtotime($finaltodate));; }?>   </B><br>
		Report was run on <?php  if(isset($TIMEOFREPORT)) {echo   date("d/m/Y H:i:s", strtotime($TIMEOFREPORT)); }?>
									<br>Name----------------------Date--------------------Signature----------------</span>

			</th>
	
			 </center>
			 </tr>
         <tr>
          <th>Invoice No</th>
     <th>Name</th>
	     <th>Added</th>
		 	     
		 	     <th>Before</th>
<th>After</th>
		      <th>Price</th>
		
	     <th>From</th>
		   <th>To</th>
		  <th>Branch</th>
		 <th>Added Date</th>
		 	 <th>Supplier</th>
			 <th>Batch</th>

<th>Added by</th>
	<th>More</th>
                 </tr>
             </thead>
	  <?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'];	
  
  
  $deleteincoming=$this->usermodel->populatuserpermissionsdataarray('incomingstock','delete',$userid);


 if(!is_array($mystock)) 

 {


   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 

    $myqty=0; 
  	foreach ($mystock as $c): 

		 

             ?>



          
             <tr>
                
            <?php 
$id=$c->id;
$myqty=$myqty+$c->total;

?>
    <td><?php
if(trim($c->invoice_number !="")){
 echo$c->invoice_number ; 
}else{
	 	 echo $c->invoice ; 
}	
if(trim($c->item_id !="")){
	
	if(($c->invoice_number!="") ||($c->invoice!="")){
	echo "<BR>".$c->item_id ; 

	}else{
		
	echo $c->item_id ; 
	
	}

}

if(trim($c->description !="")){
	if(trim($c->description) != trim($c->item_id)){
	echo "<BR>".$c->description ; 
	}
 
 
}		

 
 ?>
 



</td>
                 <td><?php 
	$itemid=$c->item_id;
	
	$mycategory = $this->usermodel->populateall('products','code', $itemid);
	


if(is_array($mycategory)) {

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


}} else {
    echo 'No Product .';
}
	
?>
</td>

 	

    <td><?php echo $c->total ; ?></td>
		    <td><?php echo $c->item_id1 ; ?></td>
	    <td><?php echo $c->balance ; ?></td>


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

		<td>
												 
	<?php 
					// $branch="";
					 $stockfrom=$c->stockfrom;

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



if(is_array($branchfrom)) {

   foreach($branchfrom as $branchfromrow){

   echo $branchfromrow->name;
 
 
}} else {
    echo $stockfrom;
}
	
?>
												 
	 </td>											 
			
		 <td>
												 
	<?php 
					// $branch="";
					// $type=$c->type;
 $type=$c->stockto;
					 $branchtype= $this->usermodel->populateall('branch','id',$type);



if(is_array($branchtype)) {

   foreach($branchtype as $branchtyperow){

   echo $branchtyperow->name;
 
 
}} else {
    echo $type;
}
	
?>
												 
	 </td>											 
			
	
	
	
	

	
	<td>
												 
	<?php 
					

					 $branchs= $this->usermodel->populateall('branch','id',$c->branchid);



if(is_array($branchs)) {

   foreach($branchs as $branchsrow){

   echo $branchsrow->name;
 
 
}} else {
 
}
	
?>
												 
	 </td>											 
			
	
	
	
	
	
	
	 <td><?php echo $c->date ; ?></td>
	 
		 
			 
		 
		  <td><?php 
		  
		  
		  
		  
		  
		  $allstocks = $this->usermodel->getstockbyinvoice($c->invoice_number);
						 $mysupplier=$allstocks[0]['supplier'];
if($mysupplier !=""){
$supliers=$this->usermodel->geteuser($mysupplier);

if($supliers[0]['company']!=""){
	   echo $supliers[0]['company'];
}else{
   echo $supliers[0]['firstname'];	
}

   
   
   
   
   
}else{
	
 echo "Internal ";	




}
		  
		  
		  

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

		 
		 
		 
	 <td><?php  $userids= $c->userid ;

$myuser=$this->usermodel->geteuser($userids);
   echo $myname=$myuser[0]['firstname'];

  ?></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>
									<?php
										//if($deleteincoming==true){
											
											?>
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
										
														<?php						
if(trim($c->description !="")){
 //echo "<BR>".$c->description ; 
 
 ?>
 
                                       
	  	  	  	 <a  id="more" target="_blank"  class="btn btn-default" href="<?php echo base_url();?>user/viewmyexpense?pono=<?php   {echo  $c->description;}  ?>&finaltotal=<?php   {echo  1;}  ?>">Expenses  </a>

											   <?php
}	
?>
		
                                        <!-- 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>
                                        
                                        <!-- teacher DELETION LINK -->
                                        
                                    </ul>
											<?php
										//}
									//	?>
                                </div>
</td>
             </tr>

	<?php endforeach;} ?>

             
			  
			  <!--
			  								<tr border="1" background="green">
									<td colspan="2"><b></b></td>

									<td><input type="text" name="total" style="background:#999999 ; width:100px" readonly="true"  value="<?php if(isset($myqty)) { $myqty;   }?>" class="form-field"/> </td>
</td>
	<td colspan="3"></td>								
</tr>
	
	
	-->
	

        </table>	
											
									
									
					</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="newstock">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/viewmorestock?randomitemidentifier=<?php echo $itemid;?>">
 <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 Category</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addcategory' , 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="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 name">
		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</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">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="category" name="btn_addcategory" class="btn btn-primary"> Add Category   </button>

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

    

				</div>

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





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

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

 
</div>


















