393 lines
15 KiB
PHP
Executable File
393 lines
15 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.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);
|
|
}
|
|
}
|
|
|
|
?>
|