FEAT_RFQ_NONEB_COMPLETE
This commit is contained in:
parent
761f5cc9bb
commit
33d0476728
@ -628,12 +628,11 @@ class LeadsController extends BaseController
|
|||||||
|
|
||||||
public function createRFQ()
|
public function createRFQ()
|
||||||
{
|
{
|
||||||
|
|
||||||
// print_r($this->request->getPost('json')); die();
|
|
||||||
|
|
||||||
$data = $this->request->getPost();
|
$data = $this->request->getPost();
|
||||||
$lead_id = $data['lead_id'];
|
$lead_id = $data['lead_id'];
|
||||||
$data['type'] = 1;
|
$data['type'] = 1;
|
||||||
|
|
||||||
|
// Deactivate previous RFQs
|
||||||
$this->RFQModel
|
$this->RFQModel
|
||||||
->where('lead_id', $lead_id)
|
->where('lead_id', $lead_id)
|
||||||
->where('type', 1)
|
->where('type', 1)
|
||||||
@ -641,43 +640,34 @@ class LeadsController extends BaseController
|
|||||||
->set('is_active', 0)
|
->set('is_active', 0)
|
||||||
->update();
|
->update();
|
||||||
|
|
||||||
$registrationJson = $data['registration_json'] ?? null; // Use null coalescing operator for safety
|
$registrationJson = $data['registration_json'] ?? null;
|
||||||
|
|
||||||
|
if (!$registrationJson) {
|
||||||
|
// Fetch latest registration_json from database
|
||||||
|
$registrationJson = $this->RFQModel->select('registration_json')
|
||||||
|
->where("lead_id", $lead_id)
|
||||||
|
->orderBy('id', 'DESC')
|
||||||
|
->limit(1)
|
||||||
|
->get()
|
||||||
|
->getRow('registration_json');
|
||||||
|
}
|
||||||
|
|
||||||
if ($registrationJson) {
|
if ($registrationJson) {
|
||||||
// If registration_json is provided, insert the data directly
|
$data['registration_json'] = $registrationJson;
|
||||||
$result = $this->RFQModel->insert($data);
|
|
||||||
} else {
|
|
||||||
// If registration_json is not provided, fetch the latest registration_json from the database
|
|
||||||
$this->RFQModel->select('registration_json')
|
|
||||||
->where("lead_id", $lead_id)
|
|
||||||
->order_by('id', 'DESC') // Assuming 'id' is an auto-increment field
|
|
||||||
->limit(1);
|
|
||||||
|
|
||||||
$query = $this->RFQModel->get();
|
|
||||||
$latestRegistrationJson = $query->row()->registration_json ?? null;
|
|
||||||
|
|
||||||
if ($latestRegistrationJson) {
|
|
||||||
// If a valid registration_json is found, update the data and insert
|
|
||||||
$data['registration_json'] = $latestRegistrationJson;
|
|
||||||
$result = $this->RFQModel->insert($data);
|
|
||||||
} else {
|
|
||||||
// If no registration_json is found, insert the data as-is
|
|
||||||
$result = $this->RFQModel->insert($data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert new RFQ
|
||||||
|
$result = $this->RFQModel->insert($data);
|
||||||
|
|
||||||
if ($result) {
|
if ($result) {
|
||||||
|
$message = ($data['submit_type'] == 'QCR') ? "QCR submitted successfully" : "RFQ submitted successfully";
|
||||||
$message = "RFQ submitted successfully";
|
|
||||||
if ($data['submit_type'] == 'QCR') {
|
|
||||||
$message = "QCR submitted successfully";
|
|
||||||
}
|
|
||||||
return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200);
|
return $this->respond(['status' => true, 'id' => $result, 'message' => $message, 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => false, 'id' => $result, 'message' => "Failed to create RFQ", 'data' => $data], 200);
|
return $this->respond(['status' => false, 'message' => "Failed to create RFQ", 'data' => $data], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function createQCR()
|
public function createQCR()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -3132,5 +3122,4 @@ class LeadsController extends BaseController
|
|||||||
// kint::dump($data);
|
// kint::dump($data);
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1128,7 +1128,11 @@
|
|||||||
prependTable(policySummary[key],key);
|
prependTable(policySummary[key],key);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
$('.loader').fadeIn();
|
||||||
|
$('.loader-mask').fadeIn();
|
||||||
toastr.success("Policy Information Collected ","SUCCESS");
|
toastr.success("Policy Information Collected ","SUCCESS");
|
||||||
|
$('.loader').fadeOut();
|
||||||
|
$('.loader-mask').delay(350).fadeOut('slow');
|
||||||
console.log("Updated policy data in localStorage:", existingData);
|
console.log("Updated policy data in localStorage:", existingData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user