MERGE_TEST_BUG_FIXES

This commit is contained in:
Ubuntu 2026-07-06 16:03:55 +05:30
commit 55e2d41044
5 changed files with 35 additions and 14 deletions

View File

@ -1037,7 +1037,7 @@ class ClientController extends AdminController
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
$editData['client_branch']['role'] = get_role_id();
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList(null, $id, 'update');
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList([1,3,2], $id, 'update');
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
foreach ($clientPoliceData as $key => $value) {

View File

@ -4539,6 +4539,14 @@ class LeadsController extends BaseController
return $this->respond(['status' => false, 'message' => 'Failed to create policy', 'data' => null], 200);
}
if (empty($client_id) && ! empty($data['client_id'])) {
$client_id = $data['client_id'];
}
if (empty($branch_id) && ! empty($data['client_branch_id'])) {
$branch_id = $data['client_branch_id'];
}
$result = $this->createClientPolicyWithLeadData($data, $client_id, $branch_id);
// print_r($result); die;

View File

@ -190,7 +190,7 @@ class LeadsModel extends Model
public function getLeadForInsertClientList($type = null, $client_id = null, $from = null)
{
$query = $this->db->table('leads')
->select('leads.*, user_profiles.first_name as user_name, policy_type.allocg')
->select('leads.*, user_profiles.first_name as user_name, policy_type.allocg, policy_type.policy_type as policy_type_name')
->join('user_profiles', 'leads.created_by = user_profiles.id')
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
->where('leads.is_active', 1)
@ -200,13 +200,24 @@ class LeadsModel extends Model
$query->where("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)");
if ($client_id) {
$query->join('clients', 'clients.id = ' . (int) $client_id)
->join('client_branch', 'client_branch.client_id = clients.id AND client_branch.is_active = 1')
->where('leads.client_name = clients.client_name', null, false)
->where('leads.client_short_name = clients.short_name', null, false)
->where('leads.branch_name = client_branch.branch_name', null, false)
->where('leads.branch_code = client_branch.branch_code', null, false)
->groupBy('leads.id');
$clientId = (int) $client_id;
$query->groupStart()
->where('leads.client_id', $clientId)
->orWhere(
"EXISTS (
SELECT 1
FROM clients c
INNER JOIN client_branch cb ON cb.client_id = c.id AND cb.is_active = 1
WHERE c.id = {$clientId}
AND leads.client_name = c.client_name
AND leads.client_short_name = c.short_name
AND leads.branch_name = cb.branch_name
AND leads.branch_code = cb.branch_code
)",
null,
false
)
->groupEnd();
}
} else {
$query->groupStart()
@ -214,14 +225,16 @@ class LeadsModel extends Model
->orWhere("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)")
->groupEnd();
if ($type) {
$query->whereIn('leads.lead_type', $type);
}
if ($client_id) {
$query->where('leads.client_id', $client_id);
}
}
if ($type) {
$query->whereIn('leads.lead_type', $type);
}
$query->groupStart()
->where("policy_type.allocg != 'EB'")
->orWhere("(policy_type.allocg = 'EB' AND leads.proposel_data IS NOT NULL AND leads.proposel_data <> '')")

View File

@ -244,7 +244,7 @@ table.dataTable thead th {
<option value="">Select Opportunity</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
<option value="<?= $value['id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['policy_type_name'] ?? 'N/A' ?> - <?= $value['user_name'] ?></option>
<?php } ?>
<?php } ?>
</select>

View File

@ -396,7 +396,7 @@ input:checked + .slider_blue::before {
<option value="">Select Opportunity</option>
<?php if(isset($lead_data)) { ?>
<?php foreach ($lead_data as $value) { ?>
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id']?>", data-branchid="<?= $value['client_branch_id']?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['user_name'] ?></option>
<option value="<?= $value['id']?>" data-clientid="<?= $value['client_id'] ?>" data-branchid="<?= $value['client_branch_id'] ?>"><?= $value['client_name'] ?> - <?= $value['branch_name'] ?> - <?= $value['policy_type_name'] ?? 'N/A' ?> - <?= $value['user_name'] ?></option>
<?php } ?>
<?php } ?>
</select>