diff --git a/app/Controllers/Admin/Customer/CustomerController.php b/app/Controllers/Admin/Customer/CustomerController.php index a61753c..bbc2e0e 100644 --- a/app/Controllers/Admin/Customer/CustomerController.php +++ b/app/Controllers/Admin/Customer/CustomerController.php @@ -3,12 +3,13 @@ namespace App\Controllers\Admin\Customer; use App\Controllers\Admin\AdminController; +use App\Entities\Equipment\Part\IpEntity; +use App\Services\Customer\ClientService; use CodeIgniter\HTTP\RequestInterface; + use CodeIgniter\HTTP\ResponseInterface; use Psr\Log\LoggerInterface; -use App\Services\Customer\ClientService; - abstract class CustomerController extends AdminController { private ?ClientService $_clientService = null; @@ -30,9 +31,23 @@ abstract class CustomerController extends AdminController { //$item_type(CPU,RAM,STORAGE등)에 따라 선언된 getFormFieldOption용 foreach (SERVICE_ITEM_TYPES as $item_type => $label) { + if ($item_type == 'IP') { + $occupied_ips = []; + $forbidden_ips = []; + } $options = []; foreach ($this->getService()->getEquipmentService($item_type)->getEntities() as $entity) { $options[$entity->getPK()] = $entity->getTitle(); + if ($item_type == 'IP') { + if ($entity->getStatus() === IpEntity::STATUS_OCCUPIED) { + $occupied_ips[] = $entity->getPK(); + } + if ($entity->getStatus() === IpEntity::STATUS_FORBIDDEN) { + $forbidden_ips[] = $entity->getPK(); + } + $this->occupied_ips = $occupied_ips; + $this->forbidden_ips = $forbidden_ips; + } } $this->setFilterFieldOption($item_type, $options); } diff --git a/app/Controllers/Admin/Customer/ServicePaymentController.php b/app/Controllers/Admin/Customer/ServicePaymentController.php index d1b2ccd..7557f0b 100644 --- a/app/Controllers/Admin/Customer/ServicePaymentController.php +++ b/app/Controllers/Admin/Customer/ServicePaymentController.php @@ -107,7 +107,7 @@ class ServicePaymentController extends CustomerController private function getServices(ServiceEntity $serviceEntity): array { $temps = [ - 'serial' => $serviceEntity->getSerialCode(), + 'code' => $serviceEntity->getTitle(), 'billing_at' => $serviceEntity->getBillingAt(), 'items' => [] ]; diff --git a/app/Controllers/Admin/Equipment/Part/IpController.php b/app/Controllers/Admin/Equipment/Part/IpController.php index f35ba1e..41bc83e 100644 --- a/app/Controllers/Admin/Equipment/Part/IpController.php +++ b/app/Controllers/Admin/Equipment/Part/IpController.php @@ -2,14 +2,14 @@ namespace App\Controllers\Admin\Equipment\Part; -use CodeIgniter\HTTP\RequestInterface; -use CodeIgniter\HTTP\ResponseInterface; -use Psr\Log\LoggerInterface; - use App\Helpers\Equipment\Part\IpHelper; use App\Services\Equipment\Part\IpService; use App\Services\Equipment\Part\LineService; +use CodeIgniter\HTTP\RequestInterface; + +use CodeIgniter\HTTP\ResponseInterface; +use Psr\Log\LoggerInterface; class IpController extends PartController { diff --git a/app/Entities/Customer/ServiceEntity.php b/app/Entities/Customer/ServiceEntity.php index 7ce45c8..49390b1 100644 --- a/app/Entities/Customer/ServiceEntity.php +++ b/app/Entities/Customer/ServiceEntity.php @@ -25,7 +25,7 @@ class ServiceEntity extends CustomerEntity $this->_ownerEntity = $ownerEntity; } //타 객체정의 부분 - public function getSerialCode(): string + public function getTitle(): string { return "S" . $this->getPK(); } diff --git a/app/Entities/Equipment/Part/IpEntity.php b/app/Entities/Equipment/Part/IpEntity.php index c6b969f..3b0e7cb 100644 --- a/app/Entities/Equipment/Part/IpEntity.php +++ b/app/Entities/Equipment/Part/IpEntity.php @@ -8,4 +8,7 @@ class IpEntity extends PartEntity { const PK = IpModel::PK; const TITLE = IpModel::TITLE; + const STATUS_AVAILABLE = "default"; + const STATUS_OCCUPIED = "occupied"; + const STATUS_FORBIDDEN = "forbidden"; } diff --git a/app/Helpers/Customer/ServiceItemHelper.php b/app/Helpers/Customer/ServiceItemHelper.php index 0fd514c..c024229 100644 --- a/app/Helpers/Customer/ServiceItemHelper.php +++ b/app/Helpers/Customer/ServiceItemHelper.php @@ -29,6 +29,22 @@ class ServiceItemHelper extends CustomerHelper $form = parent::getFieldForm($field, $value, $viewDatas, $extras); } break; + case 'IP': + if (!is_array($viewDatas['control']['filter_optons'][$field])) { + throw new \Exception(__METHOD__ . "에서 {$field}의 field_options가 array형태가 아닙니다."); + } + //CodeIgniter 4의 form_dropdown()은 options 배열로만 값을 받기 때문에, disabled 속성 같은 개별 옵션에 대한 HTML 속성 추가는 기본적으로 지원하지 않습니다. + $form_temps = ["'; + $form = implode("", $form_temps); + //dd($viewDatas['occupied_ips']); + break; default: $form = parent::getFieldForm($field, $value, $viewDatas, $extras); break; diff --git a/app/Language/en/Equipment/Part/Ip.php b/app/Language/en/Equipment/Part/Ip.php index 78f7614..cfa53df 100644 --- a/app/Language/en/Equipment/Part/Ip.php +++ b/app/Language/en/Equipment/Part/Ip.php @@ -16,8 +16,8 @@ return [ "STATUS" => [ 'default' => "사용가능", "pause" => "일시정지", - "occupied" => "사용중", - "forbidden" => "사용금지됨", + "occupied" => "서비스중", + "forbidden" => "금지됨", "delete" => "삭제", ], ]; diff --git a/app/Models/Customer/ServiceModel.php b/app/Models/Customer/ServiceModel.php index 8351ba2..8f7da73 100644 --- a/app/Models/Customer/ServiceModel.php +++ b/app/Models/Customer/ServiceModel.php @@ -8,14 +8,13 @@ class ServiceModel extends CustomerModel { const TABLE = "serviceinfo"; const PK = "uid"; - const TITLE = "title"; + const TITLE = "uid"; protected $table = self::TABLE; protected $primaryKey = self::PK; protected $returnType = ServiceEntity::class; protected $allowedFields = [ "clientinfo_uid", "ownerinfo_uid", - "title", "type", "location", "switch", @@ -40,7 +39,6 @@ class ServiceModel extends CustomerModel case "ownerinfo_uid": $rule = "required|numeric"; break; - case "title": case "type": case "location": case "switch": diff --git a/app/Services/Customer/ServiceItem/ServiceItemIpService.php b/app/Services/Customer/ServiceItem/ServiceItemIpService.php new file mode 100644 index 0000000..a64768f --- /dev/null +++ b/app/Services/Customer/ServiceItem/ServiceItemIpService.php @@ -0,0 +1,49 @@ +_ipService) { + $this->_ipService = new IpService($this->request); + } + return $this->_ipService; + } + + public function create(array $formDatas, mixed $entity = null): ServiceItemEntity + { + //ip의 경우 서비스중으로 설정작업 + $entity = parent::create($formDatas, $entity); + $this->getIpService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED); + } + public function modify(mixed $entity, array $formDatas): ServiceEntity + { + //code가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음 + if (array_key_exists('code', $formDatas) && $formDatas['code'] !== $entity->getCode()) { + //code의 경우 기존code는 사용가능으로 설정작업 + $this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE); + //coded의 경우 변경된 code는 서비스중으로 설정작업 + $this->getCodeService()->setStatus($formDatas['code'], IpEntity::STATUS_OCCUPIED); + } + return parent::modify($entity, $formDatas); + } + final public function delete(mixed $entity): bool + { + //code의 경우 기존code는 사용가능으로 설정작업 + $this->getCodeService()->setStatus($entity->getCode(), IpEntity::STATUS_AVAILABLE); + return parent::delete($entity); + } +} diff --git a/app/Services/Customer/ServiceItemService.php b/app/Services/Customer/ServiceItem/ServiceItemService.php similarity index 65% rename from app/Services/Customer/ServiceItemService.php rename to app/Services/Customer/ServiceItem/ServiceItemService.php index 23342a1..3772fd7 100644 --- a/app/Services/Customer/ServiceItemService.php +++ b/app/Services/Customer/ServiceItem/ServiceItemService.php @@ -1,12 +1,13 @@ getCodeService()->setStatus($formDatas['code'], CodeEntity::STATUS_OCCUPIED); + // return parent::create($formDatas, $entity); + // } + // public function modify(mixed $entity, array $formDatas): ServiceEntity + // { + // //code가 기존과 다를경우 //toggle,batchjob의 경우 $formDatas에 code가 없을수도 있음 + // if (array_key_exists('code', $formDatas) && $formDatas['code'] !== $entity->getCode()) { + // //code의 경우 기존code는 사용가능으로 설정작업 + // $this->getCodeService()->setStatus($entity->getCode(), CodeEntity::STATUS_AVAILABLE); + // //coded의 경우 변경된 code는 서비스중으로 설정작업 + // $this->getCodeService()->setStatus($formDatas['code'], CodeEntity::STATUS_OCCUPIED); + // } + // return parent::modify($entity, $formDatas); + // } + // final public function delete(mixed $entity): bool + // { + // //code의 경우 기존code는 사용가능으로 설정작업 + // $this->getCodeService()->setStatus($entity->getCode(), CodeEntity::STATUS_AVAILABLE); + // return parent::delete($entity); + // } \ No newline at end of file diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index cfabddd..415f502 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -8,7 +8,6 @@ use CodeIgniter\HTTP\IncomingRequest; use App\Entities\Equipment\CodeEntity; use App\Services\Equipment\CodeService; -use PhpOffice\PhpSpreadsheet\Calculation\Web\Service; class ServiceService extends CustomerService { @@ -32,7 +31,6 @@ class ServiceService extends CustomerService return [ "clientinfo_uid", "ownerinfo_uid", - "title", "type", "location", "switch", @@ -53,7 +51,7 @@ class ServiceService extends CustomerService } public function getIndexFields(): array { - return ['clientinfo_uid', 'ownerinfo_uid', 'title', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'updated_at', 'status']; + return ['clientinfo_uid', 'ownerinfo_uid', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'updated_at', 'status']; } public function getCodeService(): CodeService { diff --git a/app/Services/Equipment/Part/IpService.php b/app/Services/Equipment/Part/IpService.php index cae5660..f8625f4 100644 --- a/app/Services/Equipment/Part/IpService.php +++ b/app/Services/Equipment/Part/IpService.php @@ -52,4 +52,15 @@ class IpService extends PartService $formDatas['status'] = DEFAULTS['STATUS']; return $this->create($formDatas, new IpEntity()); } + + //상태변경 + public function setStatus(int $uid, string $status): IpEntity + { + //code의 경우 사용가능/사용중으로 설정작업 + $entity = $this->getEntity($uid); + if (!$entity) { + throw new \Exception("{$uid}에 대한 IP정보를 찾을수 없습니다."); + } + return $this->getModel()->modify($entity, ['status' => $status]); + } } diff --git a/app/Views/admin/payment/invoice.php b/app/Views/admin/payment/invoice.php index faf0493..cb72741 100644 --- a/app/Views/admin/payment/invoice.php +++ b/app/Views/admin/payment/invoice.php @@ -34,7 +34,7 @@
| 서비스: = $service['serial'] ?> | +서비스: = $service['code'] ?> | 지급기한: = $service['billing_at'] ?> |
|---|---|---|
|