<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/viewtocktaking";
		alert(" printing...........");
    }else {

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

		    // document.body.innerHTML = originalContents;

	}
}

 
	</script>
    <script type="text/javascript">
  
		
		 $(document).on("click", "#managebtndelete", function()
        {
          var itemid = $(this).data('id');
		  $("#itemid1").val(itemid); 
		  
        });
		$(document).on("click", "#editbtn", function()
        {
		 var mycategoryid = $(this).data('id');
		  $("#mycategoryid").val(mycategoryid); 
		   
			var qtymode = $(this).data('qtymode');
		   $("#qtymode").val(qtymode);
 
		    var code = $(this).data('code');
		   $("#code").val(code); 
		   
		     var amount = $(this).data('amount');
		   $("#amount").val(amount); 
		    var amountmode = $(this).data('amountmode');
		   $("#amountmode").val(amountmode);
 
 
		   		   
   var status = $(this).data('status');
		   $("#status").val(status);
 
		    var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var category = $(this).data('category');
		   $("#category").val(category); 
		    var unit = $(this).data('unit');
		   $("#unit").val(unit);
 
		    var name = $(this).data('name');
		   $("#name").val(name); 
		   
		     var quantity = $(this).data('quantity');
		   $("#quantity").val(quantity); 
		 
		  
		  
		   
        });
		
		
		
		
    </script>   
   <style type="text/css">
  
  

    #printable { 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%; }
    }
    </style>
   	
 <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>
Pay slip.
<br>
 <a class="btn btn-default" href="<?php echo base_url(); ?>user/viewmember">View Employees?</a>
	<a class="btn btn-default" href="<?php echo base_url(); ?>user/payrollsetup"> Pay/Deduction Setup</a>
	<a class="btn btn-default" href="<?php echo base_url(); ?>user/salaryhistory"> Salary History</a>
		<a class="btn btn-default" href="<?php echo base_url(); ?>user/viewrequest"> Human Resource</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
				echo $this->session->flashdata('activemsg'); 								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
	<table cellpadding="0" cellspacing="0" border="1"  style="border-color:#CCCCCC; width:100%;" id="sortable_table" >

	
	
				 <tr>
							<td valign="top" colspan="2">
							<center>
<?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'];	


   function formatMoney($number, $fractional=false) {
						if ($fractional) {
							$number = sprintf('%.2f', $number);
						}
						while (true) {
							$replaced = preg_replace('/(-?\d+)(\d\d\d)/', '$1,$2', $number);
							if ($replaced != $number) {
								$number = $replaced;
							} else {
								break;
							}
						}
						return $number;
					}









								$profile = $this->usermodel->populateall('smsconfig','id',$companyid);

	
		if(!is_array($profile)) 

 {
	 $this->session->set_flashdata('msg', '<div class="alert alert-danger fade in">
						 <a href="#" class="close" data-dismiss="alert">&times;</a><strong>Error!</strong>Upload photo</div>');
							

    }else {

    
          
  	foreach ($profile as $c): 
$photo= $c->logo;
		 	if($photo!=""){
		 
		 
		
		
	
			
		
		$img=$c->logo;
	
		$img1='uploads/';
	$url = base_url().$img1.$img;

 
 ?>
 <div >
<img class="img-circle" src="<?php echo $url ?>" height="100" width="100" style="border-radius:4px;  ">		 

</div>



	 <?php }else{
		 ?>

				<?php
	 }
		 endforeach; ?>

              <?php }?>
						
						
						
				
						
						
									

										<?php $bussinessname=$configuration[0]['businessname']; if(isset($bussinessname)) {echo   $bussinessname; }
										
									
										
										?>
								
								<br><B>NAME</B>--<?php echo strtoupper($member[0]['firstname']."  ".$member[0]['lastname'])?>-------<?php $member[0]['createdate'];?>---<B>Signature</B>------------</br></span>
</br>
								</center></td>
								
								
							</tr>
						
	
	
	
	
	
	
	
          <tr> <td colspan="2"><center><h2>Pay Slip for  <?php echo$payroll[0]['slarymonth'];?> <?php echo$payroll[0]['salaryyear'];?>.       </h2></center>
		  
		 <!-- Payment Date:<?php echo$member[0]['createdate'];?>-->
		  </td>   </tr>
       
      <tr> <td><b>Emp Number</b></td>     <td><b><?php echo$member[0]['number'];?></b></td></tr>
	    <tr><td><b>Name</b></td>     <td><b><?php echo$member[0]['firstname']."  ".$member[0]['lastname'] ?></b></td></tr>
	     <tr> <td><b>National ID</b></td>     <td><b><?php echo$member[0]['idno'];?></b></td></tr>
		  <tr><td><b>Phone</b></td>     <td><b><?php echo$member[0]['phone'];?></b></td></tr>
		  <tr><td><b>Email</b></td>     <td><b><?php echo$member[0]['email'];?></b></td></tr>

			  <tr><td colspan="2"><center><h3>Payment details</h3></center></td></tr>





   <tr> <td><b> Basic Salary</b></td>     <td><b><?php $salary=$payroll[0]['salary'];    echo formatMoney($salary,true)  ;?></b></td></tr>
	    






			
				  <?php
				  			   $pay=0;
						   
							  $netpay=0; 
			//			   

if(is_array($employeepayments)) {

   foreach($employeepayments as $row)
   {
   $category=trim($row->category);
    $qtymode=trim($row->qtymode);
    $unit=trim($row->unit);
    $status=trim($row->status);
    $name=trim($row->name);
    $code=trim($row->code);

   $quantity=trim($row->quantity);
    $amount=trim($row->amount);
	  $amountmode=trim($row->amountmode);
	 $total=$quantity*$amount;
	
		if($category=="Pay"){
						$pay=$pay+$total;
?>
  <tr>
<td><b><?php echo$name;?></b></td>
<td><b><?php  echo formatMoney($total,true)  ;?></b></td>

	 </tr>

<?php
			
		}
			
			
			
			}
}			 
				  $ttpay=$salary+$pay;
				  
				  
				  
			
				  
				  ?>
			
				

		  <tr><td><b>Gross Salary</b></td>     <td><b><?php echo formatMoney($ttpay,true)  ;?></b></td></tr>

		
							  <tr><td colspan="2"><center><h3>Deductions details</h3></center></td></tr>

				  
				  
				   <?php
				  			   $deduction=0;
						   
							   
			//			   

if(is_array($employeepayments)) {

   foreach($employeepayments as $row)
   {
   $category=trim($row->category);
    $qtymode=trim($row->qtymode);
    $unit=trim($row->unit);
    $status=trim($row->status);
    $name=trim($row->name);
    $code=trim($row->code);

   $quantity=trim($row->quantity);
    $amount=trim($row->amount);
	  $amountmode=trim($row->amountmode);
	 $total=$quantity*$amount;
	
		if($category=="Deduction"){
						$deduction=$deduction+$total;

?>
  <tr>
<td><b><?php echo$name;?></b></td>
<td><b><?php echo formatMoney($total,true)  ;?></b></td>

	 </tr>

<?php


		}
			}
}			 
				
				  
				  
				  
			 
				  							  $netpay=$ttpay-$deduction; 

				  ?>
				  
			
				  		  <tr><td><b>Total Deductions</b></td>     <td><b><?php  echo formatMoney($deduction,true)  ;?></b></td></tr>
				  		  <tr><td colspan="2"> <br> </td></tr>

		<tr><td><b>Relief</b></td>     <td><b></b></td></tr>

				  <tr> <td><b>Personal Relief</b></td>     <td><b><?php $relief=$payroll[0]['relief'];   echo formatMoney($relief,true)  ;?></b></td></tr>
	   <!--  <tr> <td><b>Nhif Relief</b></td>     <td><b><?php $nhifrelief=$payroll[0]['nhifrelief'];   echo formatMoney($nhifrelief,true)  ;?></b></td></tr>
 
				  
				  -->
				 

		  		  <tr><td><b>Net Salary</b></td>     <td><b><?php    echo formatMoney($netpay,true)  ;         ?></b></td></tr>

		  
		  
		  <?php
		  
		  if($payroll[0]['loanbalance']>0){
			  ?>
				  <tr><td><b>Loan Balance</b></td>     <td><b><?php    echo formatMoney($payroll[0]['loanbalance'],true)  ;         ?></b></td></tr>  
		  <?php
		  }
		  ?>
		  				  		  <tr><td colspan="2"> <br> </td></tr>

		  
<tr><td><b>Payment Method</b></td>     <td><b><?php $method=$payroll[0]['method'];
	  	  		  $data= $this->usermodel->populateallarray('paymentmethodes','id',$method);
				  
				echo$method=$data[0]['name'];
	  
	  ?></b></td></tr>
		  <tr><td><b>Bank Name</b></td>     <td><b><?php 
		  
		  
	  $banks = $this->usermodel->populateallarray('glaccounts','number',$payroll[0]['bankname']);

		if($banks !=false){
				echo $banks[0]["accountname"];
		}else{
			echo $payroll[0]['bankname'];
		}
  
		  
		  
		  ?></b></td></tr>
		  <tr><td><b>Bank Account</b></td>     <td><b><?php echo$payroll[0]['bankaccount'];?></b></td></tr>

   
   
   
		  <tr><td><br><b>Name</b></td>     <td valign="bottom"><b>Sign:..........</b></td></tr>
		  <tr><td><br><b>Name</b></td>     <td valign="bottom"><b>Sign:..........</b></td></tr>

   
   
   
   
</table>













								
				
							




							
									
									
					</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">Add payment</h4>
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/assignpayrollsetup' , 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="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">
	<input type="hidden" name="action" value="insert"id="action" class="form-control" required placeholder="Enter action">
<input type="hidden" name="view" value="user/mypayrollsetup?randomitemidentifier=<?php echo $member[0]['id']; ?>"id="view" class="form-control" required placeholder="Enter status">
			  		<input type="hidden" readonly name="myid" value="<?php echo set_value('myid',$member[0]['id']); ?>"id="myid" class="form-control" required placeholder="Enter itemid">

	
 <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="selected" ></option>

		<option value="Pay"  >Pay</option>
		<option value="Deduction"  >Deduction</option>
		<option value="Bonus"  >Bonus</option>


		</select>
		

	</div>
  </div>
  	<div class="form-group">
    <label for="inputcode" class="col-sm-2 control-label">	Code </label>
    <div class="col-sm-10">
	
		  		<input type="text" readonly name="code" id="code" value="<?php echo set_value('code'); ?>" class="form-control" required placeholder="Enter 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" readonly name="name" id="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="inputamountmode" class="col-sm-2 control-label">Amount Mode?</label>
    <div class="col-sm-10">
	<select class="form-control" name="amountmode"  id="amountmode" required>
		<option value=""  selected="selected"></option>

		<option value="Fixed"  >Fixed Amount</option>
		<option value="Variable"  >Variable Amount</option>

		</select>
		

	</div>
  </div>
  <div class="form-group">
    <label for="inputamount" class="col-sm-2 control-label">	Amount </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="amount"  id="amount" value="" class="form-control" required placeholder="Enter amount">
		 
				
		<span class="text-danger"> <?php echo form_error('amount'); ?>
		
		</span>
	</div>
  </div>


  
  <div class="form-group">
    <label for="inputqtymode" class="col-sm-2 control-label">Qty Mode?</label>
    <div class="col-sm-10">
	<select class="form-control" name="qtymode" id="qtymode" required>
		<option value=""  selected="selected" ></option>

		<option value="Fixed"  >Fixed qty</option>
		<option value="Variable"  >Variable qty</option>

		</select>
		

	</div>
  </div>
  <div class="form-group">
    <label for="inputquantity" class="col-sm-2 control-label">	Quantity </label>
    <div class="col-sm-10">
	
		  		<input type="number" name="quantity" value="" id="quantity" class="form-control" required placeholder="Enter quantity">
		 
				
		
		</span>
	</div>
  </div>

	

	<div class="form-group">

    <label for="inputunit" class="col-sm-2 control-label">	Unit </label>
    <div class="col-sm-10">
	
		  		<input type="text" name="unit"  id="unit" value="<?php echo set_value('unit'); ?>" class="form-control"  placeholder="Enter unit if any">
		 
				
		<span class="text-danger"> <?php echo form_error('unit'); ?>
		
		</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"   id="status" required>
		<option value=""  selected="selected" ></option>

		<option value="Active"  >Active</option>
		<option value="Inactive"  >Inactivet</option>

		</select>
		

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

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="salarycharges" name="btn_addsalarycharges" class="btn btn-primary"> SAVE  </button>

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

    

				</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">Process payment</h4>
      </div>
      <div class="modal-body">
      
	  	

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

         $YEAR = date('Y');


				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/processsinglepayment' , 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="inputsalaryyear" class="col-sm-2 control-label">	Year </label>
    <div class="col-sm-10">
		<input type="hidden" name="view" value="user/salaryhistory"id="view" class="form-control" required placeholder="Enter status">

	<input type="hidden" name="view1" value="user/mypayrollsetup?randomitemidentifier=<?php echo $member[0]['id']; ?>"id="view" class="form-control" required placeholder="Enter status">
	<input type="hidden" name="action" value="insert"id="action" class="form-control" required placeholder="Enter action">

		  		<input type="number" name="salaryyear" value="<?php echo set_value('salaryyear',$YEAR); ?>" class="form-control" required placeholder="Enter salary year">
		 
							  		<input type="hidden" readonly name="myid" value="<?php echo set_value('myid',$member[0]['id']); ?>"id="myid" class="form-control" required placeholder="Enter itemid">

		<span class="text-danger"> <?php echo form_error('salaryyear'); ?>
		
		</span>
	</div>
  </div>	
	<div class="form-group">
    <label for="inputslarymonth" class="col-sm-2 control-label">	Month </label>
    <div class="col-sm-10">
	
     <select name='slarymonth' class="form-control" required>
    <option value=''>--Select Month for payment--</option>
    <option  value='Janaury'>Janaury</option>
    <option value='February'>February</option>
    <option value='March'>March</option>
    <option value='April'>April</option>
    <option value='May'>May</option>
    <option value='June'>June</option>
    <option value='July'>July</option>
    <option value='August'>August</option>
    <option value='September'>September</option>
    <option value='October'>October</option>
    <option value='November'>November</option>
    <option value='December'>December</option>
    </select> 		 
				
		<span class="text-danger"> <?php echo form_error('name'); ?>
		
		</span>
	</div>
  </div>

  
  
    <div class="form-group">
    <label for="inputpayment" class="col-sm-2 control-label">	Payment</label>
    <div class="col-sm-10">
	<select class="form-control" name="payment" required>

		<option  readonly value="<?php echo $member[0]['paymentmode']; ?>"  selected="selected"><?php echo $member[0]['paymentmode']; ?></option>



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

	</div>
  </div>


	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="payment" name="btn_processpayment" class="btn btn-primary"> Process Payment  </button>

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

    

				</div>

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


					
					



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

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

 
</div>


















