Esempio n. 1
0
 /**
  * @abstract    获取文件JSON数据
  * @return      null
  */
 public function getfilesAction()
 {
     $this->archiveFile();
     // 请求参数
     $request = $this->getRequest()->getParams();
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $dept = $user_session->user_info['dept_id'];
     $archive = 0;
     if (isset($request['search_archive']) && ($request['search_archive'] == '已归档' || $request['search_archive'] == '1')) {
         $archive = 1;
     }
     $where = "1 = 1";
     // 是否用于文件归档
     if (isset($request['type']) && $archive == 0) {
         $where = "t1.archive = 0";
     }
     if (!isset($request['all'])) {
         $where .= " and t1.private=0";
     }
     if (isset($request['full'])) {
         $where = "1=1";
     }
     foreach ($request as $k => $v) {
         if ($v != '') {
             if ("search_upload_date_from" == $k && $v) {
                 $where .= " and t1.upload_time >= '" . str_replace('T', ' ', $v) . "'";
             } else {
                 if ("search_upload_date_to" == $k && $v) {
                     $where .= " and t1.upload_time <= '" . str_replace('T00:00:00', ' 23:59:59', $v) . "'";
                 } else {
                     if ("search_archive_date_from" == $k && $v) {
                         $where .= " and t1.archive_time >= '" . str_replace('T', ' ', $v) . "'";
                     } else {
                         if ("search_archive_date_to" == $k && $v) {
                             $where .= " and t1.archive_time <= '" . str_replace('T00:00:00', ' 23:59:59', $v) . "'";
                         } else {
                             if ("search_archive" == $k) {
                                 if (!isset($request['full']) || $request['full'] != 1) {
                                     $where .= " and t1.archive = {$archive}";
                                 }
                             } else {
                                 if ("search_del" == $k) {
                                     $where .= " and t1.del = {$v}";
                                 } else {
                                     $col = str_replace('search_', '', $k);
                                     if ($col != $k) {
                                         // 查询条件
                                         $where .= " and ifnull(t1." . $col . ",'') like '%" . $v . "%'";
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $upload = new Dcc_Model_Upload();
     if (isset($request['full'])) {
         $where1 = $where2 = "";
     } else {
         $where1 = " and (t1.create_user = {$user} or t1.update_user = {$user})";
         $where2 = " and (FIND_IN_SET({$user}, share_user) or FIND_IN_SET({$dept}, share_dept))";
     }
     $data = $upload->getFilesList($where . $where1, $where . $where2);
     $employee = new Hra_Model_Employee();
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['create_time'] = strtotime($data[$i]['create_time']);
         $data[$i]['update_time'] = strtotime($data[$i]['update_time']);
         $data[$i]['upload_time'] = strtotime($data[$i]['upload_time']);
         $data[$i]['archive'] = $data[$i]['archive'] == 1 ? true : false;
         // 共享期间
         $begin = $data[$i]['share_time_begin'];
         $end = $data[$i]['share_time_end'];
         $data[$i]['share_time'] = $begin == '2013-01-01' ? '' : $begin;
         $data[$i]['share_time'] .= "~";
         $data[$i]['share_time'] .= $end == '2099-12-31' ? '' : $end;
         $data[$i]['share_time'] = $data[$i]['share_time'] == '~' ? '' : $data[$i]['share_time'];
         $data[$i]['share_time_begin'] = strtotime($data[$i]['share_time_begin']);
         $data[$i]['share_time_end'] = strtotime($data[$i]['share_time_end']);
         // 共享给个人
         $share_user = $data[$i]['share_id'];
         if ($share_user) {
             $share = str_replace("E", "", $share_user);
             $share_name = $employee->getInfosByOneLine($share_user);
             $data[$i]['share_name'] = $share_name['cname'];
         }
         // 共享给部门
         $share_dept = $data[$i]['share_dept'];
         if ($share_dept) {
             $share = str_replace("D", "", $share_dept);
             $share_name = $upload->getDeptNames($share_dept);
             $data[$i]['share_dept_name'] = $share_name['dept_name'];
         }
     }
     echo Zend_Json::encode($data);
     exit;
 }