emppaydate_model = new Emppaydate_model(); $this->payroll_model = new payroll_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'] = 'Employee Pay Details'; $this->loadViews("emppayListing", $this->global); } /** * This function is used to load the payment list for a employee. */ function emppayListing() { $data['userRecords'] = $this->emppaydate_model->emppayListing(); $this->global['pageTitle'] = 'Employee Loan List'; $this->loadViews("emppayListing", $this->global, $data, NULL); } /** * This function is used to load the add new payment for an employee. */ function addemppaydate() { $result['empdetails'] = $this->payroll_model->getEmpID(); $this->global['pageTitle'] = 'Add Employee Pay'; $this->loadViews("addemppaydate", $this->global, $result); } function addNewemppay() { $EmpID = $this->request->getPost('EmpID'); $Loan_Amount = $this->request->getPost('Loan_Amount'); $Load_Issued_date = $this->request->getPost('loan_issued_date'); if (!empty($Load_Issued_date)) { $Load_Issued_date = format_date($Load_Issued_date); } else { $Load_Issued_date = null; } $Due_Amount = $this->request->getPost('monthly_due'); $Due_Started = $this->request->getPost('due_started'); if (!empty($Due_Started)) {$Due_Started = format_date($Due_Started);} else { $Due_Started = null; } $No_Of_Dues = $this->request->getPost('no_of_due'); $Paid_due = $this->request->getPost('paid_due'); $Remaining_Due = $this->request->getPost('remaining_due'); $Paid_Amount = $this->request->getPost('Paid_Amount'); $CreateBy = $this->session->get('userId'); $loandetails = array('EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Created_By' => $CreateBy); $path = ROOTPATH.'public/uploads/images/'; $file2 = $this->request->getFile('request_letter'); if ($file2 && $file2->isValid() && !$file2->hasMoved()) { if(!is_dir($path)) { mkdir($path, 0777, true); } $request_letter = $file2->getName().rand(00,99); $file2->move($path,$request_letter); $loandetails['request_letter'] = $request_letter; } else{ $loandetails['request_letter'] = NULL; } $file1 = $this->request->getFile('payment_statement'); if ($file1 && $file1->isValid() && !$file1->hasMoved()) { if(!is_dir($path)) { mkdir($path, 0777, true); } $payment_statement = $file1->getName().rand(00,99); $file1->move($path,$payment_statement); $loandetails['payment_statement'] = $payment_statement; } else{ $loandetails['payment_statement'] = NULL; } if ($Loan_Amount != 0) { $result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'add'); if ($result2 > 0) { echo ""; } else { echo ""; } } return redirect()->to('/emppayListings'); } /** * This function is used for editing purpose and it has oldest values only. */ function editOldemppay($paydataid = "") { $data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid); $data['loan_histoty'] = $this->emppaydate_model->getUserLoanHistoryInfo($data['emppay'][0]->Loan_ID); $this->global['pageTitle'] = 'Edit Employee Pay Monthly Details '; $this->loadViews("editOldemppay", $this->global, $data, NULL); } function downloadEmpLoanData($paydataid = "") { $data['emppay'] = $this->emppaydate_model->getUserInfo($paydataid); $data['loan_histoty'] = $this->emppaydate_model->getUserLoanHistoryInfo($data['emppay'][0]->Loan_ID); // Load HTML view $html = view('loan_pdf', $data); $mpdf = new Mpdf(); $mpdf->SetTitle("Employee Loan Report"); $mpdf->WriteHTML($html); // Download the PDF $fName = $data['emppay'][0]->PAYEMPID."-loan-details.pdf"; return $mpdf->Output($fName, "D"); } /** * This function is used for stored new values after editing. */ function editemppay() { $EmpID = $this->request->getPost('EmpID'); $loan_ID = $this->request->getPost('loanid'); $Loan_Amount = $this->request->getPost('Loan_Amount'); $Load_Issued_date = $this->request->getPost('loan_issued_date'); if (!empty($Load_Issued_date)) {$Load_Issued_date = format_date($Load_Issued_date);} else { $Load_Issued_date = null; } $Due_Amount = $this->request->getPost('monthly_due'); $Due_Started = $this->request->getPost('due_started'); if (!empty($Due_Started)) {$Due_Started = format_date($Due_Started); } else { $Due_Started = null; } $No_Of_Dues = $this->request->getPost('no_of_due'); $Paid_due = $this->request->getPost('paid_due'); $Remaining_Due = $this->request->getPost('remaining_due'); $Paid_Amount = $this->request->getPost('Paid_Amount'); $Last_Mod_By = $this->session->get('userId'); $loandetails = array('Loan_ID' => $loan_ID, 'EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Last_Mod_By' => $Last_Mod_By); $path = ROOTPATH.'public/uploads/images/'; $file2 = $this->request->getFile('request_letter'); if ($file2 && $file2->isValid() && !$file2->hasMoved()) { if(!is_dir($path)) { mkdir($path, 0777, true); } $request_letter = $file2->getName().rand(00,99); $file2->move($path,$request_letter); $loandetails['request_letter'] = $request_letter; } else{ $loandetails['request_letter'] = $this->request->getPost('hidden_request_letter') ? $this->request->getPost('hidden_request_letter') : NULL; } $file1 = $this->request->getFile('payment_statement'); if ($file1 && $file1->isValid() && !$file1->hasMoved()) { if(!is_dir($path)) { mkdir($path, 0777, true); } $payment_statement = $file1->getName().rand(00,99); $file1->move($path,$payment_statement); $loandetails['payment_statement'] = $payment_statement; } else{ $loandetails['payment_statement'] = $this->request->getPost('hidden_payment_statement') ? $this->request->getPost('hidden_payment_statement') : NULL; } if ($Loan_Amount != 0 and $loan_ID != '') { $result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'update'); if ($result2 > 0) { echo ""; } else { echo ""; } } else if ($Loan_Amount != 0 and $loan_ID == '') { $loandetails = array('EmpID' => $EmpID, 'Loan_Amount' => $Loan_Amount, 'Loan_Issued_Date' => $Load_Issued_date, 'Monthly_Due' => $Due_Amount, 'Due_Start_Date' => $Due_Started, 'No_of_Dues' => $No_Of_Dues, 'Paid_Due' => $Paid_due, 'Remaining_Due' => $Remaining_Due, 'Paid_Amount' => $Paid_Amount, 'is_Active' => 1, 'Created_By' => $Last_Mod_By); $result2 = $this->emppaydate_model->addLoanInfo($loandetails, 'add'); if ($result2 > 0) { echo ""; } else { echo ""; } } return redirect()->to('/emppayListings'); } function deleteEmpPay() { $LoanID = $this->request->getPost('id'); //echo $EmpID; $result = $this->emppaydate_model->deleteEmployeePay($LoanID); if ($result == 1) { echo "Deleted Sucessfully..!"; } else { echo "Something Went wrong. Try Later..!"; } } }