diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1527b8cc..ef4c655c 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -360,6 +360,9 @@ $routes->group("/util", ["filter" => "authMVC"], function ($routes) { $routes->get('removeInstallments', 'LeadsController::removeInstallments'); }); +$routes->post("policy_tranction/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); +$routes->cli("cli/sendInstallmentRemainderMail","PolicyTransactionController::sendInstallmentRemainderMail"); + $routes->group("policy_tranction", ["filter" => "authMVC"], function ($routes) { $routes->group("inception", ["filter" => "authMVC"], function ($routes) { diff --git a/app/Controllers/MasterController.php b/app/Controllers/MasterController.php index fa094bb8..0a3c357d 100755 --- a/app/Controllers/MasterController.php +++ b/app/Controllers/MasterController.php @@ -1680,7 +1680,7 @@ class MasterController extends AdminController ["filePath" => ROOTPATH."public/sample_excel/sample_inception.xls","fileName" => "sample_inception.xls"], ["filePath" => ROOTPATH."public/assets/images/login_bg.jpg","fileName" => "login_bg.jpg"] ]; - $email_id = 'srinivas.saravanan@venbainfotech.com'; + $email_id = ['srinivas.saravanan@venbainfotech.com','srinivassaravanan2002@gmail.com']; $params = ['mail'=>$email_id]; $common = ['mail_type'=>'test_mail_cli']; // $bcc = "vijayalakshmi@nhanceindia.in,vitvelz@gmail.com,velmurugan.s@venbainfotech.com,hariharan@nhanceindia.in,hariharan@jubiliant.in,srinivas.saravanan@venbainfotech.com"; diff --git a/app/Controllers/PolicyTransactionController.php b/app/Controllers/PolicyTransactionController.php index d0242215..d7270335 100644 --- a/app/Controllers/PolicyTransactionController.php +++ b/app/Controllers/PolicyTransactionController.php @@ -32,10 +32,13 @@ use App\Models\InvPaymentDetailsModel; use App\Models\BatchFileModel; use App\Models\FileModel; use App\Models\COShareStmtDetailsModel; -use Kint; +use App\Models\BdsPlacementModel; +use Kint\Kint; +use App\Helpers\MailHelper; +use Exception; class PolicyTransactionController extends BaseController -{ +{ use ResponseTrait; protected $myLogger; @@ -64,6 +67,7 @@ class PolicyTransactionController extends BaseController protected $batchFileModel; protected $filesModel; protected $coShareStmtDetailsModel; + protected $BdsPlacementModel; public function __construct() { @@ -94,6 +98,7 @@ class PolicyTransactionController extends BaseController $this->batchFileModel = new BatchFileModel(); $this->filesModel = new FileModel(); $this->coShareStmtDetailsModel = new COShareStmtDetailsModel(); + $this->BdsPlacementModel = new BdsPlacementModel(); $this->invoiceStatus = [ 'pending' => 'Pending', 'generated' => 'Generated', @@ -182,8 +187,7 @@ class PolicyTransactionController extends BaseController $issuer, $status ); - - }else{ + } else { $ids = $this->request->getPost('ids'); $ids = array_filter(explode(',', $ids)); @@ -1831,7 +1835,7 @@ class PolicyTransactionController extends BaseController if (isset($isFromDashboard) && !empty($isFromDashboard) && $isFromDashboard == 1) { $ids = $this->request->getPost('ids'); - + $ids = array_filter(explode(',', $ids)); if (!empty($ids)) { @@ -2801,4 +2805,105 @@ class PolicyTransactionController extends BaseController ->update(); return $this->respond(['dataStatus' => true, 'code' => 200], 200); } + + public function sendInstallmentRemainderMail() + { + + $this->myLogger->logme("error", "Cron Job For Send Installment Remainder Mail Started"); + + try { + + try { + + $bdsInstallmentData = $this->BdsPlacementModel->getClientInstallmentDetails(); + + }catch (Exception $e) { + + $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); + + } + $this->myLogger->logme("error", "Data for BDS Installment " . json_encode($bdsInstallmentData)); + // dd($bdsInstallmentData); + + if (empty($bdsInstallmentData)) { + + $this->myLogger->logme("error", "No Client Installment is Due in the 15th Day"); + + return false; + } + + foreach ($bdsInstallmentData as $installmentData) { + + $mailData = $this->PrepareBDSMailData($installmentData); + $to_mail = $mailData['to_mail']; + $message = $mailData['message']; + $subject = $mailData['subject']; + + $this->myLogger->logme("error", "Installment Pending for" . $subject); + + $common = ['mail_type' => 'installment_amount_due_remainder_mail']; + + $res = MailHelper::send_email(['mail' => $to_mail, 'subject' => $subject, 'message' => $message, 'common' => $common]); + + $res = json_decode($res); + $this->myLogger->logme('error', 'res: ' . json_encode($res)); + + if ($res->status == 'success') { + return true; + } else { + return false; + } + } + } catch (Exception $e) { + + $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); + } + } + + protected function PrepareBDSMailData($data) + { + + try { + + $installment_amount = $data['installment_amount']; + $payment_date = date('d-m-Y', strtotime($data['payment_date'])); + $client = $data['client_name']; + $branch = $data['branch_name']; + $sales_person_mail = $data['sales_person']; + $heads = $data['heads']; + $admins = $data['admins']; + $buisness_team = $data['buisness_team']; + $policy_no = $data['policy_no']; + $client_short_name = isset($data['short_name']) && $data['short_name'] != null ? $data['short_name'] : $data['client_name']; + + $subject = "Installment Amount Due For Client - {$client_short_name} - Policy NO({$policy_no}) is Due On - {$payment_date}"; + + $message = "Policy Installment for Client - {$client}, Branch - {$branch} is Due on {$payment_date} + with amount of {$installment_amount}.
+ Policy No : {$policy_no}"; + + + $to_mail = array_merge( + array_column($heads, 'email'), + array_column($admins, 'email'), + array_column($buisness_team, 'email'), + [$sales_person_mail] + ); + + $to_mail = array_unique($to_mail); + + $this->myLogger->logme("error", "Selected To Address : " . json_encode($to_mail)); + + // dd($to_mail); + return [ + 'to_mail' => $to_mail, + 'message' => $message, + 'subject' => $subject + ]; + + } catch (Exception $e) { + + $this->myLogger->logme('error', 'Exception: ' . $e->getMessage() . 'Page: ' . $e->getFile() . ' Line: ' . $e->getLine()); + } + } } diff --git a/app/Models/BdsPlacementModel.php b/app/Models/BdsPlacementModel.php new file mode 100644 index 00000000..2cd7c6f4 --- /dev/null +++ b/app/Models/BdsPlacementModel.php @@ -0,0 +1,93 @@ +db->table("bds_installment_payment_details bipd") + ->select("bipd.*, ct.client_name,ct.short_name, cb.branch_name, leads.salse_person_id,cp.policy_no") + ->join("policy_transaction pt", "pt.id = bipd.pt_id") + ->join("clients ct", "ct.id = pt.client_id") + ->join("client_branch cb", "cb.id = pt.client_branch_id") + ->join("leads", "leads.id = bipd.lead_id") + ->join("client_policy cp","cp.id = pt.client_policy_id") + ->where("bipd.is_active", 1) + ->where("bipd.payment_date", date('Y-m-d', strtotime('+15 days'))); + + $data = $builder->get()->getResultArray(); + + // Loop through to extract sales person details + foreach ($data as &$row) { + $sales_person_ids = json_decode($row['salse_person_id'], true); + $sales_person_id = $sales_person_ids[0] ?? null; + + if ($sales_person_id) { + $user = $this->db->table('user_profiles') + ->select('email') // or whatever field + ->where('id', $sales_person_id) + ->get() + ->getRowArray(); + + $row['sales_person'] = $user['email'] ?? 'N/A'; + } else { + $row['sales_person'] = 'Not Assigned'; + } + + $head = $this->db->table('user_profiles') + ->select('email') // or whatever field + ->where('role', 5) + ->where('is_active',1) + ->get() + ->getResultArray(); + + + $row['heads'] = $head; + + $admin = $this->db->table('user_profiles') + ->select('email') + ->where("is_active",1) + ->where("role",1) + ->get() + ->getResultArray(); + + $row['admins'] = $admin; + + $buisenessTeam = $this->db->table("user_teams ut") + ->select("up.email") + ->join('user_profiles up','up.id = ut.user_id and up.is_active = 1') + ->where("ut.team_id",7) + ->where("ut.is_active",1) + ->get() + ->getResultArray(); + + $row['buisness_team'] = $buisenessTeam; + + + } + + + return $data; + } +} diff --git a/app/Models/TicketMasterModel.php b/app/Models/TicketMasterModel.php index 62a5e101..b85dad62 100644 --- a/app/Models/TicketMasterModel.php +++ b/app/Models/TicketMasterModel.php @@ -541,7 +541,7 @@ class TicketMasterModel extends Model AND th.is_active = 1), tm.created_at )) BETWEEN 13 AND 20 THEN "13-20 Days" - ELSE "Above 20 Days"g + ELSE "Above 20 Days" END AS tat_category', 'COUNT(*) AS count' ]) diff --git a/app/Views/leads_form.php b/app/Views/leads_form.php index 265d1f32..25044797 100644 --- a/app/Views/leads_form.php +++ b/app/Views/leads_form.php @@ -777,6 +777,7 @@ console.log(response.message, 'SUCCESS'); $('#appendArea_' + dataIncrement).append(response.data); + console.log("Policy Type ID : ",policy_type_id); if (policy_type_id == 1 || policy_type_id == 6 || policy_type_id == 7) { let newId = 'appendAreaForClaim_' + dataIncrement; diff --git a/app/Views/leads_form_handler.php b/app/Views/leads_form_handler.php index 11ba47a7..f796ee6e 100644 --- a/app/Views/leads_form_handler.php +++ b/app/Views/leads_form_handler.php @@ -719,6 +719,11 @@ if (isset($selected_lead_type)) { $('#policy_type_id').val(data.policy_type_id || '').select2(); $('.loader').fadeOut(); $('.loader-mask').delay(350).fadeOut('slow'); + $(".loss_date").each(function () { + flatpickr(this, { + dateFormat: "d-m-Y", + }); + }); }, 1000); }, 1000); }, 2000); diff --git a/app/Views/leads_non_eb.php b/app/Views/leads_non_eb.php index 0dc0d785..9c826359 100644 --- a/app/Views/leads_non_eb.php +++ b/app/Views/leads_non_eb.php @@ -1,41 +1,41 @@ @@ -233,8 +233,8 @@ hr.solid { " . $value['policy_type'] .""; + if (in_array($value['allocg'], ["Non-EB", "Marine"])) { + echo ""; } } } @@ -247,11 +247,11 @@ hr.solid { @@ -260,13 +260,19 @@ hr.solid { --> @@ -308,11 +314,11 @@ hr.solid { @@ -355,60 +361,83 @@ hr.solid { \ No newline at end of file diff --git a/app/Views/rfq/claims_details_non_eb.php b/app/Views/rfq/claims_details_non_eb.php index 9a7b590b..04592201 100644 --- a/app/Views/rfq/claims_details_non_eb.php +++ b/app/Views/rfq/claims_details_non_eb.php @@ -13,6 +13,21 @@ } ?> +
+ + +
+
+ + +
+
+ + +
-
- - -