931 lines
29 KiB
PHP
Executable File
931 lines
29 KiB
PHP
Executable File
<?php
|
|
|
|
namespace App\Controllers;
|
|
|
|
use App\Controllers\BaseController;
|
|
|
|
use CodeIgniter\Validation\Exceptions\ValidationException;
|
|
|
|
use Mpdf\Mpdf;
|
|
|
|
use App\Models\Monthlypay_model;
|
|
|
|
/**
|
|
* Module : Payslip
|
|
* Monthlypay Class to control all monthly pay related operations.
|
|
* @author : Venba
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
* @example : Revised at 15th april 2024
|
|
*/
|
|
class Monthlypay extends BaseController
|
|
{
|
|
|
|
protected $monthlypay_model;
|
|
protected $session;
|
|
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->monthlypay_model = new Monthlypay_model();
|
|
$this->session = session();
|
|
helper('form'); //$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'] = 'Monthly Pay Details';
|
|
|
|
$this->loadviews('monthlyListing', $this->global);
|
|
}
|
|
|
|
function loadPublicholidays()
|
|
{
|
|
|
|
|
|
$data['days'] = $this->monthlypay_model->getPublicHoldays();
|
|
$this->global['pageTitle'] = 'Public Holidays';
|
|
|
|
$this->loadviews('publicholidays', $this->global, $data, NULL);
|
|
}
|
|
function deletePublicHoliday()
|
|
{
|
|
$d = $this->request->getPost('param1');
|
|
|
|
$res = $this->monthlypay_model->deleteHoliday($d);
|
|
if ($res == 1) {
|
|
echo "Deleted Successfully..!";
|
|
} else {
|
|
echo "Something Wrong, Try Later...!";
|
|
}
|
|
}
|
|
|
|
function savePublicHolidays()
|
|
{
|
|
$jsondata = $this->request->getPost('param1');
|
|
$phpdata = json_decode((string)$jsondata);
|
|
$total = 0;
|
|
|
|
foreach ($phpdata as $d) {
|
|
|
|
if (!empty($d->Holiday_Name)) {
|
|
|
|
$hname = $d->Holiday_Name;
|
|
$hdate = format_date($d->Date);//3rd
|
|
|
|
$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->request->getPost('month')) {
|
|
|
|
$current = $this->request->getPost('month');
|
|
$month_short_name = substr((string)$current, 0, 3);
|
|
$year = substr((string)$current, 4);
|
|
$month_arr = date_parse($month_short_name);
|
|
$month = $month_arr['month'];
|
|
$current = $year . "-" . $month . '-01';
|
|
$monthdays = cal_days_in_month(CAL_GREGORIAN, $month_arr['month'], $year);
|
|
$begin = new \DateTime($year . '-' . $month . '-01');
|
|
$end = new \DateTime($year . '-' . $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');
|
|
}
|
|
// dd( $sundayarray);
|
|
$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'] = 'Monthly Attendance';
|
|
$this->loadViews("attendance", $this->global, $data, NULL);
|
|
}
|
|
|
|
function saveAttendance()
|
|
{
|
|
|
|
$total = 0;
|
|
$jsondata = $this->request->getPost('param1');
|
|
$phpdata = json_decode((string)$jsondata, true);
|
|
$date = $this->request->getPost('param2');
|
|
$NoofDays = $this->request->getPost('param3');
|
|
$Month_Year = format_date($date);
|
|
$CreateBy = $this->session->get('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'];
|
|
$sundayCount = $data['Total Sunday'];
|
|
|
|
$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, 'sunday_count' => $sundayCount , '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->monthlypay_model = new monthlypay_model();
|
|
|
|
$data['userRecords'] = $this->monthlypay_model->monthlyListing();
|
|
|
|
$this->global['pageTitle'] = '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'] = 'Add Monthly Pay';
|
|
|
|
$this->loadviews('addMontly', $this->global, NULL);
|
|
}
|
|
|
|
function addNewmonthly()
|
|
{
|
|
|
|
$this->validator->setRules(['month_year'=> 'trim|required',
|
|
'emp_id'=> 'trim|required',
|
|
'LOP_days'=> 'trim|required',
|
|
'OT_Hrs_Worked'=> 'trim|required',
|
|
'Loan_Recovered'=> 'trim|required',
|
|
'Incentives'=> 'trim|required',
|
|
'Other_Deductions'=> 'trim|required']);
|
|
|
|
if ($this->validator->run() == FALSE) {
|
|
$this->addmonthly();
|
|
} else {
|
|
$month_year = $this->request->getPost('month_year');
|
|
$emp_id = $this->request->getPost('emp_id');
|
|
$LOP_days = $this->request->getPost('LOP_days');
|
|
$OT_Hrs_Worked = $this->request->getPost('OT_Hrs_Worked');
|
|
$Loan_Recovered = $this->request->getPost('Loan_Recovered');
|
|
|
|
$Incentives = $this->request->getPost('Incentives');
|
|
$Other_Deductions = $this->request->getPost('Other_Deductions');
|
|
|
|
$CreateBy = $this->session->get('userId');
|
|
|
|
|
|
$createddt = get_current_date_time();
|
|
|
|
$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'] = 'Edit Monthly Listing';
|
|
|
|
$this->loadViews("editOldmonthly", $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
* This function is used for stored new values after editing.
|
|
*/
|
|
function editmonthly()
|
|
{
|
|
|
|
helper('form'); //$this->load->library('form_validation');
|
|
|
|
$EmpID = $this->request->getPost('EmpID');
|
|
$month_year = $this->request->getPost('Month_Year');
|
|
$this->validator->setRules([
|
|
'month_year'=> 'trim|required',
|
|
'EmpID'=> 'trim|required',
|
|
'LOP_Days'=> 'trim|required',
|
|
'OT_Hrs_Worked'=> 'trim|required',
|
|
'Loan_Recovered'=> 'trim|required',
|
|
//'Loan_Balance'=>'trim|required',
|
|
'Incentives'=> 'trim|required',
|
|
'Other_Deductions'=> 'trim|required']);
|
|
|
|
|
|
if ($this->validator->run() == FALSE) {
|
|
|
|
$this->editOldmonthly($EmpID, $month_year);
|
|
} else {
|
|
|
|
|
|
$month_year = $this->request->getPost('Month_Year');
|
|
$EmpID = $this->request->getPost('EmpID');
|
|
$LOP_Days = $this->request->getPost('LOP_Days');
|
|
$OT_Hrs_Worked = $this->request->getPost('OT_Hrs_Worked');
|
|
$Loan_Recovered = $this->request->getPost('Loan_Recovered');
|
|
|
|
$Incentives = $this->request->getPost('Incentives');
|
|
$Other_Deductions = $this->request->getPost('Other_Deductions');
|
|
$LastModBy = $this->session->get('userId');
|
|
|
|
|
|
$LastModTime = get_current_date_time();
|
|
|
|
|
|
|
|
$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');
|
|
}
|
|
}
|
|
|
|
/* this function used to permission page*/
|
|
function permissionslip()
|
|
{
|
|
$this->global['pageTitle'] = '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->request->getPost('emp');
|
|
$Date = $this->request->getPost('date');
|
|
$CUR = format_date($Date);
|
|
// print_r($CUR);die;
|
|
$From = $this->request->getPost('timepicker1');
|
|
$To = $this->request->getPost('timepicker2');
|
|
$Shift = $this->request->getPost('shift');
|
|
$Permission = $this->request->getPost('Pretime');
|
|
$Reason = $this->request->getPost('Reason');
|
|
$Createdby = $this->session->get('userId');
|
|
//$Remarks = $this->request->getPost('Remarks');
|
|
|
|
|
|
$Createdtime = get_current_date_time();
|
|
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 = '".base_url()."permissionlist';
|
|
</script>";
|
|
} else {
|
|
echo "<script type='text/javascript'>alert('Not Created Permission Form');
|
|
window.location = '".base_url()."permission';
|
|
|
|
</script>";
|
|
//redirect('permission');
|
|
}
|
|
}
|
|
//this function used to database value get listing page view that values//
|
|
function permissionlist()
|
|
{
|
|
|
|
$this->global['pageTitle'] = '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 = format_date($record->Date, 0, 'd-m-Y');
|
|
// }
|
|
// $permissionpdf = $id . '-' . $name . '-' . $date;
|
|
|
|
|
|
// 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 = 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);
|
|
// }
|
|
public 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('d-m-Y', strtotime($record->Date));
|
|
}
|
|
$permissionpdf = $id . '-' . $name . '-' . $date;
|
|
|
|
// Generate the view into a variable
|
|
$html = view('permissionpdf', $data);
|
|
|
|
// Create an instance of mPDF
|
|
$mpdf = new Mpdf([
|
|
'mode' => 'utf-8',
|
|
'format' => 'A4-P',
|
|
'margin_left' => 10,
|
|
'margin_right' => 10,
|
|
'margin_top' => 10,
|
|
'margin_bottom' => 10,
|
|
'margin_header' => 10,
|
|
'margin_footer' => 6,
|
|
]);
|
|
|
|
// Set additional configurations
|
|
$mpdf->SetDisplayMode('fullpage');
|
|
$mpdf->SetTitle('Permission');
|
|
|
|
// If you have a custom HTML header, set it here
|
|
// $mpdf->SetHTMLHeader($HtmlHeading);
|
|
|
|
// Write the HTML to the PDF
|
|
$mpdf->WriteHTML($html);
|
|
|
|
// Output the PDF to the browser
|
|
$mpdf->Output('Permissionslip' . $permissionpdf . '.pdf', 'D');
|
|
}
|
|
|
|
//this function used to Production salary Details
|
|
|
|
|
|
|
|
|
|
|
|
function productionsalary()
|
|
{
|
|
|
|
|
|
$this->global['pageTitle'] = 'ProductionSalary';
|
|
|
|
|
|
|
|
$data['productionsalary'] = $this->monthlypay_model->productionsalarycost();
|
|
|
|
|
|
|
|
$this->loadviews('salarycostforproduction', $this->global, $data, NULL);
|
|
}
|
|
|
|
|
|
function addnew()
|
|
{
|
|
|
|
$date = $this->request->getPost('datepick');
|
|
$date = format_date($date);
|
|
|
|
$prod = $this->request->getPost('pton');
|
|
// echo $prod;
|
|
$mper = $this->request->getPost('today_abs');
|
|
// echo $mper;
|
|
|
|
$ttl = $this->request->getPost('today_salary');
|
|
// echo $ttl;
|
|
$salary = $this->request->getPost('calc');
|
|
//echo $salary;
|
|
|
|
$Createdby = $this->session->get('userId');
|
|
|
|
$acc_createddt = get_current_date_time();
|
|
|
|
$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->request->getPost('sno');
|
|
// echo $sno;
|
|
$date = $this->request->getPost('date');
|
|
$date = format_date($date);
|
|
// echo $date;
|
|
$prod = $this->request->getPost('prod');
|
|
// echo $prod;
|
|
$mper = $this->request->getPost('pra');
|
|
// echo $mper;
|
|
|
|
$ttl = $this->request->getPost('sal');
|
|
// echo $ttl;
|
|
$salary = $this->request->getPost('ast');
|
|
// echo $salary;
|
|
|
|
$updatedby = $this->session->get('userId');
|
|
|
|
$acc_createddt = get_current_date_time();
|
|
|
|
$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->request->getPost("id");
|
|
// echo $date;
|
|
$daydate = date('Y-m', strtotime((string)$date));
|
|
//echo $date; die;
|
|
$daydate = $daydate . '-01';
|
|
//$dat = date('d');
|
|
// echo $daydate; echo "";
|
|
$WH = 'WH' . date('j', strtotime((string)$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((string)$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->request->getPost('term');
|
|
// //$ab = format_date($da);
|
|
// //echo strtotime($da);
|
|
// $da = '01-'.$da;
|
|
// //echo $da;
|
|
|
|
|
|
// $ab = format_date($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'] = $this->CompanyName.' : ProductionSalary';
|
|
// // $da =$this->request->getPost('term');
|
|
// $da=$this->request->getPost('datepi');
|
|
// //$ab = format_date($da);
|
|
// //echo $da;
|
|
// $da= '01-'.$da;
|
|
// //echo $d;
|
|
|
|
|
|
// $ab = format_date($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'] = 'ProductionSalary';
|
|
|
|
$da = $this->request->getPost('datepi');
|
|
if (!empty($da)) {
|
|
$da = '01-' . $da;
|
|
}
|
|
$from_date = $this->request->getPost('from_date');
|
|
// echo $from_date;
|
|
$to_date = $this->request->getPost('to_date');
|
|
//echo $to_date;
|
|
|
|
|
|
|
|
|
|
$ab = empty($da) ? "" : format_date($da);
|
|
// echo $ab;
|
|
$from = empty($from_date) ? "" : format_date($from_date);
|
|
//echo $from;
|
|
$to = empty($to_date) ? "" : format_date($to_date);
|
|
//echo $to;
|
|
|
|
$data['productionsalary'] = $this->monthlypay_model->cost($ab, $from, $to);
|
|
$this->loadviews('salarycostforproduction', $this->global, $data, NULL);
|
|
}
|
|
}
|