FIX_LOG_ISSUE
This commit is contained in:
parent
2ac40373b1
commit
3ac38fc5dc
@ -2406,6 +2406,36 @@ class EmployeeRestController extends AdminController
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
private function hasValidClientLogo(?string $logo): bool
|
||||||
|
{
|
||||||
|
if ($logo === null || trim($logo) === '') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path = parse_url(trim($logo), PHP_URL_PATH) ?? trim($logo);
|
||||||
|
$filename = basename(rtrim($path, '/'));
|
||||||
|
|
||||||
|
return $filename !== '' && strcasecmp($filename, 'logo') !== 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPreClientLogoUrl($preClientId): string
|
||||||
|
{
|
||||||
|
if (is_string($preClientId) && preg_match('/^[a-f0-9]{32}$/i', $preClientId)) {
|
||||||
|
$preClient = $this->clientModel->where('MD5(id)', $preClientId)->first();
|
||||||
|
} else {
|
||||||
|
$preClient = $this->clientModel->where('id', $preClientId)->first();
|
||||||
|
}
|
||||||
|
|
||||||
|
$logoFilename = $preClient['client_logo'] ?? '';
|
||||||
|
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
|
||||||
|
|
||||||
|
if (!empty($logoFilename) && file_exists($logoPath)) {
|
||||||
|
return base_url() . 'public/uploads/logo/' . $logoFilename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
public function getClientDetails()
|
public function getClientDetails()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -2430,18 +2460,8 @@ class EmployeeRestController extends AdminController
|
|||||||
&& !empty($postData['data']['client'])
|
&& !empty($postData['data']['client'])
|
||||||
) {
|
) {
|
||||||
$postLogo = $postData['data']['client']['client_logo'] ?? '';
|
$postLogo = $postData['data']['client']['client_logo'] ?? '';
|
||||||
if (empty($postLogo)) {
|
if (!$this->hasValidClientLogo($postLogo)) {
|
||||||
if (is_string($pre_client_id) && preg_match('/^[a-f0-9]{32}$/i', $pre_client_id)) {
|
$postData['data']['client']['client_logo'] = $this->getPreClientLogoUrl($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($postData, 200);
|
||||||
@ -2458,11 +2478,7 @@ class EmployeeRestController extends AdminController
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($client) {
|
if ($client) {
|
||||||
$logoFilename = $client['client_logo'] ?? '';
|
$client['client_logo'] = $this->getPreClientLogoUrl($pre_client_id);
|
||||||
$logoPath = ROOTPATH . 'public/uploads/logo/' . $logoFilename;
|
|
||||||
$client['client_logo'] = (!empty($logoFilename) && file_exists($logoPath))
|
|
||||||
? base_url() . 'public/uploads/logo/' . $logoFilename
|
|
||||||
: '';
|
|
||||||
|
|
||||||
$clientPolicy = $this->clientPolicyModel
|
$clientPolicy = $this->clientPolicyModel
|
||||||
->where('client_id', $client['id'] ?? null)
|
->where('client_id', $client['id'] ?? null)
|
||||||
@ -2488,7 +2504,19 @@ class EmployeeRestController extends AdminController
|
|||||||
'client_id' => $post_client_id,
|
'client_id' => $post_client_id,
|
||||||
'client_branch_id' => $post_branch_id
|
'client_branch_id' => $post_branch_id
|
||||||
];
|
];
|
||||||
return $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
|
$postResponse = $restAuthController->callThirdPartyGETAPI($queryParams, 'getClientDetails');
|
||||||
|
$postData = is_string($postResponse) ? json_decode($postResponse, true) : null;
|
||||||
|
|
||||||
|
if (
|
||||||
|
is_array($postData)
|
||||||
|
&& !empty($postData['data']['client'])
|
||||||
|
&& !$this->hasValidClientLogo($postData['data']['client']['client_logo'] ?? '')
|
||||||
|
) {
|
||||||
|
$postData['data']['client']['client_logo'] = '';
|
||||||
|
return $this->respond($postData, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $postResponse;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
return $this->respond(['status' => 'failed', 'code' => 404, 'data' => []], 200);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user