FIX_Bug
This commit is contained in:
parent
f19c1b9627
commit
a59e19d425
@ -659,8 +659,14 @@ class LeadsController extends BaseController
|
||||
$request_data = $this->request->getPost();
|
||||
$data = sanitizeInputArrayAdvanced($request_data);
|
||||
$data['client_type'] = 1;
|
||||
$actual_lead_id = $data['actual_lead_id'] ?? null; // adjust to however you get this
|
||||
|
||||
if ($data['lead_type'] != 1) {
|
||||
$isType1Flow = $data['lead_type'] == 1 || (!empty($actual_lead_id) && $actual_lead_id != 0 && $data['lead_type'] == 3);
|
||||
|
||||
|
||||
// if ($data['lead_type'] != 1)
|
||||
if (!$isType1Flow) {
|
||||
// lead_type != 1 (and not the special type-3 override) → fetch client data
|
||||
$client_data = $this->clientModel->where('id', $data['client_id'])->where('is_active', 1)->first();
|
||||
$data['client_name'] = $client_data['client_name'];
|
||||
$data['client_short_name'] = $client_data['short_name'];
|
||||
@ -760,7 +766,8 @@ class LeadsController extends BaseController
|
||||
$form_docs_name = "docs_name_" . $index_plus_one;
|
||||
$leads_file_primary_key = $data['leads_file_id'] ?? [];
|
||||
$files = $this->request->getFileMultiple($form_file_name);
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $data[$form_docs_name], $leads_file_primary_key);
|
||||
$docs_names_from_post = $data[$form_docs_name] ?? [];
|
||||
$multi_file_data = $this->uploadMultiFiles($files, $docs_names_from_post, $leads_file_primary_key);
|
||||
|
||||
// Separate the insurer and insurer branch, handle missing or invalid data
|
||||
if (isset($data['insurer'][$index]) && strpos($data['insurer'][$index], '-') !== false) {
|
||||
@ -950,10 +957,15 @@ class LeadsController extends BaseController
|
||||
$insertCount[] = $insert;
|
||||
$this->insertLeadStatus($insert, $value['status'], 3);
|
||||
|
||||
if ($value['lead_type'] == 1 && $value['status'] == 'won') {
|
||||
$leadDataForClient = $this->leadsModel->find($insert);
|
||||
$this->createClientWithLeadData($leadDataForClient);
|
||||
}
|
||||
$actual_lead_id = $value['actual_lead_id'] ?? null;
|
||||
|
||||
$isType1Flow = $value['lead_type'] == 1
|
||||
|| (! empty($actual_lead_id) && $actual_lead_id != 0 && $value['lead_type'] == 3);
|
||||
|
||||
if ($isType1Flow && $value['status'] == 'won') {
|
||||
$leadDataForClient = $this->leadsModel->find($insert);
|
||||
$this->createClientWithLeadData($leadDataForClient);
|
||||
}
|
||||
|
||||
if ($value['lead_form_type'] == 1) {
|
||||
//for this push the job to the calculateMembersDemography() function
|
||||
@ -978,10 +990,16 @@ class LeadsController extends BaseController
|
||||
{
|
||||
if ($this->leadsModel->where('id', $id)->set($data[0])->update()) {
|
||||
|
||||
// Define these FIRST before using them
|
||||
$actual_lead_id = $data[0]['actual_lead_id'] ?? null;
|
||||
|
||||
$isType1Flow = $data[0]['lead_type'] == 1
|
||||
|| (!empty($actual_lead_id) && $actual_lead_id != 0 && $data[0]['lead_type'] == 3);
|
||||
|
||||
$this->insertMultiFilesData($data[0]['multi_file_data'], $id, $data[0]['lead_form_type']);
|
||||
$this->insertLeadStatus($id, $data[0]['status'], 3);
|
||||
|
||||
if ($data[0]['lead_type'] == 1 && $data[0]['status'] == 'won') {
|
||||
if ($isType1Flow && $data[0]['status'] == 'won') {
|
||||
$leadDataForClient = $this->leadsModel->find($id);
|
||||
if (empty($leadDataForClient['is_client_created'])) {
|
||||
$this->createClientWithLeadData($leadDataForClient);
|
||||
@ -1079,7 +1097,7 @@ class LeadsController extends BaseController
|
||||
$file_name = file_Upload_for_lead($value, $uploadFilePath, UPLOAD_EXT_LEAD_FILES);
|
||||
$multi_file_data[] = [
|
||||
'file_name' => $file_name,
|
||||
'docs_name' => $docs_names[$index],
|
||||
'docs_name' => $docs_names[$index] ?? '',
|
||||
'id' => $primaryKey[$index] ?? "",
|
||||
];
|
||||
}
|
||||
|
||||
@ -189,7 +189,7 @@
|
||||
</a>
|
||||
<div class="dropdown-menu dropdown-menu-right">
|
||||
<?php $isNonEb = isset($row['lead_form_type']) && (int) $row['lead_form_type'] === 2; ?>
|
||||
<a class="dropdown-item btnEdit" data-id="<?php echo $row['id']; ?>" data-ft="<?php echo $row['lead_form_type']; ?>" onclick="getLeadsDataForEdit('<?php echo htmlspecialchars($row['id'], ENT_QUOTES) ?>', '<?php echo htmlspecialchars($row['lead_form_type'], ENT_QUOTES) ?>')">
|
||||
<a class="dropdown-item btnEdit" data-id="<?php echo $row['id']; ?>" data-ft="<?php echo $row['lead_form_type']; ?>" onclick="getLeadsDataForEdit('<?php echo htmlspecialchars($row['id'], ENT_QUOTES) ?>', '<?php echo htmlspecialchars($row['lead_form_type'], ENT_QUOTES) ?>', '<?php echo htmlspecialchars($row['actual_lead_id'] ?? 0, ENT_QUOTES) ?>')">
|
||||
<i class="mdi mdi-pencil mr-2 text-muted font-18 vertical-middle"></i>Edit
|
||||
</a>
|
||||
<?php if ($isNonEb) {?>
|
||||
@ -820,11 +820,12 @@
|
||||
|
||||
}
|
||||
|
||||
function getLeadsDataForEdit(lead_id, lead_form_type){
|
||||
function getLeadsDataForEdit(lead_id, lead_form_type, actual_lead_id = 0){
|
||||
|
||||
console.log('lead_id', lead_id);
|
||||
console.log('lead_form_type', lead_form_type);
|
||||
let actual_lead_id = 0; // Hardcoded to 0 since this is an edit operation
|
||||
console.log('actual_lead_id', actual_lead_id);
|
||||
// let actual_lead_id = 0; // Hardcoded to 0 since this is an edit operation
|
||||
//Here After Edit URL: /type / actual_lead_id (0) / lead_id
|
||||
let url = '<?php echo base_url('/util/getLeadNonEB/') ?>' + lead_form_type + '/' + actual_lead_id + '/' + lead_id;
|
||||
// old URL
|
||||
|
||||
@ -106,8 +106,8 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
|
||||
<div class="form-group col-md-4">
|
||||
<label for="lead_type">Opportunity Type<span class="text-danger">*</span></label>
|
||||
<select class="form-control" id="lead_type" name="lead_type" required>
|
||||
<option value="">Select Opportunity Type</option>
|
||||
<?php
|
||||
<option value="">Select Opportunity Type</option>
|
||||
<?php
|
||||
if (isset($lead_type) && count($lead_type)) {
|
||||
foreach ($lead_type as $key => $value) {
|
||||
if ($key == 1) {
|
||||
@ -1364,7 +1364,7 @@ var pageBackButton = '<a href="<?= base_url('leads/list') ?>" class="topbar-icon
|
||||
// // ── Short name EXISTS — just populate and validate ────────
|
||||
// $('#client_short_name').val(existingShortName);
|
||||
// // validateInput($('#client_short_name')[0], 'clients', 'short_name');
|
||||
|
||||
|
||||
// } else {}
|
||||
// Auto-generate short name from company name
|
||||
// Use a small delay to ensure DOM is ready
|
||||
|
||||
Loading…
Reference in New Issue
Block a user