Merge branch 'main' of bitbucket.org:jubilian/nhance_partner_be
This commit is contained in:
commit
2c6b3f853b
@ -151,25 +151,28 @@ $routes->group('api', ['filter' => 'appSignature'], function ($routes) {
|
||||
$routes->get("dashboard/productivityDashboard", "DashboardController::productivityDashboard");
|
||||
|
||||
//DASHBOARD Season 1 EXPORT EXCEL (ManagerDashboard - staffLevelPendingSummaryData)
|
||||
$routes->get("dashboard/downloadStaffPendingSummaryExcel", "ExcelExportController::downloadStaffPendingSummaryExcel");
|
||||
$routes->get("dashboard/downloadStaffPendingSummaryExcelByID", "ExcelExportController::downloadStaffPendingSummaryExcelByID");
|
||||
$routes->get("dashboard/downloadExcelStaffPendingSummary", "ExcelExportController::downloadExcelStaffPendingSummary");
|
||||
$routes->get("dashboard/downloadExcelStaffPendingSummaryByID", "ExcelExportController::downloadExcelStaffPendingSummaryByID");
|
||||
|
||||
//DASHBOARD Season 2 EXPORT EXCEL (businessDashboard)
|
||||
$routes->get("dashboard/downloadBrokerPoliciesExcel", "ExcelExportController::downloadBrokerPoliciesExcel");
|
||||
$routes->get("dashboard/downloadInsurerPoliciesExcel", "ExcelExportController::downloadInsurerPoliciesExcel");
|
||||
$routes->get("dashboard/downloadProductPoliciesExcel", "ExcelExportController::downloadProductPoliciesExcel");
|
||||
$routes->get("dashboard/downloadExcelBroker", "ExcelExportController::downloadBrokerPoliciesExcel");
|
||||
$routes->get("dashboard/downloadExcelInsurer", "ExcelExportController::downloadInsurerPoliciesExcel");
|
||||
$routes->get("dashboard/downloadExcelProduct", "ExcelExportController::downloadProductPoliciesExcel");
|
||||
|
||||
//DASHBOARD Season 3 EXPORT EXCEL (partnerDashboard)
|
||||
$routes->get("dashboard/downloadT50AgentPoliciesExcel", "ExcelExportController::downloadT50AgentPoliciesExcel"); // whole agent but top 50
|
||||
$routes->get("dashboard/downloadAgentMonthlyPoliciesExcel", "ExcelExportController::downloadAgentMonthlyPoliciesExcel"); // particular Agent
|
||||
$routes->get("dashboard/downloadLowPremiumAgentExcel", "ExcelExportController::downloadLowPremiumAgentExcel");
|
||||
$routes->get("dashboard/downloadAgentsWithoutPoliciesExcel", "ExcelExportController::downloadAgentsWithoutPoliciesExcel");
|
||||
$routes->get("dashboard/downloadExcelPerformingAgentsTop50", "ExcelExportController::downloadExcelPerformingAgentsTop50"); // PerformingAgents Top50
|
||||
$routes->get("dashboard/downloadExcelPerformingAgentsByID", "ExcelExportController::downloadExcelPerformingAgentsByID"); // PerformingAgents ParticularAgent
|
||||
$routes->get("dashboard/downloadExcelLowPremium", "ExcelExportController::downloadExcelLowPremium"); // NonPerforming Below50K
|
||||
$routes->get("dashboard/downloadExcelWithoutPolicies", "ExcelExportController::downloadExcelWithoutPolicies"); //NonPerforming NoBuiness
|
||||
|
||||
//DASHBOARD Season 4 EXPORT EXCEL AS ZIP (partnerDashboard - 3Excel in Zip Folder)
|
||||
$routes->get("dashboard/downloadExcelAsZIP", "ExcelExportController::downloadExcelAsZIP");
|
||||
|
||||
//DASHBOARD Season 5 EXPORT EXCEL (productivityDashboard)
|
||||
$routes->get("dashboard/downloadStaffAndProductPoliciesExcel", "ExcelExportController::downloadStaffAndProductPoliciesExcel");
|
||||
$routes->get("dashboard/downloadExcelStaffAndProduct", "ExcelExportController::downloadExcelStaffAndProduct");
|
||||
|
||||
//REPORT
|
||||
$routes->get('reports/endorsement-excel', 'ExcelExportController::downloadExcelEndorsement');
|
||||
|
||||
|
||||
|
||||
@ -218,18 +221,4 @@ $routes->get("processjob", "JobWorker::processJob");
|
||||
$routes->get('checkPolicyDoc', 'PolicyController::readFile');
|
||||
$routes->get('calculateCommission', 'PolicyController::calculateCommission');
|
||||
$routes->get('testPolicy', 'QuotationController::testPolicy');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -493,7 +493,7 @@ class DashboardController extends ResourceController
|
||||
|
||||
// Initialize the details array to ensure the final output is always structured.
|
||||
$message = "Partner Dashboard Data Retrieved Successfully";
|
||||
$details = [ 'monthlyPolicyCount' => [],'noPolicyTimeRange' => [],'below50tPremiumTimeRange' => []];
|
||||
$details = [ 'agentsPerformanceList' => [],'nonAgentsPerformanceList' => [],'nonAgentsPerformanceListPremium' => []];
|
||||
// 'agentNoPolicyLast10Days' => [],// 'agentBelow50tPremiumLast10Days' => [],
|
||||
|
||||
try {
|
||||
@ -501,7 +501,7 @@ class DashboardController extends ResourceController
|
||||
$date = $this->request->getGet('date');
|
||||
$date = $date ?? date('Y-m-d');
|
||||
|
||||
$data1 = $this->agentMonthlyPolicyCountandPremiumAmount($date, $manager_id, false);
|
||||
$data1 = $this->getDataPerformingAgents($date, $manager_id, false);
|
||||
|
||||
if (!empty($data1)) {
|
||||
|
||||
@ -513,9 +513,9 @@ class DashboardController extends ResourceController
|
||||
});
|
||||
}
|
||||
|
||||
$details['monthlyPolicyCount'] = $data1;
|
||||
$details['noPolicyTimeRange'] = $this->agentNoPolicyTimeRange($manager_id,$raw);
|
||||
$data2 = $this->getLowPremiumAgentData($manager_id,$raw);
|
||||
$details['agentsPerformanceList'] = $data1;
|
||||
$details['nonAgentsPerformanceList'] = $this->getDataNonAgentsPerformanceList($manager_id,$raw);
|
||||
$data2 = $this->getDataLowPremiumAgent($manager_id,$raw);
|
||||
if (!empty($data2)) {
|
||||
|
||||
$lastIndex2 = count(reset($data2)) - 1;
|
||||
@ -525,14 +525,14 @@ class DashboardController extends ResourceController
|
||||
return (float)$rowD[$lastIndex2] <=> (float)$rowC[$lastIndex2];
|
||||
});
|
||||
}
|
||||
$details['below50tPremiumTimeRange'] = $data2;
|
||||
$details['nonAgentsPerformanceListPremium'] = $data2;
|
||||
|
||||
|
||||
// $details['monthlyPremiumAmount'] = $this->agentMonthlyPremiumAmount($date,$manager_id,$raw);
|
||||
// $details['agentsPerformanceListPremium'] = $this->agentMonthlyPremiumAmount($date,$manager_id,$raw);
|
||||
|
||||
$ref['monthlyPolicyCountAndPremiumAmount_total_records'] = is_array($details['monthlyPolicyCount']) ? count($details['monthlyPolicyCount']) : 0;
|
||||
$ref['noPolicyTimeRange_total_records'] = is_array($details['noPolicyTimeRange']) ? count($details['noPolicyTimeRange']) : 0;
|
||||
$ref['below50tPremiumTimeRange_total_records'] = is_array($details['below50tPremiumTimeRange']) ? count($details['below50tPremiumTimeRange']) : 0;
|
||||
$ref['agentsPerformanceList_monthlyPolicyCountAndPremiumAmount_totalRecords'] = is_array($details['agentsPerformanceList']) ? count($details['agentsPerformanceList']) : 0;
|
||||
$ref['nonAgentsPerformanceList_noPolicyTimeRange_totalRecords'] = is_array($details['nonAgentsPerformanceList']) ? count($details['nonAgentsPerformanceList']) : 0;
|
||||
$ref['nonAgentsPerformanceListPremium_below50tPremiumTimeRange_totalRecords'] = is_array($details['nonAgentsPerformanceListPremium']) ? count($details['nonAgentsPerformanceListPremium']) : 0;
|
||||
|
||||
|
||||
// 2. Check for overall emptiness (optional, but good practice)
|
||||
@ -826,7 +826,7 @@ class DashboardController extends ResourceController
|
||||
}
|
||||
|
||||
//Step 2
|
||||
public function agentMonthlyPolicyCountandPremiumAmount($customDate,$manager_id, $raw){
|
||||
public function getDataPerformingAgents($customDate,$manager_id, $raw){
|
||||
|
||||
|
||||
$builder = $this->db->table('partner_policy pp');
|
||||
@ -890,7 +890,7 @@ class DashboardController extends ResourceController
|
||||
// }
|
||||
|
||||
//Step 3 no buiness
|
||||
public function agentNoPolicyTimeRange($managerId, $raw){
|
||||
public function getDataNonAgentsPerformanceList($managerId, $raw){
|
||||
|
||||
// $builder = $this->db->table('partner_agent pa');
|
||||
// $builder->select('
|
||||
@ -959,8 +959,8 @@ class DashboardController extends ResourceController
|
||||
}
|
||||
|
||||
//Step 4
|
||||
//any changed in this query also change in do the same in ExcelExportController - getLowPremiumAgentData
|
||||
public function getLowPremiumAgentData($manager_id, $raw){
|
||||
//any changed in this query also change in do the same in ExcelExportController - getDataLowPremiumAgent
|
||||
public function getDataLowPremiumAgent($manager_id, $raw){
|
||||
|
||||
$builder = $this->db->table('partner_policy pp');
|
||||
|
||||
|
||||
@ -93,6 +93,10 @@ class EnquiryController extends ResourceController
|
||||
$data = $this->enquiryModel->getEnquiry('ALL');
|
||||
}
|
||||
|
||||
// echo (string) $db->getLastQuery();
|
||||
// echo $this->db->getLastQuery()->getQuery();die;
|
||||
|
||||
|
||||
|
||||
foreach ($data as $key => $row) {
|
||||
if($row['created_on'] !== null)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -59,11 +59,18 @@ class SalesExecutive extends ResourceController
|
||||
{
|
||||
try{
|
||||
$data = $this->request->getJSON(true);
|
||||
|
||||
$email = (!empty($data['email'])) ? $data['email'] : null;
|
||||
$mobile = (!empty($data['mobile'])) ? $data['mobile'] : null;
|
||||
|
||||
if ($email === null && $mobile === null) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => 'Email or Mobile is required'], 500);
|
||||
}
|
||||
|
||||
$insertData = [
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'mobile' => $data['mobile'],
|
||||
'email' => $email,
|
||||
'mobile' => $mobile,
|
||||
'address' => $data['address'],
|
||||
'manager_id' => $data['manager_id'],
|
||||
'created_by' => $data['created_by'],
|
||||
@ -75,7 +82,18 @@ class SalesExecutive extends ResourceController
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
// return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
$message = $e->getMessage();
|
||||
if (strpos($message, '1062') !== false || strpos($message, 'Duplicate entry') !== false) {
|
||||
if (strpos($message, 'sales_executive_unique_mobile') !== false) {
|
||||
$message = 'Mobile number already exists';
|
||||
} elseif (strpos($message, 'sales_executive_email') !== false) {
|
||||
$message = 'Email already exists';
|
||||
} else {
|
||||
$message = 'Duplicate record found';
|
||||
}
|
||||
}
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $message], 500);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,11 +114,17 @@ class SalesExecutive extends ResourceController
|
||||
if (!$salesExecutive) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'Date Not Found'], 200);
|
||||
}
|
||||
$email = (!empty($data['email'])) ? $data['email'] : null;
|
||||
$mobile = (!empty($data['mobile'])) ? $data['mobile'] : null;
|
||||
|
||||
if ($email === null && $mobile === null) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => 'Either Email or Mobile must be provided'], 500);
|
||||
}
|
||||
|
||||
$updateData = [
|
||||
'name' => $data['name'] ?? null,
|
||||
'email' => $data['email'] ?? null,
|
||||
'mobile' => $data['mobile'] ?? null,
|
||||
'email' => $email,
|
||||
'mobile' => $mobile,
|
||||
'address' => $data['address'] ?? null,
|
||||
'updated_by' => $data['updated_by'] ?? null,
|
||||
];
|
||||
@ -110,7 +134,18 @@ class SalesExecutive extends ResourceController
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
// return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
|
||||
$message = $e->getMessage();
|
||||
if (strpos($message, '1062') !== false || strpos($message, 'Duplicate entry') !== false) {
|
||||
if (strpos($message, 'sales_executive_unique_mobile') !== false) {
|
||||
$message = 'Mobile number already exists';
|
||||
} elseif (strpos($message, 'sales_executive_email') !== false) {
|
||||
$message = 'Email already exists';
|
||||
} else {
|
||||
$message = 'Duplicate record found';
|
||||
}
|
||||
}
|
||||
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $message], 500);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -254,7 +254,7 @@ class StaffController extends ResourceController
|
||||
'mobile' => $data['mobile'] ?? null,
|
||||
'role_id' => $data['role_id'],
|
||||
'manager_id' => $data['manager_id'] ?? null,
|
||||
'handler_id' => json_encode($data['handler_id'] ?? []),
|
||||
'handler_id' => (isset($data['handler_id']) && !empty($data['handler_id'])) ? json_encode($data['handler_id']) : json_encode([]),
|
||||
'created_by' => $data['created_by']
|
||||
];
|
||||
|
||||
@ -285,18 +285,15 @@ class StaffController extends ResourceController
|
||||
return $this->respond(['status' => 'failed', 'code' => 200, 'data' => 'Date Not Found'], 200);
|
||||
}
|
||||
|
||||
|
||||
$updateData = [
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'mobile' => $data['mobile'],
|
||||
'role_id' => $data['role_id'],
|
||||
'handler_id' => !empty($data['handler_id']) ? json_encode($data['handler_id']) : [],
|
||||
'handler_id' => (isset($data['handler_id']) && !empty($data['handler_id'])) ? json_encode($data['handler_id']) : json_encode([]),
|
||||
'updated_by' => $data['updated_by'],
|
||||
];
|
||||
|
||||
|
||||
|
||||
$this->StaffModel->update($id, $updateData);
|
||||
|
||||
return $this->respond(['status' => 'success', 'code' => 200, 'data' => []], 200);
|
||||
|
||||
@ -64,7 +64,7 @@ class EnquiryModel extends Model
|
||||
->join('partner_agent A', 'A.id = partner_enquiry.agent_id', 'left')
|
||||
->join('partner_staff S', 'S.id = partner_enquiry.assigned_to', 'left')
|
||||
->join('partner_quotation Q', 'Q.enquiry_id = partner_enquiry.id AND Q.status = "Accepted" ', 'left')
|
||||
->join('insurers I', 'I.id = Q.insurer_id', 'left')
|
||||
->join('insurers I', 'I.id = partner_enquiry.insurer_id', 'left')
|
||||
->join('partner_policy P', 'P.quotation_id = Q.id', 'left')
|
||||
->join('partner_brokers PB', 'PB.id = partner_enquiry.broker_id', 'left')
|
||||
->join('partner_payment_mode_master pm', 'pm.id = Q.payment_mode_id', 'left')
|
||||
|
||||
Loading…
Reference in New Issue
Block a user