	<?php	
			 public function addsalary()
    {
		
			$session_data = $this->session->userdata('logged_in');

   
 	$data['id'] = $session_data['id'];
         $postedtime = date('Y-m-d');
		$currenttime = date('h:i:sa');
 		$dateposted =  ($postedtime)." ".$currenttime ;
		 $userid = $data['id'];
		  	$data['companyid'] = $session_data['companyid'];
	 $companyid = $data['companyid'];
		 				  $myid = $this->input->post("myid");

			  $year = $this->input->post("year");
		 		 $month = $this->input->post("month");
				  $type = $this->input->post("type");
		 		 $designation = $this->input->post("designation");
		 		 $allowance = $this->input->post("allowance");

		   	  $paytype = $this->input->post("paytype");
			  
		     $nohours = $this->input->post("nohours");
			 	 $salary = $this->input->post("salary");
				
			$nodays = $this->input->post("nodays");
			  $nodaysyearly = $this->input->post("nodaysyearly");
			  $annualsalary = $this->input->post("annualsalary");
			  $monthlysalary = $this->input->post("monthlysalary");
			  $dailysalary = $this->input->post("dailysalary");
			  $comments = $this->input->post("comments");
			  $vat = $this->input->post("vat");
			 $payee = trim($this->input->post("payee"));
				$nssf = trim($this->input->post("nssf"));
				
				
				  $nihf = $this->input->post("nihf");
			 $other = trim($this->input->post("other"));
				$loan = trim($this->input->post("loan"));
				
			
			  		  $this->form_validation->set_rules("salary", "salary", "trim|required");
			  		  $this->form_validation->set_rules("type", "Payment type", "trim|required");
			  		  $this->form_validation->set_rules("month", "month", "trim|required");
			  		  $this->form_validation->set_rules("year", "year", "trim|required");

			  
			$data['errors'] = validation_errors();
          if ($this->form_validation->run() == FALSE)
        {
      $this->load->view("template/headerpayee");

		
		 $this->load->view('userdata/payroll', $data);
		$this->load->view("template/footerpayee");
		}
		 else
		{
					   //validation succeeds
					 	if ($this->input->post('btn_addpayroll') == "payroll")
					   {
												$data=array(		
			'userid'=>$userid,
			'type'=>$type,
				'allowance'=>$allowance,
				'designation'=>$designation,
		  	'paytype'=>$paytype,
			
			
			'dateposted'=>$dateposted,
				
			 'salary'=>$salary,
			'nohours'=>$nohours,
			'nodays'=>$nodays,
			'nodaysyearly'=>$nodaysyearly,
			'annualsalary'=>$annualsalary,
				'monthlysalary'=>$monthlysalary,
				'dailysalary'=>$dailysalary,
				
			'comments'=>$comments,
			'vat'=>$vat,
				 'nihf'=>$nihf,
			'other'=>$other,
			'loan'=>$loan,
					
			'month'=>$month,
			'year'=>$year,
			'employeeid'=>$myid,
						'companyid'=>$companyid,

								);
														$usr_result = $this->usermodel->add($data,'payroll');

					

							
							//check if userallowance and password is correct
							if ($usr_result ==TRUE) //active user record is present
							{
								
								 
						 $this->session->set_flashdata('msg', '<div class="alert alert-success fade in"><a href="#" class="close" data-dismiss="alert">&times;</a>
						 
								<strong>Success!</strong> You have successfully Added a new  salary..</div>');	
										
												redirect('user/payroll?randomitemidentifier='.$myid);	
	
													
							}
							else if ($usr_result ==FALSE) 
							{     

			 $this->session->set_flashdata('msg', '<div class="alert alert-danger fade in"><a href="#" class="close" data-dismiss="alert">&times;</a>
						  <strong>Error!</strong> The salary  was not added.. Try again</div>');
								
												redirect('user/payroll?randomitemidentifier='.$myid);	
	
							}
					   }
					   else
					   {
							redirect('login');
					   }
	    }
    }
	
	?>