851 lines
28 KiB
PHP
851 lines
28 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
require APPPATH . '/third_party/mpdf/mpdf.php';
|
|
|
|
/**
|
|
* Class : Cost Center (Cost Center Controller)
|
|
* User Class to control all user related operations.
|
|
* @author : VenbaMail Mali
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
*/
|
|
class monthlypay extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('monthlypay_model');
|
|
$this->load->library('session');
|
|
$this->load->library('form_validation');
|
|
// $this->load->library('pagination');
|
|
|
|
$this->isLoggedIn();
|
|
}
|
|
/**
|
|
* This function used to load the first screen of the user
|
|
*/
|
|
public function index()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Monthly Pay Details';
|
|
|
|
$this->loadviews('monthlyListing',$this->global);
|
|
}
|
|
|
|
function loadPublicholidays()
|
|
{
|
|
|
|
|
|
$data['days'] = $this-> monthlypay_model->getPublicHoldays();
|
|
$this->global['pageTitle'] = 'Siddharth : Public Holidays';
|
|
|
|
$this->loadviews('publicholidays',$this->global,$data,NULL);
|
|
|
|
}
|
|
function deletePublicHoliday()
|
|
{
|
|
$d = $this->input->post('param1');
|
|
|
|
$res = $this->monthlypay_model->deleteHoliday($d);
|
|
if($res == 1){
|
|
echo "Deleted Successfully..!";
|
|
}else{echo "Something Wrong, Try Later...!";}
|
|
}
|
|
|
|
function savePublicHolidays()
|
|
{
|
|
$jsondata = $this->input->post('param1');
|
|
$phpdata = json_decode($jsondata);
|
|
$total =0;
|
|
|
|
foreach($phpdata as $d)
|
|
{
|
|
|
|
if(!empty($d->Holiday_Name)){
|
|
|
|
$hname = $d->Holiday_Name;
|
|
$hdate = date_format(date_create($d->Date),'Y-m-d');
|
|
|
|
$tostore = array('H_Name'=>$hname,'H_Date'=>$hdate);
|
|
$isExist = $this->monthlypay_model->checkHoliday($hdate);
|
|
|
|
if($isExist[0]['count'] == 0)
|
|
{
|
|
$count = $this->monthlypay_model->saveHolidays($tostore,'i');
|
|
$total = $total + $count;
|
|
}
|
|
else
|
|
{
|
|
$count = $this->monthlypay_model->saveHolidays($tostore,'u');
|
|
$total = $total + $count;
|
|
}
|
|
}
|
|
}
|
|
|
|
echo $total . "-Holiday(s) Saved Successfully..!";
|
|
}
|
|
|
|
|
|
function attendanceLoad()
|
|
{
|
|
|
|
$month['month'] = '';
|
|
$monthdays = 0;
|
|
$begin = 0;
|
|
$end =0;
|
|
|
|
if($this->input->post('month'))
|
|
{
|
|
|
|
$current = $this->input->post('month');
|
|
$month = substr($current,0,3);
|
|
$year = substr($current,4);
|
|
$month=date_parse($month);
|
|
$current = $year."-".$month['month'].'-01';
|
|
$monthdays =cal_days_in_month(CAL_GREGORIAN,$month['month'],$year);
|
|
$begin = new DateTime($year.'-'.$month['month'].'-01');
|
|
$end = new DateTime($year.'-'.$month['month'].'-'.$monthdays);
|
|
|
|
}
|
|
if(empty($current))
|
|
{
|
|
// echo "fresh";
|
|
$current = date("Y-m");
|
|
$year = date("Y");
|
|
$month = date("m");
|
|
$current = $current."-01";
|
|
$monthdays =cal_days_in_month(CAL_GREGORIAN,$month,$year);
|
|
$begin = new DateTime($year.'-'.$month.'-01');
|
|
$end = new DateTime($year.'-'.$month.'-'.$monthdays);
|
|
}
|
|
|
|
|
|
$sundayarray =array();
|
|
while ($begin <= $end)
|
|
{
|
|
if($begin->format("D") == "Sun")
|
|
{
|
|
array_push($sundayarray,$begin->format("d"));
|
|
}
|
|
$begin->modify('+1 day');
|
|
}
|
|
$noofsundays = count($sundayarray);
|
|
|
|
$publicholidaysarray = $this-> monthlypay_model->getPublicHoldays($current);
|
|
$string ="attendance";
|
|
$data['noofsundays']=$noofsundays;
|
|
$data['noofpublicholidays']=count($publicholidaysarray);
|
|
$data['publicholidaysarray']=$publicholidaysarray;
|
|
$data['sundayarray']=$sundayarray;
|
|
$data['monthdays']=$monthdays;
|
|
$data['datefordropdown'] = $current;
|
|
$data['attendance'] = $this-> monthlypay_model->monthlyAttendance($current);
|
|
$data['emppay'] = $this-> monthlypay_model->getEmpPayDetails($current,$string);
|
|
$this->global['pageTitle'] = 'Siddharth : Monthly Attendance';
|
|
$this->loadViews("attendance", $this->global, $data, NULL);
|
|
}
|
|
|
|
function saveAttendance()
|
|
{
|
|
|
|
$total = 0;
|
|
$jsondata = $this->input->post('param1');
|
|
$phpdata = json_decode($jsondata,true);
|
|
$date = $this->input->post('param2');
|
|
$NoofDays = $this->input->post('param3');
|
|
$Month_Year = date('Y-m-d',strtotime($date));
|
|
$CreateBy = $this->session->userdata ( 'userId' );
|
|
// echo 'from COn' . $date;
|
|
// print_r($phpdata);die();[Paid Leave
|
|
// echo count($phpdata);
|
|
//echo $NoofDays.'sdjksjh';
|
|
$EmpID ='temp';
|
|
foreach($phpdata as $data)
|
|
{
|
|
|
|
|
|
$EmpID = $data['Employee ID'];
|
|
$W1H = $data['1W'];$W1OT = $data['1OT']; $W2H = $data['2W'];$W2OT = $data['2OT'];$W3H = $data['3W'];$W3OT = $data['3OT'];$W4H = $data['4W'];$W4OT = $data['4OT'];
|
|
$W5H = $data['5W'];$W5OT = $data['5OT']; $W6H = $data['6W'];$W6OT = $data['6OT']; $W7H = $data['7W'];$W7OT = $data['7OT']; $W8H = $data['8W'];$W8OT = $data['8OT'];
|
|
$W9H = $data['9W'];$W9OT = $data['9OT']; $W10H = $data['10W'];$W10OT = $data['10OT']; $W11H = $data['11W'];$W11OT = $data['11OT']; $W12H = $data['12W'];$W12OT = $data['12OT'];
|
|
$W13H = $data['13W'];$W13OT = $data['13OT']; $W14H = $data['14W'];$W14OT = $data['14OT']; $W15H = $data['15W'];$W15OT = $data['15OT']; $W16H = $data['16W'];$W16OT = $data['16OT'];
|
|
$W17H = $data['17W'];$W17OT = $data['17OT']; $W18H = $data['18W'];$W18OT = $data['18OT']; $W19H = $data['19W'];$W19OT = $data['19OT']; $W20H = $data['20W'];$W20OT = $data['20OT'];
|
|
$W21H = $data['21W'];$W21OT = $data['21OT']; $W22H = $data['22W'];$W22OT = $data['22OT']; $W23H = $data['23W'];$W23OT = $data['23OT']; $W24H = $data['24W'];$W24OT = $data['24OT'];
|
|
$W25H = $data['25W'];$W25OT = $data['25OT']; $W26H = $data['26W'];$W26OT = $data['26OT']; $W27H = $data['27W'];$W27OT = $data['27OT']; $W28H = $data['28W'];$W28OT = $data['28OT'];
|
|
if(!empty($data['29W'])){$W29H = $data['29W'];}else{$W29H=null;} if(!empty($data['29OT'])){$W29OT = $data['29OT'];}else{$W29OT=null;} if(!empty($data['30W'])){$W30H = $data['30W'];}else{$W30H=null;}
|
|
if(!empty($data['30OT'])){$W30OT = $data['30OT'];}else{$W30OT=null;} if(!empty($data['31W'])){$W31H = $data['31W'];}else{$W31H=null;}if(!empty($data['31OT'])){$W31OT = $data['31OT'];}else{$W31OT=null;}
|
|
$totalworkinghrs = $data['Total Hrs'];$totalothrs = $data['OT Hrs'];$paidleave = $data['Paid Leave'];$daysworked = $data['Days Worked'];$absent = $data['Absent'];
|
|
|
|
$monthattendance = array('Month_Year'=>$Month_Year,'NoofDays'=>$NoofDays,'EmpID'=>$EmpID,'WH1'=>$W1H,'OT1'=>$W1OT,'WH2'=>$W2H,'OT2'=>$W2OT,'WH3'=>$W3H,'OT3'=>$W3OT,
|
|
'WH4'=>$W4H,'OT4'=>$W4OT,'WH5'=>$W5H,'OT5'=>$W5OT,'WH6'=>$W6H,'OT6'=>$W6OT,'WH7'=>$W7H,'OT7'=>$W7OT,'WH8'=>$W8H,'OT8'=>$W8OT,'WH9'=>$W9H,'OT9'=>$W9OT,'WH10'=>$W10H,'OT10'=>$W10OT,
|
|
'WH11'=>$W11H,'OT11'=>$W11OT,'WH12'=>$W12H,'OT12'=>$W12OT,'WH13'=>$W13H,'OT13'=>$W13OT,'WH14'=>$W14H,'OT14'=>$W14OT,'WH15'=>$W15H,'OT15'=>$W15OT,'WH16'=>$W16H,'OT16'=>$W16OT,
|
|
'WH17'=>$W17H,'OT17'=>$W17OT,'WH18'=>$W18H,'OT18'=>$W18OT,'WH19'=>$W19H,'OT19'=>$W19OT,'WH20'=>$W20H,'OT20'=>$W20OT,'WH21'=>$W21H,'OT21'=>$W21OT,'WH22'=>$W22H,'OT22'=>$W22OT,
|
|
'WH23'=>$W23H,'OT23'=>$W23OT,'WH24'=>$W24H,'OT24'=>$W24OT,'WH25'=>$W25H,'OT25'=>$W25OT,'WH26'=>$W26H,'OT26'=>$W26OT,'WH27'=>$W27H,'OT27'=>$W27OT,'WH28'=>$W28H,'OT28'=>$W28OT,
|
|
'WH29'=>$W29H,'OT29'=>$W29OT,'WH30'=>$W30H,'OT30'=>$W30OT,'WH31'=>$W31H,'OT31'=>$W31OT,'Total_WHrs'=>$totalworkinghrs,'Total_OTHrs'=>$totalothrs,'Paid_Leave'=>$paidleave,
|
|
'Days_Worked'=>$daysworked,'Absent'=>$absent,'Created_by'=>$CreateBy);
|
|
|
|
|
|
$res = $this->monthlypay_model->saveAttendance($monthattendance,$Month_Year,$EmpID);
|
|
// echo $res;
|
|
$total = $total + $res;
|
|
// die();
|
|
}
|
|
echo $total . "-Employee(s) Attendance saved Successfully..!";
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
function monthlyListing()
|
|
{
|
|
|
|
|
|
$this->load->model('monthlypay_model');
|
|
|
|
$data['userRecords'] = $this->monthlypay_model->monthlyListing();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Monthly Pay List';
|
|
|
|
$this->loadViews("monthlyListing", $this->global, $data, NULL);
|
|
}
|
|
|
|
/**
|
|
* This function is used to load the filtering monthly list
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
* This function is used to load the add new monthlypay
|
|
*/
|
|
function addmonthly()
|
|
{
|
|
|
|
|
|
|
|
//$data['emp_id'] = $this->monthlypay_model->getmonthlypay();
|
|
|
|
$this->global['pageTitle'] = 'siddharth : Add Monthly Pay';
|
|
|
|
$this->loadviews('addMontly',$this->global, NULL);
|
|
|
|
}
|
|
|
|
function addNewmonthly()
|
|
{
|
|
|
|
|
|
$this->form_validation->set_rules('Month_Year','month_year','trim|required');
|
|
$this->form_validation->set_rules('EmpID','emp_id','trim|required');
|
|
$this->form_validation->set_rules('LOP_days','LOP_days','trim|required');
|
|
$this->form_validation->set_rules('OT_Hrs_Worked','OT_Hrs_Worked','trim|required');
|
|
$this->form_validation->set_rules('Loan_Recovered','Loan_Recovered','trim|required');
|
|
|
|
$this->form_validation->set_rules('Incentives','Incentives','trim|required');
|
|
$this->form_validation->set_rules('Other_Deductions','Other_Deductions','trim|required');
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->addmonthly();
|
|
}
|
|
else
|
|
{
|
|
$month_year = $this->input->post('month_year');
|
|
$emp_id = $this->input->post('emp_id');
|
|
$LOP_days = $this->input->post('LOP_days');
|
|
$OT_Hrs_Worked = $this->input->post('OT_Hrs_Worked');
|
|
$Loan_Recovered = $this->input->post('Loan_Recovered');
|
|
|
|
$Incentives = $this->input->post('Incentives');
|
|
$Other_Deductions = $this->input->post('Other_Deductions');
|
|
|
|
$CreateBy = $this->session->userdata ( 'userId' );
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$monthlypayExists = $this->monthlypay_model->checkmonthlypayExists( $monthlypay);
|
|
|
|
if(count($CodeExists) == 0)
|
|
{
|
|
$montlypay = array('month_year'=>$month_year, 'emp_id'=>$emp_id,'LOP_days'=>$LOP_days,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Other_Deductions'=>$Other_Deductions,'CreatedBy'=>$CreateBy,'createdDate'=>$createddt);
|
|
$this->monthlypay_model->addNewmonthly($monthlypay);
|
|
}
|
|
|
|
|
|
|
|
Print_r('Successfully Created Monthly pay details');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* This function is used for editing purpose and it has oldest values.
|
|
*/
|
|
|
|
function editOldmonthly($EmpID='',$month_year='')
|
|
{
|
|
/*if($employeeid == null)
|
|
{
|
|
|
|
redirect('monthlypay/monthlyListing');
|
|
}*/
|
|
|
|
|
|
|
|
$data['monthly'] = $this->monthlypay_model->getUserInfo($EmpID,$month_year);
|
|
//$data['monthly_pay_inputs'] = $this->monthlylisting_model->getUserInfo($employeeid);
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Edit Monthly Listing';
|
|
|
|
$this->loadViews("editOldmonthly", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function is used for stored new values after editing.
|
|
*/
|
|
function editmonthly()
|
|
{
|
|
|
|
$this->load->library('form_validation');
|
|
|
|
$EmpID= $this->input->post('EmpID');
|
|
$month_year = $this->input->post('Month_Year');
|
|
$this->form_validation->set_rules('Month_Year','month_year','trim|required');
|
|
$this->form_validation->set_rules('EmpID','EmpID','trim|required');
|
|
$this->form_validation->set_rules('LOP_Days','LOP_Days','trim|required');
|
|
$this->form_validation->set_rules('OT_Hrs_Worked','OT_Hrs_Worked','trim|required');
|
|
$this->form_validation->set_rules('Loan_Recovered','Loan_Recovered','trim|required');
|
|
//$this->form_validation->set_rules('Loan_Balance','Loan_Balance','trim|required');
|
|
$this->form_validation->set_rules('Incentives','Incentives','trim|required');
|
|
$this->form_validation->set_rules('Other_Deductions','Other_Deductions','trim|required');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
|
|
$this->editOldmonthly($EmpID,$month_year);
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
|
|
$month_year = $this->input->post('Month_Year');
|
|
$EmpID = $this->input->post('EmpID');
|
|
$LOP_Days =$this->input->post('LOP_Days');
|
|
$OT_Hrs_Worked = $this->input->post('OT_Hrs_Worked');
|
|
$Loan_Recovered = $this->input->post('Loan_Recovered');
|
|
|
|
$Incentives = $this->input->post('Incentives');
|
|
$Other_Deductions = $this->input->post('Other_Deductions');
|
|
$LastModBy = $this->session->userdata ( 'userId' );
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$LastModTime = $dt->format('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
$monthdata = array();
|
|
|
|
|
|
$monthdata = array('Month_Year'=>$month_year,'EmpID'=>$EmpID,'LOP_Days'=>$LOP_Days,'OT_Hrs_Worked'=>$OT_Hrs_Worked,'Loan_Recovered'=>$Loan_Recovered,'Incentives'=>$Incentives,'Other_Deductions'=>$Other_Deductions,'Last_Mod_By'=>$LastModBy,'Last_Mod_Time'=>$LastModTime);
|
|
|
|
|
|
|
|
$result = $this->monthlypay_model->editmonth($monthdata,$EmpID);
|
|
|
|
|
|
if($result == true)
|
|
{
|
|
$this->session->set_flashdata('success', 'updated successfully');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_flashdata('error', 'updation failed');
|
|
}
|
|
//echo success;
|
|
|
|
redirect('monthlyListings');
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
|
|
/* this function used to permission page*/
|
|
function permissionslip()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : Monthly Pay Details';
|
|
|
|
$data['emplists']=$this->monthlypay_model->emplist();
|
|
|
|
|
|
$this->loadviews('permission',$this->global,$data,NULL);
|
|
}
|
|
|
|
/*this function used to view page value get database move it now*/
|
|
function addper()
|
|
{
|
|
|
|
|
|
|
|
$EmpID = $this->input->post('emp');
|
|
$Date =$this->input->post('date');
|
|
$CUR = date('Y-m-d',strtotime($Date));
|
|
// print_r($CUR);die;
|
|
$From = $this->input->post('timepicker1');
|
|
$To = $this->input->post('timepicker2');
|
|
$Shift = $this->input->post('shift');
|
|
$Permission = $this->input->post('Pretime');
|
|
$Reason= $this->input->post('Reason');
|
|
$Createdby = $this->session->userdata('userId');
|
|
//$Remarks = $this->input->post('Remarks');
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$Createdtime = $dt->format('Y-m-d H:i:s');
|
|
if(!empty($EmpID)){
|
|
$Permissiondata = array('EmpID'=>$EmpID,'Date'=>$CUR,'From'=>$From,'To'=>$To,'Shift'=>$Shift,'Permission'=>$Permission,'Reason'=>$Reason,'Createby'=>$Createdby,'Createdtime'=>$Createdtime); }
|
|
//print_r($Permissiondata);exit;
|
|
|
|
|
|
$result = $this->monthlypay_model->addper($Permissiondata);
|
|
// print_r($result);die;
|
|
if(!empty($result)){
|
|
echo "<script type='text/javascript'>alert('Successfully Created Permission Form');
|
|
window.location = 'Permissionlist';
|
|
</script>";
|
|
|
|
}else{
|
|
echo "<script type='text/javascript'>alert('Not Created Permission Form');
|
|
window.location = 'Permission';
|
|
|
|
</script>";
|
|
//redirect('permission');
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
//this function used to database value get listing page view that values//
|
|
function permissionlist(){
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Monthly Pay Details';
|
|
|
|
$data['permissionlist']=$this->monthlypay_model->perlist();
|
|
|
|
//print_r($data);die;
|
|
$this->loadviews('permissionlist',$this->global,$data,NULL);
|
|
}
|
|
|
|
//this function used to pdf value display //
|
|
function permissionpdf($SNO){
|
|
|
|
$data['per'] = $this->monthlypay_model->pdf($SNO);
|
|
|
|
$id='';
|
|
$name ='';
|
|
$permissionpdf='';
|
|
$date = '';
|
|
foreach($data['per'] as $record){
|
|
|
|
$id= $record ->EmpID;
|
|
$name =$record ->FirstName;
|
|
$date =date_format(date_create($record ->date),'d-m-Y');
|
|
|
|
}
|
|
$permissionpdf = $id.'-'.$name.'-'.$date;
|
|
|
|
|
|
$this->load->view($this->config->item('admin_folder') .'/permissionpdf',$data);
|
|
|
|
$mpdf=new mPDF('utf-8','A4-P',10, 10,10, 10, 10, 38, 4, 6);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->SetHTMLHeader($HtmlHeading);
|
|
$mpdf->SetTitle('Permission');
|
|
$html = $this->load->view('permissionpdf',$data,true);
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
//$mpdf->setFooter($HTMLFooter . "Page {PAGENO} of {nb}");
|
|
//$mpdf->list_indent_first_level = 1;
|
|
$mpdf->setAutoTopMargin = 'stretch';
|
|
$mpdf->setAutoBottomMargin = 'stretch';
|
|
$mpdf->WriteHTML($html);
|
|
$mpdf->Output('Permissionslip'.$permissionpdf.'.pdf','I',$php);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
//this function used to Production salary Details
|
|
|
|
|
|
|
|
|
|
|
|
function productionsalary(){
|
|
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : ProductionSalary';
|
|
|
|
|
|
|
|
$data['productionsalary'] = $this->monthlypay_model->productionsalarycost();
|
|
|
|
|
|
|
|
$this->loadviews('salarycostforproduction',$this->global,$data,NULL);
|
|
}
|
|
|
|
|
|
function addnew()
|
|
{
|
|
|
|
$date=$this->input->post('datepick');
|
|
$date = date('Y-m-d',strtotime($date));
|
|
|
|
$prod = $this->input->post('pton');
|
|
// echo $prod;
|
|
$mper= $this->input->post('today_abs');
|
|
// echo $mper;
|
|
|
|
$ttl = $this->input->post('today_salary');
|
|
// echo $ttl;
|
|
$salary= $this->input->post('calc');
|
|
//echo $salary;
|
|
|
|
$Createdby = $this->session->userdata('userId');
|
|
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$acc_createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$productions = array('date'=>$date,
|
|
'production'=>$prod,
|
|
'emppresent'=>$mper,
|
|
'totalsalary '=>$ttl,
|
|
'salaryton'=>$salary,
|
|
'createdon'=>$acc_createddt,
|
|
'createdby'=>$Createdby );
|
|
//print_r($productions);
|
|
// die;
|
|
$result = $this->monthlypay_model->productionsalarycosts($productions);
|
|
if( $result >= 0){
|
|
|
|
|
|
|
|
echo "<script type='text/javascript'>alert('Successfully Saved!');
|
|
|
|
|
|
</script>";
|
|
|
|
redirect('monthlypay/productionsalary','refresh');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
function edited(){
|
|
|
|
$sno=$this->input->post('sno');
|
|
// echo $sno;
|
|
$date=$this->input->post('date');
|
|
$date = date('Y-m-d',strtotime($date));
|
|
// echo $date;
|
|
$prod = $this->input->post('prod');
|
|
// echo $prod;
|
|
$mper= $this->input->post('pra');
|
|
// echo $mper;
|
|
|
|
$ttl = $this->input->post('sal');
|
|
// echo $ttl;
|
|
$salary= $this->input->post('ast');
|
|
// echo $salary;
|
|
|
|
$updatedby = $this->session->userdata('userId');
|
|
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$acc_createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
$productions = array('date'=>$date,
|
|
'production'=>$prod,
|
|
'emppresent'=>$mper,
|
|
'totalsalary '=>$ttl,
|
|
'salaryton'=>$salary,
|
|
'updatedon'=>$acc_createddt,
|
|
'updatedby'=>$updatedby );
|
|
|
|
//print_r($productions);
|
|
$result = $this->monthlypay_model->updateproduction($productions,$sno);
|
|
if( $result >= 0){
|
|
|
|
|
|
|
|
echo "Updated Successfully Saved";
|
|
|
|
redirect('monthlypay/productionsalary','refresh');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*date click on day salary,absent name, total absent display*/
|
|
|
|
function dateFunctionChangeVales()
|
|
{
|
|
|
|
|
|
|
|
$date = $this->input->post("id");
|
|
// echo $date;
|
|
$daydate = date('Y-m',strtotime($date));
|
|
//echo $date; die;
|
|
$daydate = $daydate . '-01';
|
|
//$dat = date('d');
|
|
// echo $daydate; echo "";
|
|
$WH = 'WH' . date('j',strtotime($date));
|
|
// echo $WH;
|
|
|
|
$yesterday = $this->monthlypay_model->attyesterday($WH,$daydate);
|
|
// print_r($yesterday);die;
|
|
|
|
$values = 0;
|
|
$absEmp = array();
|
|
//echo $value; die;
|
|
foreach ($yesterday as $weekda => $value) {
|
|
|
|
if ($value[$WH] != 0) {
|
|
|
|
$values++;
|
|
$absendId = $value['EmpID'];
|
|
$absendName = $value['FirstName'];
|
|
|
|
|
|
$absEmp [] = $absendId . "-" . $absendName; //absend empid and name list
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//print_r($absentName);die;
|
|
$data['today'] = $values;
|
|
|
|
$OT = 'OT' . date('j',strtotime($date));
|
|
|
|
$CUR_month = date('t');
|
|
|
|
$toDayEmployee = $this->monthlypay_model->dayAllPersentEmpSalary($WH, $OT, $daydate);
|
|
|
|
|
|
$EmpID = 0;
|
|
|
|
$employeeSalary = 0;
|
|
|
|
foreach ($toDayEmployee as $value) {
|
|
$values = 0;
|
|
$totalothour = 0;
|
|
|
|
if ($value[$WH] != 0) {
|
|
|
|
$totalothour = $value[$OT];
|
|
//echo $totalothour;die;
|
|
$values = 1;
|
|
|
|
//print_r($values); die;
|
|
$Empid = $value['EmpID'];
|
|
//print_r($value['EmpID']);
|
|
|
|
$totalEmployeePersent = $this->monthlypay_model->persentEmployeeDetails($Empid);
|
|
|
|
|
|
$HRA_Amount = $totalEmployeePersent[0]->HRA_Amount;
|
|
$Basic_Pay = $totalEmployeePersent[0]->Basic_Pay;
|
|
$totalsalary = $totalEmployeePersent[0]->TotalSalary;
|
|
$dayFoodAmt = $totalEmployeePersent[0]->Food_Allowances;
|
|
//$allowances =$totalEmployeePersent[0]->Allowances;
|
|
//echo "hra amount";print_r(array($HRA_Amount,$Basic_Pay,$totalsalary));
|
|
//$Allowances = $allowances * $values;
|
|
$Food_Allowances = $dayFoodAmt * $values;
|
|
|
|
$daySalary = $Basic_Pay / $CUR_month;
|
|
/**per day salary working hour**/
|
|
//echo $daySalary.'<br/>';
|
|
|
|
$dayHra = $HRA_Amount / $CUR_month;
|
|
/** per day hra amount **/
|
|
//echo $dayHra.'<br/>';
|
|
|
|
$onehoursSalary = ($daySalary + $dayHra) / 8;
|
|
/**one hour salay ot calculation**/
|
|
if ($totalothour != 0) /** if ot not equal zero **/ {
|
|
$totSalayOT = $totalothour * $onehoursSalary;
|
|
} else {
|
|
$totSalayOT = 0;
|
|
}
|
|
$currentDaySalary = $daySalary * $values;
|
|
/** current day salary working days calculation**/
|
|
|
|
|
|
$currentDayHra = $dayHra * $values;
|
|
/** total working days hra calculations**/
|
|
// echo $currentDayHra.'<br/>';
|
|
$currentDatePF = $currentDaySalary + $currentDayHra + $totSalayOT;
|
|
/** current date pf calculation**/
|
|
if ($totalsalary <= 20000) {
|
|
|
|
$esiAmount = $currentDatePF * 1.75 / 100;
|
|
/** esiamount not elgiable for 20000 **/
|
|
} else {
|
|
$esiAmount = 0;
|
|
}
|
|
$pfAmount = $currentDaySalary * 12 / 100;
|
|
/** pf amount per day**/
|
|
|
|
//echo $totalothour;die;
|
|
$salaryInCurrentdays = $currentDaySalary + $totSalayOT + $currentDayHra + $Food_Allowances;
|
|
$salaryInCurrentday = $salaryInCurrentdays - ($esiAmount + $pfAmount);
|
|
$employeeSalary += round($salaryInCurrentday);
|
|
// echo $employeeSalary;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//$salaryInCurrentday++;
|
|
|
|
|
|
$data['employeeSalary'] = $employeeSalary;
|
|
|
|
//print_r($data);
|
|
// }
|
|
echo json_encode($data);
|
|
}
|
|
|
|
|
|
|
|
// function forreport()
|
|
// {
|
|
|
|
|
|
// $da =$this->input->post('term');
|
|
// //$ab = date('Y-m-d',strtotime($da));
|
|
// //echo strtotime($da);
|
|
// $da = '01-'.$da;
|
|
// //echo $da;
|
|
|
|
|
|
// $ab = date('Y-m-d',strtotime($da));
|
|
|
|
// //strtotime(str_replace('/', '-', '27/05/1990')
|
|
// //echo $ab; die;
|
|
|
|
|
|
|
|
// $result = $this->monthlypay_model->cost($ab);
|
|
|
|
// echo json_encode($result);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function salarycost()
|
|
// {
|
|
|
|
|
|
// $this->global['pageTitle'] = 'Siddharth : ProductionSalary';
|
|
// // $da =$this->input->post('term');
|
|
// $da=$this->input->post('datepi');
|
|
// //$ab = date('Y-m-d',strtotime($da));
|
|
// //echo $da;
|
|
// $da= '01-'.$da;
|
|
// //echo $d;
|
|
|
|
|
|
// $ab = date('Y-m-d',strtotime($da));
|
|
|
|
// //strtotime(str_replace('/', '-', '27/05/1990')
|
|
// //echo $ab; die;
|
|
|
|
|
|
|
|
// $data['productionsalary'] = $this->monthlypay_model->cost($ab);
|
|
|
|
|
|
|
|
// //print_r( $data['$productionsalary']); die;
|
|
|
|
|
|
// //echo json_encode($result);
|
|
// // $this->loadviews('salarycostforproduction',$this->$data,NULL);
|
|
|
|
// $this->loadviews('salarycostforproduction',$this->global,$data,NULL);
|
|
|
|
// }
|
|
|
|
function salarycost()
|
|
{
|
|
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : ProductionSalary';
|
|
|
|
$da=$this->input->post('datepi');
|
|
if(!empty($da)){
|
|
$da= '01-'.$da;
|
|
}
|
|
$from_date=$this->input->post('from_date');
|
|
// echo $from_date;
|
|
$to_date=$this->input->post('to_date');
|
|
//echo $to_date;
|
|
|
|
|
|
|
|
|
|
$ab = empty($da)?"":date('Y-m-d',strtotime($da));
|
|
// echo $ab;
|
|
$from = empty($from_date)?"":date('Y-m-d',strtotime($from_date));
|
|
//echo $from;
|
|
$to = empty($to_date)?"":date('Y-m-d',strtotime($to_date));
|
|
//echo $to;
|
|
|
|
$data['productionsalary'] = $this->monthlypay_model->cost($ab,$from,$to);
|
|
$this->loadviews('salarycostforproduction',$this->global,$data,NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|