Exemplo n.º 1
0
 /**
  * @abstract    获取部门树数据
  * @param       number  $parentId  上级部门ID
  * @return      array   $dept
  */
 public function getTree($parentId)
 {
     $dept = array();
     $data = array();
     $return = array();
     $dept = new Hra_Model_Dept();
     $parentId = str_replace("D", "", str_replace("E", "", $parentId));
     $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_dbprefix . 'employee_dept'), array("id", "parentid", "text" => "name"))->where("t1.active = 1 and parentid = " . $parentId)->order(array('t1.name'));
     $data = $this->fetchAll($sql)->toArray();
     // 判断是否包含子部门
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['checked'] = false;
         if ($dept->fetchAll("parentId = " . $data[$i]['id'])->count() > 0) {
             $data[$i]['leaf'] = false;
             $data[$i]['children'] = $this->getTree($data[$i]['id'], false);
         } else {
             $data[$i]['leaf'] = true;
         }
         $data[$i]['id'] = "D" . $data[$i]['id'];
     }
     // 格式化根数据格式
     if ($parentId == 0) {
         $dept = array('id' => "D0", 'parentId' => 0, 'text' => '总公司', 'leaf' => false, 'checked' => false, 'expanded' => true, 'children' => $data);
     } else {
         $dept = $data;
     }
     return $dept;
 }
Exemplo n.º 2
0
 public function getprintAction()
 {
     $result = array('success' => true, 'info' => '');
     $request = $this->getRequest()->getParams();
     if (isset($request['id']) && isset($request['type_id'])) {
         $req = new Erp_Model_Purchse_Req();
         $items = new Erp_Model_Purchse_Reqitems();
         $purchse_type = new Erp_Model_Purchse_Type();
         $dept = new Hra_Model_Dept();
         $typeData = $purchse_type->getData($request['type_id']);
         $reqData = $req->getData(null, $request['id']);
         $itemsData = $items->getData($request['id']);
         $type = '其它';
         if ($typeData['name'] == '物料原材料' || $typeData['name'] == '辅料工具') {
             $type = '物料原材料';
         }
         $tpl = new Erp_Model_Tpl();
         $tplHtmlData = $tpl->fetchRow("type = 'req' and name = '" . $type . "'")->toArray();
         $tplHtml = $tplHtmlData['html'];
         $itemsHtml = '';
         $itemsHtml_office = '';
         $itemsHtml_other = '';
         $i = 0;
         foreach ($itemsData as $item) {
             $i++;
             // 获取需求部门名称
             $deptName = '无';
             if ($item['items_dept_id'] > 0) {
                 $deptData = $dept->fetchRow("id = " . $item['items_dept_id'])->toArray();
                 $deptName = $deptData['name'];
             }
             $itemsHtml .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td>' . $item['items_code'] . '</td>
                     <td width="100px" style="word-wrap:break-word;">' . $item['items_name'] . '</td>
                     <td width="150px" style="word-wrap:break-word;">' . $item['items_description'] . '</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $item['items_price'] . '</td>
                     <td>' . $item['items_line_total'] . '</td>
                     <td>' . $item['items_date_req'] . '</td>
                     <td>' . $item['items_project_info'] . '</td>
                     <td>' . $item['items_order_req_num'] . '</td>
                     <td>' . $item['items_customer_address'] . '</td>
                     <td>' . $item['items_customer_aggrement'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
             $itemsHtml_office .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td width="100px" style="word-wrap:break-word;">' . $item['items_name'] . '</td>
                     <td width="150px" style="word-wrap:break-word;">' . $item['items_description'] . '</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $item['items_price'] . '</td>
                     <td>' . $item['items_line_total'] . '</td>
                     <td>' . $item['items_date_req'] . '</td>
                     <td>' . $item['items_supplier'] . '</td>
                     <td>' . $item['items_model'] . '</td>
                     <td>' . $deptName . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
             $itemsHtml_other .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td width="100px" style="word-wrap:break-word;">' . $item['items_name'] . '</td>
                     <td width="150px" style="word-wrap:break-word;">' . $item['items_description'] . '</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $item['items_price'] . '</td>
                     <td>' . $item['items_line_total'] . '</td>
                     <td>' . $item['items_date_req'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
         }
         $orderInfo = array('title' => '采购申请 - ' . $typeData['name'], 'date' => $reqData['create_time'], 'total' => $reqData['total'], 'number' => $reqData['number'], 'dept' => $reqData['dept'], 'applier' => $reqData['apply_user_name'], 'reason' => $reqData['reason'], 'remark' => $reqData['remark'], 'items' => $itemsHtml, 'items_office' => $itemsHtml_office, 'items_other' => $itemsHtml_other, 'company_logo' => HOME_PATH . '/public/images/company.png');
         foreach ($orderInfo as $key => $val) {
             $tplHtml = str_replace('<tpl_' . $key . '>', $val, $tplHtml);
         }
         $result['info'] = $tplHtml;
     } else {
         $result['success'] = false;
     }
     /* echo $tplHtml;
        exit; */
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 /**
  * 获取员工列表数据
  * @param   array $condition
  * @return  array $data
  */
 public function getData($condition = array())
 {
     //echo '<pre>';print_r($condition);exit;
     $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name))->joinLeft(array('t2' => $this->_dbprefix . 'user'), "t1.id = t2.employee_id", array('account' => 'id', 'account_active' => 'active'))->joinLeft(array('t3' => $this->_dbprefix . 'user'), "t1.create_user = t3.id", array())->joinLeft(array('t4' => $this->_name), "t3.employee_id = t4.id", array('creater' => 'cname'))->joinLeft(array('t5' => $this->_dbprefix . 'user'), "t1.update_user = t5.id", array())->joinLeft(array('t6' => $this->_name), "t5.employee_id = t6.id", array('updater' => 'cname'))->joinLeft(array('t7' => $this->_dbprefix . 'employee_dept'), "t7.id = t1.dept_id", array('dept_parentid' => 'parentid', 'dept_name' => 'name'))->joinLeft(array('t8' => $this->_dbprefix . 'employee_post'), "t8.id = t1.post_id", array('post_name' => 'name'))->joinLeft(array('t9' => $this->_name), "t9.id = t1.manager_id", array('manager_name' => 'cname'))->joinLeft(array('t10' => $this->_dbprefix . 'public_options'), "t10.id = t1.area_id", array('area' => 'name'))->joinLeft(array('t11' => $this->_dbprefix . 'public_options'), "t11.id = t1.professional_qualifications_id", array('professional_qualifications' => 'name'))->joinLeft(array('t12' => $this->_name), "t12.id = t1.dept_manager_id", array('dept_manager_name' => 'cname'))->joinLeft(array('t13' => $this->_dbprefix . 'employee_type'), "t13.id = t1.employment_type", array('employee_type_name' => 'name'))->where("t1.active = " . $condition['active'])->order(array('t1.number'));
     if ($condition['entry_date_from']) {
         $sql->where("t1.entry_date >= '" . $condition['entry_date_from'] . "'");
     }
     if ($condition['entry_date_to']) {
         $sql->where("t1.entry_date <= '" . $condition['entry_date_to'] . "'");
     }
     if ($condition['dept_id'] && $condition['dept_id'] != 'null') {
         $dept = json_decode($condition['dept_id']);
         if (count($dept)) {
             $sql->where("t1.dept_id in (" . implode(',', $dept) . ")");
         }
     }
     if ($condition['employment_type'] && $condition['employment_type'] != 'null') {
         $employment_type = json_decode($condition['employment_type']);
         if (count($employment_type)) {
             $sql->where("t1.employment_type in (" . implode(',', $employment_type) . ")");
         }
     }
     if ($condition['key']) {
         $sql->where("t1.cname like '%" . $condition['key'] . "%' or t1.ename like '%" . $condition['key'] . "%' or t1.number like '%" . $condition['key'] . "%'");
     }
     $total = $this->fetchAll($sql)->count();
     if ($condition['type'] == 'data') {
         $sql->limitPage($condition['page'], $condition['limit']);
     }
     //echo $sql;exit;
     $data = $this->fetchAll($sql)->toArray();
     $deptModel = new Hra_Model_Dept();
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['dept_info'] = $data[$i]['dept_parentid'] > 0 ? $deptModel->getDeptInfoDesc($data[$i]['dept_id']) : $data[$i]['dept_name'];
         $data[$i]['create_time'] = strtotime($data[$i]['create_time']);
         $data[$i]['update_time'] = strtotime($data[$i]['update_time']);
         $data[$i]['sex'] = intval($data[$i]['sex']);
         $data[$i]['driving_license'] = intval($data[$i]['driving_license']);
         $data[$i]['marital_status'] = intval($data[$i]['marital_status']);
         $data[$i]['politics_status'] = intval($data[$i]['politics_status']);
         $data[$i]['employment_type'] = intval($data[$i]['employment_type']);
         $data[$i]['hide'] = $data[$i]['hide'] == 1 ? true : false;
         $data[$i]['active'] = $data[$i]['active'] == 1 ? true : false;
         $data[$i]['leader'] = $data[$i]['leader'] == 1 ? true : false;
         $data[$i]['account'] = $data[$i]['account'] != '' ? true : false;
         $data[$i]['account_active'] = $data[$i]['account_active'] == 1 ? true : false;
         $data[$i]['dept_id'] = intval($data[$i]['dept_id']);
         $data[$i]['post_id'] = intval($data[$i]['post_id']);
         $data[$i]['manager_id'] = intval($data[$i]['manager_id']);
         $data[$i]['dept_manager_id'] = intval($data[$i]['dept_manager_id']);
         $data[$i]['area_id'] = intval($data[$i]['area_id']);
         $data[$i]['professional_qualifications_id'] = intval($data[$i]['professional_qualifications_id']);
     }
     //echo '<pre>';print_r($data);exit;
     if ($condition['type'] == 'csv') {
         $data_csv = array();
         $title = array('cnt' => '#', 'active' => '在职', 'account' => '系统账号', 'account_active' => '账号状态', 'employee_type_name' => '用工形式', 'work_place' => '工作地点', 'number' => '工号', 'cname' => '中文名', 'ename' => '英文名', 'sex' => '性别', 'birthday' => '出生日期', 'dept_name' => '部门', 'dept_info' => '部门信息', 'manager_name' => '上级主管', 'dept_manager_name' => '部门主管', 'post_name' => '职位', 'email' => '邮箱', 'tel' => '电话', 'msn' => 'MSN', 'official_qq' => '企业QQ', 'short_num' => '短号', 'ext' => '分机号', 'address' => '家庭住址', 'area' => '地区', 'offical_address' => '户籍地址', 'other_contact' => '紧急联系人', 'other_relationship' => '双方关系', 'other_contact_way' => '联系方式', 'work_years' => '工作年限', 'politics_status' => '政治面貌', 'employment_type' => '用工形式', 'dept_manager_name' => '部门主管', 'manager_name' => '上级主管', 'marital_status' => '婚否', 'marry_day' => '结婚纪念日', 'children_birthday' => '小孩生日', 'id_card' => '身份证号', 'insurcode' => '社保号', 'salary' => '薪水', 'professional_qualifications' => '技术职称等级', 'driving_license' => '驾照', 'bank' => '开户行', 'bank_num' => '银行卡号', 'accumulation_fund_code' => '公积金号', 'education' => '学历', 'school' => '毕业院校', 'major' => '专业', 'entry_date' => '入职日期', 'regularization_date' => '转正日期', 'labor_contract_start' => '劳动合同-开始', 'labor_contract_end' => '劳动合同-截止', 'leave_date' => '离职日期', 'remark' => '备注', 'create_user' => '创建人', 'create_time' => '创建时间', 'update_user' => '更新人', 'update_time' => '更新时间');
         array_push($data_csv, $title);
         $i = 0;
         foreach ($data as $d) {
             $i++;
             $info = array('cnt' => $i, 'active' => $d['active'] == 1 ? '是' : '否', 'account' => $d['account'] == 1 ? '有' : '无', 'account_active' => $d['account_active'] == 1 ? '是' : '否', 'employee_type_name' => $d['employee_type_name'], 'work_place' => $d['work_place'], 'number' => $d['number'], 'cname' => $d['cname'], 'ename' => $d['ename'], 'sex' => $d['sex'], 'birthday' => $d['birthday'], 'dept_name' => $d['dept_name'], 'dept_info' => $d['dept_info'], 'manager_name' => $d['manager_name'], 'dept_manager_name' => $d['dept_manager_name'], 'post_name' => $d['post_name'], 'email' => $d['email'], 'tel' => $d['tel'], 'msn' => $d['msn'], 'official_qq' => $d['official_qq'], 'short_num' => $d['short_num'], 'ext' => $d['ext'], 'address' => $d['address'], 'area' => $d['area'], 'offical_address' => $d['offical_address'], 'other_contact' => $d['other_contact'], 'other_relationship' => $d['other_relationship'], 'other_contact_way' => $d['other_contact_way'], 'work_years' => $d['work_years'], 'politics_status' => $d['politics_status'], 'employment_type' => $d['employment_type'], 'dept_manager_name' => $d['dept_manager_name'], 'manager_name' => $d['manager_name'], 'marital_status' => $d['marital_status'] == 1 ? '是' : '否', 'marry_day' => $d['marry_day'], 'children_birthday' => $d['children_birthday'], 'id_card' => $d['id_card'], 'insurcode' => $d['insurcode'], 'salary' => $d['salary'], 'professional_qualifications' => $d['professional_qualifications'], 'driving_license' => $d['driving_license'] == 1 ? '有' : '无', 'bank' => $d['bank'], 'bank_num' => $d['bank_num'], 'accumulation_fund_code' => $d['accumulation_fund_code'], 'education' => $d['education'], 'school' => $d['school'], 'major' => $d['major'], 'entry_date' => $d['entry_date'], 'regularization_date' => $d['regularization_date'], 'labor_contract_start' => $d['labor_contract_start'], 'labor_contract_end' => $d['labor_contract_end'], 'leave_date' => $d['leave_date'], 'remark' => $d['remark'], 'create_user' => $d['creater'], 'create_time' => date('Y-m-d H:i:s', $d['create_time']), 'update_user' => $d['updater'], 'update_time' => date('Y-m-d H:i:s', $d['update_time']));
             array_push($data_csv, $info);
         }
         return $data_csv;
     }
     return array('total' => $total, 'rows' => $data);
 }
Exemplo n.º 5
0
 /**
  * @abstract    添加、删除、修改部门属性
  * @return      null
  */
 public function editAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '编辑成功');
     $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['user_id'];
     $json = json_decode($request['json']);
     $updated = $json->updated;
     $inserted = $json->inserted;
     $deleted = $json->deleted;
     $dept = new Hra_Model_Dept();
     if (count($updated) > 0) {
         foreach ($updated as $val) {
             $data = array('parentid' => $val->parentId, 'name' => $val->name, 'manager_id' => $val->manager_id, 'description' => $val->description, 'remark' => $val->remark, 'active' => $val->active, 'update_time' => $now, 'update_user' => $user);
             $where = "id = " . $val->id;
             try {
                 $dept->update($data, $where);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     if (count($inserted) > 0) {
         foreach ($inserted as $val) {
             $data = array('parentid' => $val->parentId, 'name' => $val->name, 'manager_id' => $val->manager_id, 'description' => $val->description, 'remark' => $val->remark, 'active' => $val->active, 'create_time' => $now, 'create_user' => $user, 'update_time' => $now, 'update_user' => $user);
             try {
                 $dept->insert($data);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             $employee = new Hra_Model_Employee();
             if ($employee->fetchAll("dept_id = " . $val->id)->count() == 0) {
                 try {
                     $dept->deleteDeptTreeData($val->id);
                 } catch (Exception $e) {
                     $result['result'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $result['result'] = false;
                 $result['info'] = '部门ID' . $val->id . '已使用,不能删除';
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }