dbmsv3 init...1

This commit is contained in:
choi.jh 2025-10-17 15:22:52 +09:00
parent 6e9cdd8644
commit c08d960bb0
5 changed files with 51 additions and 62 deletions

File diff suppressed because one or more lines are too long

View File

@ -198,7 +198,7 @@ class CommonHelper
return $ips; return $ips;
} }
final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string final public function form_dropdown_common(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string
{ {
// 필터 옵션이 없으면 빈 배열로 초기화 // 필터 옵션이 없으면 빈 배열로 초기화
if (!array_key_exists($field, $viewDatas['control']['field_optons'])) { if (!array_key_exists($field, $viewDatas['control']['field_optons'])) {
@ -206,28 +206,17 @@ class CommonHelper
} }
$extra = ""; $extra = "";
foreach ($extras as $extra_tag => $extra_value) { foreach ($extras as $extra_tag => $extra_value) {
$extra .= sprintf(" %s=\"%s\"", $extra_tag, htmlspecialchars($extra_value, ENT_QUOTES, 'UTF-8')); $extra .= sprintf(" %s=\"%s\"", $extra_tag, $extra_value);
} }
// $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체 // $formOptions는 필터 옵션 배열로, key는 필터 엔티티의 PK, value는 필터 엔티티 객체
$html = sprintf("<select name=\"%s\" %s>", $field, $extra); $html = sprintf("<select name=\"%s\" %s>", $field, $extra);
$html .= "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>"; $html .= "<option value=\"\">" . lang("{$viewDatas['class_path']}.label.{$field}") . " 선택" . "</option>";
$html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes); $html .= $this->form_dropdown_common_process($field, $value, $viewDatas, $extras, $attributes, $isAll);
$html .= '</select>'; $html .= '</select>';
return $html; return $html;
} }
//필수항목 //필수함수
public function getFieldLabel(string $field, string $label, array $viewDatas, array $extras = []): string protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string
{
switch ($field) {
default:
// required가 있으면 class 추가
$extras = (strpos($viewDatas['control']['field_rules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras;
$label = form_label($label, $field, ['class' => 'form-label-sm', ...$extras]);
break;
}
return $label;
}
protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string
{ {
$html = ""; $html = "";
switch ($field) { switch ($field) {
@ -238,11 +227,11 @@ class CommonHelper
$attribute = ""; $attribute = "";
$label = ""; $label = "";
if ($option_value instanceof CommonEntity) { if ($option_value instanceof CommonEntity) {
if ($option_key != $value && $option_value->getStatus() != $option_value::DEFAULT_STATUS) { if ($option_key != $value && $option_value->getStatus() != $option_value::DEFAULT_STATUS && !$isAll) {
continue; continue;
} }
foreach ($attributes as $attribute_name => $attribute_value) { foreach ($attributes as $attribute_name => $attribute_value) {
$attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value()); $attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value);
} }
$label = $option_value->getCustomTitle(); $label = $option_value->getCustomTitle();
} else { } else {
@ -254,6 +243,17 @@ class CommonHelper
} }
return $html; return $html;
} }
public function getFieldLabel(string $field, string $label, array $viewDatas, array $extras = []): string
{
switch ($field) {
default:
// required가 있으면 class 추가
$extras = (strpos($viewDatas['control']['field_rules'][$field], 'required') !== false) ? ["class" => "text-danger", "required" => "", ...$extras] : $extras;
$label = form_label($label, $field, ['class' => 'form-label-sm', ...$extras]);
break;
}
return $label;
}
public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string public function getFieldForm(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
switch ($field) { switch ($field) {
@ -280,7 +280,7 @@ class CommonHelper
} }
$form = implode(" ", $forms); $form = implode(" ", $forms);
} else { } else {
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras); $form = form_dropdown($field, $value, $viewDatas, $extras);
} }
break; break;
case 'issue_at': case 'issue_at':
@ -301,16 +301,11 @@ class CommonHelper
// $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce'; // $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' tinymce' : 'tinymce';
$form = form_textarea($field, $value ?? "", $extras); $form = form_textarea($field, $value ?? "", $extras);
break; break;
case 'user_uid':
case 'old_clientinfo_uid':
case 'clientinfo_uid':
case 'serviceinfo_uid':
case 'serverinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
default: default:
if (in_array($field, $viewDatas['control']['actionFilters'])) { if (in_array($field, $viewDatas['control']['actionFilters'])) {
if (str_contains($field, "_uid")) {
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
}
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras); $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
} else { } else {
$form = form_input($field, $value ?? "", $extras); $form = form_input($field, $value ?? "", $extras);
@ -358,19 +353,6 @@ class CommonHelper
break; break;
default: default:
if (in_array($field, $viewDatas['control']['actionFilters'])) { if (in_array($field, $viewDatas['control']['actionFilters'])) {
// //index 액션에서만 filter_options를 변경시 선택된 값을 변경하는 기능
// if ($viewDatas['control']['action'] == 'index') {
// $extras["onChange"] = sprintf(
// "document.location.href='%s/toggle/%s/%s?%s='+this.options[this.selectedIndex].value",
// current_url(),
// $viewDatas['entity']->getPK(),
// $field,
// $field
// );
// $value = $this->getFieldForm($field, $value, $viewDatas, $extras);
// } else {
// $value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) ? $viewDatas['control']['field_optons'][$field][$value] : "";
// }
if (str_contains($field, "_uid")) { if (str_contains($field, "_uid")) {
$value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : ""; $value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : "";
} else { } else {
@ -387,17 +369,14 @@ class CommonHelper
public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string public function getListFilter(string $field, mixed $value, array $viewDatas, array $extras = []): string
{ {
switch ($field) { switch ($field) {
case 'user_uid':
case 'old_clientinfo_uid':
case 'clientinfo_uid':
case 'serviceinfo_uid':
case 'serverinfo_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras);
break;
default: default:
if (in_array($field, $viewDatas['control']['actionFilters'])) { if (in_array($field, $viewDatas['control']['actionFilters'])) {
$filter = $this->getFieldForm($field, $value, $viewDatas, $extras); if (str_contains($field, "_uid")) {
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
}
$attributes = [];
$isAll = true;
$filter = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes, $isAll);
} else { } else {
$filter = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) ? $viewDatas['control']['field_optons'][$field][$value] : ""; $filter = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) ? $viewDatas['control']['field_optons'][$field][$value] : "";
} }

View File

@ -24,7 +24,7 @@ class ServiceHelper extends CustomerHelper
$value = $viewDatas['entity']->getServerEntity()->getPK(); $value = $viewDatas['entity']->getServerEntity()->getPK();
} }
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$attributes = ['data-price' => 'getPrice']; $attributes = ['data-price' => 'price'];
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break; break;
case 'amount': case 'amount':

View File

@ -12,7 +12,7 @@ class ServerPartHelper extends EquipmentHelper
parent::__construct(); parent::__construct();
$this->setTitleField(field: ServerPartModel::TITLE); $this->setTitleField(field: ServerPartModel::TITLE);
} }
protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = []): string protected function form_dropdown_common_process(string $field, mixed $value, array $viewDatas, array $extras = [], array $attributes = [], bool $isAll = false): string
{ {
$html = ""; $html = "";
switch ($field) { switch ($field) {
@ -26,11 +26,11 @@ class ServerPartHelper extends EquipmentHelper
$attribute = ""; $attribute = "";
$label = ""; $label = "";
if ($option_value instanceof CommonEntity) { if ($option_value instanceof CommonEntity) {
if ($option_key != $value && $option_value->getStatus() != $option_value::DEFAULT_STATUS) { if ($option_key != $value && $option_value->getStatus() != $option_value::DEFAULT_STATUS && !$isAll) {
continue; continue;
} }
foreach ($attributes as $attribute_name => $attribute_value) { foreach ($attributes as $attribute_name => $attribute_value) {
$attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value()); $attribute .= sprintf(" %s=\"%s\"", $attribute_name, $option_value->$attribute_value);
} }
$label = $option_value->getCustomTitle(); $label = $option_value->getCustomTitle();
} else { } else {
@ -50,8 +50,8 @@ class ServerPartHelper extends EquipmentHelper
switch ($field) { switch ($field) {
case 'part_uid': case 'part_uid':
$extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field'; $extras['class'] = array_key_exists('class', $extras) ? $extras['class'] . ' select-field' : 'select-field';
$extras['onChange'] = "document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price'); document.querySelector('input[name=\'title\']').value = this.options[this.selectedIndex].getAttribute('data-title')"; $extras['onChange'] = "document.querySelector('input[name=\'title\']').value = this.options[this.selectedIndex].getAttribute('data-title'); document.querySelector('input[name=\'amount\']').value = this.options[this.selectedIndex].getAttribute('data-price')";
$attributes = ['data-title' => 'getTitle', 'data-price' => 'getPrice']; $attributes = ['data-title' => 'title', 'data-price' => 'price'];
$form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes); $form = $this->form_dropdown_common($field, $value, $viewDatas, $extras, $attributes);
break; break;
case 'extra': case 'extra':

View File

@ -136,7 +136,12 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK(); $formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID(); $formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
$formDatas['title'] = sprintf("[%s] %s 서비스비용", $serviceEntity->getBillingAt(), $serviceEntity->getServerEntity->getTitle()); $formDatas['title'] = sprintf(
"[%s/%s] %s 서비스비용",
$serviceEntity->getServerEntity()->getCode(),
$serviceEntity->getServerEntity()->getIP(),
date("Y년 n월", strtotime($serviceEntity->getBillingAt()))
);
$formDatas['amount'] = $serviceEntity->getAmount(); $formDatas['amount'] = $serviceEntity->getAmount();
$formDatas['billing'] = PAYMENT['BILLING']['MONTH']; $formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$formDatas['billing_at'] = $serviceEntity->getBillingAt(); $formDatas['billing_at'] = $serviceEntity->getBillingAt();
@ -157,7 +162,12 @@ class PaymentService extends CommonService implements ServiceInterface, ServerPa
$formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID(); $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID();
$formDatas['serviceinfo_uid'] = $serviceEntity->getPK(); $formDatas['serviceinfo_uid'] = $serviceEntity->getPK();
$formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID(); $formDatas['serverinfo_uid'] = $serviceEntity->getServerInfoUID();
$formDatas['title'] = $formDatas['title'] = sprintf("[%s] %s 서비스비용", $serviceEntity->getBillingAt(), $serviceEntity->getServerEntity->getTitle()); $formDatas['title'] = sprintf(
"[%s/%s] %s 서비스비용",
$serviceEntity->getServerEntity()->getCode(),
$serviceEntity->getServerEntity()->getIP(),
date("Y년 n월", strtotime($serviceEntity->getBillingAt()))
);
$formDatas['amount'] = $serviceEntity->getAmount(); $formDatas['amount'] = $serviceEntity->getAmount();
$formDatas['billing'] = PAYMENT['BILLING']['MONTH']; $formDatas['billing'] = PAYMENT['BILLING']['MONTH'];
$formDatas['billing_at'] = $serviceEntity->getBillingAt(); $formDatas['billing_at'] = $serviceEntity->getBillingAt();