diff --git a/app/Controllers/LeadsController.php b/app/Controllers/LeadsController.php index 9384b60d..b046ee78 100644 --- a/app/Controllers/LeadsController.php +++ b/app/Controllers/LeadsController.php @@ -454,19 +454,44 @@ class LeadsController extends BaseController 'errors' => ['required' => 'Entity Type is required'], ]; + $clientNameRules = 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]'; + $clientShortNameRules = 'required|regex_match[/^[a-zA-Z0-9_-]+$/]'; + + // Only validate for uniqueness if it's a new client being specified. + // If an existing client is selected from the dropdown, `client_id` will be present. + if (empty($postData['client_id'])) { + $ignoreClientId = null; + if ($id) { // This is an update of a lead + $lead = $this->leadsModel->find($id); + if ($lead && !empty($lead['is_client_created'])) { + $ignoreClientId = $lead['is_client_created']; + } + } + + if ($ignoreClientId) { + $clientNameRules .= '|is_unique[clients.client_name,id,' . $ignoreClientId . ']'; + $clientShortNameRules .= '|is_unique[clients.short_name,id,' . $ignoreClientId . ']'; + } else { + $clientNameRules .= '|is_unique[clients.client_name]'; + $clientShortNameRules .= '|is_unique[clients.short_name]'; + } + } + $rules['client_name'] = [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9_ -]+$/]', + 'rules' => $clientNameRules, 'errors' => [ 'required' => 'Client Name is required', 'regex_match' => 'Client Name only letters, numbers, space, hyphens and underscores are allowed', + 'is_unique' => 'This Client Name already exists.', ], ]; $rules['client_short_name'] = [ - 'rules' => 'required|regex_match[/^[a-zA-Z0-9_-]+$/]', + 'rules' => $clientShortNameRules, 'errors' => [ - 'required' => 'Client Short Name is required', - 'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed' + 'required' => 'Client Short Name is required', + 'regex_match' => 'Client Short Name only letters, numbers, hyphens and underscores are allowed', + 'is_unique' => 'This Client Short Name already exists.', ], ]; } @@ -925,6 +950,11 @@ 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); + } + if ($value['lead_form_type'] == 1) { //for this push the job to the calculateMembersDemography() function $job_details = new Jobs(); @@ -950,6 +980,14 @@ class LeadsController extends BaseController $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') { + $leadDataForClient = $this->leadsModel->find($id); + if (empty($leadDataForClient['is_client_created'])) { + $this->createClientWithLeadData($leadDataForClient); + } + } + return $this->respond(['status' => true, 'lead_id' => $id, 'message' => "Opportunity updated successfully", 'data' => $data], 200); } return $this->respond(['status' => false, 'lead_id' => $id, 'message' => "Failed to update Opportunity", 'data' => $data], 200); diff --git a/app/Views/UserList.php b/app/Views/UserList.php index 3e927271..0adae2ad 100755 --- a/app/Views/UserList.php +++ b/app/Views/UserList.php @@ -78,13 +78,8 @@ table.dataTable tbody td { float: left !important; } - .table th, - .table td { - padding: 8px; - } - - table.dataTable tbody td { - padding: 4px 4px !important; + .col-12 { + max-width: 98% !important; } /* Tooltip Styles */ @@ -247,9 +242,12 @@ table.dataTable tbody td { border:1px solid rgba(41, 139, 142, 1); } - .dt-buttons.btn-group{ - display: grid; - grid-template-columns: 1fr .4fr .5fr .2fr; + .dt-buttons.btn-group{ + width: 100%; + display: flex; + align-items: center; + justify-content: flex-end; + gap: 8px; } #user-table_filter input{ width:100%; } @@ -361,15 +359,15 @@ table.dataTable tbody td {

Users

--> - +
- - - - - - + + + + + + @@ -384,8 +382,8 @@ table.dataTable tbody td { is_active == 1){ echo 'Active'; }else{ echo 'In-Active'; } ?> -
NameEmailMobile NoRoleStatusActionName Email Mobile No Role Status Action 
- +