diff --git a/app.zip b/app.zip deleted file mode 100644 index 08b67b87..00000000 Binary files a/app.zip and /dev/null differ diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 93f75b0c..066f3a49 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -92,6 +92,12 @@ $routes->post('gatheredCustAndQty', 'Driver::gatheredCustAndQty'); // Driver Monthly Pay Inputs Routes $routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'driverMonthlyPayInputs', 'Driver::driverMonthlyPayInputs'); $routes->post('saveMonthlyData', 'Driver::saveMonthlyData'); +$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'driverViewPay', 'Driver::viewGenerator'); +$routes->post('checkDriverExistPay', 'Driver::checkDriverExistPay'); +$routes->post('driverPayslip', 'Driver::driverPayslip'); +$routes->post('getDriver', 'Driver::getDriver'); +$routes->match(['GET', 'POST', 'PUT', 'DELETE'], 'driverPrintPdf', 'Driver::driverPrintPdf'); + // Asset Detail Routes $routes->get('assetListing', 'Assetdetails::assetListing'); $routes->get('addasset', 'Assetdetails::addasset'); diff --git a/app/Controllers/Driver.php b/app/Controllers/Driver.php index 23ddaca3..f1f46924 100755 --- a/app/Controllers/Driver.php +++ b/app/Controllers/Driver.php @@ -4,6 +4,7 @@ namespace App\Controllers; use App\Controllers\BaseController; use App\Models\Driver_model; +use Mpdf\Mpdf; class Driver extends BaseController @@ -277,12 +278,12 @@ class Driver extends BaseController $attendance->diesel = $monthly_pay_array[$attendance->driver_id]->diesel; $attendance->shed_duty_amount = $monthly_pay_array[$attendance->driver_id]->shed_duty_amount; $attendance->driver_final_payment = $monthly_pay_array[$attendance->driver_id]->driver_final_payment; + $attendance->payroll_id = $monthly_pay_array[$attendance->driver_id]->payroll_id; } } $data['monthinputs'] = $attendance_data; $data['dropdownvalue'] = $current; - // dd($data['monthinputs']); $this->global['pageTitle'] = 'Driver Monthly Inputs'; $this->loadViews("driverMonthlyPayInputs", $this->global, $data, NULL); @@ -338,4 +339,231 @@ class Driver extends BaseController echo $total . "- Driver Updated Successfully "; } + // payroll-------> + public function viewGenerator() + { + + $data['Payon'] = $this->driver_model->getPayOn(); + + $this->global['pageTitle'] = 'Payroll Generater'; + + $this->loadViews("driverPaySlipGenerate", $this->global, $data, NULL); + } + + function getDriver() + { + $id = $this->request->getPost('id1'); + + $result = $this->driver_model->getDriverlist2($id); + + $HTML = ""; + + if (count($result) > 0) { + + foreach ($result as $list) { + + $HTML .= ""; + } + } + echo $HTML; + } + + function checkDriverExistPay() + { + $driver = $this->request->getPost('driver'); + $payon = $this->request->getPost('payon'); + $result = $this->driver_model->checkDriverExistPay($driver, $payon); + echo json_encode(count($result)); + } + + public function driverPayslip() + { + + $PayOn = $this->request->getPost('payon'); + $Driver = $this->request->getPost('driver'); + + $res = $this->driver_model->getMonthlyPayDetails($Driver, $PayOn); + + $result = $res[0]; + + $data = [ + 'PayOn' => $result->month_year, + 'driver_id' => $result->driver_id, + 'driver_name' => $result->driver_name, + 'no_of_loads' => $result->no_of_loads, + 'driver_monthly_salary_amount' => $result->driver_monthly_salary_amount, + 'driver_monthly_food_amount' => $result->driver_monthly_food_amount, + 'driver_earnings_amount' => $result->driver_earnings_amount, + 'diesel' => $result->diesel, + 'shed_duty_amount' => $result->shed_duty_amount, + 'driver_final_payment' => $result->driver_final_payment, + 'created_by' => $this->session->get('userId') + ]; + + $insert = $this->driver_model->insertPayroll($data); + return $insert; + + } + + public function driverPrintPdf() + { + + $filename = " "; + $html = ""; + $All = $this->request->getPost('All'); + $Payon = $this->request->getPost('PayOn'); + $m = date("M", mktime(0, 0, 0, (int)$Payon, 10)); + $y = substr((string)$Payon, 3); + + + if ($All != '') { + $filename = 'PayslipFor-' . $m . '-' . $y; + $result = $this->driver_model->getEmpAll($Payon); + + if ($result > 0) { + for ($i = 0; $i < count($result); $i++) { + + $EmpID = $result[$i]['EmpId']; + + $Data['PayDetails'] = $this->driver_model->GetPayslipdata($Payon, $EmpID); + + + $totalsalary = $Data['PayDetails'][0]->TotalSalary; + $totalsalaryinwords = $this->convertNumberToWords(round($totalsalary)); + $Data['amtinwords'] = $totalsalaryinwords; + + + $html .= view("driverPayslipGeneratePrint", $Data); + + + } + } + } else { + $EmpID = $this->request->getPost('Driver'); + + $Data['PayDetails'] = $this->driver_model->GetPayslipdata($Payon, $EmpID); + + $name = $Data['PayDetails'][0]->name; + $filename = 'PayslipFor-' . $EmpID . ' ' . $name . ' ' . $m . ' ' . $y; + + $totalsalary = $Data['PayDetails'][0]->driver_final_payment; + $totalsalaryinwords = $this->convertNumberToWords(round($totalsalary)); + $Data['amtinwords'] = $totalsalaryinwords; + // print_r ($Data);exit(); + // echo view("driverPayslipGeneratePrint", $Data);die; + $html = view("driverPayslipGeneratePrint", $Data); + } + + + $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, + 'setAutoTopMargin' => 'stretch', + 'setAutoBottomMargin' => 'stretch' + ]); + $mpdf->SetDisplayMode('fullpage'); + // $mpdf->SetHTMLHeader($HtmlHeading); + $mpdf->setFooter("Page {PAGENO} of {nb}"); + $mpdf->list_indent_first_level = 1; + $mpdf->WriteHTML($html); + $mpdf->SetTitle('Resico:DriverPayslip'); + + $mpdf->Output("driverPayslip-" . $filename . ".pdf", 'D'); + + } + + function convertNumberToWords($number) { + $numberWords = [ + 0 => "Zero", + 1 => "One", + 2 => "Two", + 3 => "Three", + 4 => "Four", + 5 => "Five", + 6 => "Six", + 7 => "Seven", + 8 => "Eight", + 9 => "Nine", + 10 => "Ten", + 11 => "Eleven", + 12 => "Twelve", + 13 => "Thirteen", + 14 => "Fourteen", + 15 => "Fifteen", + 16 => "Sixteen", + 17 => "Seventeen", + 18 => "Eighteen", + 19 => "Nineteen", + 20 => "Twenty", + 30 => "Thirty", + 40 => "Forty", + 50 => "Fifty", + 60 => "Sixty", + 70 => "Seventy", + 80 => "Eighty", + 90 => "Ninety" + ]; + + if ($number == 0) { + return $numberWords[0]; + } + + $word = ''; + + if ($number >= 10000000) { + $crore = floor($number / 10000000); + if ($crore > 0) { + $word .= $this->convertNumberToWords($crore) . " Crore "; + } + $number %= 10000000; + } + + if ($number >= 100000) { + $lakh = floor($number / 100000); + if ($lakh > 0) { + $word .= $this->convertNumberToWords($lakh) . " Lakh "; + } + $number %= 100000; + } + + if ($number >= 1000) { + $thousand = floor($number / 1000); + if ($thousand > 0) { + $word .= $this->convertNumberToWords($thousand) . " Thousand "; + } + $number %= 1000; + } + + if ($number >= 100) { + $hundred = floor($number / 100); + if ($hundred > 0) { + $word .= $this->convertNumberToWords($hundred) . " Hundred "; + } + $number %= 100; + } + + if ($number > 0) { + if ($word !== '') { + $word .= "and "; + } + if ($number <= 20) { + $word .= $numberWords[$number]; + } else { + $word .= $numberWords[floor($number / 10) * 10]; + if ($number % 10 > 0) { + $word .= " " . $numberWords[$number % 10]; + } + } + } + + return trim($word); + } + + } \ No newline at end of file diff --git a/app/Controllers/Inwardgateregister.php b/app/Controllers/Inwardgateregister.php index 2465fd89..988f4ce5 100755 --- a/app/Controllers/Inwardgateregister.php +++ b/app/Controllers/Inwardgateregister.php @@ -33,6 +33,7 @@ class Inwardgateregister extends BaseController */ public function __construct() { + parent::__construct(); $this->inwardgateregister_model = new Inwardgateregister_model(); $this->IGRRemarks_model = new IGRRemarks_model(); @@ -42,6 +43,7 @@ class Inwardgateregister extends BaseController $this->logger = service('logger'); // Load the logger service $this->isLoggedIn(); + } /** * This function used to load the first screen of the user @@ -1524,11 +1526,48 @@ function updateIGRWeight(){ ->join('t_employee_details', 't_igr_remarkes.remark_by = t_employee_details.EmpID', 'left') ->where('t_igr_remarkes.igr_no', $data['igr_no']) ->findAll(); + + $this->sendRemarkMail($this->request->getPost('igr_no'),$this->request->getPost('remark'),session()->get('EmpID')); echo json_encode($data); } + public function sendRemarkMail($IGRNo,$remark,$empCode) + { + if(session()->get('roleText') == 'System Administrator') // id is 1 + { + $roleId = 2; + } + else if(session()->get('roleText') == 'Auditor') // id is 2 + { + $roleId = 1; + } + + + + $result_for_email = $this->inwardgateregister_model->getDetailsforEmail($this->session->get('userId'),$roleId); + + $email = ""; + for ($i = 0; $i < count($result_for_email['emails']); $i++) { + $email .= $result_for_email['emails'][$i]->email . " , "; + } + $email = rtrim($email, " ,"); + + $content = 'A new remark was created by '.$result_for_email['full_name'].' against IGR no '.$IGRNo.', "'.$remark.'"'; + + $notification = new Notification(); + $notification->sendEmail([ + 'recipient_email' => $email, + 'subject' => $result_for_email['company'].' - IGR Remark Raised', + 'description' => $content, + 'company' => $result_for_email['company'], + 'from_mail'=> $result_for_email['from_mail'] + ]); + + + } + public function saveIGRHistory($hist){ $field = $hist['key']; diff --git a/app/Models/Driver_model.php b/app/Models/Driver_model.php index 3664b621..843cd5e8 100755 --- a/app/Models/Driver_model.php +++ b/app/Models/Driver_model.php @@ -47,14 +47,16 @@ class Driver_model extends Model return $this->table . '.' . $field; }, $this->allowedFields)); - $selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, t_driver.driver_name,ip_clients.client_name as customer,ip_invoices.received_qty as quantity," . $fields; + $selectFields = "CONCAT_WS(' ', t_employee_details.FirstName, t_employee_details.LastName) AS FullName, t_employee_details.IsActive as employee_isactive, t_driver.driver_name,ip_clients.client_name as customer,ip_invoices.received_qty as quantity,t_driver_payroll.id as payroll_id,t_driver_payroll.PayOn," . $fields; + $month_year = get_date_time_dynamical_format('Y-m-d','m-Y',"$from"); return $this->select($selectFields) ->join('t_driver', 't_driver.driver_id = ' . $this->table . '.driver_id', 'left') ->join('tbl_users', 'tbl_users.userId = ' . $this->table . '.created_by', 'left') ->join('t_employee_details', 'tbl_users.EmpID = t_employee_details.EmpID', 'left') ->join('ip_invoices', 'ip_invoices.invoice_number = ' . $this->table . '.invoice_number', 'left') ->join('ip_clients', 'ip_clients.client_id = ip_invoices.client_id', 'left') + ->join('t_driver_payroll', 't_driver_payroll.driver_id = '.$this->table.'.driver_id and t_driver_payroll.PayOn = "'.$month_year.'"', 'left') ->where($this->table.'.date BETWEEN "'.$from.'" AND "'.$to.'"') ->where($this->table . '.driver_id', $driver_id) ->where($this->table . '.isactive', 1) @@ -107,12 +109,16 @@ class Driver_model extends Model function driverMonthlyPayInputs($monthYear){ $builder = $this->db->table('t_driver_monthly_pay_inputs'); - $query = $builder->where('t_driver_monthly_pay_inputs.month_year', $monthYear) - ->groupBy('t_driver_monthly_pay_inputs.driver_id, t_driver_monthly_pay_inputs.month_year') - ->get(); + $builder->select('t_driver_monthly_pay_inputs.*, t_driver_payroll.id as payroll_id'); + $builder->join('t_driver_payroll', 't_driver_payroll.driver_id = t_driver_monthly_pay_inputs.driver_id', 'left'); + $builder->where('t_driver_monthly_pay_inputs.month_year', $monthYear); + $builder->groupBy('t_driver_monthly_pay_inputs.driver_id, t_driver_monthly_pay_inputs.month_year'); + $query = $builder->get(); $result = $query->getResult(); - return $result; + + return $result; + } @@ -153,6 +159,99 @@ class Driver_model extends Model } } + function getPayOn() + { + $builder = $this->db->table('t_driver_monthly_pay_inputs') + ->select('DISTINCT(month_year)') + ->orderBy("month_year", "desc"); + $query = $builder->get(); + return $query->getResult(); + } + + function getDriverlist2($Payon = '') + { + $builder = $this->db->table('t_driver_monthly_pay_inputs Pay') + ->select('Pay.driver_id as driver_id,driver.driver_name as name') + ->join('t_driver driver', 'Pay.driver_id = driver.driver_id'); + if ($Payon != '') { + $builder->where('Pay.month_year', $Payon); + } + $builder->orderBy("Pay.driver_id", "asc"); + + $query = $builder->get(); + return $query->getResult(); + } + + function checkDriverExistPay($driver_id, $payon) + { + + $builder = $this->db->table('t_driver_payroll') + ->select('PayOn,driver_id') + ->where('PayOn', $payon) + ->where('driver_id', $driver_id); + $query = $builder->get(); + return $query->getResult(); + } + + function getMonthlyPayDetails($driver_id, $PayOn) + { + $builder = $this->db->table('t_driver_monthly_pay_inputs MonthlyPay ') + ->select('MonthlyPay.*') + ->where('MonthlyPay.driver_id', $driver_id) + ->where('MonthlyPay.month_year', $PayOn); + + $query = $builder->get(); + return $query->getResult(); + } + + function insertPayroll($data) + { + $builder = $this->db->table('t_driver_payroll'); + $builder->insert($data); + $count = $this->db->affectedRows(); + return $count; + } + + function getEmpAll($Payon = '') + { + + $builder = $this->db->table('t_payroll Pay') + ->select('Pay.EmpID as EmpId,Emp.FirstName as Fname,Emp.LastName as Lname') + ->join('t_employee_details Emp', 'Pay.EmpID = Emp.EmpID'); + if ($Payon != '') { + $builder->where('Pay.PayOn', $Payon); + } + $builder->orderBy("Pay.EmpID", "asc"); + + $query = $builder->get(); + return $query->getResultArray(); + } + + function GetPayslipdata($PayOn = '', $EmpId = '') + { + //echo "FROM MODEL" . $PayOn . $EmpId; + $builder = $this->db->table('t_driver_payroll Pay')->select('Pay.*,driver.driver_name as name ') + ->join('t_driver driver', 'Pay.driver_id = driver.driver_id'); + if ($PayOn != '') { + $builder->where('Pay.PayOn', $PayOn); + } + if ($EmpId != '') { + $builder->where('Pay.driver_id', $EmpId); + } + if ($PayOn != '') { + $builder->orderBy("Pay.driver_id", "asc"); + } + if ($PayOn == '' && $EmpId == '') { + $builder->orderBy("Pay.PayOn", "desc"); + } + $query = $builder->get(); + + return $query->getResult(); + + } + + + } ?> diff --git a/app/Models/Inwardgateregister_model.php b/app/Models/Inwardgateregister_model.php index 6d05c7a2..f1bbb384 100755 --- a/app/Models/Inwardgateregister_model.php +++ b/app/Models/Inwardgateregister_model.php @@ -1200,7 +1200,7 @@ class Inwardgateregister_model extends Model return $query->getResult(); } - public function getDetailsforEmail($userId) + public function getDetailsforEmail($userId,$roleId = 2) { $query0 = $this->db->query(" SELECT CompanyName,EmailAddress @@ -1217,7 +1217,7 @@ class Inwardgateregister_model extends Model $query2 = $this->db->query(" SELECT email FROM tbl_users - WHERE isDeleted = 0 AND roleId = 2" // hardcoded because auditor role only. refer with gwm 29/01/2025 + WHERE isDeleted = 0 AND roleId =".$roleId // hardcoded because auditor role only. refer with gwm 29/01/2025 ); $emails = $query2->getResult(); diff --git a/app/Views/driverAttendance.php b/app/Views/driverAttendance.php index c0847e95..b7fc4bda 100755 --- a/app/Views/driverAttendance.php +++ b/app/Views/driverAttendance.php @@ -73,12 +73,13 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y');
| = esc($record['salary_amount']) ?> | = esc($record['food_amount']) ?> | = esc($record['load_type']) ?> | -+ | '> @@ -126,9 +127,8 @@ $datefordropdown = format_date($datefordropdown, 0, 'M-Y'); - - - + + | diff --git a/app/Views/driverMonthlyPayInputs.php b/app/Views/driverMonthlyPayInputs.php index 88f4a420..7fe49926 100644 --- a/app/Views/driverMonthlyPayInputs.php +++ b/app/Views/driverMonthlyPayInputs.php @@ -277,10 +277,10 @@ } ?>Key)) { + payroll_id)) { echo "contenteditable='true';"; } ?> - Key)) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" + payroll_id)) { ?> title="Payslip Calculated" style="text-align:right;color:blue;" style="text-align:right;" > diesel)) { @@ -291,10 +291,10 @@ } ?> | Key)) {
+ payroll_id)) {
echo "contenteditable='true';";
} ?>
- Key)) { ?> title="Payslip Calculated"
+ payroll_id)) { ?> title="Payslip Calculated"
style="text-align:right;color:blue;"
style="text-align:right;" >
diff --git a/app/Views/driverPaySlipGenerate.php b/app/Views/driverPaySlipGenerate.php
new file mode 100755
index 00000000..dae14f9a
--- /dev/null
+++ b/app/Views/driverPaySlipGenerate.php
@@ -0,0 +1,230 @@
+ "Jan", "02" => "Feb", "03" => "Mar", "04" => "Apr", "05" => "May", "06" => "June", "07" => "July", "08" => "Aug", "09" => "Sep", "10" => "Oct", "11" => "Nov", "12" => "Dec");
+?>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/Views/driverPayslipGeneratePrint.php b/app/Views/driverPayslipGeneratePrint.php
new file mode 100755
index 00000000..0650169c
--- /dev/null
+++ b/app/Views/driverPayslipGeneratePrint.php
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| + | + | + | + | Total | @@ -847,9 +850,6 @@ $(document).ready(function () { - - - if (is_management_team == 1) { var dayWorkPaid = dayWorks + paidLeave + lopDay; } else { @@ -880,14 +880,13 @@ $(document).ready(function () { - var currentDaySalary = daySalary * dayWorkPaid; - + var currentDaySalary = daySalary * dayWorkPaid; + if (isNaN(currentDaySalary)) { currentDaySalary = 0; } - var currentDayHra = dayHra * dayWorkPaid; + var currentDayHra = dayHra * dayWorkPaid; + if (isNaN(currentDayHra)) { currentDayHra = 0; } - - var current_loan_amt = 0; var autoLoan = parseFloat(monthDue); @@ -946,7 +945,6 @@ $(document).ready(function () { var employeeSalary = Math.round(empMonthSalary); - //console.log( employeeSalary); var cals = (employeeSalary).toFixed(0); diff --git a/app/Views/viewinwardgateregister.php b/app/Views/viewinwardgateregister.php index 854a31f3..f92ca43e 100755 --- a/app/Views/viewinwardgateregister.php +++ b/app/Views/viewinwardgateregister.php @@ -219,6 +219,9 @@ | Invoice Qty | Net weight | +Taxable Amt | +Tax Amt | +Total Amt | Vechicle No | Driver | Transporter | @@ -257,6 +260,9 @@ReceivedQuantity ?> | NetWeight ?> | +taxable_value ?> | +gst_amount ?> | +gst_amount + (int)$record->gst_amount) ?> | VehicleNo ?> | DriverName ?> | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|