FEAT_NONEB_GDRIVE_APPROACH
This commit is contained in:
parent
804d98aa8c
commit
171be333e8
@ -130,3 +130,6 @@ HEALTH_INDIA_USERNAME =
|
|||||||
HEALTH_INDIA_PASSWORD =
|
HEALTH_INDIA_PASSWORD =
|
||||||
|
|
||||||
HEALTH_INDIA_PRIMARY_KEY_CONSTANT =
|
HEALTH_INDIA_PRIMARY_KEY_CONSTANT =
|
||||||
|
|
||||||
|
LEAD_INSURER_FROM_MAIL_ID =
|
||||||
|
LEAD_CLIENT_FROM_MAIL_ID =
|
||||||
51
app/Config/RfqConfig.php
Normal file
51
app/Config/RfqConfig.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
namespace Config;
|
||||||
|
|
||||||
|
use CodeIgniter\Config\BaseConfig;
|
||||||
|
|
||||||
|
class RfqConfig extends BaseConfig
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Google Drive parent folder IDs for RFQ and QCR sheets.
|
||||||
|
*/
|
||||||
|
public string $rfqParentFolderId = '1MnYh5PTPDlc9mYMGsjmTv02y8EZ-BQf1';
|
||||||
|
public string $qcrParentFolderId = '1MnYh5PTPDlc9mYMGsjmTv02y8EZ-BQf1';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default permissions for created sheets.
|
||||||
|
* Copied from GoogleSheetController::$config.
|
||||||
|
*/
|
||||||
|
public array $permissions = [
|
||||||
|
'editors' => [
|
||||||
|
'vitvelz@gmail.com',
|
||||||
|
'velz1990@gmail.com',
|
||||||
|
'venkateshraman786@gmail.com',
|
||||||
|
],
|
||||||
|
'viewers' => [],
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default protections for RFQ sheets.
|
||||||
|
* Copied from GoogleSheetController::$config.
|
||||||
|
*/
|
||||||
|
public array $protections = [
|
||||||
|
[
|
||||||
|
'range' => 'RFQ Page!B12:C12',
|
||||||
|
'users' => [
|
||||||
|
'velz1990@gmail.com',
|
||||||
|
'vitvelz@gmail.com',
|
||||||
|
'firebase-adminsdk-mcdfe@nhance-ee8d1.iam.gserviceaccount.com',
|
||||||
|
],
|
||||||
|
'groups' => [],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'range' => 'Claims Page!A1',
|
||||||
|
'users' => [
|
||||||
|
'velz1990@gmail.com',
|
||||||
|
'venkateshraman786@gmail.com',
|
||||||
|
'firebase-adminsdk-mcdfe@nhance-ee8d1.iam.gserviceaccount.com',
|
||||||
|
],
|
||||||
|
'groups' => [],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
@ -503,6 +503,8 @@ $routes->group("leads", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->match(['get', 'post'],"list", "LeadsController::viewLeadsList");
|
$routes->match(['get', 'post'],"list", "LeadsController::viewLeadsList");
|
||||||
$routes->post("create", "LeadsController::createLead");
|
$routes->post("create", "LeadsController::createLead");
|
||||||
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
|
$routes->get("list/(:any)", "LeadsController::getLeadDataForEdit/$1");
|
||||||
|
$routes->get("createRfqSheet", "LeadsController::createRfqSheet");
|
||||||
|
$routes->get("mailTemplate", "LeadsController::getLeadMailTemplate");
|
||||||
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
|
$routes->get("sendMail", "LeadsController::sendMailWithAttachement");
|
||||||
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
|
$routes->post("sendMail", "LeadsController::sendMailWithAttachement");
|
||||||
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
$routes->get("exportQCRandRFQ/(:any)", "LeadsController::exportQCRandRFQ/$1");
|
||||||
@ -516,6 +518,10 @@ $routes->group("rfq", ["filter" => "authMVC"], function ($routes) {
|
|||||||
$routes->post("createQCR", "LeadsController::createQCR");
|
$routes->post("createQCR", "LeadsController::createQCR");
|
||||||
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
$routes->get("list/(:any)", "LeadsController::viewRFQ/$1");
|
||||||
$routes->get("nonEB","LeadsController::rfqNonEB");
|
$routes->get("nonEB","LeadsController::rfqNonEB");
|
||||||
|
// Non-EB dedicated RFQ/QCR endpoints (do not alter existing ones)
|
||||||
|
$routes->get("nonEB/rfq/(:any)","LeadsController::viewNonEbRFQFromList/$1");
|
||||||
|
$routes->get("nonEB/qcr/(:any)","LeadsController::viewNonEbQCRFromList/$1");
|
||||||
|
$routes->get("placementData/(:num)", "LeadsController::getPlacementData/$1");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,11 @@
|
|||||||
<?php namespace App\Libraries;
|
<?php
|
||||||
|
namespace App\Libraries;
|
||||||
|
|
||||||
use Google_Client;
|
use Google_Client;
|
||||||
use Google_Service_Sheets;
|
|
||||||
use Google_Service_Drive;
|
use Google_Service_Drive;
|
||||||
use Google_Service_Sheets_ValueRange;
|
use Google_Service_Sheets;
|
||||||
use Google_Service_Sheets_BatchUpdateSpreadsheetRequest;
|
use Google_Service_Sheets_BatchUpdateSpreadsheetRequest;
|
||||||
|
use Google_Service_Sheets_ValueRange;
|
||||||
|
|
||||||
class GoogleSheetLib
|
class GoogleSheetLib
|
||||||
{
|
{
|
||||||
@ -12,7 +13,6 @@ class GoogleSheetLib
|
|||||||
protected Google_Service_Sheets $sheets;
|
protected Google_Service_Sheets $sheets;
|
||||||
protected Google_Service_Drive $drive;
|
protected Google_Service_Drive $drive;
|
||||||
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->client = new Google_Client();
|
$this->client = new Google_Client();
|
||||||
@ -28,7 +28,7 @@ class GoogleSheetLib
|
|||||||
// Required scopes
|
// Required scopes
|
||||||
$this->client->addScope([
|
$this->client->addScope([
|
||||||
Google_Service_Drive::DRIVE,
|
Google_Service_Drive::DRIVE,
|
||||||
Google_Service_Sheets::SPREADSHEETS
|
Google_Service_Sheets::SPREADSHEETS,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Init services
|
// Init services
|
||||||
@ -53,7 +53,7 @@ class GoogleSheetLib
|
|||||||
public function write(string $spreadsheetId, array $values, string $range = 'Sheet1')
|
public function write(string $spreadsheetId, array $values, string $range = 'Sheet1')
|
||||||
{
|
{
|
||||||
$body = new Google_Service_Sheets_ValueRange([
|
$body = new Google_Service_Sheets_ValueRange([
|
||||||
'values' => $values
|
'values' => $values,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->sheets
|
$this->sheets
|
||||||
@ -81,7 +81,6 @@ class GoogleSheetLib
|
|||||||
return $response->getBody()->getContents();
|
return $response->getBody()->getContents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ================= COPY TEMPLATE ================= */
|
/* ================= COPY TEMPLATE ================= */
|
||||||
|
|
||||||
public function copyTemplate(string $templateId, string $name, string $folderId): string
|
public function copyTemplate(string $templateId, string $name, string $folderId): string
|
||||||
@ -92,9 +91,9 @@ class GoogleSheetLib
|
|||||||
'name' => $name,
|
'name' => $name,
|
||||||
'parents' => [$folderId],
|
'parents' => [$folderId],
|
||||||
|
|
||||||
]),[
|
]), [
|
||||||
'supportsAllDrives' => true,
|
'supportsAllDrives' => true,
|
||||||
'fields' => 'id, name, parents'
|
'fields' => 'id, name, parents',
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -124,9 +123,9 @@ class GoogleSheetLib
|
|||||||
new \Google_Service_Drive_Permission([
|
new \Google_Service_Drive_Permission([
|
||||||
'type' => $type,
|
'type' => $type,
|
||||||
'role' => $role,
|
'role' => $role,
|
||||||
'emailAddress' => $email
|
'emailAddress' => $email,
|
||||||
]),
|
]),
|
||||||
['sendNotificationEmail' => false,'supportsAllDrives' => true]
|
['sendNotificationEmail' => false, 'supportsAllDrives' => true]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,25 +145,24 @@ class GoogleSheetLib
|
|||||||
'addProtectedRange' => [
|
'addProtectedRange' => [
|
||||||
'protectedRange' => [
|
'protectedRange' => [
|
||||||
'range' => [
|
'range' => [
|
||||||
'sheetId' => $sheetId
|
'sheetId' => $sheetId,
|
||||||
|
],
|
||||||
|
'warningOnly' => false,
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'warningOnly' => false
|
|
||||||
]
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->sheets->spreadsheets->batchUpdate(
|
$this->sheets->spreadsheets->batchUpdate(
|
||||||
$spreadsheetId,
|
$spreadsheetId,
|
||||||
new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
new Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
||||||
'requests' => $requests
|
'requests' => $requests,
|
||||||
])
|
])
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function applyProtections(string $spreadsheetId, array $protections)
|
public function applyProtections(string $spreadsheetId, array $protections)
|
||||||
{
|
{
|
||||||
// Fetch spreadsheet metadata
|
// Fetch spreadsheet metadata
|
||||||
$spreadsheet = $this->sheets->spreadsheets->get(
|
$spreadsheet = $this->sheets->spreadsheets->get(
|
||||||
$spreadsheetId,
|
$spreadsheetId,
|
||||||
@ -188,13 +186,13 @@ class GoogleSheetLib
|
|||||||
|
|
||||||
$rangeStr = $protection['range'];
|
$rangeStr = $protection['range'];
|
||||||
|
|
||||||
if (!str_contains($rangeStr, '!')) {
|
if (! str_contains($rangeStr, '!')) {
|
||||||
throw new \Exception("Invalid range format: {$rangeStr}");
|
throw new \Exception("Invalid range format: {$rangeStr}");
|
||||||
}
|
}
|
||||||
|
|
||||||
[$sheetName, $a1] = explode('!', $rangeStr, 2);
|
[$sheetName, $a1] = explode('!', $rangeStr, 2);
|
||||||
|
|
||||||
if (!isset($sheetMap[$sheetName])) {
|
if (! isset($sheetMap[$sheetName])) {
|
||||||
throw new \Exception("Sheet not found: {$sheetName}");
|
throw new \Exception("Sheet not found: {$sheetName}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,27 +211,27 @@ class GoogleSheetLib
|
|||||||
'warningOnly' => false,
|
'warningOnly' => false,
|
||||||
'editors' => [
|
'editors' => [
|
||||||
'users' => $protection['users'] ?? [],
|
'users' => $protection['users'] ?? [],
|
||||||
'groups' => $protection['groups'] ?? []
|
'groups' => $protection['groups'] ?? [],
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
$requests[] = [
|
$requests[] = [
|
||||||
'addProtectedRange' => [
|
'addProtectedRange' => [
|
||||||
'protectedRange' => $protectedRange
|
'protectedRange' => $protectedRange,
|
||||||
]
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($requests)) {
|
if (! empty($requests)) {
|
||||||
$batch = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
$batch = new \Google_Service_Sheets_BatchUpdateSpreadsheetRequest([
|
||||||
'requests' => $requests
|
'requests' => $requests,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->sheets->spreadsheets->batchUpdate($spreadsheetId, $batch);
|
$this->sheets->spreadsheets->batchUpdate($spreadsheetId, $batch);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ================= URL ================= */
|
/* ================= URL ================= */
|
||||||
|
|
||||||
@ -242,15 +240,14 @@ class GoogleSheetLib
|
|||||||
return "https://docs.google.com/spreadsheets/d/{$sheetId}/edit";
|
return "https://docs.google.com/spreadsheets/d/{$sheetId}/edit";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function convertA1ToGridRange($a1, $sheetId, $maxRows, $maxCols)
|
private function convertA1ToGridRange($a1, $sheetId, $maxRows, $maxCols)
|
||||||
{
|
{
|
||||||
if (preg_match('/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/i', $a1, $m)) {
|
if (preg_match('/^([A-Z]+)(\d+)(?::([A-Z]+)(\d+))?$/i', $a1, $m)) {
|
||||||
|
|
||||||
$startCol = $this->colToIndex($m[1]);
|
$startCol = $this->colToIndex($m[1]);
|
||||||
$startRow = intval($m[2]) - 1;
|
$startRow = intval($m[2]) - 1;
|
||||||
|
|
||||||
if (!empty($m[3])) {
|
if (! empty($m[3])) {
|
||||||
$endCol = $this->colToIndex($m[3]) + 1;
|
$endCol = $this->colToIndex($m[3]) + 1;
|
||||||
$endRow = intval($m[4]);
|
$endRow = intval($m[4]);
|
||||||
} else {
|
} else {
|
||||||
@ -263,22 +260,21 @@ class GoogleSheetLib
|
|||||||
'startRowIndex' => $startRow,
|
'startRowIndex' => $startRow,
|
||||||
'endRowIndex' => $endRow,
|
'endRowIndex' => $endRow,
|
||||||
'startColumnIndex' => $startCol,
|
'startColumnIndex' => $startCol,
|
||||||
'endColumnIndex' => $endCol
|
'endColumnIndex' => $endCol,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \Exception("Unsupported A1 format: {$a1}");
|
throw new \Exception("Unsupported A1 format: {$a1}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function colToIndex($letters)
|
private function colToIndex($letters)
|
||||||
{
|
{
|
||||||
$letters = strtoupper($letters);
|
$letters = strtoupper($letters);
|
||||||
$index = 0;
|
$index = 0;
|
||||||
for ($i = 0; $i < strlen($letters); $i++) {
|
for ($i = 0; $i < strlen($letters); $i++) {
|
||||||
$index = $index * 26 + (ord($letters[$i]) - 64);
|
$index = $index * 26 + (ord($letters[$i]) - 64);
|
||||||
}
|
}
|
||||||
return $index - 1;
|
return $index - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
@ -108,10 +107,9 @@ class LeadsModel extends Model
|
|||||||
'quote_received_insurer',
|
'quote_received_insurer',
|
||||||
'acm_id',
|
'acm_id',
|
||||||
'policy_with_correction',
|
'policy_with_correction',
|
||||||
'agreed_percentage',
|
'agreed_percentage', 'misc',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
// Callbacks
|
// Callbacks
|
||||||
protected $allowCallbacks = true;
|
protected $allowCallbacks = true;
|
||||||
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
protected $beforeInsert = ["checkAndADDCreatedByValue"];
|
||||||
@ -176,7 +174,7 @@ class LeadsModel extends Model
|
|||||||
->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left')
|
->join('lead_files', 'leads.id = lead_files.lead_id AND lead_files.type = 2 AND lead_files.is_active = 1', 'left')
|
||||||
->where('leads.is_active', 1);
|
->where('leads.is_active', 1);
|
||||||
|
|
||||||
if (!empty($where)) {
|
if (! empty($where)) {
|
||||||
$data->where($where);
|
$data->where($where);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,8 +192,6 @@ class LeadsModel extends Model
|
|||||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
||||||
->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
|
->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$query->where('leads.lead_type', $type);
|
$query->where('leads.lead_type', $type);
|
||||||
}
|
}
|
||||||
@ -291,12 +287,10 @@ class LeadsModel extends Model
|
|||||||
// $lead_data[0]['total'] = $total;
|
// $lead_data[0]['total'] = $total;
|
||||||
// $lead_data[0]['policy_with_correction'] = $policy_with_correction_count;
|
// $lead_data[0]['policy_with_correction'] = $policy_with_correction_count;
|
||||||
|
|
||||||
|
|
||||||
// // dd($lead_data[0]);
|
// // dd($lead_data[0]);
|
||||||
// return $lead_data[0];
|
// return $lead_data[0];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
public function getDashData()
|
public function getDashData()
|
||||||
{
|
{
|
||||||
// Get all unique statuses
|
// Get all unique statuses
|
||||||
@ -339,7 +333,7 @@ class LeadsModel extends Model
|
|||||||
// Calculate total
|
// Calculate total
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($lead_data as $key => $val) {
|
foreach ($lead_data as $key => $val) {
|
||||||
if (!str_ends_with($key, '_ids')) {
|
if (! str_ends_with($key, '_ids')) {
|
||||||
$total += (int) $val;
|
$total += (int) $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,6 +346,4 @@ class LeadsModel extends Model
|
|||||||
return $lead_data;
|
return $lead_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use CodeIgniter\Model;
|
use CodeIgniter\Model;
|
||||||
@ -22,6 +21,6 @@ class PolicyTypeModel extends Model
|
|||||||
"etp",
|
"etp",
|
||||||
"iep",
|
"iep",
|
||||||
"itp",
|
"itp",
|
||||||
"question_json",'itep','etep', 'policy_category',
|
"question_json", 'itep', 'etep', 'policy_category', 'misc',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user