load->model('monthlypay_model'); $this->load->library('session'); $this->load->library('form_validation'); $this->isLoggedIn(); $this->CompanyName = $this->global['CompanyName']; } /** * Index Page for this controller (default function of the class) */ public function index() { //$this->global['pageTitle'] = 'Resico : Monthly Pay Details'; $this->global['pageTitle'] = $this->CompanyName.' : Monthly Pay Details'; $this->loadviews('monthlyListing',$this->global); } /** * To dispaly the holidays information has list */ function loadPublicholidays() { $data['days'] = $this-> monthlypay_model->getPublicHoldays(); //$this->global['pageTitle'] = 'Resico : Public Holidays'; $this->global['pageTitle'] = $this->CompanyName.' : Public Holiday '; $this->loadviews('publicholidays',$this->global,$data,NULL); } /** * To deleted holidays information */ 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...!";} } /** * To add and update public holidays information */ 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..!"; } /** * For Employee's monthly attendance information as list */ 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)) { $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'] = 'Resico : Monthly Attendance'; $this->global['pageTitle'] = $this->CompanyName.' : Employee Monthly Attendance'; $this->loadViews("attendance", $this->global, $data, NULL); } /** * To save Employee's monthly attendance information */ 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' ); $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); $total = $total + $res; } echo $total . "-Employee(s) Attendance saved Successfully..!"; } /** * To Employee's monthly wise payment list. */ function monthlyListing() { $this->load->model('monthlypay_model'); $data['userRecords'] = $this->monthlypay_model->monthlyListing(); //$this->global['pageTitle'] = 'Resico : Monthly Pay List'; $this->global['pageTitle'] = $this->CompanyName.' : Monthly Payment Details'; $this->loadViews("monthlyListing", $this->global, $data, NULL); } /** * To load the add new monthlypay * note : not in use */ function addmonthly() { //$this->global['pageTitle'] = 'Resico : Add Monthly Pay'; $this->global['pageTitle'] = $this->CompanyName.' : Add Monthly Pay'; $this->loadviews('addMontly',$this->global, NULL); } /** * For store new data into DB. * note : not in use */ 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'); } } /** * For editing purpose and it has oldest values. * note : not in use */ function editOldmonthly($EmpID='',$month_year='') { $data['monthly'] = $this->monthlypay_model->getUserInfo($EmpID,$month_year); //$this->global['pageTitle'] = 'Resico : Edit Monthly Listing'; $this->global['pageTitle'] = $this->CompanyName.' : Edit Monthly Listing'; $this->loadViews("editOldmonthly", $this->global, $data,NULL); } /** * For stored new values after editing. * note : not in use */ 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'); } redirect('monthlyListings'); } } /** * To load employee payment details for permission screen * note : not in use **/ function permissionslip() { //$this->global['pageTitle'] = 'Resico : Permission Slip'; //$this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; $data['emplists']=$this->monthlypay_model->emplist(); $this->loadviews('permission',$this->global,$data,NULL); } /** * To store new permission details into DB. * note : not in use **/ function addper() { $EmpID = $this->input->post('emp'); $Date =$this->input->post('date'); $CUR = date('Y-m-d',strtotime($Date)); $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'); $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); } $result = $this->monthlypay_model->addper($Permissiondata); if(!empty($result)){ echo ""; } else{ echo ""; } } /** * To get permission slip details for listing * note : not in use */ function permissionlist(){ // $this->global['pageTitle'] = 'Resico : Permission Listing'; // $this->global['pageTitle'] = $this->CompanyName.' : Edit Service Purchase order form'; // $data['permissionlist']=$this->monthlypay_model->perlist(); // $this->loadviews('permissionlist',$this->global,$data,NULL); } /** * To display permissionslip details for PDF * note : not in use */ 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->SetTitle('Resico : Permission'); $mpdf->SetHTMLHeader($HtmlHeading); $html = $this->load->view('permissionpdf',$data,true); $mpdf->SetDisplayMode('fullpage'); $mpdf->setAutoTopMargin = 'stretch'; $mpdf->setAutoBottomMargin = 'stretch'; $mpdf->WriteHTML($html); $mpdf->Output('Permissionslip'.$permissionpdf.'.pdf','I',$php); } /** * To load pagenotfound view */ function pageNotFound() { //$this->global['pageTitle'] = 'Resico : 404 - Page Not Found'; $this->global['pageTitle'] = $this->CompanyName.' : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>