FEAT_NONEB_GDRIVE_APPROACH

This commit is contained in:
velz 2026-03-06 11:17:17 +05:30
parent 804d98aa8c
commit 171be333e8
8 changed files with 3533 additions and 1547 deletions

View File

@ -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
View 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' => [],
],
];
}

View File

@ -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

View File

@ -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
@ -94,7 +93,7 @@ class GoogleSheetLib
]), [ ]), [
'supportsAllDrives' => true, 'supportsAllDrives' => true,
'fields' => 'id, name, parents' 'fields' => 'id, name, parents',
] ]
); );
@ -124,7 +123,7 @@ 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,23 +145,22 @@ 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
@ -213,20 +211,20 @@ 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);
@ -242,7 +240,6 @@ 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)) {
@ -263,7 +260,7 @@ class GoogleSheetLib
'startRowIndex' => $startRow, 'startRowIndex' => $startRow,
'endRowIndex' => $endRow, 'endRowIndex' => $endRow,
'startColumnIndex' => $startCol, 'startColumnIndex' => $startCol,
'endColumnIndex' => $endCol 'endColumnIndex' => $endCol,
]; ];
} }
@ -280,5 +277,4 @@ private function colToIndex($letters)
return $index - 1; return $index - 1;
} }
} }

View File

@ -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"];
@ -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
@ -352,6 +346,4 @@ class LeadsModel extends Model
return $lead_data; return $lead_data;
} }
} }

View File

@ -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