addClassName('Service'); } public function getModelClass(): ServiceModel { return new ServiceModel(); } public function getEntityClass(): ServiceEntity { return new ServiceEntity(); } public function getFormFields(): array { return [ "clientinfo_uid", "ownerinfo_uid", "title", "type", "location", "switch", "code", "raid", "billing_at", "start_at", "status" ]; } public function getFilterFields(): array { return ["clientinfo_uid", 'ownerinfo_uid', 'type', 'location', 'switch', 'code', 'raid', 'status']; } public function getBatchJobFields(): array { return ['status']; } public function getIndexFields(): array { return ['clientinfo_uid', 'ownerinfo_uid', 'title', 'type', 'location', 'switch', 'code', 'raid', 'billing_at', 'start_at', 'updated_at', 'status']; } public function getCodeService(): CodeService { if (!$this->_codeService) { $this->_codeService = new CodeService($this->request); } return $this->_codeService; } //Entity의 관련객체정의용 protected function setRelatedEntity(mixed $entity): ServiceEntity { //고객정보정의 $entity->setClient($this->getClient($entity->getClientUID())); //관리자정보정의 $entity->setOwner($this->getClient($entity->getOwnerUID())); return parent::setRelatedEntity($entity); } //기본 기능부분 //다음 달로 결제일을 연장합니다. public function extendPaymentDate(ServiceEntity $entity): void { $this->getModel()->extendPaymentDate($entity->getPK()); } public function create(array $formDatas, mixed $entity = null): ServiceEntity { //code의 경우 서비스중으로 설정작업 $this->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); } }