public function process()
 {
     $context = \CADB\Model\Context::instance();
     \CADB\Lib\importResource('app-guide-edit');
     $this->layout = 'admin';
     if (!$this->params['nid']) {
         \CADB\Lib\Error('모범단체협약서 번호를 입력하세요.');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Guide::getFieldInfo(1);
     $this->guide = \CADB\Guide\DBM::getGuide($this->params['nid']);
     if (!$this->guide) {
         \CADB\Lib\Error('존재하지않는 모범단체협약서입니다.');
     }
     $this->taxonomylist = \CADB\Taxonomy\DBM::getTaxonomyList();
     $taxonomys = \CADB\Guide\DBM::getTaxonomy($this->guide['cid']);
     $this->taxonomy = \CADB\Taxonomy::getTaxonomy($taxonomys);
     $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($taxonomys);
     foreach ($taxonomy_terms as $c => $taxo) {
         foreach ($taxo as $t => $term) {
             $this->taxonomy_terms[$c][$term['parent']][$t] = $term;
         }
     }
     $this->current_taxonomys = $taxonomys;
     $clauses = \CADB\Guide\DBM::getClauses($this->params['nid']);
     $c = 0;
     foreach ($clauses as $i => $cl) {
         if (!$c) {
             $this->preamble = \CADB\Guide::getClause($cl['id']);
         }
         if (!$cl['parent']) {
             $cl['nsubs'] = 0;
             $cl['articles'] = array();
             $this->indexes[$i] = $cl;
             $index_map[$cl['id']] = $i;
         } else {
             $idx = $index_map[$cl['parent']];
             $this->indexes[$idx]['articles'][] = $cl;
             $this->indexes[$idx]['nsubs']++;
         }
         $c++;
     }
     if ($this->preamble) {
         $this->preamble['terms'] = \CADB\Guide\DBM::getClauseTerms($this->guide['vid'], $this->preamble['id']);
     }
 }
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->params['table'] = 'guide';
     $this->params['mode'] = 'delete';
     if (!$this->params['nid']) {
         \CADB\Lib\Error('모범단협 번호를 지정하세요');
     }
     $this->guide = \CADB\Guide\DBM::getGuide($this->params['nid']);
     if (!$this->guide) {
         \CADB\Lib\Error('존재하지 않는 모범단협번호입니다');
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     \CADB\Guide\DBM::deleteGuide($this->guide);
     $this->nid = $this->params['nid'];
     \CADB\Lib\RedirectURL('/admin/standards');
 }
 private function validateGuide()
 {
     if ($this->params['mode'] != 'add') {
         if (!$this->params['nid']) {
             \CADB\RespondJson::ResultPage(array(-1, '모범단협번호를 지정하세요'));
         }
         $this->guide = \CADB\Guide\DBM::getGuide($this->params['nid']);
         if (!$this->guide) {
             \CADB\RespondJson::ResultPage(array(-1, '존재하지 않는 모범단협번호입니다'));
         }
     }
     if ($this->params['mode'] != 'delete') {
         if (!$this->params['subject']) {
             \CADB\RespondJson::ResultPage(array(-2, '모범단협 제목을 입력하세요'));
         }
         if (!$this->params['year']) {
             \CADB\RespondJson::ResultPage(array(-2, '모범단협 년도를 입력하세요'));
         }
     }
 }