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); }
public function process() { $this->params['output'] = 'json'; $context = \CADB\Model\Context::instance(); $fields = \CADB\Fields::getFields('all', 1); $this->fields = array(); foreach ($fields as $f => $v) { if (!$this->fields[$v['table']]) { $this->fields[$v['table']] = array(); } $this->fields[$v['table']][] = array('field' => 'f' . $f, 'subject' => $v['subject'], 'type' => $v['type'], 'multiple' => $v['multiple'] ? true : false, 'cid' => $v['cid']); } $this->fields['owner'][] = array('field' => 'owner', 'subject' => '운영자', 'type' => 'int', 'multiple' => false); $this->fields['organize'][] = array('field' => 'nid', 'subject' => '단체협약', 'type' => 'int', 'multiple' => true); $nid = \CADB\Guide::getCurrent($this->params['nid'] ? $this->params['nid'] : 1); foreach ($this->params as $k => $v) { if (preg_match("/^[ao]{1}[0-9]+\$/i", $k)) { $args[$k] = $v; } } if ($this->params['q'] && !mb_detect_encoding($this->params['q'], 'UTF-8', true)) { $this->params['q'] = mb_convert_encoding($this->params['q'], 'utf-8', 'euckr'); } $this->params['page'] = 1; /* organize search */ $organize_total_cnt = \CADB\Organize::totalCnt($this->params['q'], $args); $organize_total_page = (int) (($organize_total_cnt - 1) / ($this->params['limit'] ? $this->params['limit'] : 10)) + 1; if ($organize_total_cnt) { $this->organize = \CADB\Organize::getList($this->params['q'], 1, $this->params['limit'] ? $this->params['limit'] : 10, $args); for ($i = 0; $i < count($this->organize); $i++) { if (\CADB\Privilege::checkOrganizes($this->organize[$i])) { $this->organize[$i]['owner'] = 1; } else { $this->organize[$i]['owner'] = 0; } $this->organize[$i]['nid'] = array(); $agreement = \CADB\Agreement::getAgreementsByOid($this->organize[$i]['oid'], $this->organize[$i]['vid']); if ($agreement && is_array($agreement)) { foreach ($agreement as $ag) { $this->organize[$i]['nid'][] = array('nid' => $ag['nid'], 'did' => $ag['did'], 'subject' => $ag['subject']); } } } $this->result['orgs'] = array('total_cnt' => $organize_total_cnt, 'total_page' => $organize_total_page, 'count' => @count($this->organize), 'more' => $organize_total_cnt > @count($this->organize) ? 1 : 0); } else { $this->result['orgs'] = array('total_cnt' => 0, 'total_page' => 0, 'count' => 0, 'more' => 0, 'error' => '검색결과가 없습니다.'); } /* standard guide */ $taxonomys = \CADB\Guide::getTaxonomy($nid); foreach ($this->params as $k => $v) { if (preg_match("/^a[0-9]+\$/i", $k) && in_array((int) substr($k, 1), $taxonomys)) { $g_args[$k] = $v; } } $this->standard = \CADB\Guide::getList($this->params['q'], $g_args); $this->result['standard'] = array('q' => $this->params['q'], 'taxonomy' => $args, 'count' => @count($this->standard) > 0 ? @count($this->standard) : 0); /* articles */ \CADB\Agreement::setTaxonomy($taxonomys); $total_cnt = \CADB\Agreement::totalCnt($this->params['q'], $args); $total_page = (int) (($total_cnt - 1) / ($this->params['limit'] ? $this->params['limit'] : 10)) + 1; if ($total_cnt) { $this->articles = \CADB\Agreement::getList($this->params['q'], 1, $this->params['limit'] ? $this->params['limit'] : 10, $args); $this->result['articles'] = array('total_cnt' => $total_cnt, 'total_page' => $total_page, 'count' => @count($this->articles), 'more' => $total_cnt > @count($this->articles) ? 1 : 0); } else { $this->result['articles'] = array('total_cnt' => 0, 'total_page' => 0, 'count' => 0, 'more' => 0, 'error' => '검색결과가 없습니다.'); } }
public function process() { $this->output = 'json'; $context = \CADB\Model\Context::instance(); if (!($rdb = $context->getProperty('service.redis'))) { \CADB\RespondJson::ResultPage(array(-1, '자동완성 기능이 활성화 되어 있지 않습니다.')); } if (!$this->themes) { $this->themes = $context->getProperty('service.themes'); } $nid = \CADB\Guide::getCurrent(); $cids = \CADB\Guide::getTaxonomy(); $guide_taxonomy = \CADB\Taxonomy::getTaxonomy($cids); $fields = \CADB\Fields\DBM::searchField('autocomplete', 1); $field_cids = array(); $this->fields = array(); if (is_array($fields)) { foreach ($fields as $fid => $f) { switch ($f['type']) { case 'taxonomy': $field_cids[] = $f['cid']; break; case 'char': $this->fields[$f['table']][$fid] = $f; break; } } } if (count($field_cids)) { $field_taxonomy = \CADB\Taxonomy::getTaxonomy($field_cids); $this->taxonomy = array_merge($guide_taxonomy, $field_taxonomy); } else { $this->taxonomy = $guide_taxonomy; } if (is_array($this->taxonomy) && @count($this->taxonomy)) { $txcids = array(); foreach ($this->taxonomy as $cid => $tx) { $txcids[] = $cid; } $this->taxonomy_terms = \CADB\Taxonomy::getTaxonomyTerms($txcids); foreach ($this->taxonomy_terms as $cid => $taxo_terms) { foreach ($taxo_terms as $tid => $terms) { $this->buildAutocomplete($terms['name'], $terms['name'], 20); } } } \CADB\Organize::setMode('admin'); $total_cnt = \CADB\Organize::totalCnt('', null); $orgs = \CADB\Organize::getList('', -1, 0, null); for ($i = 0; $i < $total_cnt; $i++) { $row = $orgs[$i]; if ($row['nojo']) { $nojo = trim($row['nojo']); $this->buildAutocomplete($nojo, $nojo, 15); $this->spaceBuildAutocomplete($nojo, $nojo, 15); if (preg_match("/^전국/i", $nojo)) { $nojo2 = preg_replace("/^전국/i", "", trim($nojo)); $this->buildAutocomplete($nojo2, $nojo, 15); $this->spaceBuildAutocomplete($nojo2, $nojo, 15); } } for ($s = 1; $s <= 4; $s++) { $score = 15 - $s * 3; if ($row['sub' . $s]) { $name = trim($row['sub' . $s]); $this->buildAutocomplete($name, $name, $score); $this->spaceBuildAutocomplete($name, $name, $score); } } if (is_array($this->fields['organize'])) { foreach ($this->fields['organize'] as $fid => $f) { if ($row['f' . $fid]) { $v = explode(",", $row['f' . $fid]); for ($k = 0; $k < @count($v); $k++) { $name = trim($v[$k]); $this->buildAutocomplete($name, $name, 1); $this->spaceBuildAutocomplete($name, $name, 1); } } } } } if (is_array($this->fields)) { foreach ($this->fields as $table => $fieldlist) { if ($table == 'organize') { continue; } } } $this->remakeRedis(); }
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; }