Merge branch 'dev' of bitbucket.org:jubilian/nhance into dev
This commit is contained in:
commit
7160c10999
@ -519,7 +519,6 @@ class ClientController extends AdminController
|
||||
public function updateEmpAndPolicyStatus()
|
||||
{
|
||||
$return = $this->clientPolicyModel->updateStatus();
|
||||
return $return;
|
||||
$this->myLogger->logme('error', 'Client Policy Status Update Count: {data}', ['data' => $return['client']]);
|
||||
$this->myLogger->logme('error', 'Employee Policy Status Update Count: {data}', ['data' => $return['emp']]);
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ use App\Controllers\JobWorker;
|
||||
use App\Controllers\Jobs\SubJob;
|
||||
use App\Controllers\EmployeeServiceController;
|
||||
use App\Controllers\EmpDataServiceController;
|
||||
use App\Models\LeadsModel;
|
||||
use App\Models\ThzMasterModel;
|
||||
use CodeIgniter\API\ResponseTrait;
|
||||
|
||||
@ -171,7 +172,7 @@ class EmployeeController extends AdminController
|
||||
return $this->respond(['dataStatus' => false, 'code' => 404, 'message' => 'no data found'], 200);
|
||||
} else {
|
||||
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason'], 'is_comparison_skipped' => $file['is_comparison_skipped']], 200);
|
||||
return $this->respond(['dataStatus' => true, 'code' => 200, 'data' => $file['reason'], 'is_comparison_skipped' => $file['is_comparison_skipped'], 'policy_id' => $file['policy_id']], 200);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3151,6 +3152,8 @@ class EmployeeController extends AdminController
|
||||
{
|
||||
$file_id = $this->request->getGet('file_id');
|
||||
$not_skiped = $this->request->getGet('not_skiped') ?? null;
|
||||
$this->myLogger->logme('error', json_encode($this->request->getGet() ?? []));
|
||||
|
||||
|
||||
if(!empty($not_skiped)){
|
||||
$file_model = new FileModel();
|
||||
@ -3161,11 +3164,36 @@ class EmployeeController extends AdminController
|
||||
}
|
||||
|
||||
if(!empty($file_id)){
|
||||
|
||||
$r = Jobs::addJob(['job_name' => 'excelFileDataValidation','payload' => ['file_id' => $file_id]]);
|
||||
$message = "Inception and Member data comparision skiped successfully by the user id : " . get_session_userid();
|
||||
$this->myLogger->logme('error', $message);
|
||||
|
||||
$file_model = new FileModel();
|
||||
$file_model->where('id', $file_id)->set(['is_comparison_skipped' => 1])->update();
|
||||
|
||||
$policy_id = $this->request->getGet('policy_id') ?? null;
|
||||
|
||||
if ($policy_id) {
|
||||
|
||||
$client_policy_data = $this->clientPolicyModel->where('id', $policy_id)->first();
|
||||
|
||||
if (!empty($client_policy_data) && isset($client_policy_data['is_from_lead'])) {
|
||||
$lead_id = $client_policy_data['is_from_lead'];
|
||||
|
||||
if (!empty($lead_id)) {
|
||||
$lead_model = new LeadsModel();
|
||||
$lead_model->where('id', $lead_id)->set(['policy_with_correction' => 1])->update();
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'Lead ID missing for policy ID: ' . $policy_id);
|
||||
}
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'No client policy data found for policy ID: ' . $policy_id);
|
||||
}
|
||||
} else {
|
||||
$this->myLogger->logme('error', 'Policy ID not provided in GET request.');
|
||||
}
|
||||
|
||||
return $this->respond(['status' => true, 'code' => 200, 'message' => 'Inception and Member data comparision skiped successfully!'], 200);
|
||||
}else{
|
||||
return $this->respond(['status' => false, 'code' => 500, 'message' => 'Failed to skip the comparison!'], 200);
|
||||
|
||||
@ -2390,7 +2390,9 @@ class EmployeeServiceController extends AdminController
|
||||
// --------- MEMBER DATA AND INCEPTION DATA COMPARISION ------------------------------------------------------------------------
|
||||
|
||||
public function compareMemberDataAndInceptionData($params)
|
||||
{
|
||||
{
|
||||
helper('excel_util_helper');
|
||||
|
||||
$file_id = $params['file_id'] ?? null;
|
||||
if (empty($file_id)) {
|
||||
return ['status' => false, 'msg' => 'File ID is missing'];
|
||||
|
||||
@ -210,13 +210,13 @@ class Home extends PublicController
|
||||
public function checkPolicyDoc()
|
||||
{
|
||||
|
||||
// $this->convertToPdf();die();
|
||||
try
|
||||
{ // $this->convertToPdf();die();
|
||||
// Replace with your actual Gemini API key
|
||||
$apiKey = 'AIzaSyBbx-uotRBqkYhqLpmD60420E_a0G0duP8';
|
||||
|
||||
$apiKey = getenv('GEMINI_API_KEY');
|
||||
// The model to use and the API endpoint
|
||||
$model = "gemini-pro";
|
||||
$model = "gemini-2.5-flash";
|
||||
$model = getenv('GEMINI_MODEL');
|
||||
// $model = "gemini-1.5-pro";
|
||||
// $model = "gemini-1.5-pro";
|
||||
$url = "https://generativelanguage.googleapis.com/v1beta/models/{$model}:generateContent?key={$apiKey}";
|
||||
@ -233,7 +233,7 @@ class Home extends PublicController
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mimeType = finfo_file($finfo, $filePath);
|
||||
finfo_close($finfo);
|
||||
// print_r($mimeType);die();
|
||||
print_r($mimeType);die();
|
||||
// Define supported inline MIME types
|
||||
$supportedInlineMimeTypes = ['application/pdf','text/csv'];
|
||||
|
||||
@ -242,8 +242,8 @@ class Home extends PublicController
|
||||
$base64Content = base64_encode($fileContent);
|
||||
// The prompt you want to send to the model
|
||||
// $prompt = "give me a json with emp data like name,age,dob,mobile and email. only json not any explanations";
|
||||
$prompt = "Read the following motor policy pdf document and convert into JSON format as sample specified. Give me only JSON,not any explanations.";
|
||||
$prompt .= '"{\"policy\":{\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa_od\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"';
|
||||
$prompt = "Read the following motor policy pdf document and convert into JSON format as sample specified. Give me only JSON,not any explanations.while pick up premium break up give own damage, third party ,personal accident and taxes as mentioned in JSON format.Notes:vehicle_type should be like Two Wheeler,Four Feeler,Good Vehicle,Bus, Tractor,Commercial Vehicle.rto_state_code is first two char of reg_no and rto_city_code 3rd & 4th char of reg_no and it should be two digit numeric code. Any date should be in mysql date format";
|
||||
$prompt .= '"{\"policy\":{\"policy_number\":\"\",\"issue_date\":\"\",\"period\":{\"start\":\"\",\"end\":\"\"},\"insurer\":\"\",\"previous_policy_number\":\"\"},\"insured\":{\"name\":\"\",\"father_name\":\"\",\"address\":[\"\"],\"mobile\":\"\",\"id_proofs\":{\"aadhaar\":\"\",\"pan\":\"\"}},\"vehicle\":{\"reg_no\":\"\",\"rto_state_code\":\"\",\"rto_city_code\":\"\",\"weight\":\"\",\"fuel_type\":\"\",\"date_of_registration\":\"\",\"year_of_manufacture\":\"\",\"engine_no\":\"\",\"chassis_no\":\"\",\"make\":\"\",\"model\":\"\",\"year\":\"\",\"cubic_capacity\":\"\",\"vehicle_type\":\"\"},\"rto\":\"\",\"premium\":{\"tp\":0,\"od\":0,\"pa\":0,\"taxes\":{},\"total\":0,\"in_words\":\"\"},\"endorsements\":[{\"code\":\"\",\"desc\":\"\"}]}"';
|
||||
|
||||
$payloadPart = null;
|
||||
|
||||
@ -253,7 +253,7 @@ class Home extends PublicController
|
||||
];
|
||||
// Conditionally handle the file upload based on MIME type
|
||||
if (in_array($mimeType, $supportedInlineMimeTypes)) {
|
||||
echo "Detected supported format inline MIME type ({$mimeType})";
|
||||
// echo "Detected supported format inline MIME type ({$mimeType})";
|
||||
// Handle PDF as inline data
|
||||
$fileContent = file_get_contents($filePath);
|
||||
$base64Content = base64_encode($fileContent);
|
||||
@ -272,10 +272,10 @@ class Home extends PublicController
|
||||
];
|
||||
} else {
|
||||
// Handle Excel/CSV using the Files API
|
||||
echo "Detected unsupported inline MIME type ({$mimeType}). Uploading via Files API...\n";
|
||||
// echo "Detected unsupported inline MIME type ({$mimeType}). Uploading via Files API...\n";
|
||||
$fileInfo = $this->uploadFileToGemini($filePath, $apiKey); // Pass apiKey
|
||||
|
||||
print_r($fileInfo);
|
||||
// print_r($fileInfo);
|
||||
// The file part, using the URI from the Files API upload
|
||||
$file_part = [
|
||||
"fileData" => [
|
||||
@ -321,24 +321,70 @@ class Home extends PublicController
|
||||
|
||||
// Check for cURL errors
|
||||
if (curl_errno($ch)) {
|
||||
echo 'cURL Error: ' . curl_error($ch);
|
||||
}
|
||||
|
||||
$curl_error = curl_error($ch);
|
||||
throw new Exception("cURL Error: " . $curl_error);
|
||||
}
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
// Close the cURL handle
|
||||
curl_close($ch);
|
||||
$ch = null; // Mark handle as closed
|
||||
// Check for non-successful HTTP status codes
|
||||
if ($http_code < 200 || $http_code >= 300) {
|
||||
throw new Exception("API returned non-successful HTTP status code: $http_code. Response: " . substr($response, 0, 200) . '...');
|
||||
}
|
||||
|
||||
// Decode the JSON response
|
||||
$responseData = json_decode($response, true);
|
||||
echo '<pre>';
|
||||
print_r($responseData);
|
||||
echo '<pre>';
|
||||
// Check if the response contains generated text
|
||||
if (isset($responseData['candidates'][0]['content']['parts'][0]['text'])) {
|
||||
$generatedText = $responseData['candidates'][0]['content']['parts'][0]['text'];
|
||||
echo "Generated Text: " . $generatedText;
|
||||
} else {
|
||||
echo "Error or no text generated. Response: " . $response;
|
||||
$responseData = json_decode($response, true, 512, JSON_THROW_ON_ERROR);
|
||||
$text_path = $responseData['candidates'][0]['content']['parts'][0]['text'] ?? null;
|
||||
|
||||
if ($text_path) {
|
||||
$generatedText = $text_path;
|
||||
log_message('info', "Successfully received generated text.");
|
||||
|
||||
// 9. Attempt to extract and decode the exact JSON from the generated text
|
||||
$json_string = '';
|
||||
|
||||
// Preferred: Regex to find content inside a JSON markdown block: ```json\n(.*?)\n```
|
||||
$extracted_json_match = [];
|
||||
if (preg_match('/```json\s*(.*?)\s*```/s', $generatedText, $extracted_json_match)) {
|
||||
$json_string = trim($extracted_json_match[1]);
|
||||
} else {
|
||||
// Fallback: Find the first '{' and the last '}'
|
||||
$start = strpos($generatedText, '{');
|
||||
$end = strrpos($generatedText, '}');
|
||||
if ($start !== false && $end !== false && $end > $start) {
|
||||
$json_string = substr($generatedText, $start, $end - $start + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($json_string)) {
|
||||
throw new Exception("Could not extract a valid JSON string from the generated text.");
|
||||
}
|
||||
|
||||
// Decode the extracted JSON string
|
||||
$final_data = json_decode($json_string, true, 512, JSON_THROW_ON_ERROR);
|
||||
|
||||
log_message('info', "Extracted and decoded final JSON data successfully.");
|
||||
echo '<pre>';
|
||||
print_r($final_data);
|
||||
// return $final_data;
|
||||
|
||||
} else {
|
||||
// No generated text found, possibly a model safety block or API structure change
|
||||
throw new Exception("Response structure invalid or no generated text candidate found.");
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Log the error
|
||||
log_message('ERROR', "$request_id: Fatal Error: " . $e->getMessage());
|
||||
|
||||
// Ensure cURL handle is closed if an exception occurred after initialization but before closing
|
||||
if ($ch !== null) {
|
||||
curl_close($ch);
|
||||
}
|
||||
return null; // Return null on failure
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ class LeadsController extends BaseController
|
||||
protected $issuer;
|
||||
protected $clientType;
|
||||
protected $leadType;
|
||||
protected $leadsStatus;
|
||||
public $leadsStatus;
|
||||
protected $claim_type_for_gpa;
|
||||
protected $cause_of_death;
|
||||
protected $buisnessType;
|
||||
|
||||
@ -1646,21 +1646,53 @@ if (!function_exists('check_dup_mobileno')) {
|
||||
}
|
||||
}
|
||||
|
||||
// if (!function_exists('check_dup_email')) {
|
||||
// function check_dup_email(array $row, array $existing_mobilenos)
|
||||
// {
|
||||
// is_valid_or_empty_email($row['13']);
|
||||
// if(!empty($row['13'])){
|
||||
// foreach ($existing_mobilenos as $k => $value) {
|
||||
// if (strtolower($row['5']) == 'self' && $row['13'] == $value['email_corporate']) {
|
||||
// return array('status' => false, 'error' => "Duplicate Email");
|
||||
// // break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return array('status' => true);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (!function_exists('check_dup_email')) {
|
||||
function check_dup_email(array $row, array $existing_mobilenos)
|
||||
{
|
||||
if(!empty($row['13'])){
|
||||
foreach ($existing_mobilenos as $k => $value) {
|
||||
if (strtolower($row['5']) == 'self' && $row['13'] == $value['email_corporate']) {
|
||||
return array('status' => false, 'error' => "Duplicate Email");
|
||||
// break;
|
||||
$errorMessages = [];
|
||||
|
||||
// Validate email
|
||||
$emailCheck = is_valid_or_empty_email($row['13'] ?? "");
|
||||
if (!$emailCheck) {
|
||||
$errorMessages[] = 'Invalid email format';
|
||||
}
|
||||
|
||||
// Check duplicate only if email is not empty
|
||||
if (!empty($row['13'])) {
|
||||
foreach ($existing_mobilenos as $value) {
|
||||
if (strtolower(trim($row['5'])) === 'self' && trim($row['13']) === trim($value['email_corporate'])) {
|
||||
$errorMessages[] = 'Duplicate Email';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array('status' => true);
|
||||
|
||||
// Prepare final return
|
||||
if (!empty($errorMessages)) {
|
||||
return ['status' => false, 'error' => implode(' & ', $errorMessages)];
|
||||
}
|
||||
|
||||
return ['status' => true, 'error' => ''];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!function_exists('generate_family_relationship_array')) {
|
||||
function generate_family_relationship_array($family_structure_from_policy_terms)
|
||||
{
|
||||
@ -2403,3 +2435,24 @@ if (!function_exists('check_age_validation')) {
|
||||
// ------------- END OF LEAD MEMBER DATA LIST VALIDATIONS --------------------------------------
|
||||
|
||||
|
||||
if (!function_exists('is_valid_or_empty_email')) {
|
||||
function is_valid_or_empty_email($email)
|
||||
{
|
||||
// If empty or null → return success
|
||||
if (empty($email) && $email != 0) {
|
||||
// return ['status' => true, 'error' => 'Value is empty'];
|
||||
return true;
|
||||
}
|
||||
|
||||
// If valid email → return success
|
||||
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||
// return ['status' => true, 'error' => 'Valid email format'];
|
||||
return true;
|
||||
}
|
||||
|
||||
// If invalid email → return failure
|
||||
// return ['status' => false, 'error' => 'Invalid email format'];
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -431,8 +431,8 @@ class ClientPolicyModel extends Model
|
||||
$emp_count = $this->db->affectedRows();
|
||||
|
||||
// Log the result
|
||||
log_message('info', "Client policies updated: {$client_count}");
|
||||
log_message('info', "Employee policies updated: {$emp_count}");
|
||||
log_message('error', "Client policies updated: {$client_count}");
|
||||
log_message('error', "Employee policies updated: {$emp_count}");
|
||||
|
||||
return ['client' => $client_count, 'emp' => $emp_count];
|
||||
}
|
||||
|
||||
@ -106,6 +106,7 @@ class LeadsModel extends Model
|
||||
'is_insurer_auto_mail',
|
||||
'quote_received_insurer',
|
||||
'acm_id',
|
||||
'policy_with_correction',
|
||||
];
|
||||
|
||||
|
||||
@ -204,78 +205,151 @@ class LeadsModel extends Model
|
||||
return $result;
|
||||
}
|
||||
|
||||
// public function getDashData()
|
||||
// {
|
||||
// $statuses = $this->db->table('leads')
|
||||
// ->select('status, policy_with_correction')
|
||||
// ->where("is_active", 1)
|
||||
// ->groupBy('status')
|
||||
// ->get()
|
||||
// ->getResultArray();
|
||||
|
||||
// $policy_with_correction_count = $this->db->table('leads')
|
||||
// ->where('is_active', 1)
|
||||
// ->where('policy_with_correction', 1)
|
||||
// ->countAllResults();
|
||||
|
||||
// $selectParts = [];
|
||||
|
||||
// foreach ($statuses as $status) {
|
||||
// $s = $status['status'];
|
||||
// $alias = strtolower(str_replace(' ', '_', $s));
|
||||
|
||||
// // Count alias
|
||||
// $selectParts[] = "SUM(CASE WHEN status = '{$s}' THEN 1 ELSE 0 END) AS `{$alias}`";
|
||||
|
||||
// // IDs alias
|
||||
// $selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$s}' THEN leads.id ELSE NULL END) AS `{$alias}_ids`";
|
||||
// }
|
||||
|
||||
// $select = implode(", ", $selectParts);
|
||||
|
||||
// // Start query builder
|
||||
// $builder = $this->db->table('leads');
|
||||
|
||||
// $builder->select($select);
|
||||
|
||||
// // Auditing subquery
|
||||
// $subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
|
||||
// FROM auditing_history
|
||||
// WHERE table_name = 'leads' AND field_name = 'status'
|
||||
// GROUP BY pk)";
|
||||
|
||||
// $builder->join("{$subquery} AS th", 'leads.id = th.pk', 'left');
|
||||
|
||||
// // Date filtering for last status change
|
||||
// $dateLimit = 3;
|
||||
// $dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
|
||||
|
||||
// $builder->groupStart()
|
||||
// ->where('th.last_claim_status_change <=', $dateThreshold)
|
||||
// ->orWhere('th.last_claim_status_change IS NULL')
|
||||
// ->groupEnd();
|
||||
|
||||
// // Add only active
|
||||
// $builder->where("leads.is_active", 1);
|
||||
|
||||
// $lead_data = $builder->get()->getResultArray();
|
||||
|
||||
// // dd($this->db->getLastQuery());
|
||||
|
||||
// // Fallback for empty results
|
||||
// if (empty($lead_data)) {
|
||||
// $lead_data[0] = ['total' => 0];
|
||||
// foreach ($statuses as $status) {
|
||||
// $alias = strtolower(str_replace(' ', '_', $status['status']));
|
||||
// $lead_data[0][$alias] = 0;
|
||||
// $lead_data[0]["{$alias}_ids"] = '';
|
||||
// }
|
||||
// }
|
||||
|
||||
// // Calculate total
|
||||
// $total = 0;
|
||||
// foreach ($lead_data[0] as $key => $value) {
|
||||
// // if (!str_ends_with($key, '_ids') && $key != "won") {
|
||||
// // $total += (int) $value;
|
||||
// // }
|
||||
|
||||
// if (!str_ends_with($key, '_ids')) {
|
||||
// $total += (int) $value;
|
||||
// }
|
||||
// }
|
||||
|
||||
// $total = $total + $policy_with_correction_count ?? 0;
|
||||
// $lead_data[0]['total'] = $total;
|
||||
// $lead_data[0]['policy_with_correction'] = $policy_with_correction_count;
|
||||
|
||||
|
||||
// // dd($lead_data[0]);
|
||||
// return $lead_data[0];
|
||||
// }
|
||||
|
||||
|
||||
public function getDashData()
|
||||
{
|
||||
// Get all unique statuses
|
||||
$statuses = $this->db->table('leads')
|
||||
->select('status')
|
||||
->where("is_active", 1)
|
||||
->groupBy('status')
|
||||
->select('DISTINCT(status)')
|
||||
->where('is_active', 1)
|
||||
->get()
|
||||
->getResultArray();
|
||||
|
||||
|
||||
$policy_with_correction_data = $this->db->table('leads')
|
||||
->select('COUNT(id) AS count, GROUP_CONCAT(id) AS ids')
|
||||
->where('is_active', 1)
|
||||
->where('policy_with_correction', 1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
if (empty($statuses)) {
|
||||
return ['total' => 0];
|
||||
}
|
||||
|
||||
// Build dynamic select fields for each status
|
||||
$selectParts = [];
|
||||
|
||||
foreach ($statuses as $status) {
|
||||
$s = $status['status'];
|
||||
$alias = strtolower(str_replace(' ', '_', $s));
|
||||
|
||||
// Count alias
|
||||
$selectParts[] = "SUM(CASE WHEN status = '{$s}' THEN 1 ELSE 0 END) AS `{$alias}`";
|
||||
|
||||
// IDs alias
|
||||
$selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$s}' THEN leads.id ELSE NULL END) AS `{$alias}_ids`";
|
||||
foreach ($statuses as $row) {
|
||||
$status = $row['status'];
|
||||
$alias = strtolower(str_replace(' ', '_', $status));
|
||||
|
||||
$selectParts[] = "SUM(CASE WHEN status = '{$status}' THEN 1 ELSE 0 END) AS `{$alias}`";
|
||||
$selectParts[] = "GROUP_CONCAT(CASE WHEN status = '{$status}' THEN id END) AS `{$alias}_ids`";
|
||||
}
|
||||
|
||||
|
||||
$select = implode(", ", $selectParts);
|
||||
|
||||
// Start query builder
|
||||
$builder = $this->db->table('leads');
|
||||
|
||||
$builder->select($select);
|
||||
|
||||
// Auditing subquery
|
||||
$subquery = "(SELECT pk, MAX(created_at) AS last_claim_status_change
|
||||
FROM auditing_history
|
||||
WHERE table_name = 'leads' AND field_name = 'status'
|
||||
GROUP BY pk)";
|
||||
|
||||
$builder->join("{$subquery} AS th", 'leads.id = th.pk', 'left');
|
||||
|
||||
// Date filtering for last status change
|
||||
$dateLimit = 3;
|
||||
$dateThreshold = date('Y-m-d H:i:s', strtotime("-{$dateLimit} days"));
|
||||
|
||||
$builder->groupStart()
|
||||
->where('th.last_claim_status_change <=', $dateThreshold)
|
||||
->orWhere('th.last_claim_status_change IS NULL')
|
||||
->groupEnd();
|
||||
|
||||
// Add only active
|
||||
$builder->where("leads.is_active", 1);
|
||||
|
||||
$lead_data = $builder->get()->getResultArray();
|
||||
|
||||
// Fallback for empty results
|
||||
if (empty($lead_data)) {
|
||||
$lead_data[0] = ['total' => 0];
|
||||
foreach ($statuses as $status) {
|
||||
$alias = strtolower(str_replace(' ', '_', $status['status']));
|
||||
$lead_data[0][$alias] = 0;
|
||||
$lead_data[0]["{$alias}_ids"] = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main query
|
||||
$lead_data = $this->db->table('leads')
|
||||
->select($select)
|
||||
->where('is_active', 1)
|
||||
->get()
|
||||
->getRowArray();
|
||||
|
||||
// Calculate total
|
||||
$total = 0;
|
||||
foreach ($lead_data[0] as $key => $value) {
|
||||
if (!str_ends_with($key, '_ids') && $key != "won") {
|
||||
$total += (int) $value;
|
||||
foreach ($lead_data as $key => $val) {
|
||||
if (!str_ends_with($key, '_ids')) {
|
||||
$total += (int) $val;
|
||||
}
|
||||
}
|
||||
$lead_data[0]['total'] = $total;
|
||||
|
||||
// dd($lead_data[0]);
|
||||
return $lead_data[0];
|
||||
|
||||
$lead_data['total'] = $total;
|
||||
$lead_data['policy_with_correction'] = $policy_with_correction_data['count'] ?? 0;
|
||||
$lead_data['policy_with_correction_ids'] = $policy_with_correction_data['ids'] ?? null;
|
||||
|
||||
// dd($lead_data);
|
||||
return $lead_data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -463,6 +463,7 @@ function fetchFileError(file_id) {
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
console.log('fetchFileError response', response);
|
||||
$(this).find(".modal-body").html("");
|
||||
if (response.code === 200 && response.dataStatus === true && response.data !== "") {
|
||||
|
||||
@ -475,6 +476,7 @@ function fetchFileError(file_id) {
|
||||
let buttonAdded = false;
|
||||
let error_code = 0;
|
||||
let is_comparison_skipped = response.is_comparison_skipped ?? null;
|
||||
let policy_id = response.policy_id ?? null;
|
||||
|
||||
for (var key in file_error_data['error_summary']) {
|
||||
// console.log(key);
|
||||
@ -594,8 +596,8 @@ function fetchFileError(file_id) {
|
||||
file_error_html +=
|
||||
"<div id='confirmationdiv' class='mt-2 text-center'>" +
|
||||
"<p class='mb-2'>Do you want to skip the comparison?</p>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+">No</button>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+" data-pid="+policy_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+" data-pid="+policy_id+">No</button>" +
|
||||
"</div>";
|
||||
buttonAdded = true;
|
||||
} else if (hasError14 && !hasError15 && error_code == 14) {
|
||||
@ -603,8 +605,8 @@ function fetchFileError(file_id) {
|
||||
file_error_html +=
|
||||
"<div id='confirmationdiv' class='mt-2 text-center'>" +
|
||||
"<p class='mb-2'>Do you want to skip the comparison?</p>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+">No</button>" +
|
||||
"<button id='confirmYes' class='btn btn-success btn-sm mx-1' data-id="+file_id+" data-pid="+policy_id+">Yes</button>" +
|
||||
"<button id='confirmNo' class='btn btn-danger btn-sm mx-1' data-id="+file_id+" data-pid="+policy_id+">No</button>" +
|
||||
"</div>";
|
||||
buttonAdded = true;
|
||||
}
|
||||
@ -1090,6 +1092,10 @@ function checkValues() {
|
||||
|
||||
$(document).on('click', '#confirmYes', function() {
|
||||
let file_id = $(this).data('id');
|
||||
let policy_id = $(this).data('pid');
|
||||
|
||||
console.log('file_id', file_id);
|
||||
console.log('policy_id', policy_id);
|
||||
|
||||
Swal.fire({
|
||||
title: "Are you sure?",
|
||||
@ -1110,7 +1116,7 @@ $(document).on('click', '#confirmYes', function() {
|
||||
$.ajax({
|
||||
url: '<?= base_url("util/proceedExcelFileDataValidation") ?>', // replace with actual API URL
|
||||
type: 'GET',
|
||||
data: { file_id: file_id },
|
||||
data: { file_id: file_id, policy_id: policy_id },
|
||||
success: function(response) {
|
||||
console.log('API response:', response);
|
||||
|
||||
|
||||
@ -62,7 +62,7 @@
|
||||
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.3/dist/umd/popper.min.js"></script>
|
||||
|
||||
<link rel="manifest" href="../manifest.json">
|
||||
<!-- <link rel="manifest" href="../manifest.json"> -->
|
||||
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
|
||||
@ -71,15 +71,15 @@
|
||||
|
||||
|
||||
<script>
|
||||
if ('serviceWorker' in navigator) {
|
||||
window.addEventListener('load', function() {
|
||||
navigator.serviceWorker.register('../service-worker.js').then(function(registration) {
|
||||
// console.log('Service Worker registration successful with scope:', registration.scope);
|
||||
}, function(err) {
|
||||
// console.log('Service Worker registration failed:', err);
|
||||
});
|
||||
});
|
||||
}
|
||||
// if ('serviceWorker' in navigator) {
|
||||
// window.addEventListener('load', function() {
|
||||
// navigator.serviceWorker.register('../service-worker.js').then(function(registration) {
|
||||
// // console.log('Service Worker registration successful with scope:', registration.scope);
|
||||
// }, function(err) {
|
||||
// // console.log('Service Worker registration failed:', err);
|
||||
// });
|
||||
// });
|
||||
// }
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.8.1/slick-theme.min.css" />
|
||||
|
||||
@ -209,9 +209,13 @@ $isActive = get_role_id() == STAFF_ROLE_ID && in_array(ENROLLMENT_TEAM_ID, user_
|
||||
$index = 0;
|
||||
foreach ($lead_data as $key => $value) : ?>
|
||||
<?php
|
||||
if ($key == "total" || $key == "won" || substr($key, -4) === "_ids") {
|
||||
if ($key == "total" || substr($key, -4) === "_ids") {
|
||||
continue;
|
||||
} // Skip the total key
|
||||
}
|
||||
// if ($key == "total" || $key == "won" || substr($key, -4) === "_ids") {
|
||||
// continue;
|
||||
// }
|
||||
// Skip the total key
|
||||
?>
|
||||
<?php
|
||||
// Initialize color set and shade indexes
|
||||
|
||||
Loading…
Reference in New Issue
Block a user