public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     if (!$this->params['oid']) {
         \CADB\Lib\Error("조직 고유아이디를 입력하세요.");
     }
     $this->fields = \CADB\Organize::getFieldInfo(1);
     $this->organize = \CADB\Organize::getOrganizeByOid($this->params['oid']);
     if (!$this->organize) {
         \CADB\Lib\Error("조직정보를 검색할 수 없습니다.");
     }
     $ret = \CADB\Organize\DBM::delete($this->fields, $this->params['oid']);
     if (!$ret) {
         foreach ($this->params as $k => $v) {
             if (preg_match("/^o[0-9]+\$/i", $k)) {
                 $args[$k] = $v;
             }
         }
         $queryString = $this->makeQuery($this->params['q'], $args);
         \CADB\Lib\RedirectURL('/admin/orgs/' . ($queryString ? "?" . $queryString : ""));
     } else {
         \CADB\Lib\Error(\CADB\Organize\DBM::errorMsg());
     }
 }
 public function process()
 {
     $this->params['output'] = 'json';
     $context = \CADB\Model\Context::instance();
     $this->fields = \CADB\Organize::getFieldInfo(1);
     /* check field type */
     if ($this->params['mode'] == 'delete') {
         if (!$this->params['oid']) {
             \CADB\RespondJson::ResultPage(array(-1, '삭제할 단체 번호를 입력하세요'));
         }
     } else {
         if (!$this->params['nojo']) {
             \CADB\RespondJson::ResultPage(array(-1, '노조명을 입력하세요'));
         }
         foreach ($this->fields as $fid => $v) {
             if ($v['required']) {
                 if (!$this->params['f' . $fid]) {
                     \CADB\RespondJson::ResultPage(array($fid, $v['subject'] . '을 입력하세요'));
                 }
             }
         }
     }
     if ($this->params['oid']) {
         $this->organize = \CADB\Organize::getOrganizeByOid($this->params['oid']);
         if (!$this->organize) {
             \CADB\RespondJson::ResultPage(array(-2, '존재하지 않는 단체입니다.'));
         }
         if ($this->params['mode'] == 'delete') {
             $ret = \CADB\Organize\DBM::delete($this->fields, $this->params['oid']);
         } else {
             $ret = \CADB\Organize\DBM::modify($this->fields, $this->organize, $this->params);
         }
         if ($ret < 0) {
             \CADB\RespondJson::ResultPage(array(-3, '데이터베이스를 수정하는 도중 장애가 발생했습니다.'));
         }
     } else {
         $ret = \CADB\Organize\DBM::insert($this->fields, $this->params);
         if ($ret < 0) {
             \CADB\RespondJson::ResultPage(array(-3, \CADB\Organize\DBM::errorMsg() ? \CADB\Organize\DBM::errorMsg() : '데이터베이스에 입력하는 도중 장애가 발생했습니다.'));
         }
     }
     $this->oid = $ret;
 }
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     if (!$this->params['oid']) {
         \CADB\Lib\Error("조직 고유아이디를 입력하세요.");
     }
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Organize::getFieldInfo(1);
     $this->organize = \CADB\Organize::getOrganizeByOid($this->params['oid']);
     if (!$this->organize) {
         \CADB\Lib\Error("조직정보를 검색할 수 없습니다.");
     }
     $agreement = \CADB\Agreement::getAgreementsByOid($this->params['oid']);
     //		$this->fields['nid'] = array('subject' => '단체협약','type'=>'int','multiple'=>true);
     if ($agreement && is_array($agreement)) {
         foreach ($agreement as $ag) {
             $this->organize['nid'][] = array('nid' => $ag['nid'], 'did' => $ag['did'], 'subject' => $ag['subject']);
         }
     }
     foreach ($this->fields as $fid => $f) {
         if ($f['type'] == 'taxonomy') {
             $taxonomy_cids[] = $f['cid'];
         }
     }
     if (count($taxonomy_cids)) {
         $this->taxonomy = \CADB\Taxonomy::getTaxonomy($taxonomy_cids);
     }
     $cids = array_keys($this->taxonomy);
     if ($cids) {
         $taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($cids);
         foreach ($taxonomy_terms as $cid => $terms) {
             $this->taxonomy_terms[$cid] = \CADB\Taxonomy::makeTree($terms);
         }
     }
 }
 public static function checkParent($depth, $args)
 {
     $dbm = \CADB\DBM::instance();
     for ($d = 1; $d < min($depth, 5); $d++) {
         $parent = $args['p' . $d];
         if ($d == 1) {
             $name = $args['nojo'];
         } else {
             $name = $args['sub' . ($d - 1)];
         }
         if ($name && !$parent) {
             self::setErrorMsg("상급단체 " . $name . "는 DB에 없는 단위이거나, 선택하기에서 선택하지 않으셨습니다.");
             return -1;
         }
         if ($name && $parent) {
             $org = \CADB\Organize::getOrganizeByOid($parent);
             if (!$org) {
                 self::setErrorMsg("상급단체 " . $name . "는 DB에 없는 단위입니다.");
                 return -1;
             }
             if ($d == 1) {
                 $o_name = $org['nojo'];
             } else {
                 $o_name = $org['sub' . ($d - 1)];
             }
             if ($o_name != $name) {
                 self::setErrorMsg("상급단체 " . $name . "이 DB에 있는 상급 단위 이름과 다릅니다.");
                 return -1;
             }
         }
     }
     return 0;
 }