FIX_MULTIPLE_POLICY_CREATE_IN_THE_LEAD_NEED_TO_LIST_IN_THE_DROPDOWN
This commit is contained in:
parent
00b1afd8fb
commit
f72bbfe799
@ -1037,7 +1037,7 @@ class ClientController extends AdminController
|
|||||||
$editData['client_branch'] = $this->clientBranchModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
$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_relation'] = $this->clientRMModel->where(['client_id' => $id, 'is_active' => 1])->findAll();
|
||||||
$editData['client_branch']['role'] = get_role_id();
|
$editData['client_branch']['role'] = get_role_id();
|
||||||
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList([2], $id);
|
$editData['lead_data'] = $this->leadsModel->getLeadForInsertClientList(null, $id, 'update');
|
||||||
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
|
$clientPoliceData = $this->clientPolicyModel->getClientPolicyByClientId($id);
|
||||||
|
|
||||||
foreach ($clientPoliceData as $key => $value) {
|
foreach ($clientPoliceData as $key => $value) {
|
||||||
|
|||||||
@ -187,30 +187,46 @@ class LeadsModel extends Model
|
|||||||
return $data->orderBy('leads.id', 'desc')->findAll();
|
return $data->orderBy('leads.id', 'desc')->findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getLeadForInsertClientList($type = null, $client_id = null)
|
public function getLeadForInsertClientList($type = null, $client_id = null, $from = null)
|
||||||
{
|
{
|
||||||
$query = $this->db->table('leads')
|
$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')
|
||||||
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
->join('user_profiles', 'leads.created_by = user_profiles.id')
|
||||||
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
->join('policy_type', 'leads.policy_type_id = policy_type.id', 'left')
|
||||||
->where('leads.is_active', 1)
|
->where('leads.is_active', 1)
|
||||||
->where('leads.status', 'won')
|
->where('leads.status', 'won');
|
||||||
->groupStart()
|
|
||||||
|
if ($from === 'update') {
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$query->groupStart()
|
||||||
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
->where("(leads.is_client_created = '' OR leads.is_client_created IS NULL)")
|
||||||
->orWhere("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)")
|
->orWhere("(leads.is_policy_created = '' OR leads.is_policy_created IS NULL)")
|
||||||
->groupEnd()
|
|
||||||
->groupStart()
|
|
||||||
->where("policy_type.allocg != 'EB'")
|
|
||||||
->orWhere("(policy_type.allocg = 'EB' AND leads.proposel_data IS NOT NULL AND leads.proposel_data <> '')")
|
|
||||||
->groupEnd();
|
->groupEnd();
|
||||||
|
|
||||||
if ($type) {
|
if ($type) {
|
||||||
$query->whereIn('leads.lead_type', $type);
|
$query->whereIn('leads.lead_type', $type);
|
||||||
}
|
}
|
||||||
if ($client_id) {
|
if ($client_id) {
|
||||||
$query->where('leads.client_id', $client_id);
|
$query->where('leads.client_id', $client_id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$query->groupStart()
|
||||||
|
->where("policy_type.allocg != 'EB'")
|
||||||
|
->orWhere("(policy_type.allocg = 'EB' AND leads.proposel_data IS NOT NULL AND leads.proposel_data <> '')")
|
||||||
|
->groupEnd();
|
||||||
|
|
||||||
$result = $query->get()->getResultArray();
|
$result = $query->get()->getResultArray();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user