public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $fields = \CADB\Guide::getFieldInfo(1);
     if (!$this->params['id']) {
         $this->result = array('found' => false, 'error' => '모범단협 조항번호를 입력하세요');
     } else {
         $this->fields = array();
         foreach ($fields as $f => $v) {
             $this->fields[] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']);
         }
         $this->standard = \CADB\Guide::getClause($this->params['id']);
         if (!$this->standard) {
             $this->result = array('found' => false, 'error' => '존재하지 않는 모범단협 조항입니다');
         } else {
             $this->result = array('found' => true);
             $terms = \CADB\Guide\DBM::getClauseTaxonomyTerms($this->standard['nid'], $this->standard['id']);
             $this->standard['taxonomy'] = [];
             if (is_array($terms)) {
                 $this->standard['taxonomy'] = [];
                 foreach ($terms as $t => $taxo) {
                     $this->standard['taxonomy'][] = array('tid' => $t, 'cid' => $taxo['cid'], 'name' => $taxo['name']);
                 }
             }
         }
     }
 }
 public function process()
 {
     if (!$this->params['output']) {
         $this->params['output'] = 'json';
     }
     $context = \CADB\Model\Context::instance();
     if (!$this->params['nid']) {
         if ($this->params['output'] != 'json') {
             \CADB\Lib\Error('복사할 모범단체협약서 번호를 입력하세요.');
         } else {
             \CADB\RespondJson::ResultPage(array(-1, '복사할 모범단체협약서 번호를 입력하세요.'));
         }
     }
     $this->nid = \CADB\Guide\DBM::fork($this->params['nid']);
     if (!$this->nid) {
         if ($this->params['output'] != 'json') {
             \CADB\Lib\Error(\CADB\Guide\DBM::error());
         } else {
             \CADB\RespondJson::ResultPage(array(-1, \CADB\Guide\DBM::error()));
         }
     } else {
         if ($this->params['output'] != 'json') {
             \CADB\Lib\RedirectURL(\CADB\Lib\url("admin/standards/edit") . "?nid=" . $this->nid);
         } else {
             \CADB\RespondJson::ResultPage(array($this->nid, \CADB\Lib\url("admin/standards/edit") . "?nid=" . $this->nid));
         }
     }
 }
 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()
 {
     $this->layout = 'admin';
     //		$this->css[] = 'app-admin-standard.css';
     $context = \CADB\Model\Context::instance();
     if (!$this->params['page']) {
         $this->params['page'] = 1;
     }
     $this->total_cnt = \CADB\Guide\DBM::totalCnt($this->params['q']);
     $this->page = $this->params['page'];
     $this->limit = $this->params['limit'] ? $this->params['limit'] : 15;
     $this->total_page = (int) (($this->total_cnt - 1) / $this->limit) + 1;
     if ($this->total_cnt && $this->params['page'] <= $this->total_page) {
         $this->standards = \CADB\Guide\DBM::getList($this->params['q'], $this->params['page'], $this->limit);
     }
     $this->queryString = "?" . $this->makeQuery($this->params['q']);
     $this->pagelink = \CADB\Lib\url("admin/standards") . "?" . $this->makeQuery($this->params['q']);
 }
 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 deleteClause()
 {
     \CADB\Guide\DBM::deleteClause($this->clause);
     \CADB\RespondJson::PrintResult(array('error' => $this->clause['id'], 'message' => '삭제되었습니다'));
 }