diff --git a/app/Cells/Customer/ServiceCell.php b/app/Cells/Customer/ServiceCell.php index 66461ce..1adaf7d 100644 --- a/app/Cells/Customer/ServiceCell.php +++ b/app/Cells/Customer/ServiceCell.php @@ -7,10 +7,19 @@ use App\Services\Customer\ServiceService; class ServiceCell extends CustomerCell { + + private ?PaymentService $_paymentService = null; public function __construct() { parent::__construct(new ServiceService()); } + final public function getPaymentService(): PaymentService + { + if (!$this->_paymentService) { + $this->_paymentService = new PaymentService(); + } + return $this->_paymentService; + } public function detail(array $params): string { @@ -19,14 +28,25 @@ class ServiceCell extends CustomerCell $this->getService()->setFormFilters(); $this->getService()->setFormRules(); $this->getService()->setFormOptions(); - $entities = $this->getService()->getEntities(['clientinfo_uid' => $params['userinfo_uid']]); + $unPaids = []; + $entities = []; + foreach ($this->getService()->getEntities(['clientinfo_uid' => $params['clientinfo_uid']]) as $entity) { + if (!array_key_exists($entity->getPK(), $unPaids)) { + $unPaids[$entity->getPK()] = ['cnt' => 0, 'amount' => 0]; + } + foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) as $unPaid) { + $unPaids[$entity->getPK()]['cnt'] += $unPaid->cnt; + $unPaids[$entity->getPK()]['amount'] += $unPaid->amount; + } + $entities[] = $entity; + } $template = array_key_exists('template', $params) ? $params['template'] : __FUNCTION__; return view('cells/service/' . $template, [ 'serviceCellDatas' => [ 'control' => $this->getService()->getControlDatas(), 'service' => $this->getService(), 'entities' => $entities, - 'paymentService' => new PaymentService() + 'unPaids' => $unPaids ] ]); } diff --git a/app/Controllers/Admin/Customer/ClientController.php b/app/Controllers/Admin/Customer/ClientController.php index fd90574..2f9333c 100644 --- a/app/Controllers/Admin/Customer/ClientController.php +++ b/app/Controllers/Admin/Customer/ClientController.php @@ -117,6 +117,7 @@ class ClientController extends CustomerController 'clientinfo_uid' => $entity->getPK(), 'status' => STATUS['AVAILABLE'] ]); + //서비스별 미납 Count $this->unPaids = $this->getService()->getPaymentService()->getUnPaids('clientinfo_uid', [ 'clientinfo_uid' => $entity->getPK() ]); diff --git a/app/Controllers/Admin/Customer/ServiceController.php b/app/Controllers/Admin/Customer/ServiceController.php index 93f1066..c5163b6 100644 --- a/app/Controllers/Admin/Customer/ServiceController.php +++ b/app/Controllers/Admin/Customer/ServiceController.php @@ -91,12 +91,7 @@ class ServiceController extends CustomerController protected function index_process(array $entities = []): array { //서비스별 미납 Count - $unpaids = ['count' => 0, 'amount' => 0]; - foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $row) { - $unpaids[$row->serviceinfo_uid]['count'] = $row->cnt; - $unpaids[$row->serviceinfo_uid]['amount'] = $row->amount; - }; - $this->unpaids = $unpaids; + $this->unPaids = $this->getPaymentService()->getUnPaids('serviceinfo_uid'); //부모함수처리 return parent::index_process($entities); } diff --git a/app/Controllers/Admin/Home.php b/app/Controllers/Admin/Home.php index 71f93f1..8d11e8f 100644 --- a/app/Controllers/Admin/Home.php +++ b/app/Controllers/Admin/Home.php @@ -77,14 +77,13 @@ class Home extends AdminController $this->newServiceCount = count($this->newServiceEntities); //서비스별 미납 Count $totalUnPaidCount = 0; - $unpaids = ['count' => 0, 'amount' => 0]; - foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $row) { - $unpaids[$row->serviceinfo_uid]['count'] = $row->cnt; - $unpaids[$row->serviceinfo_uid]['amount'] = $row->amount; - $totalUnPaidCount += $row->cnt; - }; - $this->unpaids = $unpaids; + $totalUnPaidAmount = 0; + foreach ($this->getPaymentService()->getUnPaids('serviceinfo_uid') as $unPaid) { + $totalUnPaidCount += $unPaid->cnt; + $totalUnPaidAmount += $unPaid->amount; + } $this->totalUnPaidCount = $totalUnPaidCount; + $this->totalUnPaidAmount = $totalUnPaidAmount; helper(['form']); return $this->getResultSuccess(); } diff --git a/app/Entities/CommonEntity.php b/app/Entities/CommonEntity.php index 31d6e3f..68e516a 100644 --- a/app/Entities/CommonEntity.php +++ b/app/Entities/CommonEntity.php @@ -17,11 +17,6 @@ abstract class CommonEntity extends Entity parent::__construct($data); } - final public function __call($name, $arguments): string - { - return ""; - } - public function getPK(): int|string { $field = constant("static::PK"); diff --git a/app/Helpers/Customer/PaymentHelper.php b/app/Helpers/Customer/PaymentHelper.php index 542501e..e47cb30 100644 --- a/app/Helpers/Customer/PaymentHelper.php +++ b/app/Helpers/Customer/PaymentHelper.php @@ -18,15 +18,16 @@ class PaymentHelper extends CustomerHelper case "countdown": //결제일Countdown $value = $viewDatas['entity']->getCountDueAt(); break; - case 'item_uid': - //ItemType에 따라 필터옵션에서 Title을 가져옴 - $value = $viewDatas['control']['field_optons'][$viewDatas['entity']->getItemType()][$value]->getTitle(); - break; case 'serviceinfo_uid': case 'clientinfo_uid': case 'billing_method': $value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value]->getTitle() : ""; break; + case 'billing': + case 'pay': + case 'status': + $value = array_key_exists($value, $viewDatas['control']['field_optons'][$field]) && $viewDatas['control']['field_optons'][$field][$value] ? $viewDatas['control']['field_optons'][$field][$value] : ""; + break; default: $value = parent::getFieldView($field, $value, $viewDatas, $extras); break; @@ -40,7 +41,6 @@ class PaymentHelper extends CustomerHelper { switch ($action) { case 'create': - case 'batchjob': case 'batchjob_delete': $action = ""; break; diff --git a/app/Helpers/Customer/ServiceHelper.php b/app/Helpers/Customer/ServiceHelper.php index 5e0475c..9b587b4 100644 --- a/app/Helpers/Customer/ServiceHelper.php +++ b/app/Helpers/Customer/ServiceHelper.php @@ -79,7 +79,11 @@ class ServiceHelper extends CustomerHelper case 'billing_at': if (array_key_exists('unPaids', $viewDatas)) { if (array_key_exists($viewDatas['entity']->getPK(), $viewDatas['unPaids'])) { - $value .= "
getPK()}\">미지급: " . $viewDatas['unPaids'][$viewDatas['entity']->getPK()] . "
"; + foreach ($viewDatas['unPaids'] as $unPaid) { + if ($unPaid->serviceinfo_uid = $viewDatas['entity']->getPK()) { + $value .= "
getPK()}\">미지급: " . $unPaid->cnt . "개,총 " . number_format($unPaid->amount) . "원
"; + } + } } } break; diff --git a/app/Interfaces/Customer/CustomerInterFace.php b/app/Interfaces/Customer/CustomerInterFace.php new file mode 100644 index 0000000..3e017cf --- /dev/null +++ b/app/Interfaces/Customer/CustomerInterFace.php @@ -0,0 +1,5 @@ + '일괄 결제 ', 'invoice' => '청구서 발행', ]; } @@ -89,6 +94,24 @@ class PaymentService extends CustomerService } return $options; } + //서비스 설정 + public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): PaymentEntity + { + if ($serverPartEntity->getBilling() === PAYMENT['BILLING']['ONETIME']) { + if ($serverPartEntity->getServiceInfoUID() === null) { + throw new \Exception("일회성 부품 추가는 서비스정보가 정의된 후에만 가능합니다."); + } + } + $formDatas = []; + $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); + $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); + $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); + $formDatas['title'] = sprintf("[%s] 일회성 추가", $serverPartEntity->getPartEntity()->getTitle()); + $formDatas['amount'] = $serverPartEntity->getAmount(); + $formDatas['billing'] = $serverPartEntity->getBilling(); + $formDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리 + return $this->create($formDatas); + } //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void @@ -99,13 +122,12 @@ class PaymentService extends CustomerService //총 미납건수, 금액 public function getUnPaids(string $group, array $where = []): array { - $rows = $this->getModel()->groupBy($group) - ->select("COUNT(uid) as cnt, SUM(amount) as amount") + return $this->getModel()->groupBy($group) + ->select("serviceinfo_uid,COUNT(uid) as cnt, SUM(amount) as amount") ->where(['billing_at <=' => date('Y-m-d')]) ->where(['status' => STATUS['UNPAID']]) ->where($where) ->get()->getResult(); - return $rows; } //생성 @@ -113,7 +135,6 @@ class PaymentService extends CustomerService { // 관리자 UID는 현재 인증된 사용자로 설정 $formDatas['user_uid'] = $this->getMyAuth()->getUIDByAuthInfo(); - dd($formDatas); return parent::create($formDatas); } //수정 diff --git a/app/Services/Customer/ServiceService.php b/app/Services/Customer/ServiceService.php index e3515be..1b2dba2 100644 --- a/app/Services/Customer/ServiceService.php +++ b/app/Services/Customer/ServiceService.php @@ -199,22 +199,6 @@ class ServiceService extends CustomerService return $this->getModel()->query($sql, [$billing_at, $status]); } //기본기능 - - //서버정보 상태설정용 - private function setServer_process(ServiceEntity $entity, mixed $serverinfo_uid, string $status): ServiceEntity - { - //서버경우 서비스중으로 설정 - $serverEntity = $this->getServerService()->getEntity($serverinfo_uid); - if (!($serverEntity instanceof ServerEntity)) { - throw new \Exception("{$serverinfo_uid}에 해당하는 서버정보를 찾을수없습니다."); - } - //서버정보 상태수정 - $serverEntity = $this->getServerService()->modify( - $serverEntity, - ['serviceEntity' => $entity, 'status' => $status], - ); - return $entity->setServerEntity($serverEntity); - } //생성 public function create(array $formDatas): ServiceEntity { @@ -222,11 +206,11 @@ class ServiceService extends CustomerService throw new \Exception("서버가 지정되지 않았습니다."); } $entity = parent::create($formDatas); - return $this->setServer_process( + return $entity->setServerEntity($this->getServerService()->setService( $entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED'] - ); + )); } //수정 public function modify(mixed $entity, array $formDatas): ServiceEntity @@ -236,7 +220,7 @@ class ServiceService extends CustomerService } //기존서버정보 사용가능으로 설정 if ($entity->getServerInfoUID() && $entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { - $entity = $this->setServer_process( + $entity = $this->getServerService()->setService( $entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE'] @@ -246,7 +230,7 @@ class ServiceService extends CustomerService $entity = parent::modify($entity, $formDatas); //신규서버정보 사용중으로 설정 if ($entity->getServerInfoUID() !== $formDatas['serverinfo_uid']) { - $entity = $this->setServer_process( + $entity = $this->getServerService()->setService( $entity, $formDatas['serverinfo_uid'], STATUS['OCCUPIED'] @@ -258,7 +242,7 @@ class ServiceService extends CustomerService public function delete(mixed $entity): ServiceEntity { //기존서버정보 사용가능으로 설정 - $entity = $this->setServer_process( + $entity = $this->getServerService()->setService( $entity, $entity->getServerEntity()->getPK(), STATUS['AVAILABLE'] @@ -269,7 +253,6 @@ class ServiceService extends CustomerService public function history(mixed $entity, array $formDatas): ServiceEntity { //서비스 정보수정 - $entity = $this->getModel()->modify($entity, $formDatas); - return $entity; + return $this->getModel()->modify($entity, $formDatas); } } diff --git a/app/Services/Equipment/CSService.php b/app/Services/Equipment/CSService.php index 3cd3d79..bdf4fba 100644 --- a/app/Services/Equipment/CSService.php +++ b/app/Services/Equipment/CSService.php @@ -2,10 +2,13 @@ namespace App\Services\Equipment; +use App\Entities\Equipment\CSEntity; +use App\Entities\Equipment\ServerPartEntity; use App\Helpers\Equipment\CSHelper; +use App\Interfaces\Equipment\ServerPartInterface; use App\Models\Equipment\CSModel; -class CSService extends EquipmentService +class CSService extends EquipmentService implements ServerPartInterface { public function __construct() { @@ -51,6 +54,28 @@ class CSService extends EquipmentService return ['type', 'status']; } //기본 기능부분 + //서비스파트 설정 + public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): CSEntity + { + $entity = $this->getEntity($uid); + if (!($entity instanceof CSEntity)) { + throw new \Exception("{$uid}에 해당하는 CS정보를 찾을수없습니다."); + } + //부품정보에 서버정보 설정 및 서비스,고객정보 정의 + $formDatas = []; + if ($status === STATUS['AVAILABLE']) { + //사용가능 + $formDatas['clientinfo_uid'] = null; + $formDatas['serviceinfo_uid'] = null; + $formDatas['serverinfo_uid'] = null; + } else { + $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); + $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); + $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); + } + $formDatas['status'] = $status; + return $this->modify($entity, $formDatas); + } //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void diff --git a/app/Services/Equipment/IPService.php b/app/Services/Equipment/IPService.php index c1165a5..c7742ec 100644 --- a/app/Services/Equipment/IPService.php +++ b/app/Services/Equipment/IPService.php @@ -3,14 +3,14 @@ namespace App\Services\Equipment; use App\Entities\Equipment\IPEntity; -use App\Entities\Equipment\LineEntity; -use App\Entities\Equipment\ServerEntity; +use App\Entities\Equipment\ServerPartEntity; use App\Helpers\Equipment\IPHelper; +use App\Interfaces\Equipment\ServerPartInterface; use App\Models\Equipment\IPModel; use App\Services\Equipment\EquipmentService; use App\Services\Equipment\LineService; -class IPService extends EquipmentService +class IPService extends EquipmentService implements ServerPartInterface { private ?LineService $_lineService = null; public function __construct() @@ -78,6 +78,30 @@ class IPService extends EquipmentService } return $options; } + //서비스 설정 + public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): IPEntity + { + $entity = $this->getEntity($uid); + if (!($entity instanceof IPEntity)) { + throw new \Exception("{$uid}에 해당하는 IP정보를 찾을수없습니다."); + } + //부품정보에 서버정보 설정 및 서비스,고객정보 정의 + $formDatas = []; + //기존IP 사용자로 고객정보 설정 + $formDatas['old_clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); + if ($status === STATUS['AVAILABLE']) { + //사용가능 + $formDatas['clientinfo_uid'] = null; + $formDatas['serviceinfo_uid'] = null; + $formDatas['serverinfo_uid'] = null; + } else { + $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); + $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); + $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); + } + $formDatas['status'] = $status; + return $this->modify($entity, $formDatas); + } //List 검색용 //OrderBy 처리 public function setOrderBy(mixed $field = null, mixed $value = null): void diff --git a/app/Services/Equipment/ServerPartService.php b/app/Services/Equipment/ServerPartService.php index 88c095a..4cbc136 100644 --- a/app/Services/Equipment/ServerPartService.php +++ b/app/Services/Equipment/ServerPartService.php @@ -168,67 +168,25 @@ class ServerPartService extends EquipmentService return $options; } //파트별 정보 수정작업 - private function setPart_process(ServerPartEntity $entity, mixed $part_uid, string $status): mixed + private function setServerPart(ServerPartEntity $entity, mixed $part_uid, string $status): mixed { //Type에 따른 부품서비스 정의 switch ($entity->getType()) { case 'SWITCH': - $partService = $this->getSwitchService(); + $partEntity = $this->getSwitchService()->setServerPart($entity, $part_uid, $status); break; case 'IP': - $partService = $this->getIPService(); + $partEntity = $this->getIPService()->setServerPart($entity, $part_uid, $status); break; case 'CS': - $partService = $this->getCSService(); + $partEntity = $this->getCSService()->setServerPart($entity, $part_uid, $status); break; default: - $partService = $this->getPartService(); - break; - } - //부품정보가져오기 - $partEntity = $partService->getEntity($part_uid); - if (!$partEntity) { - throw new \Exception(__METHOD__ . "에서 오류:{$part_uid}에 해닫하는 {$entity->getType()}정보가 없습니다."); - } - $formDatas = []; - switch ($entity->getType()) { - case 'IP': - //기존IP 사용자로 고객정보 설정 - $formDatas['old_clientinfo_uid'] = $partEntity->getClientInfoUID(); - case 'SWITCH': - case 'CS': - //부품정보에 서버정보 설정 및 서비스,고객정보 정의 - if ($status === STATUS['AVAILABLE']) { - //사용가능 - $formDatas['clientinfo_uid'] = null; - $formDatas['serviceinfo_uid'] = null; - $formDatas['serverinfo_uid'] = null; - } else { - $formDatas['clientinfo_uid'] = $entity->getClientInfoUID(); - $formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID(); - $formDatas['serverinfo_uid'] = $entity->getServerInfoUID(); - } - $formDatas['part_uid'] = $part_uid; - $formDatas['status'] = $status; - $partEntity = $partService->modify($partEntity, $formDatas); - break; + throw new \Exception(__METHOD__ . "에서 오류발생: {$entity->getType()}은 지정되지 않은 부품파트입니다."); + // break; } return $partEntity; } - //일회성 결제 추가 처리 - private function setPayment_process(ServerPartEntity $entity): PaymentEntity - { - $formDatas = []; - $formDatas['clientinfo_uid'] = $entity->getClientInfoUID(); - $formDatas['serviceinfo_uid'] = $entity->getServiceInfoUID(); - $formDatas['serverinfo_uid'] = $entity->getServerInfoUID(); - $formDatas['title'] = sprintf("부품정보 [%s]에 대한 일회성 추가", $entity->getPartEntity()->getTitle()); - $formDatas['amount'] = $entity->getAmount(); - $formDatas['billing'] = $entity->getBilling(); - $formDatas['billing_at'] = date("Y-m-d"); //일회성은 지급일이 당일기준처리 - return $this->getPaymentService()->create($formDatas); - } - //부품연결정보생성 public function create(array $formDatas): ServerPartEntity { @@ -251,27 +209,20 @@ class ServerPartService extends EquipmentService $entity = parent::create($formDatas); //부품연결정보에 부품정보 정의 $entity = $entity->setPartEntity( - $this->setPart_process($entity, $formDatas['part_uid'], STATUS['OCCUPIED']) + $this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED']) ); //일회성인경우 결제정보에 추가한다. - if ($entity->getBilling() === PAYMENT['BILLING']['ONETIME']) { - $paymentEntity = $this->setPayment_process($entity); - } + $this->getPaymentService()->setServerPart($entity, 0, ""); return $entity; } //수정 public function modify(mixed $entity, array $formDatas): ServerPartEntity { //서버정보가져오기 - $serverEntity = null; - if (array_key_exists('serverEntity', $formDatas)) { - $serverEntity = $formDatas['serverEntity']; - } else { - if (!array_key_exists('serverinfo_uid', $formDatas)) { - throw new \Exception("서버 정보가 지정되지 않았습니다."); - } - $serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']); + if (!array_key_exists('serverinfo_uid', $formDatas)) { + throw new \Exception("서버 정보가 지정되지 않았습니다."); } + $serverEntity = $this->getServerService()->getEntity($formDatas['serverinfo_uid']); if (!($serverEntity instanceof ServerEntity)) { throw new \Exception("서버 정보가 지정되지 않았습니다."); } @@ -280,21 +231,20 @@ class ServerPartService extends EquipmentService $formDatas["serverinfo_uid"] = $serverEntity->getPK(); //기존 Part_UID와 신규 Part_UID가 다르면 기존 Part정보 사용가능으로 변경 if ($entity->getPartUID() != $formDatas['part_uid']) { - $this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']); + $this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']); } //기존 정보변경 $entity = parent::modify($entity, $formDatas); //부품연결정보에 부품정보 정의 - return $entity->setPartEntity($this->setPart_process( - $entity, - $formDatas['part_uid'], - STATUS['OCCUPIED'] - )); + return $entity->setPartEntity( + $this->setServerPart($entity, $formDatas['part_uid'], STATUS['OCCUPIED']) + ); } //삭제 public function delete(mixed $entity): ServerPartEntity { - $this->setPart_process($entity, $entity->getPartUID(), STATUS['AVAILABLE']); + //부품연결정보에 부품정보 정의 + $this->setServerPart($entity, $entity->getPartUID(), STATUS['AVAILABLE']); return parent::delete($entity); } } diff --git a/app/Services/Equipment/ServerService.php b/app/Services/Equipment/ServerService.php index 2842bfd..90fb984 100644 --- a/app/Services/Equipment/ServerService.php +++ b/app/Services/Equipment/ServerService.php @@ -121,19 +121,28 @@ class ServerService extends EquipmentService throw new \Exception("Server코드[{$formDatas['code']}의 형식이 맞지않습니다"); } } - //Service별 수정 + //서비스 설정 + public function setService(ServiceEntity $serviceEntity, mixed $uid, string $status): ServerEntity + { + $entity = $this->getEntity($uid); + if (!($entity instanceof ServerEntity)) { + throw new \Exception("{$uid}에 해당하는 서버정보를 찾을수없습니다."); + } + $formDatas = []; + $formDatas['clientinfo_uid'] = $serviceEntity->getClientInfoUID(); + $formDatas['serviceinfo_uid'] = $serviceEntity->getPK(); + $formDatas['status'] = $status; + //서버정보 상태수정 + return $this->modify($entity, $formDatas); + } + // 수정 public function modify(mixed $entity, array $formDatas): ServerEntity { //서비스정보가져오기 - $serviceEntity = null; - if (array_key_exists('serviceEntity', $formDatas)) { - $serviceEntity = $formDatas['serviceEntity']; - } else { - if (!array_key_exists('serviceinfo_uid', $formDatas)) { - throw new \Exception("서비스 정보가 지정되지 않았습니다."); - } - $serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']); + if (!array_key_exists('serviceinfo_uid', $formDatas)) { + throw new \Exception("서비스 정보가 지정되지 않았습니다."); } + $serviceEntity = $this->getServiceService()->getEntity($formDatas['serviceinfo_uid']); if ($serviceEntity instanceof ServiceEntity) { //서비스상태에 따라 if ($formDatas['status'] === STATUS['AVAILABLE']) { diff --git a/app/Services/Equipment/SwitchService.php b/app/Services/Equipment/SwitchService.php index 2ed688f..d2d3730 100644 --- a/app/Services/Equipment/SwitchService.php +++ b/app/Services/Equipment/SwitchService.php @@ -2,12 +2,14 @@ namespace App\Services\Equipment; +use App\Entities\Equipment\ServerPartEntity; use App\Entities\Equipment\SwitchEntity; use App\Helpers\Equipment\SwitchHelper; +use App\Interfaces\Equipment\ServerPartInterface; use App\Models\Equipment\SwitchModel; use App\Services\Equipment\EquipmentService; -class SwitchService extends EquipmentService +class SwitchService extends EquipmentService implements ServerPartInterface { public function __construct() { @@ -48,15 +50,27 @@ class SwitchService extends EquipmentService } //기본 기능부분 //FieldForm관련용 - //상태변경 - public function setStatus(string $code, string $status): SwitchEntity + //서비스파트 설정 + public function setServerPart(ServerPartEntity $serverPartEntity, mixed $uid, string $status): SwitchEntity { - //code의 경우 사용가능/사용중으로 설정작업 - $entity = $this->getEntity($code); - if (!$entity) { - throw new \Exception("{$code}에 대한 Switch Port정보를 찾을수 없습니다."); + $entity = $this->getEntity($uid); + if (!($entity instanceof SwitchEntity)) { + throw new \Exception("{$uid}에 해당하는 스위치정보를 찾을수없습니다."); } - return $this->getModel()->modify($entity, ['status' => $status]); + //부품정보에 서버정보 설정 및 서비스,고객정보 정의 + $formDatas = []; + if ($status === STATUS['AVAILABLE']) { + //사용가능 + $formDatas['clientinfo_uid'] = null; + $formDatas['serviceinfo_uid'] = null; + $formDatas['serverinfo_uid'] = null; + } else { + $formDatas['clientinfo_uid'] = $serverPartEntity->getClientInfoUID(); + $formDatas['serviceinfo_uid'] = $serverPartEntity->getServiceInfoUID(); + $formDatas['serverinfo_uid'] = $serverPartEntity->getServerInfoUID(); + } + $formDatas['status'] = $status; + return $this->modify($entity, $formDatas); } //List 검색용 //OrderBy 처리 diff --git a/app/Views/admin/client/detail.php b/app/Views/admin/client/detail.php index 384eb9d..52b921c 100644 --- a/app/Views/admin/client/detail.php +++ b/app/Views/admin/client/detail.php @@ -80,7 +80,7 @@ - $viewDatas['entity']->getPK()]) ?> + $viewDatas['entity']->getPK()]) ?> diff --git a/app/Views/admin/welcome/banner.php b/app/Views/admin/welcome/banner.php index a6dc64a..59ed39c 100644 --- a/app/Views/admin/welcome/banner.php +++ b/app/Views/admin/welcome/banner.php @@ -132,7 +132,7 @@
-
+
건/
금일 기준 미납 서비스
diff --git a/app/Views/cells/service/detail.php b/app/Views/cells/service/detail.php index a8331e0..1640311 100644 --- a/app/Views/cells/service/detail.php +++ b/app/Views/cells/service/detail.php @@ -7,7 +7,6 @@ - getUnPaids('serviceinfo_uid', ['serviceinfo_uid' => $entity->getPK()]) ?>
@@ -59,7 +58,7 @@ - + diff --git a/app/Views/layouts/admin/left_menu/customer.php b/app/Views/layouts/admin/left_menu/customer.php index 6417892..758c627 100644 --- a/app/Views/layouts/admin/left_menu/customer.php +++ b/app/Views/layouts/admin/left_menu/customer.php @@ -12,6 +12,6 @@ 서비스내역
- 결제내역 + 결제내역
\ No newline at end of file diff --git a/app/Views/templates/admin/index_header.php b/app/Views/templates/admin/index_header.php index 6a737ea..7894ce9 100644 --- a/app/Views/templates/admin/index_header.php +++ b/app/Views/templates/admin/index_header.php @@ -11,7 +11,7 @@ 서비스현황
미납금총: getPK()]['cnt'] ?>건,getPK()]['amount']) ?>원