

<script>
	function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

    // document.body.innerHTML = printContents.fontsize(12);
     window.print();

	 if( window.print()) {
         window.location.href = "../user/incomingstorestock";
		alert(" printing...........");
    }else {

	
		      return      window.location.href = "../user/incomingstorestock";

		    // document.body.innerHTML = originalContents;

	}
}
	</script>
 <style type="text/css">
  
  

    #myprint { display: none; }
#print{  	


    background-repeat: no-repeat;
	font-size;20px;
  
    width:100%; 


}

#sale{  	


    background-repeat: no-repeat;
  
    width:100px; height:50px;


}
    @media print
    {
    	#non-printable { display: none; }
    	#printableArea { display: block; font-size:16; width:100%; }
		    	#myprint { display: block; font-size:16; width:100%; }

    }
    </style>

         <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" id="non-printable">
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
						 <span class="pull-right"> Stock history</span>	
                        <a  id="more" target="blank" class="btn btn-primary" href="<?php echo base_url();?>user/viewstore">Back to store Products </a>
	 	  	 <a  id="more"  class="btn btn-primary" href="<?php echo base_url();?>user/incomingstorestock">View all Incoming store stock</a>


				
				 <div class="pull-right"  >
<form name="print" method="post" action="">
 <input type="submit" id="print"  accesskey="p" class="btn btn-primary"  name="print"onclick="printDiv('sortable_table')" value="print receipt!" />
</form></div>
            	</div>
            </div>
			<div class="panel-body">

				<div class="widget-content nopadding table_holder table-responsive" >				
	<?PHP
	 $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('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);

 echo $this->session->flashdata('deletemsg'); 

				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>Invoice No</th>
     <th>Name</th>
	     <th>total</th>
		 <th>Added Date</th>
		 	 <th>Supplier</th>
<th>Added by</th>
	<th id="non-printable">More</th>

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

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

 {


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

		 

             ?>



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

?>
    <td><?php echo $c->invoice_number ; ?></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->date ; ?></td>
	 
		 
		 
		  <td><?php 
	$supplier=$c->supplier;
	
	$mysupplier = $this->usermodel->populateall('people','id', $supplier);
	


if(is_array($mysupplier)) {

   foreach($mysupplier as $mycategoryrow){
		echo $mycategoryrow->firstname;


}} else {
    echo 'No Supplier .';
}
	
?>
</td>
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
		 
	 <td><?php  $userids= $c->userid ;

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

  ?></td>
	 	 <td id="non-printable"> 

 
 
					<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($usertype=="admin"){
											
											?>
                                    <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='#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;} ?>

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

									<td><input type="text" name="total" style="background:#999999 ; width:100px" readonly="true"  value="<?php if(isset($myqty)) {echo $myqty;   }?>" class="form-field"/> </td>
</td>
	<td colspan="4"></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/incomingstorestock">
 <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>
		</div>
  
  </div>
			
			
			
		
		
  

 
</div>


















