

         <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>   
 
 <div class="row">
  
   	

   	<div class="col-md-12">
	
  
		<div class="panel panel-default" data-collapsed="0">
        	<div class="panel-heading">
																		  VIEW ALL THE PAY AND DEDUCTIONS
            	<div class="panel-title" id="redcolor" >
            		<i class="entypo-plus-circled"></i>
										                     <a data-toggle='modal' data-target='#addModal' class="btn btn-info">Create pay/Deductions </a>

										 <a href="<?php echo base_url();?>user/viewmember" class="btn btn-default"> Assign salary </a>	
										 <a href="<?php echo base_url();?>user/salaryhistory" class="btn btn-default">  salary History</a>	
	   <a data-toggle='modal' data-target='#uploadModal' class="btn btn-default">Upload Payment/Deductions  </a>

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

				echo $this->session->flashdata('msg'); 
								?>	
										
					<div class="row">
						<div class="col-md-12">
							
							<div class="panel-body">
	
									
									
  <table cellpadding="0" cellspacing="0" border="0" class="table  table-striped" id="example" style="border-color:#CCCCCC; width:100%;"  >

             <thead>
         <tr>
     <th>Code</th>
	      <th>Category</th>

     <th>Name</th>
	      <th>Amount</th>

	 <th>Quantity</th>
	  	 <th>Unit</th>

<th>Amount Mode</th>		 
		<th>Qty Mode</th>		 

		<th>Status</th>		 

	<th>More</th>	

                 </tr>
             </thead><tbody>
<?php








 if(!is_array($payrollsetup)) {
				    echo '<div class="alert alert-danger text-center">No pay/dedction setup</div>';

			 }else{

    
       
  
  	foreach ($payrollsetup as $c): 

		 

             ?>



             <tr>
                
            <?php 
$id=$c->id;


?>


  <td><?php echo $c->code ; ?></td>          
      <td><?php echo $c->category ; ?></td>          

  <td><?php echo $c->name ; ?></td>
    <td><?php echo $c->amount ; ?></td>

   
   	  <td><?php echo $c->quantity ; ?></td>
	  <td><?php echo $c->unit ; ?></td>

  
  
  
  
  	  <td><?php echo $c->amountmode ; ?></td>
	  <td><?php echo $c->qtymode ; ?></td>

  
  
	  <td><?php echo $c->status ; ?></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>
									
                                    <ul class="dropdown-menu dropdown-primary pull-right" role="menu">
                                        
                                        <!-- teacher EDITING LINK -->
                                      
										<?php
										if($usertype=="admin"){
											
											?>
											  <li> 
										 <a class="btn btn-danger managebtn" id="managebtndelete"		 data-id='<?php echo  $c->id;?>'    data-toggle='modal' data-target='#myModal<?php  $c->id; ?>'>	 


                                                <i class="glyphicon glyphicon-pencil"></i>
																Delete
                                                </a>
                                                        </li>
									
									
                                        <li class="divider"></li>
                                        
                                     	  <li> 

		   	 <a class="btn btn-primary editbtn" id="editbtn"  data-quantity='<?php echo  $c->quantity;?>' data-unit='<?php echo  $c->unit;?>' data-category='<?php echo  $c->category;?>' data-status='<?php echo  $c->status;?>' data-amountmode='<?php echo  $c->amountmode;?>'  data-amount='<?php echo  $c->amount;?>' data-code='<?php echo  $c->code;?>'  data-qtymode='<?php echo  $c->qtymode;?>' data-name='<?php echo  $c->name;?>' data-id='<?php echo  $c->id;?>' data-toggle='modal' data-target='#editProductModel'> 	 

                                                <i class="glyphicon glyphicon-pencil"></i>
																Update
                                                </a>
                                                        </li>
															<?php
										}
										?>
										    
                                    </ul>
										
                                </div>
</td>
		 
		 
		 
             </tr>

	<?php endforeach;} ?>

             
<tbody>
        </table>

									
									
									
					</div>	

					
					

									
									<div id="uploadModal" 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">Please upload Correct file</h4>
												  <a href="<?php echo base_url();?>downloads/payrollsetup.xlsx" class="btn btn-success"> Download  upload template </a>	

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

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadpayrollsetup' , 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="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >
									 <input type="hidden" id="view" name="view" class="view" placeholder="view" value="user/payrollsetup">

		  		
				
		<span class="text-danger"> Upload correct File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="setup" name="btn_uploadpayrollsetup" class="btn btn-default">Upload Pay/Deductions  </button>

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

    

				</div>

		</div>
	    </div>
    </div>					
					</div>				
									
					
					
						<div id="uploadModal2" 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">Please Upload Correct Products Category data(CSV)</h4>
		
      </div>
      <div class="modal-body">
      
	  	

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/uploadcategoryproducts' , 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="view" value="user/viewproductcategory"id="view" class="form-control" required placeholder="Enter view">
	
	
	<div class="form-group">
    <label for="inputsurname" class="col-sm-2 control-label">	CSV LIST</label>
    <div class="col-sm-10">
		
			<input type="file" name="file" width="400"  value="<?php echo set_value('file') ;?>" placeholder="Select EXCELL" class="form-control" required placeholder="Enter Surname"  >

		  		
				
		<span class="text-danger"> Upload correct format of CSV File  here..<?php echo form_error('file'); ?>
		
		</span>
	</div>
  </div>	
  
	

	
	 <div class="form-group">

    <div class="col-sm-offset-2 col-sm-10">
     
	         <button type="submit"  value="products" name="btn_uploadcategoryproducts" class="btn btn-primary">Upload products Category </button>

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

    

				</div>

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

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



				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addpayrollsetup' , 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="update"id="action" class="form-control" required placeholder="Enter action">
<input type="hidden" name="view" value="user/payrollsetup"id="view" class="form-control" required placeholder="Enter status">

	
 <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>


		</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" 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" 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="text" 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="myModal" 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="salarycharges">

 <input type="hidden" id="view"name="view" class="view" placeholder="view" value="user/payrollsetup">
 <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 pay/dedction</h4>
      </div>
      <div class="modal-body">
      
	  	

				<?PHP
			
				 $mylastrecord=0;
		
			$lastrecord = $this->usermodel->last_payrolltcode($companyid);
			if($lastrecord !=false){
				 $mylastrecord=$lastrecord[0]["code"]+1;
			}else{
				
				 $mylastrecord=$mylastrecord+1;
			}
				
				

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

//
				echo $this->session->flashdata('msg'); 
		
                 echo form_open('user/addpayrollsetup' , 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="view" value="user/payrollsetup"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="hidden" name="mycategoryid" value=""id="mycategoryid" class="form-control" required placeholder="Enter mycategoryid">



 <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"  required>
			<option value=""  >--Select category--</option>

		<option value="Pay"  >Pay</option>
		<option value="Deduction"  >Deduction</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" name="code" value="<?php echo set_value('code',$mylastrecord); ?>" 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" 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="inputamountmode" class="col-sm-2 control-label">Amount Mode?</label>
    <div class="col-sm-10">
	<select class="form-control" name="amountmode"  required>

		<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="text" name="amount" value="0.00" 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"  required>

		<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="text" name="quantity" value="1" 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" 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"  required>

		<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>		
									
							</div>
						</div>
				

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

 
</div>


















