diff --git a/app/Helpers/Admin/HPILO_helper.php b/app/Helpers/Admin/HPILO_helper.php
index c20a9bf..1a27026 100644
--- a/app/Helpers/Admin/HPILO_helper.php
+++ b/app/Helpers/Admin/HPILO_helper.php
@@ -6,54 +6,81 @@ function getFieldLabel_HPILOHelper($field, array $fieldRules, array $attributes
if (strpos($fieldRules[$field], 'required') !== false) {
array_push($attributes, 'style="color:red";');
}
- return sprintf("%s", implode(" ", $attributes), lang("Admin/HPILO.label.{$field}"));
+ return sprintf("%s", implode(" ", [...$attributes]), lang("Admin/HPILO.label.{$field}"));
break;
}
}
//header.php에서 getFieldForm_Helper사용
-function getFieldForm_HPILOHelper($field, $value, array $formOptions, array $attributes = array())
+function getFieldForm_HPILOHelper($field, $value, array $fieldFormOptions, array $attributes = array())
{
- $value = is_null($value) ? DEFAULTS['EMPTY'] : $value;
+ $value = $value ?: DEFAULTS['EMPTY'];
switch ($field) {
- case 'status':
case 'power':
- return form_dropdown($field, $formOptions[$field], $value, $attributes);
+ $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/HPILO.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
+ return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes, 'class' => "select-field"]);
+ // foreach ($fieldFormOptions[$field] as $key => $label) {
+ // $checkboxs[] = form_checkbox("{$field}[]", $key, in_array($key, is_array($value) ? [...$value] : [$value]), $attributes) . $label;
+ // }
+ // return implode(" ", $checkboxs);
+ // return form_multiselect($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], [...$attributes]);
+ break;
+ case 'status':
+ $fieldFormOptions[$field] = [DEFAULTS['EMPTY'] => lang("Admin/Board.label.{$field}") . " 선택", ...$fieldFormOptions[$field]];
+ return form_dropdown($field, $fieldFormOptions[$field], is_array($value) ? [...$value] : [$value], $attributes);
+ break;
+ case 'updated_at':
+ case 'created_at':
+ return form_input($field, $value, [...$attributes, 'class' => 'calender']);
break;
case 'passwd':
return sprintf(
"%s %s %s",
- form_password($field, DEFAULTS['EMPTY'], $attributes),
- lang("Admin/Board.label.confirmpassword"),
- form_password('confirmpassword', DEFAULTS['EMPTY'], $attributes),
+ form_password($field, DEFAULTS['EMPTY'], [...$attributes]),
+ lang("Admin/HPILO.label.confirmpassword"),
+ form_password('confirmpassword', DEFAULTS['EMPTY'], [...$attributes]),
);
break;
- case 'updated_at':
- case 'created_at':
- $attributes["class"] = !array_key_exists("class", $attributes) ? "calender" : $attributes["class"] . " calender";
- return form_input($field, $value, $attributes);
+ case 'content':
+ return form_textarea($field, html_entity_decode($value), [...$attributes, 'class' => 'editor', 'rows' => '20', 'cols' => '100']);
+ break;
+ case 'upload_file':
+ return form_upload($field);
break;
default:
- return form_input($field, $value, $attributes);
+ return form_input($field, $value, [...$attributes]);
break;
}
} //
function getFieldView_HPILOHelper($field, $entity, array $fieldFilters, array $fieldFormOptions, array $attributes = array())
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
case 'memory':
- return $entity->$field . "GB";
+ return $value . "GB";
break;
case 'detail':
- return nl2br($entity->$field);
+ return nl2br($value);
+ break;
+ case 'upload_file':
+ return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode("||", $value)[0], [...$attributes, "target" => "_self"]);
+ break;
+ case 'content':
+ return html_entity_decode($value);
break;
default:
- if (in_array($field, $fieldFilters)) {
- return getFieldForm_HPILOHelper($field, $entity->$field, $fieldFormOptions, $attributes);
- }
- return !isset($entity->$field) ? "{$field}:{$entity->uid}" : $entity->$field;
- return $entity->$field;
+ return in_array($field, $fieldFilters) ? $fieldFormOptions[$field][$value] : $value;
+ break;
+ }
+} //
+
+function getFieldFilter_HPILOHelper($field, $value, array $fieldFormOptions, array $attributes = array())
+{
+ $value = $value ?: DEFAULTS['EMPTY'];
+ switch ($field) {
+ default:
+ return getFieldForm_HPILOHelper($field, $value, $fieldFormOptions, $attributes);
break;
}
} //
@@ -63,40 +90,32 @@ function getFieldIndex_Column_HPILOHelper($field, $order_field, $order_value, ar
$label = lang("Admin/HPILO.label.{$field}");
$label = $field == $order_field ? sprintf('%s ', $label, $order_value == 'ASC' ? "up" : "down") : $label;
$order_value = $order_value == 'DESC' ? "ASC" : "DESC";
- return anchor(current_url() . "?order_field={$field}&order_value={$order_value}", $label, $attributes);
+ return anchor(current_url() . "?order_field={$field}&order_value={$order_value}", $label, [...$attributes]);
} //
-function getFieldIndex_Row_HPILOHelper($field, array $row, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
+function getFieldIndex_Row_HPILOHelper($field, $entity, array $fieldFilters, $fieldFormOptions, $attributes = array()): string
{
+ $value = $entity->$field ?: DEFAULTS['EMPTY'];
switch ($field) {
- case 'customer':
- return sprintf(
- "%s %s %s",
- anchor(base_url() . '/admin/hpilo/reload/' . $row['uid'], ' ', ["class" => "btn btn-sm btn-primary btn-circle fa fa-refresh", "target" => "_self"]),
- anchor(base_url() . '/admin/hpilo/console/' . $row['uid'], ' ', ["class" => "btn btn-sm btn-warning btn-circle fa fa-desktop", "target" => "_self"]),
- $row[$field]
- );
- break;
- case 'model':
- return anchor(current_url() . '/view/' . $row['uid'], $row[$field], ["target" => "_self"]);
- break;
case 'memory':
- return $row[$field] . "GB";
+ return $value . "GB";
break;
- case 'power':
- $attributes["onChange"] = sprintf('location.href="%s/reset/%s/"+this.options[this.selectedIndex].value', current_url(), $row['uid']);
- return getFieldForm_HPILOHelper($field, $row[$field], $fieldFormOptions, $attributes);
+ case 'name':
+ return anchor(current_url() . '/view/' . $entity->getPrimaryKey(), $value, [...$attributes, "target" => "_self"]);
+ break;
+ case 'upload_file':
+ return $value == DEFAULTS['EMPTY'] ? DEFAULTS['EMPTY'] : anchor(current_url() . '/download/' . $entity->getPrimaryKey(), ICONS['IMAGE_FILE'] . explode("||", $value)[0], [...$attributes, "target" => "_self"]);
break;
case 'updated_at':
case 'created_at':
- return isset($row[$field]) ? str_split($row[$field], 10)[0] : "";
+ return isset($value) ? str_split($value, 10)[0] : "";
break;
default:
if (in_array($field, $fieldFilters)) {
- $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $row['uid'], $field, $field);
- return getFieldForm_HPILOHelper($field, $row[$field], $fieldFormOptions, $attributes);
+ $attributes["onChange"] = sprintf('location.href="%s/toggle/%s/%s?%s="+this.options[this.selectedIndex].value', current_url(), $entity->getPrimaryKey(), $field, $field);
+ return getFieldFilter_HPILOHelper($field, $value, $fieldFormOptions, [...$attributes]);
}
- return $row[$field];
+ return $value;
break;
}
} //
\ No newline at end of file
diff --git a/app/Views/admin/hpilo/index.php b/app/Views/admin/hpilo/index.php
index 950bb91..56f7a88 100644
--- a/app/Views/admin/hpilo/index.php
+++ b/app/Views/admin/hpilo/index.php
@@ -5,7 +5,7 @@
= form_open(current_url(), array("method" => "get")) ?>
- 조건검색:- = getFieldForm_HPILOHelper($field, $$field, $fieldFormOptions) ?>
+ 조건검색:- = getFieldFilter_HPILOHelper($field, $$field, $fieldFormOptions) ?>
= $this->include('templates/admin/index_head'); ?>
= form_close(); ?>
@@ -19,22 +19,24 @@
작업 |
-
-
onClick="indexRowCheckBoxToggle(this);">
+
+
getStatus() != 'use' ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);">
|
- = form_checkbox(["id" => "checkbox_uid_{$row['uid']}", "name" => "batchjob_uids[]", "value" => $row['uid'], "class" => "batchjobuids_checkboxs"]); ?>
- = anchor(current_url() . '/update/' . $row['uid'], $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
+ = form_checkbox(["id" => "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?>
+ = anchor(current_url() . '/update/' . $entity->getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?>
|
- = getFieldIndex_Row_HPILOHelper($field, $row, $fieldFilters, $fieldFormOptions) ?> |
+ = getFieldIndex_Row_HPILOHelper($field, $entity, $fieldFilters, $fieldFormOptions) ?> |
- = anchor(current_url() . '/delete/' . $row['uid'], ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
+ = anchor(current_url() . '/delete/' . $entity->getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> |
- = form_checkbox(array("id" => "batchjobuids_checkbox")) ?>ALL
+ - = getFieldFilter_HPILOHelper($field, DEFAULTS['EMPTY'], $fieldFormOptions) ?>
+ - = form_submit('', '일괄처리', array("class" => "btn btn-outline btn-warning")); ?>
- = anchor(current_url() . '/insert', '입력', ["class" => "btn btn-sm btn-primary btn-circle", "target" => "_self"]) ?>
= form_close(); ?>
diff --git a/app/Views/admin/hpilo/insert.php b/app/Views/admin/hpilo/insert.php
index 46843a0..2458705 100644
--- a/app/Views/admin/hpilo/insert.php
+++ b/app/Views/admin/hpilo/insert.php
@@ -1,7 +1,7 @@
= $this->extend('layouts/admin') ?>
= $this->section('content') ?>
= $this->include('templates/admin/header'); ?>
-= form_open(current_url(), $forms['attributes'], $forms['hiddens']) ?>
+= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
@@ -9,7 +9,7 @@
= getFieldLabel_HPILOHelper($field, $fieldRules) ?>
|
- = getFieldForm_HPILOHelper($field, is_null(old($field)) ? DEFAULTS['EMPTY'] : old($field), $fieldFormOptions) ?>
+ = getFieldForm_HPILOHelper($field, old($field) ?: DEFAULTS['EMPTY'], $fieldFormOptions) ?>
= validation_show_error($field); ?>
|
diff --git a/app/Views/admin/hpilo/update.php b/app/Views/admin/hpilo/update.php
index 4d27080..878dc55 100644
--- a/app/Views/admin/hpilo/update.php
+++ b/app/Views/admin/hpilo/update.php
@@ -1,7 +1,7 @@
= $this->extend('layouts/admin') ?>
= $this->section('content') ?>
= $this->include('templates/admin/header'); ?>
-= form_open(current_url(), $forms['attributes'], $forms['hiddens']) ?>
+= form_open_multipart(current_url(), $forms['attributes'], $forms['hiddens']) ?>
@@ -9,7 +9,7 @@
= getFieldLabel_HPILOHelper($field, $fieldRules) ?>
|
- = getFieldForm_HPILOHelper($field, is_null(old($field)) ? $entity->$field : old($field), $fieldFormOptions) ?>
+ = getFieldForm_HPILOHelper($field, old($field) ?: $entity->$field, $fieldFormOptions) ?>
= validation_show_error($field); ?>
|