Beispiel #1
0
 /**
  * @abstract    获取部门JSON数据
  * @param       number $parent_id 上级菜单ID
  * @return      null
  */
 public function getdeptAction()
 {
     $data = array();
     // 请求参数
     $request = $this->getRequest()->getParams();
     $option = isset($request['option']) ? $request['option'] : 'list';
     $dept = new Hra_Model_Dept();
     if ($option == 'list') {
         $data = $dept->getList();
     } else {
         // 请求部门的层级ID
         $parentId = isset($request['parentId']) ? $request['parentId'] : 0;
         // 获取部门数据
         $data = $dept->getData($parentId);
     }
     // 将部门数据转为json格式并输出
     echo Zend_Json::encode($data);
     exit;
 }
Beispiel #2
0
 /**
  * @abstract    获取文件JSON数据
  * @return      null
  */
 public function getlistAction()
 {
     // 请求参数
     $request = $this->getRequest()->getParams();
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $limit = $request['limit'];
     $start = $request['start'];
     $dept = new Hra_Model_Dept();
     $deptdata = $dept->getList();
     $where = " 1=1 ";
     if (isset($request['search_key']) && $request['search_key']) {
         $where .= " and (file_names like '%" . $request['search_key'] . "%' \n                    or doc_names like '%" . $request['search_key'] . "%' \n                    or subject like '%" . $request['search_key'] . "%')";
     }
     if (isset($request['search_object']) && $request['search_object']) {
         $where .= " and outsendtype = '" . $request['search_object'] . "'";
     }
     if (isset($request['search_objectname']) && $request['search_objectname']) {
         $where .= " and (partner like '%" . $request['search_objectname'] . "%' ";
         foreach ($deptdata as $dd) {
             if (strpos($dd['name'], $request['search_objectname']) !== false) {
                 $deptid = $dd['id'];
                 $where .= " or dept = {$deptid}";
             }
         }
         $sql = "select group_concat(code) as codes from oa_bpartner where cname like '%" . $request['search_objectname'] . "%' or ename like '%" . $request['search_objectname'] . "%'";
         $depts = $dept->getAdapter()->query($sql)->fetchObject();
         if ($depts && $depts->codes) {
             $ds = explode(',', $depts->codes);
             for ($i = 0; $i < count($ds); $i++) {
                 $ds[$i] = "'" . $ds[$i] . "'";
             }
         }
         if (isset($ds)) {
             $where .= " or partner in (" . implode(',', $ds) . "))";
         } else {
             $where .= ")";
         }
     }
     if (isset($request['search_date_from']) && $request['search_date_from']) {
         $where .= " and handle_time >= '" . $request['search_date_from'] . " 00:00:00'";
     }
     if (isset($request['search_date_to']) && $request['search_date_to']) {
         $where .= " and handle_time <= '" . $request['search_date_to'] . " 23:59:59'";
     }
     if (isset($request['search_cc']) && $request['search_cc']) {
         $where .= " and (t1.to like '%" . $request['search_cc'] . "%' or t1.cc like '%" . $request['search_cc'] . "%')";
     }
     if (isset($request['search_sendtype']) && $request['search_sendtype']) {
         $where .= " and sendtype = '" . $request['search_sendtype'] . "'";
     }
     $send = new Dcc_Model_Send();
     $data = $send->getList($where, $start, $limit);
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['handle_time'] = strtotime($data[$i]['handle_time']);
         if ($data[$i]['cname']) {
             $data[$i]['partner_name'] = $data[$i]['partner'] . $data[$i]['cname'];
         } else {
             if ($data[$i]['ename']) {
                 $data[$i]['partner_name'] = $data[$i]['partner'] . $data[$i]['ename'];
             } else {
                 $data[$i]['partner_name'] = $data[$i]['partner'];
             }
         }
         if ($data[$i]['sendtype'] == '内发' && $data[$i]['dept']) {
             // 获取部门名称
             $dept_name = array();
             foreach (explode(',', $data[$i]['dept']) as $d) {
                 foreach ($deptdata as $dept) {
                     if ($dept['id'] == $d) {
                         $dept_name[] = $dept['name'];
                     }
                 }
             }
             $data[$i]['partner_name'] = implode(',', $dept_name);
         }
         if ($data[$i]['linkman']) {
             $data[$i]['linkman'] = $data[$i]['contact_name'] . '(' . $data[$i]['linkman'] . ')';
         }
         // 产品型号
         if ($data[$i]['doc_names']) {
             $codes = array();
             foreach (explode(',', $data[$i]['doc_names']) as $code) {
                 $codes[] = "'" . $code . "'";
             }
             $sql = "select GROUP_CONCAT(t1.model_internal) as model from oa_product_catalog t1 inner join oa_doc_code t2 on t1.id = t2.project_no where t2.code in (" . implode(',', $codes) . ")";
             $res = $send->getAdapter()->query($sql)->fetchObject();
             if ($res && $res->model) {
                 $data[$i]['model'] = $res->model;
             }
         }
         // 去冗余
         /* $rids = array();
            $rcodes = array();
            $ids = explode(',', $data[$i]['doc_ids']);
            $codes = explode(',', $data[$i]['doc_names']);
            $name = $data[$i]['file_names'];
            $fileids = $data[$i]['file_ids'];
            $k = 0;
            if(count($ids) > 1 && count(explode(',', $fileids)) == 0) {
                foreach($ids as $id) {
                    $code = $codes[$k++];
                    if($send->getAdapter()->query("select t1.id from oa_doc_files t1  where FIND_IN_SET(t1.file_ids, $fileids) and state = 'Active' and t1.id = $id and FIND_IN_SET(t1.name, '$name') ")->rowCount() > 0) {
                        $rids[] = $id;
                        $rcodes[]  = $code;
                    }
                }
                $data[$i]['doc_ids'] = implode(',', $rids);
                $data[$i]['doc_names'] = implode(',', $rcodes);
            } */
     }
     $resutl = array("totalCount" => $send->getAdapter()->query("select t1.id from oa_doc_send t1 where ({$where})")->rowCount(), "topics" => $data);
     echo Zend_Json::encode($resutl);
     exit;
 }