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 @@
"get")) ?> @@ -19,22 +19,24 @@ 작업 - - onClick="indexRowCheckBoxToggle(this);"> + + getStatus() != 'use' ? 'class="table-danger" rowcolor="red"' : 'rowcolor="red"' ?> onClick="indexRowCheckBoxToggle(this);"> - "checkbox_uid_{$row['uid']}", "name" => "batchjob_uids[]", "value" => $row['uid'], "class" => "batchjobuids_checkboxs"]); ?> - "_self"]) ?> + "checkbox_uid_{$entity->getPrimaryKey()}", "name" => "batchjob_uids[]", "value" => $entity->getPrimaryKey(), "class" => "batchjobuids_checkboxs"]); ?> + getPrimaryKey(), $total_count - (($page - 1) * $per_page + $i), ["target" => "_self"]) ?> - + - "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> + getPrimaryKey(), ICONS['DELETE'], ["class" => "btn btn-sm btn-danger btn-circle", "target" => "_self"]) ?> 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 @@ extend('layouts/admin') ?> section('content') ?> include('templates/admin/header'); ?> - + @@ -9,7 +9,7 @@ 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 @@ extend('layouts/admin') ?> section('content') ?> include('templates/admin/header'); ?> - +
- +
@@ -9,7 +9,7 @@
- $field : old($field), $fieldFormOptions) ?> + $field, $fieldFormOptions) ?>