104 lines
4.3 KiB
PHP
104 lines
4.3 KiB
PHP
<?php
|
|
|
|
namespace App\Helpers\Customer;
|
|
|
|
use App\Models\Customer\ClientModel;
|
|
|
|
class ClientHelper extends CustomerHelper
|
|
{
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->setTitleField(ClientModel::TITLE);
|
|
}
|
|
public function getFieldView(string $field, mixed $value, array $viewDatas, array $extras = []): string|null
|
|
{
|
|
switch ($field) {
|
|
case 'name':
|
|
$value = "<a href=\"/admin/customer/client/detail/{$viewDatas['entity']->getPK()}\">" . $value . "</a>";
|
|
break;
|
|
case "email":
|
|
case "phone":
|
|
$value = $this->getMyAuth()->isAccessRole(['security']) ? parent::getFieldView($field, $value, $viewDatas, $extras) : "***********";
|
|
break;
|
|
case 'account_balance':
|
|
$extras = ["class" => "btn btn-link form-label-sm", "target" => "_self", ...$extras];
|
|
$value = form_label(
|
|
number_format(intval($value)) . "원",
|
|
'index',
|
|
[
|
|
"data-src" => "/admin/customer/account?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup",
|
|
"data-bs-toggle" => "modal",
|
|
"data-bs-target" => "#index_action_form",
|
|
...$extras
|
|
]
|
|
);
|
|
break;
|
|
case 'coupon_balance':
|
|
$extras = ["class" => "btn btn-link form-label-sm", "target" => "_self", ...$extras];
|
|
$value = form_label(
|
|
number_format(intval($value)) . "개",
|
|
'index',
|
|
[
|
|
"data-src" => "/admin/customer/coupon?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup",
|
|
"data-bs-toggle" => "modal",
|
|
"data-bs-target" => "#index_action_form",
|
|
...$extras
|
|
]
|
|
);
|
|
break;
|
|
case 'point_balance':
|
|
$extras = ["class" => "btn btn-link form-label-sm", "target" => "_self", ...$extras];
|
|
$value = form_label(
|
|
number_format(intval($value)) . "원",
|
|
'index',
|
|
[
|
|
"data-src" => "/admin/customer/point?clientinfo_uid={$viewDatas['entity']->getPK()}&ActionTemplate=popup",
|
|
"data-bs-toggle" => "modal",
|
|
"data-bs-target" => "#index_action_form",
|
|
...$extras
|
|
]
|
|
);
|
|
break;
|
|
default:
|
|
$value = parent::getFieldView($field, $value, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
if (is_array($value)) {
|
|
throw new \Exception(__METHOD__ . "에서 오류: {$field}의 값이 Array형태입니다");
|
|
}
|
|
return $value;
|
|
} //
|
|
public function getListButton(string $action, string $label, array $viewDatas, array $extras = []): string
|
|
{
|
|
switch ($action) {
|
|
case 'modify':
|
|
$action = $this->getMyAuth()->isAccessRole(['security']) ? parent::getListButton($action, $label, $viewDatas, $extras) : $label;
|
|
break;
|
|
case 'create':
|
|
case 'delete':
|
|
case 'batchjob':
|
|
case 'batchjob_delete':
|
|
$action = $this->getMyAuth()->isAccessRole(['security']) ? parent::getListButton($action, $label, $viewDatas, $extras) : "";
|
|
break;
|
|
case 'history':
|
|
$extras = ["class" => "btn btn-outline btn-primary btn-circle", "target" => "_self", ...$extras];
|
|
$action = form_label(
|
|
$label ? $label : ICONS['HISTORY'],
|
|
$action,
|
|
[
|
|
"data-src" => "/admin/customer/client/history?clientinfo_uid={$viewDatas['entity']->getPK()}",
|
|
"data-bs-toggle" => "modal",
|
|
"data-bs-target" => "#index_action_form",
|
|
...$extras
|
|
]
|
|
);
|
|
break;
|
|
default:
|
|
$action = parent::getListButton($action, $label, $viewDatas, $extras);
|
|
break;
|
|
}
|
|
return $action;
|
|
}
|
|
}
|