<?php

namespace lib\Controllers\DBMS\Client;

use lib\Helpers\ServiceHelper;

class MemoController extends ClientController
{
    public function __construct()
    {
        parent::__construct();
        $this->getView()->setPath('memo');
        $this->helper = new ServiceHelper();
    } //
    //사용자용메모장 , customer_memo.php
    //CLI 접속방법 : php index.php site/client/memo/update_form/client_code/코드번호
    //WEB 접속방법 : http://localhost/site/client/memo/update_form/client_code/코드번호
    public function update_form(array $params)
    {
        if (!array_key_exists('client_code', $params)) {
            throw new \Exception("client_code 값이 정의되지 않았습니다.");
        }
        $client_code = $params['client_code'];
        $this->getClientService()->getModel()->where("Client_Code", $client_code);
        $entity = $this->getClientService()->getEntity();
        if (!$entity) {
            throw new \Exception("[$client_code]에 해당하는 사용자정보가 존재하지 않습니다.");
        }
        $this->entity = $entity;
        return $this->render(__FUNCTION__);
    }

    public function update(array $params)
    {
        if (!array_key_exists('client_code', $params)) {
            throw new \Exception("client_code 값이 정의되지 않았습니다.");
        }
        $client_code = $params['client_code'];
        $this->getClientService()->getModel()->where("Client_Code", $client_code);
        $entity = $this->getClientService()->getEntity();
        if (!$entity) {
            throw new \Exception("[$client_code]에 해당하는 사용자정보가 존재하지 않습니다.");
        }
        return $this->render(__FUNCTION__);
    }
} //Class
