コード例 #1
0
 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());
     }
 }
コード例 #2
0
 public function process()
 {
     \CADB\Lib\importResource('app-field-edit');
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     $this->taxonomy = \CADB\Taxonomy\DBM::getTaxonomyList();
     $this->fields = \CADB\Organize::getFieldInfo(0);
 }
コード例 #3
0
 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;
 }
コード例 #4
0
 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);
         }
     }
 }
コード例 #5
0
 public function process()
 {
     $this->layout = 'admin';
     $this->fullscreen = true;
     //		$this->css[] = 'app-admin-article.css';
     $context = \CADB\Model\Context::instance();
     \CADB\Organize::setMode('admin');
     $fields = \CADB\Organize::getFieldInfo(1);
     $cids = 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']);
         if ($v['type'] == 'taxonomy') {
             $cids[] = $v['cid'];
         }
     }
     if (@count($cids)) {
         $this->taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($cids);
     }
     foreach ($this->params as $k => $v) {
         if (preg_match("/^o[0-9]+\$/i", $k)) {
             $args[$k] = $v;
         }
     }
     if (!$this->params['page']) {
         $this->params['page'] = 1;
     }
     $this->total_cnt = \CADB\Organize::totalCnt($this->params['q'], $args);
     $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->orgs = \CADB\Organize::getList($this->params['q'], $this->params['page'], $this->limit, $args);
     }
     $this->queryString = "?" . $this->makeQuery($this->params['q'], $args);
     $this->pagelink = \CADB\Lib\url("admin/orgs") . "?" . $this->makeQuery($this->params['q'], $args);
 }
コード例 #6
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     $this->layout = 'admin';
     if (!$this->themes) {
         $this->themes = $context->getProperty('service.themes');
     }
     $this->fields = \CADB\Organize::getFieldInfo(1);
     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);
         }
     }
 }
コード例 #7
0
 private static function makeArgsQuery($args, $type)
 {
     $key = (int) substr($k, 1);
     $c = 0;
     if ($type == 1) {
         \CADB\Organize::getFieldInfo();
         $que = \CADB\Organize::makeQuery($q, $args, 't.rid');
     } else {
         foreach ($args as $k => $v) {
             $t = substr($k, 0, 1);
             $key = (int) substr($k, 1);
             if ($t == 'o' && self::$fields['field'][$key]) {
                 switch (self::$fields[$key]['type']) {
                     case 'taxonomy':
                         if (!is_array($v)) {
                             $v = array($v);
                         }
                         switch (self::$fields[$key]['table']) {
                             case 'agreement':
                                 $que .= ($c++ ? " AND " : "") . "(t.`table` = 'agreement' AND t.tid IN (" . implode(",", $v) . "))";
                                 break;
                             default:
                                 break;
                         }
                         break;
                     default:
                         break;
                 }
             } else {
                 if ($t == 'a' && self::$fields['taxonomy'][$key]) {
                     $que .= ($c++ ? " AND " : "") . "(t.`table` = 'agreement' AND t.tid IN (" . implode(",", $v) . "))";
                 }
             }
         }
     }
     return $que;
 }
コード例 #8
0
 public function process()
 {
     $context = \CADB\Model\Context::instance();
     \CADB\Organize::setMode('admin');
     $fields = \CADB\Organize::getFieldInfo(1);
     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']);
     }
     foreach ($this->params as $k => $v) {
         if (preg_match("/^o[0-9]+\$/i", $k)) {
             $args[$k] = $v;
         }
     }
     $this->total_cnt = \CADB\Organize::totalCnt($this->params['q'], $args);
     $this->orgs = \CADB\Organize::getList($this->params['q'], -1, 0, $args);
     $objPHPExcel = new \PHPExcel();
     $objPHPExcel->getProperties()->setCreator($context->getProperty('service.title'))->setLastModifiedBy($context->getProperty('service.title'))->setTitle('조직현황')->setSubject('조직현황')->setDescription('조직현황')->setKeywords('조직현황')->setCategory('조직현황');
     $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A1', '조직번호')->setCellValue('B1', '노조명')->setCellValue('C1', '본부명')->setCellValue('D1', '지부명')->setCellValue('E1', '지회명')->setCellValue('F1', '분회명');
     for ($i = 0; $i < count($this->fields); $i++) {
         $fidx = chr(ord("G") + $i);
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue($fidx . "1", $this->fields[$i]['subject']);
     }
     for ($i = 0; $i < @count($this->orgs); $i++) {
         $idx = 2 + $i;
         $objPHPExcel->setActiveSheetIndex(0)->setCellValue("A" . $idx, $this->orgs[$i]['oid'])->setCellValue("B" . $idx, $this->orgs[$i]['nojo'])->setCellValue("C" . $idx, $this->orgs[$i]['sub1'])->setCellValue("D" . $idx, $this->orgs[$i]['sub2'])->setCellValue("E" . $idx, $this->orgs[$i]['sub3'])->setCellValue("F" . $idx, $this->orgs[$i]['sub4']);
         for ($j = 0; $j < count($this->fields); $j++) {
             $fidx = chr(ord("G") + $j);
             $v = $this->orgs[$i][$this->fields[$j]['field']];
             switch ($this->fields[$j]['type']) {
                 case 'taxonomy':
                     if ($v) {
                         $vl = "";
                         $c = 0;
                         foreach ($v as $t => $value) {
                             $vl .= ($c++ ? "," : "") . $value['name'];
                         }
                         $objPHPExcel->setActiveSheetIndex(0)->setCellValue($fidx . $idx, $vl);
                     }
                     break;
                 default:
                     $objPHPExcel->setActiveSheetIndex(0)->setCellValue($fidx . $idx, $v);
                     break;
             }
         }
     }
     $objPHPExcel->getActiveSheet()->setTitle('조직현황');
     $objPHPExcel->setActiveSheetIndex(0);
     $filename = "organize." . date("Y.m.d") . ".xls";
     header('Content-Type: application/vnd.ms-excel');
     header('Content-Disposition: attachment;filename="' . $filename . '"');
     header('Cache-Control: max-age=0');
     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
     // Date in the past
     header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
     // always modified
     header('Cache-Control: cache, must-revalidate');
     // HTTP/1.1
     header('Pragma: public');
     // HTTP/1.0
     $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
     $objWriter->save('php://output');
     exit;
 }