FIX_CLIENT_LOG

This commit is contained in:
VENKATESHWARAN 2026-08-06 11:31:53 +05:30
parent 7dbdf444a0
commit c1a5418ff2

View File

@ -2406,28 +2406,62 @@ class EmployeeRestController extends AdminController
$pre_branch_id = $this->request->getGet('pre_branch_id');
$post_client_id = $this->request->getGet('post_client_id');
$post_branch_id = $this->request->getGet('post_branch_id');
// Both pre and post: prefer post data; fall back to pre logo if post has none
if (!empty($pre_client_id) && !empty($post_client_id)) {
$restAuthController = new RestAuthenticationController;
$queryParams = [
'client_id' => $post_client_id,
'client_branch_id' => $post_branch_id
];
$postResponse = $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
$postData = is_string($postResponse) ? json_decode($postResponse, true) : null;
if (
is_array($postData)
&& (($postData['status'] ?? '') === 'success' || (int) ($postData['code'] ?? 0) === 200)
&& !empty($postData['data']['client'])
) {
$postLogo = $postData['data']['client']['client_logo'] ?? '';
if (empty($postLogo)) {
if (is_string($pre_client_id) && preg_match('/^[a-f0-9]{32}$/i', $pre_client_id)) {
$preClient = $this->clientModel->where('MD5(id)', $pre_client_id)->first();
} else {
$preClient = $this->clientModel->where('id', $pre_client_id)->first();
}
$logoFilename = $preClient['client_logo'] ?? '';
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
if (!empty($logoFilename) && file_exists($logoPath)) {
$postData['data']['client']['client_logo'] = base_url() . 'public/uploads/logo/' . $logoFilename;
}
}
return $this->respond($postData, 200);
}
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
if (!empty($pre_client_id)) {
if (is_string($pre_client_id) && preg_match('/^[a-f0-9]{32}$/i', $pre_client_id)) {
$client = $this->clientModel->where('MD5(id)', $pre_client_id)->first();
}else{
} else {
$client = $this->clientModel->where('id', $pre_client_id)->first();
}
}
if ($client) {
$client['client_logo'] = base_url() . 'public/uploads/logo/' . $client['client_logo'];
$logoFilename = $client['client_logo'] ?? '';
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
$client['client_logo'] = (!empty($logoFilename) && file_exists($logoPath))
? base_url() . 'public/uploads/logo/' . $logoFilename
: '';
$clientPolicy = $this->clientPolicyModel
->where('client_id', $client['id'] ?? null)
->where('client_branch_id', $pre_branch_id)
->findAll();
return $this->respond([
'status' => 'success',
'code' => 200,
@ -2436,27 +2470,22 @@ class EmployeeRestController extends AdminController
'client_policy' => $clientPolicy
]
], 200);
} else {
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
} elseif (!empty($post_client_id)) {
$restAuthController = new RestAuthenticationController;
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
if (!empty($post_client_id)) {
$restAuthController = new RestAuthenticationController;
$queryParams = [
'client_id' => $post_client_id,
'client_branch_id' => $post_branch_id
];
return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
} else {
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
}
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
} catch (\Exception $e) {
return $this->respond(['status' => 'failed', 'code' => 500, 'data' => $e->getMessage()], 500);
}
}