Exemplo n.º 1
0
 public function applyAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '申请成功');
     $request = $this->getRequest()->getParams();
     $seal_id = isset($request['apply_seal_id']) ? $request['apply_seal_id'] : null;
     $review_user = isset($request['review_user']) ? $request['review_user'] : null;
     $apply_reason = isset($request['apply_reason']) ? $request['apply_reason'] : null;
     if ($seal_id) {
         $sealuse = new Hra_Model_Sealuse();
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         $data = array('seal_id' => $seal_id, 'review_user' => $review_user, 'apply_reason' => $apply_reason, 'apply_user' => $user_id, 'apply_time' => $now);
         try {
             $sealuse->insert($data);
             $mail = new Application_Model_Log_Mail();
             $seal = new Hra_Model_Seal();
             $member = new Admin_Model_Member();
             $employee = new Hra_Model_Employee();
             /* $toIds = $member->getUserids('印章管理员');
                
                $toAddress = array();
                
                foreach ($toIds as $toId){
                    $em = $employee->getEmployeeByUserId($toId);
                    array_push($toAddress, $em['info']['email']);
                } */
             $toAddress = array();
             $em = $employee->getEmployeeByUserId($review_user);
             array_push($toAddress, $em['info']['email']);
             $sealData = $seal->fetchRow("id = " . $seal_id)->toArray();
             $content = '<div>你有一个新的印章使用申请,请登录系统审核:</div>
                                 <div>
                                 <p><b>印章名称:</b>' . $sealData['name'] . '</p>
                                 <p><b>事由:</b>' . $apply_reason . '</p>
                                 <p><b>申请人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>申请时间:</b>' . $now . '</p>
                                 </div>';
             $data = array('type' => '消息', 'subject' => '印章-使用申请', 'to' => implode(',', $toAddress), 'cc' => $user_session->user_info['user_email'], 'user_id' => $review_user, 'content' => $content, 'add_date' => $now);
             try {
                 // 记录邮件日志并发送邮件
                 $mail->send($mail->insert($data));
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         } catch (Exception $e) {
             $result['success'] = false;
             $result['info'] = $e->getMessage();
         }
     } else {
         $result['success'] = false;
         $result['info'] = '未选择印章';
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 2
0
 public function indexAction()
 {
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $employee = new Hra_Model_Employee();
     $user_info = $employee->getEmployeeByUserId($user_id);
     $this->view->user_info = $user_info['info'];
 }
Exemplo n.º 3
0
 public function saveData($bom, $user, $relation)
 {
     $employee = new Hra_Model_Employee();
     $userData = $employee->getById($user);
     if ($userData && count($userData) > 0) {
         $userName = $userData['cname'];
         $data = array('bom' => $bom, 'employee_id' => $user, 'employee_name' => $userName, 'relation' => $relation, 'create_time' => date('Y-m-d H:i:s'));
         $this->insert($data);
     }
 }
Exemplo n.º 4
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'];
     $where = "table_name = 'oa_doc_upload'";
     if (isset($request['search_name']) && $request['search_name']) {
         $where .= " and t3.name like '%" . $request['search_name'] . "%'";
     }
     if (isset($request['search_description']) && $request['search_description']) {
         $where .= " and description like '%" . $request['search_description'] . "%'";
     }
     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_type']) && $request['search_type']) {
         $where .= " and action = '" . $request['search_type'] . "'";
     }
     if (isset($request['search_handle_user']) && $request['search_handle_user']) {
         $handler_user = $request['search_handle_user'];
         $employee = new Hra_Model_Employee();
         if (count($handlers = $employee->fetchAll("ename = '{$handler_user}' or cname = '{$handler_user}'")->toArray()) > 0) {
             $whereHandler = "(";
             foreach ($handlers as $handler) {
                 if ($whereHandler != '(') {
                     $whereHandler .= " or ";
                 }
                 $whereHandler .= " handle_user = "******")";
         }
         if (isset($whereHandler) && $whereHandler != '()') {
             $where .= " and " . $whereHandler;
         }
     }
     $log = new Dcc_Model_Log();
     $wherePage = $where . " and t1.type = 'files'";
     $data = $log->getList($wherePage, $start, $limit);
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['handle_time'] = strtotime($data[$i]['handle_time']);
     }
     $whereAll = $where . " and type='files'";
     $resutl = array("totalCount" => count($log->getList($wherePage, null, null)), "topics" => $data);
     echo Zend_Json::encode($resutl);
     exit;
 }
Exemplo n.º 5
0
 public function getReqRelatedUsers($numberArr)
 {
     $userInfo = array();
     $userIdsAdded = array();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $i = 0;
     foreach ($numberArr as $order) {
         $i++;
         $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name), array())->joinLeft(array('t2' => $this->_dbprefix . "erp_pur_order_items"), "t1.order_item_id = t2.id", array())->joinLeft(array('t3' => $this->_dbprefix . "erp_pur_order"), "t1.order_number = t3.number", array('order_create_user' => 'create_user'))->joinLeft(array('t4' => $this->_dbprefix . "erp_pur_req"), "t2.req_number = t4.number", array('id', 'create_user', 'apply_user'))->joinLeft(array('t5' => $this->_dbprefix . 'user'), "t4.create_user = t5.id", array())->joinLeft(array('t6' => $this->_dbprefix . 'employee'), "t5.employee_id = t6.id", array('creater_email' => 'email'))->joinLeft(array('t7' => $this->_dbprefix . 'user'), "t4.apply_user = t7.id", array())->joinLeft(array('t8' => $this->_dbprefix . 'employee'), "t7.employee_id = t8.id", array('applier_email' => 'email'))->joinLeft(array('t9' => $this->_dbprefix . 'user'), "t3.create_user = t9.id", array())->joinLeft(array('t10' => $this->_dbprefix . 'employee'), "t9.employee_id = t10.id", array('order_creater_email' => 'email'))->where("t1.order_number = '" . $order . "'");
         $data = $this->fetchRow($sql)->toArray();
         array_push($userInfo, array('user_id' => $data['order_create_user'], 'email' => $data['order_creater_email']));
         array_push($userIdsAdded, $data['order_create_user']);
         if ($data['applier_email'] != '' && $data['apply_user'] && !in_array($data['apply_user'], $userIdsAdded)) {
             array_push($userInfo, array('user_id' => $data['apply_user'], 'email' => $data['applier_email']));
         }
         // 添加采购申请人:直接主管
         if ($data['create_user'] != '') {
             array_push($userInfo, array('user_id' => $data['create_user'], 'email' => $data['creater_email']));
             array_push($userIdsAdded, $data['create_user']);
             $managerInfo = $employee->getManagerByUserId($data['create_user']);
             if (isset($managerInfo['email']) && $managerInfo['email'] != '' && !in_array($managerInfo['user_id'], $userIdsAdded)) {
                 array_push($userInfo, array('user_id' => $managerInfo['user_id'], 'email' => $managerInfo['email']));
             }
             // 添加采购申请人:部门主管
             $deptManagerInfo = $employee->getDeptManagerByUserId($data['create_user']);
             if (isset($deptManagerInfo['email']) && $deptManagerInfo['email'] != '' && !in_array($deptManagerInfo['user_id'], $userIdsAdded)) {
                 array_push($userInfo, array('user_id' => $deptManagerInfo['user_id'], 'email' => $deptManagerInfo['email']));
             }
         }
         // 获取审核人
         if ($data['id'] != '') {
             $reviewerInfo = $review->getReviewUserInfo('purchse_req_add', $data['id']);
             foreach ($reviewerInfo as $info) {
                 if (!in_array($info['user_id'], $userIdsAdded)) {
                     array_push($userInfo, $info);
                 }
             }
         }
     }
     $data = array();
     $ids = array();
     foreach ($userInfo as $user) {
         if (!in_array($user['user_id'], $ids)) {
             array_push($data, $user);
             array_push($ids, $user['user_id']);
         }
     }
     return $data;
 }
Exemplo n.º 6
0
 /**
  * @abstract    保存
  * @return      null
  */
 public function saveAction()
 {
     // 返回值数组
     $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['employee_id'];
     $bomId = $request['code_id'];
     $userId = $request['employee_id'];
     $bomIds = array();
     $userIds = array();
     if ($bomId) {
         $bomIds = explode(',', $bomId);
     }
     if ($userId) {
         $userIds = explode(',', $userId);
     }
     $bomrole = new Product_Model_Bomrole();
     $fa = new Product_Model_Fa();
     $emp = new Hra_Model_Employee();
     try {
         foreach ($bomIds as $b) {
             $bomCodes = $fa->getById($b);
             $bomCode = $bomCodes['code'];
             foreach ($userIds as $u) {
                 $userNames = $emp->getById($u);
                 $userName = $userNames['cname'];
                 $data = array('bom' => $bomCode, 'employee_id' => $u, 'employee_name' => $userName, 'relation' => '管理员增加', 'create_user' => $user, 'create_time' => $now);
                 $bomrole->insert($data);
             }
         }
     } catch (Exception $e) {
         $result['result'] = false;
         $result['info'] = $e->getMessage();
         echo Zend_Json::encode($result);
         exit;
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 7
0
 public function getlistAction()
 {
     // 请求参数
     $request = $this->getRequest()->getParams();
     $limit = $request['limit'];
     $start = $request['start'];
     $step = new Admin_Model_Step();
     $employee = new Hra_Model_Employee();
     $where = " 1=1";
     foreach ($request as $k => $v) {
         if ($v != '') {
             $col = str_replace('search_', '', $k);
             if ($col != $k) {
                 // 查询条件
                 $where .= " and " . $col . " like '%" . $v . "%'";
             }
         }
     }
     $data = $step->getList($where, $start, $limit, null);
     for ($i = 0; $i < count($data); $i++) {
         $step_user = $data[$i]['user'];
         if ($step_user) {
             $step_user_name = $employee->getInfosByOneLine($step_user);
             $data[$i]['step_user_name'] = $step_user_name['cname'];
         }
         // 重新检索角色信息
         if ($data[$i]['dept']) {
             $role = $data[$i]['dept'];
             $sql = "select GROUP_CONCAT(name) as step_dept_name from oa_user_role where id in ({$role})";
             $db = $step->getAdapter();
             $result = $db->query($sql)->fetchObject();
             $data[$i]['step_dept_name'] = $result->step_dept_name;
         }
         $data[$i]['manager'] = $data[$i]['manager'] == 1 ? true : false;
     }
     $resutl = array("totalCount" => count($step->getList($where, null, null, null)), "topics" => $data);
     echo Zend_Json::encode($resutl);
     exit;
 }
Exemplo n.º 8
0
 /**
  * @abstract    审核
  * @return      null
  */
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => 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['employee_id'];
     $val = (object) $request;
     $materiel = new Product_Model_Materiel();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $desc = new Product_Model_Desc();
     $id = $val->id;
     $remark = $val->remark1;
     $pass = $val->review_result;
     $publish = false;
     if (isset($val->ids) && $val->ids && strpos($val->ids, ',') !== false) {
         // 多个
         $ids = explode(',', $val->ids);
     } else {
         $ids = array($id);
     }
     foreach ($ids as $id) {
         // 获取物料信息
         $materielData = $desc->getOne($id);
         if (!$materielData) {
             $result['result'] = false;
             $result['info'] = "数据状态已改变";
             echo Zend_Json::encode($result);
             exit;
         }
         $review_id = $materielData->review_id;
         // 获取当前审核情况
         // 如果record记录被删除或状态已改变,报错
         $reviewWhere = "id = {$review_id}";
         $reviewRows = $review->getList($reviewWhere, "materiel_desc");
         if (count($reviewRows) == 0) {
             $result['result'] = false;
             $result['info'] = "非法数据";
             echo Zend_Json::encode($result);
             exit;
         }
         $reviewRow = $reviewRows[0];
         if ($reviewRow['finish_flg'] != 0) {
             $result['result'] = false;
             $result['info'] = "数据状态已改变";
             echo Zend_Json::encode($result);
             exit;
         }
         // 处理记录
         $recordData = array("type" => "materiel_desc", "table_name" => "oa_product_materiel_desc", "table_id" => $id, "handle_user" => $user, "handle_time" => $now, "action" => "审批", "result" => $pass == 1 ? "批准" : ($pass == 2 ? "拒绝" : "转审"), "ip" => $_SERVER['REMOTE_ADDR'], "remark" => $remark);
         // 增加记录
         $record->insert($recordData);
         // 通过方式
         $method = $reviewRow['method'];
         if ($pass == 1) {
             if ($method == 2) {
                 // 任何一人处理即通过
                 $finish_flg = 1;
                 $actual_user = $user;
                 $finish_time = $now;
             } else {
                 // 所有人都需要审核,检查是否所有人都已经审核
                 $plan_user = $reviewRow['plan_user'];
                 $actual_user = $reviewRow['actual_user'];
                 $actual_user = !$actual_user ? $user : $actual_user . "," . $user;
                 // 检查计划审核人和实际审核人是否一致
                 $planA = explode(',', $plan_user);
                 $actualA = explode(',', $actual_user);
                 $passFlg = true;
                 foreach ($planA as $u) {
                     if ($u && !in_array($u, $actualA)) {
                         $passFlg = false;
                     }
                 }
                 if ($passFlg) {
                     $finish_flg = 1;
                     $finish_time = $now;
                 } else {
                     $finish_flg = 0;
                     $finish_time = null;
                 }
             }
             // 审核情况
             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
         } else {
             if ($pass == 3) {
                 // 转审
                 $finish_flg = 0;
                 if ($method == 2) {
                     // 处理方式为任意时,一个人转审之后其他人员也删除
                     $plan_user = str_replace('E', '', $val->transfer_id);
                 } else {
                     // 更改审核情况中的审核人
                     $plan_users = explode(',', $reviewRow['plan_user']);
                     for ($i = 0; $i < count($plan_users); $i++) {
                         if ($plan_users[$i] == $user) {
                             $plan_users[$i] = str_replace('E', '', $val->transfer_id);
                             break;
                         }
                     }
                     $plan_user = implode(',', $plan_users);
                 }
                 // 审核情况
                 $reviewData = array("plan_user" => $plan_user, "method" => 1);
             } else {
                 // 退回
                 $actual_user = null;
                 $finish_time = null;
                 $finish_flg = 0;
                 // 退回选项
                 $return = $reviewRow['return'];
                 if ($return == 2) {
                     // 退到初始状态
                     // 需更新的审核记录: 所有
                     $reviewWhere = "type = 'materiel_desc' and file_id = {$id}";
                     // 审核情况更新数据
                     $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                     // 文件状态不更新
                 } else {
                     if ($return == 4) {
                         // 退到本阶段开始
                         // 需更新的审核记录
                         $reviewWhere = "type = 'materiel_desc' and finish_flg = 0 and file_id = {$id}";
                         // 审核情况更新数据
                         $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                         // 文件状态不更新
                     } else {
                         if ($return == 3) {
                             // 退到上一阶段
                             // 需更新的审核记录:最后一个finish_flg为1的数据和第一个finish_flg为0的数据
                             $last_1 = $first_0 = 0;
                             foreach ($reviewRows as $r) {
                                 if ($r['finish_flg'] == 1) {
                                     $last_1 = $r['id'];
                                 }
                                 if ($r['finish_flg'] == 0 && $first_0 == null) {
                                     $first_0 = $r['id'];
                                 }
                             }
                             $reviewWhere = "id = {$last_1} or id = {$first_0}";
                             // 审核情况更新数据
                             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                             // 文件状态不更新
                         } else {
                             $fileWhere = "id = {$id}";
                             // 更新文件状态为退回
                             $mData = array("state" => "Return");
                             // 退到初始状态
                             // 更新所有record的finish_flg为0
                             $reviewWhere = "type = 'materiel_desc' and file_id = {$id}";
                             // 审核情况
                             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                         }
                     }
                 }
             }
         }
         // 如果所有record的记录的finish_flg 都为1,则发布
         if ($finish_flg == 1 && $review->fetchAll("type = 'materiel_desc' and finish_flg = 0 and file_id = {$id}")->count() == 1) {
             $publish = true;
             // 修改物料信息
             $descData = array('ver' => $materielData->ver_after, 'name' => $materielData->name_after, 'description' => $materielData->desc_after, 'manufacturers' => $materielData->manufacturers_after, 'supply1' => $materielData->supply1_after, 'supply2' => $materielData->supply2_after, 'data_file_id' => $materielData->data_file_id_after, 'tsr_id' => $materielData->tsr_id_after, 'first_report_id' => $materielData->first_report_id_after);
             $descWhere = "id = " . $materielData->mid;
             $mData = array("state" => "Active", "archive_time" => $now);
             $fileWhere = "id = {$id}";
         }
         try {
             // 更新审核情况
             $review->update($reviewData, $reviewWhere);
             // 更新文件
             if (isset($fileWhere)) {
                 $desc->update($mData, $fileWhere);
             }
             if (isset($descWhere)) {
                 $materiel->update($descData, $descWhere);
             }
             $this->operate("物料变更评审");
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         // 邮件任务
         // 文件提交者或更新人
         $owner = $materielData['create_user'];
         $dev = false;
         $type = "物料变更申请(物料代码:" . $materielData['code'] . ")";
         // 发邮件的情况:
         // 1、单站审核结束 $finish_flg = 1 && $publish = false
         if ($finish_flg == 1 && !$publish) {
             $subject = $type . "审批";
             // $to = 下一站审核人
             $current = $review->getFirstNoReview("materiel_desc", $id);
             $to = $employee->getInfosByOneLine($current['plan_user']);
             //
             $cc = $employee->getInfosByOneLine($owner);
             $cc = $cc['email'];
             $content = "你有一个" . $type . "需要审批,请登录系统查看详情!";
         }
         // 2、所有审核结束  $publish = true
         if ($publish) {
             $subject = $type . "发布";
             $to = $employee->getInfosByOneLine($owner);
             $cc = $employee->getInfosByOneLine($record->getEmployeeIds($materielData['id'], 'materiel_desc'));
             $cc = $cc['email'];
             //                 $cc = "";
             $detail = "物料代码:" . $materielData['code'];
             if ($materielData['name_before'] != $materielData['name_after']) {
                 if ($detail) {
                     $detail .= '<br>';
                 }
                 $detail .= "名称:" . $materielData['name_before'] . " → " . $materielData['name_after'];
             }
             if ($materielData['desc_before'] != $materielData['desc_after']) {
                 if ($detail) {
                     $detail .= '<br>';
                 }
                 $detail .= "描述:" . $materielData['desc_before'] . " → " . $materielData['desc_after'];
             }
             if ($materielData['supply1_before'] != $materielData['supply1_after']) {
                 if ($detail) {
                     $detail .= '<br>';
                 }
                 $detail .= "供应商1:" . $materielData['supply1_code_before'] . $materielData['supply1_cname_before'] . " → " . $materielData['supply1_code_after'] . $materielData['supply1_cname_after'];
             }
             if ($materielData['supply2_before'] != $materielData['supply2_after']) {
                 if ($detail) {
                     $detail .= '<br>';
                 }
                 $detail .= "供应商2:" . $materielData['supply2_code_before'] . $materielData['supply2_cname_before'] . " → " . $materielData['supply2_code_after'] . $materielData['supply2_cname_after'];
             }
             if ($materielData['manufacturers_before'] != $materielData['manufacturers_after']) {
                 if ($detail) {
                     $detail .= '<br>';
                 }
                 $detail .= "制造商:" . $materielData['manufacturers_before'] . " → " . $materielData['manufacturers_after'];
             }
             $content = "你申请的" . $type . "已通过审批,物料信息已自动变更,请登录系统查看详情!<br>变更详情:<br>{$detail}";
         }
         // 3、退回 isset($return)
         if (isset($return)) {
             $subject = $type . "退回";
             $to = $employee->getInfosByOneLine($owner);
             $cc = "";
             // 原审核人
             if ($reviewRow['plan_user']) {
                 $orgUser = $reviewRow['plan_user'];
                 $cc = $employee->getInfosByOneLine($orgUser);
                 $cc = $cc['email'];
             }
             $content = "你申请的" . $type . "已被退回,请登录系统查看详情!";
         }
         // 4、转审 $pass == 3
         if ($pass == 3) {
             $subject = $type . "转审";
             $toUser = str_replace('E', '', $val->transfer_id);
             $to = $employee->getInfosByOneLine($toUser);
             // 原审核人
             if ($reviewRow['plan_user']) {
                 $orgUser = $reviewRow['plan_user'];
                 $owner .= "," . $orgUser;
             }
             $cc = $employee->getInfosByOneLine($owner);
             $cc = $cc['email'];
             $content = "有新的" . $type . "被转移到你处审批,请登录系统查看详情!";
         }
         if (isset($subject)) {
             $mailData = array('type' => $type, 'subject' => $subject, 'to' => $to['email'], 'cc' => $cc, 'content' => $content, 'send_time' => $now, 'add_date' => $now);
             $mail = new Application_Model_Log_Mail();
             try {
                 $mailId = $mail->insert($mailData);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
             if ($mailId) {
                 $mail->send($mailId);
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 9
0
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '审核成功');
     $request = $this->getRequest()->getParams();
     $review_id = isset($request['review_id']) ? $request['review_id'] : null;
     $review_operate = isset($request['review_operate']) ? $request['review_operate'] : null;
     $review_current_step = isset($request['review_current_step']) ? $request['review_current_step'] : null;
     // 当前阶段(review表ID)
     $review_last_step = isset($request['review_last_step']) ? $request['review_last_step'] : null;
     // 是否当前阶段为最后一阶段
     $review_to_finish = isset($request['review_to_finish']) ? $request['review_to_finish'] : null;
     // 是否批准后当前阶段结束
     $review_next_step = isset($request['review_next_step']) ? $request['review_next_step'] : null;
     // 下一阶段(review表ID)
     $review_remark = isset($request['review_remark']) ? $request['review_remark'] : null;
     $review_transfer_user = isset($request['review_transfer_user']) ? $request['review_transfer_user'] : null;
     //转审人
     if ($review_id && $review_operate) {
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         $employee_id = $user_session->user_info['employee_id'];
         // 评审意见
         $review_info = '意见: ' . $review_remark;
         $price = new Erp_Model_Sale_Price();
         $user = new Application_Model_User();
         $review = new Dcc_Model_Review();
         $employee = new Hra_Model_Employee();
         $priceData = $price->getData(null, $review_id);
         // 更新审核状态及审核意见
         if ($review_operate == 'transfer') {
             // 转审
             $tmp = $priceData['review_info'] != '' ? $priceData['review_info'] . '<br>' : '';
             $review_info = $tmp . $now . ': ' . $user_session->user_info['user_name'] . ' [审核-转审] [' . $review_info . ']';
             $price->update(array('review_info' => $review_info), "id = " . $review_id);
             $reviewState = $review->fetchRow("type = 'sale_price_add' and finish_flg = 0 and file_id = " . $review_id, "id")->toArray();
             // 转审对象
             $transferUserInfo = $user->getEmployeeInfoById($review_transfer_user);
             $reviewUsers = $reviewState['plan_user'];
             $reviewUserArr = explode(',', $reviewUsers);
             $reviewer = array();
             if ($reviewState['method'] == 2) {
                 // 任意: 直接替换审核人为转审对象
                 foreach ($reviewUserArr as $review_user) {
                     if ($review_user == $employee_id) {
                         array_push($reviewer, $transferUserInfo['id']);
                     }
                 }
             } else {
                 // 全部: 替换当前审核人为转审对象,其余审核人保留
                 foreach ($reviewUserArr as $review_user) {
                     if ($review_user == $employee_id) {
                         array_push($reviewer, $transferUserInfo['id']);
                     } else {
                         if (!in_array($review_user, $reviewer)) {
                             array_push($reviewer, $review_user);
                         }
                     }
                 }
             }
             $reviewerstr = implode(',', $reviewer);
             $review->update(array('plan_user' => $reviewerstr), "id = " . $reviewState['id']);
             // 发送邮件通知制单人
             $reviewResult = '<font style="color: #FF0000"><b>转审</b></font>';
             $mail = new Application_Model_Log_Mail();
             $to = $transferUserInfo['email'];
             $mailContent = '<div>销售价格申请审核:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $priceData['number'] . '</p>
                             <p><b>申请人:</b>' . $priceData['creater'] . '</p>
                             <p><b>描述:</b>' . $priceData['description'] . '</p>
                             <p><b>备注:</b>' . $priceData['remark'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $priceData['review_info'] . '</p>
                             </div>';
             $mailData = array('type' => '消息', 'subject' => '销售价格申请-转审', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $user_session->user_info['user_id'], 'content' => $mailContent, 'add_date' => $now);
             try {
                 // 记录邮件日志并发送邮件
                 $mail->send($mail->insert($mailData));
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
             }
         } else {
             if ($review_operate == 'no') {
                 // 更新申请状态
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-拒绝] [' . $review_info . ']';
                 $tmp = $priceData['review_info'] != '' ? $priceData['review_info'] . '<br>' : '';
                 $data = array('state' => 1, 'review_info' => $tmp . $review_info);
                 $price->update($data, "id = " . $review_id);
                 // 删除当前申请的审核配置
                 $review->delete("type = 'sale_price_add' and file_id = " . $review_id);
                 // 发送邮件通知制单人
                 $reviewResult = '<font style="color: #FF0000"><b>拒绝</b></font>';
                 $mail = new Application_Model_Log_Mail();
                 $applyEmployeeData = $user->fetchRow("id = " . $priceData['create_user'])->toArray();
                 $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                 $to = $applyEmployee['email'];
                 $mailContent = '<div>销售价格申请审核:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $priceData['number'] . '</p>
                             <p><b>申请人:</b>' . $priceData['creater'] . '</p>
                             <p><b>描述:</b>' . $priceData['description'] . '</p>
                             <p><b>备注:</b>' . $priceData['remark'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $priceData['review_info'] . '</p>
                             </div>';
                 $mailData = array('type' => '消息', 'subject' => '销售价格申请-审核', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $priceData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                 try {
                     // 记录邮件日志并发送邮件
                     $mail->send($mail->insert($mailData));
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                 }
             } else {
                 $help = new Application_Model_Helpers();
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-批准] [' . $review_info . ']';
                 $tmp = $priceData['review_info'] != '' ? $priceData['review_info'] . '<br>' : '';
                 $reqUpdateData = array('review_info' => $tmp . $review_info);
                 $reviewData = $review->fetchRow("id = " . $review_current_step)->toArray();
                 $actual_user = $reviewData['actual_user'] == '' ? $user_session->user_info['employee_id'] : $reviewData['actual_user'] . ',' . $user_session->user_info['employee_id'];
                 $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                 // 当前审核阶段为最后一阶段
                 if ($review_last_step == 1) {
                     // 当前阶段已完结
                     if ($review_to_finish == 1) {
                         $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                         $reviewResult = '<font style="color: #006400"><b>发布</b></font>';
                         // 发布:检查客户的当前产品(包括类别)是否存在生效价格(如存在则更新历史价格为作废)
                         $price->updatePriceByPriceId($review_id);
                         // 更新申请状态
                         $reqUpdateData['state'] = 2;
                         $reqUpdateData['release_time'] = $now;
                         // 更新审核记录表
                         $review->update($data, "id = " . $review_current_step);
                         $mail = new Application_Model_Log_Mail();
                         $applyEmployeeData = $user->fetchRow("id = " . $priceData['create_user'])->toArray();
                         $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                         $to = $applyEmployee['email'];
                         $cc = $user_session->user_info['user_email'];
                         $mailContent = '<div>销售价格审核批准,请登录系统查看:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $priceData['number'] . '</p>
                             <p><b>申请人:</b>' . $priceData['creater'] . '</p>
                             <p><b>描述:</b>' . $priceData['description'] . '</p>
                             <p><b>备注:</b>' . $priceData['remark'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $reqUpdateData['review_info'] . '</p>
                             </div>';
                         $mailData = array('type' => '消息', 'subject' => '销售价格申请-发布', 'to' => $to, 'cc' => $cc, 'user_id' => $priceData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                         try {
                             // 记录邮件日志并发送邮件
                             $mail->send($mail->insert($mailData));
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                         }
                     } else {
                         $data = array('actual_user' => $actual_user);
                         $review->update($data, "id = " . $review_current_step);
                     }
                 } else {
                     // 当前阶段已完结
                     if ($review_to_finish == 1) {
                         $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                         $reviewResult = '<font style="color: #006400"><b>批准</b></font>';
                         // 进入下一阶段
                         // 更新审核记录表
                         $review->update($data, "id = " . $review_current_step);
                         // 邮件通知下一阶段审核人
                         $reviewNextStepData = $review->fetchRow("id = " . $review_next_step)->toArray();
                         $mailTo = explode(',', $reviewNextStepData['plan_user']);
                         if ($mailTo) {
                             $mailContent = '<div>销售价格申请,请登录系统查看:</div>
                                         <div>
                                         <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                                         <p><b>审核结果:</b>' . $reviewResult . '</p>
                                         <p><b>审核意见:</b>' . $review_remark . '</p>
                                         <p><b>申请单号:</b>' . $priceData['number'] . '</p>
                                         <p><b>申请人:</b>' . $priceData['creater'] . '</p>
                                         <p><b>描述:</b>' . $priceData['description'] . '</p>
                                         <p><b>备注:</b>' . $priceData['remark'] . '</p>
                                         <hr>
                                         <p><b>审核日志:</b></p><p>' . $reqUpdateData['review_info'] . '</p>
                                         </div>';
                             $mailData = array('type' => '消息', 'subject' => '销售价格申请-新申请', 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent, 'add_date' => $now);
                             $resultMail = $help->sendMailToStep($mailTo, $mailData);
                             if (!$resultMail['success']) {
                                 $result = $resultMail;
                             }
                         }
                     } else {
                         $data = array('actual_user' => $actual_user);
                         $review->update($data, "id = " . $review_current_step);
                         // 等待其他审核人批准
                     }
                 }
                 // 更新申请状态
                 $price->update($reqUpdateData, "id = " . $review_id);
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 10
0
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '审核成功');
     $request = $this->getRequest()->getParams();
     $review_id = isset($request['review_id']) ? $request['review_id'] : null;
     //$review_type_id = isset($request['review_type_id']) ? $request['review_type_id'] : null;
     $review_operate = isset($request['review_operate']) ? $request['review_operate'] : null;
     $review_current_step = isset($request['review_current_step']) ? $request['review_current_step'] : null;
     // 当前阶段(review表ID)
     $review_last_step = isset($request['review_last_step']) ? $request['review_last_step'] : null;
     // 是否当前阶段为最后一阶段
     $review_to_finish = isset($request['review_to_finish']) ? $request['review_to_finish'] : null;
     // 是否批准后当前阶段结束
     $review_next_step = isset($request['review_next_step']) ? $request['review_next_step'] : null;
     // 下一阶段(review表ID)
     $review_remark = isset($request['review_remark']) ? $request['review_remark'] : null;
     $review_transfer_user = isset($request['review_transfer_user']) ? $request['review_transfer_user'] : null;
     //转审人
     $review_transfer = $request['review_transfer'] == 1 ? true : false;
     if ($review_id && $review_operate) {
         $transfer = new Erp_Model_Purchse_Transfer();
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         $employee_id = $user_session->user_info['employee_id'];
         // 评审意见
         $review_info = '意见: ' . $review_remark;
         $req = new Erp_Model_Purchse_Req();
         $user = new Application_Model_User();
         $review = new Dcc_Model_Review();
         $employee = new Hra_Model_Employee();
         $reqData = $req->getData(null, $review_id);
         // 更新审核状态及审核意见
         if ($review_operate == 'transfer') {
             // 转审
             $review_info = $reqData['review_info'] . '<br>' . $now . ': ' . $user_session->user_info['user_name'] . ' [审核-转审] [' . $review_info . ']';
             $req->update(array('review_info' => $review_info), "id = " . $review_id);
             $reviewState = $review->fetchRow("type = 'purchse_req_add' and finish_flg = 0 and file_id = " . $review_id, "id")->toArray();
             // 转审对象
             $transferUserInfo = $user->getEmployeeInfoById($review_transfer_user);
             $reviewUsers = $reviewState['plan_user'];
             $reviewUserArr = explode(',', $reviewUsers);
             $reviewer = array();
             if ($reviewState['method'] == 2) {
                 // 任意: 直接替换审核人为转审对象
                 foreach ($reviewUserArr as $review_user) {
                     if ($review_user == $employee_id) {
                         array_push($reviewer, $transferUserInfo['id']);
                     }
                 }
             } else {
                 // 全部: 替换当前审核人为转审对象,其余审核人保留
                 foreach ($reviewUserArr as $review_user) {
                     if ($review_user == $employee_id) {
                         array_push($reviewer, $transferUserInfo['id']);
                     } else {
                         if (!in_array($review_user, $reviewer)) {
                             array_push($reviewer, $review_user);
                         }
                     }
                 }
             }
             $reviewerstr = implode(',', $reviewer);
             $review->update(array('plan_user' => $reviewerstr), "id = " . $reviewState['id']);
             // 发送邮件通知制单人
             $reviewResult = '<font style="color: #FF0000"><b>转审</b></font>';
             $mail = new Application_Model_Log_Mail();
             $to = $transferUserInfo['email'];
             $mailContent = '<div>采购申请审核:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $reqData['number'] . '</p>
                             <p><b>申请部门:</b>' . $reqData['dept'] . '</p>
                             <p><b>申请人:</b>' . $reqData['apply_user_name'] . '</p>
                             <p><b>制单人:</b>' . $reqData['creater'] . '</p>
                             <p><b>类别:</b>' . $reqData['type'] . '</p>
                             <p><b>事由:</b>' . $reqData['reason'] . '</p>
                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">¥' . round($reqData['total'], 2) . '</a></p>
                             <p><b>备注:</b>' . $reqData['remark'] . '</p>
                             <p><b>制单时间:</b>' . $reqData['create_time'] . '</p>
                             <p><b>更新时间:</b>' . $reqData['update_time'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $reqData['review_info'] . '</p>
                             </div>';
             $mailData = array('type' => '消息', 'subject' => '采购申请-转审', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $user_session->user_info['user_id'], 'content' => $mailContent, 'add_date' => $now);
             try {
                 // 记录邮件日志并发送邮件
                 $mail->send($mail->insert($mailData));
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
             }
         } else {
             if ($review_operate == 'no') {
                 // 更新采购申请状态
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-拒绝] [' . $review_info . ']';
                 $data = array('state' => 1, 'transfer_description' => null, 'review_info' => $reqData['review_info'] . '<br>' . $review_info);
                 $req->update($data, "id = " . $review_id);
                 if ($review_transfer) {
                     $transfer->update(array('state' => 1), "id = " . $reqData['transfer_id']);
                 }
                 // 删除当前申请的审核配置
                 $review->delete("type = 'purchse_req_add' and file_id = " . $review_id);
                 // 发送邮件通知制单人
                 $reviewResult = '<font style="color: #FF0000"><b>拒绝</b></font>';
                 $mail = new Application_Model_Log_Mail();
                 $applyEmployeeData = $user->fetchRow("id = " . $reqData['create_user'])->toArray();
                 $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                 $to = $applyEmployee['email'];
                 $mailContent = '<div>采购申请审核:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $reqData['number'] . '</p>
                             <p><b>申请部门:</b>' . $reqData['dept'] . '</p>
                             <p><b>申请人:</b>' . $reqData['apply_user_name'] . '</p>
                             <p><b>制单人:</b>' . $reqData['creater'] . '</p>
                             <p><b>类别:</b>' . $reqData['type'] . '</p>
                             <p><b>事由:</b>' . $reqData['reason'] . '</p>
                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">¥' . round($reqData['total'], 2) . '</a></p>
                             <p><b>备注:</b>' . $reqData['remark'] . '</p>
                             <p><b>制单时间:</b>' . $reqData['create_time'] . '</p>
                             <p><b>更新时间:</b>' . $reqData['update_time'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $reqData['review_info'] . '</p>
                             </div>';
                 $mailData = array('type' => '消息', 'subject' => '采购申请-审核', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $reqData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                 try {
                     // 记录邮件日志并发送邮件
                     $mail->send($mail->insert($mailData));
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                 }
             } else {
                 $help = new Application_Model_Helpers();
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-批准] [' . $review_info . ']';
                 $reqUpdateData = array('review_info' => $reqData['review_info'] . '<br>' . $review_info);
                 $reviewData = $review->fetchRow("id = " . $review_current_step)->toArray();
                 $actual_user = $reviewData['actual_user'] == '' ? $user_session->user_info['employee_id'] : $reviewData['actual_user'] . ',' . $user_session->user_info['employee_id'];
                 $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                 // 当前审核阶段为最后一阶段
                 if ($review_last_step == 1) {
                     // 当前阶段已完结
                     if ($review_to_finish == 1) {
                         if ($review_transfer) {
                             if ($reqData['transfer_type'] == '取消') {
                                 $this->cancelReq($review_id);
                             } else {
                                 $this->approveTransferUpdateItems($reqData['transfer_id']);
                             }
                             $transfer->update(array('state' => 2), "id = " . $reqData['transfer_id']);
                         }
                         $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                         $reviewResult = '<font style="color: #006400"><b>发布</b></font>';
                         // 发布
                         // 更新申请状态
                         $reqUpdateData['state'] = 2;
                         $reqUpdateData['transfer_description'] = null;
                         $reqUpdateData['release_time'] = $now;
                         // 更新审核记录表
                         $review->update($data, "id = " . $review_current_step);
                         $mail = new Application_Model_Log_Mail();
                         $applyEmployeeData = $user->fetchRow("id = " . $reqData['create_user'])->toArray();
                         $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                         $to = $applyEmployee['email'];
                         $cc = $user_session->user_info['user_email'];
                         // 发布通知采购员
                         $buyer = new Erp_Model_Purchse_Buyer();
                         $buyerData = $buyer->getData();
                         foreach ($buyerData as $b) {
                             $cc .= ',' . $b['email'];
                         }
                         $mailContent = '<div>采购申请审核批准,请登录系统查看:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>申请单号:</b>' . $reqData['number'] . '</p>
                             <p><b>申请部门:</b>' . $reqData['dept'] . '</p>
                             <p><b>申请人:</b>' . $reqData['apply_user_name'] . '</p>
                             <p><b>制单人:</b>' . $reqData['creater'] . '</p>
                             <p><b>类别:</b>' . $reqData['type'] . '</p>
                             <p><b>事由:</b>' . $reqData['reason'] . '</p>
                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">¥' . round($reqData['total'], 2) . '</a></p>
                             <p><b>备注:</b>' . $reqData['remark'] . '</p>
                             <p><b>制单时间:</b>' . $reqData['create_time'] . '</p>
                             <p><b>更新时间:</b>' . $reqData['update_time'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $reqUpdateData['review_info'] . '</p>
                             </div>';
                         $mailData = array('type' => '消息', 'subject' => '采购申请-发布', 'to' => $to, 'cc' => $cc, 'user_id' => $reqData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                         try {
                             // 记录邮件日志并发送邮件
                             $mail->send($mail->insert($mailData));
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                         }
                     } else {
                         $data = array('actual_user' => $actual_user);
                         $review->update($data, "id = " . $review_current_step);
                         // 等待其他审核人批准
                     }
                 } else {
                     // 当前阶段已完结
                     if ($review_to_finish == 1) {
                         $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                         $reviewResult = '<font style="color: #006400"><b>批准</b></font>';
                         // 进入下一阶段
                         // 更新审核记录表
                         $review->update($data, "id = " . $review_current_step);
                         // 邮件通知下一阶段审核人
                         $reviewNextStepData = $review->fetchRow("id = " . $review_next_step)->toArray();
                         $mailTo = explode(',', $reviewNextStepData['plan_user']);
                         if ($mailTo) {
                             $mailContent = '<div>新建采购申请,请登录系统查看:</div>
                                         <div>
                                         <p><b>申请单号:</b>' . $reqData['number'] . '</p>
                                         <p><b>申请部门:</b>' . $reqData['dept'] . '</p>
                                         <p><b>申请人:</b>' . $reqData['apply_user_name'] . '</p>
                                         <p><b>制单人:</b>' . $reqData['creater'] . '</p>
                                         <p><b>类别:</b>' . $reqData['type'] . '</p>
                                         <p><b>事由:</b>' . $reqData['reason'] . '</p>
                                         <p><b>金额:</b><a style="color: #467500;font-weight: bold;">¥' . round($reqData['total'], 2) . '</a></p>
                                         <p><b>备注:</b>' . $reqData['remark'] . '</p>
                                         <p><b>制单时间:</b>' . $reqData['create_time'] . '</p>
                                         <p><b>更新时间:</b>' . $reqData['update_time'] . '</p>
                                         <hr>
                                         <p><b>审核日志:</b></p><p>' . $reqUpdateData['review_info'] . '</p>
                                         </div>';
                             $mailData = array('type' => '消息', 'subject' => '采购申请-新申请', 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent, 'add_date' => $now);
                             $resultMail = $help->sendMailToStep($mailTo, $mailData);
                             if (!$resultMail['success']) {
                                 $result = $resultMail;
                             }
                         }
                     } else {
                         $data = array('actual_user' => $actual_user);
                         $review->update($data, "id = " . $review_current_step);
                         // 等待其他审核人批准
                     }
                 }
                 // 更新申请状态
                 $req->update($reqUpdateData, "id = " . $review_id);
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 11
0
 /**
  * @abstract    审核
  * @return      null
  */
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => 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['employee_id'];
     $val = (object) $request;
     $materiel = new Product_Model_Materiel();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $id = $val->id;
     $remark = $val->remark1;
     $pass = $val->review_result;
     $publish = false;
     if (isset($val->code) && $val->code != '') {
         $code = $val->code;
         // 检查code是否重复
         if ($materiel->fetchAll("id != {$id} and code = '" . $code . "'")->count() > 0) {
             $result['result'] = false;
             $result['info'] = "代码“" . $code . "”已经存在";
             echo Zend_Json::encode($result);
             exit;
         }
     }
     if (isset($val->ids) && $val->ids && strpos($val->ids, ',') !== false) {
         // 多个
         $ids = explode(',', $val->ids);
     } else {
         $ids = array($id);
     }
     $newCodes = array();
     foreach ($ids as $id) {
         // 获取物料信息
         $materielData = $materiel->getOne($id);
         if (!$materielData) {
             $result['result'] = false;
             $result['info'] = "数据状态已改变";
             echo Zend_Json::encode($result);
             exit;
         }
         $review_id = $materielData->review_id;
         // 获取当前审核情况
         // 如果record记录被删除或状态已改变,报错
         $reviewWhere = "id = {$review_id}";
         $reviewRows = $review->getList($reviewWhere, "materiel");
         if (count($reviewRows) == 0) {
             $result['result'] = false;
             $result['info'] = "非法数据";
             echo Zend_Json::encode($result);
             exit;
         }
         $reviewRow = $reviewRows[0];
         if ($reviewRow['finish_flg'] != 0) {
             $result['result'] = false;
             $result['info'] = "数据状态已改变";
             echo Zend_Json::encode($result);
             exit;
         }
         // 处理记录
         $recordData = array("type" => "materiel", "table_name" => "oa_product_materiel", "table_id" => $id, "handle_user" => $user, "handle_time" => $now, "action" => "审批", "result" => $pass == 1 ? "批准" : ($pass == 2 ? "拒绝" : "转审"), "ip" => $_SERVER['REMOTE_ADDR'], "remark" => $remark);
         // 增加记录
         $record->insert($recordData);
         // 通过方式
         $method = $reviewRow['method'];
         if ($pass == 1) {
             if ($method == 2) {
                 // 任何一人处理即通过
                 $finish_flg = 1;
                 $actual_user = $user;
                 $finish_time = $now;
             } else {
                 // 所有人都需要审核,检查是否所有人都已经审核
                 $plan_user = $reviewRow['plan_user'];
                 $actual_user = $reviewRow['actual_user'];
                 $actual_user = !$actual_user ? $user : $actual_user . "," . $user;
                 // 检查计划审核人和实际审核人是否一致
                 $planA = explode(',', $plan_user);
                 $actualA = explode(',', $actual_user);
                 $passFlg = true;
                 foreach ($planA as $u) {
                     if ($u && !in_array($u, $actualA)) {
                         $passFlg = false;
                     }
                 }
                 if ($passFlg) {
                     $finish_flg = 1;
                     $finish_time = $now;
                 } else {
                     $finish_flg = 0;
                     $finish_time = null;
                 }
             }
             // 审核情况
             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
         } else {
             if ($pass == 3) {
                 // 转审
                 $finish_flg = 0;
                 if ($method == 2) {
                     // 处理方式为任意时,一个人转审之后其他人员也删除
                     $plan_user = str_replace('E', '', $val->transfer_id);
                 } else {
                     // 更改审核情况中的审核人
                     $plan_users = explode(',', $reviewRow['plan_user']);
                     // 审核人不在审核人列表中,并且是管理员,则替换所有人
                     if (!in_array($user, $plan_users) && (Application_Model_User::checkPermissionByRoleName('物料管理员') || Application_Model_User::checkPermissionByRoleName('系统管理员'))) {
                         $plan_users = array(str_replace('E', '', $val->transfer_id));
                     } else {
                         for ($i = 0; $i < count($plan_users); $i++) {
                             if ($plan_users[$i] == $user) {
                                 $plan_users[$i] = str_replace('E', '', $val->transfer_id);
                                 break;
                             }
                         }
                     }
                     $plan_user = implode(',', $plan_users);
                 }
                 // 审核情况
                 $reviewData = array("plan_user" => $plan_user, "method" => 1);
             } else {
                 // 退回
                 $actual_user = null;
                 $finish_time = null;
                 $finish_flg = 0;
                 // 退回选项
                 $return = $reviewRow['return'];
                 if ($return == 2) {
                     // 退到初始状态
                     // 需更新的审核记录: 所有
                     $reviewWhere = "type = 'materiel' and file_id = {$id}";
                     // 审核情况更新数据
                     $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                     // 文件状态不更新
                 } else {
                     if ($return == 4) {
                         // 退到本阶段开始
                         // 需更新的审核记录
                         $reviewWhere = "type = 'materiel' and finish_flg = 0 and file_id = {$id}";
                         // 审核情况更新数据
                         $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                         // 文件状态不更新
                     } else {
                         if ($return == 3) {
                             // 退到上一阶段
                             // 需更新的审核记录:最后一个finish_flg为1的数据和第一个finish_flg为0的数据
                             $last_1 = $first_0 = 0;
                             foreach ($reviewRows as $r) {
                                 if ($r['finish_flg'] == 1) {
                                     $last_1 = $r['id'];
                                 }
                                 if ($r['finish_flg'] == 0 && $first_0 == null) {
                                     $first_0 = $r['id'];
                                 }
                             }
                             $reviewWhere = "id = {$last_1} or id = {$first_0}";
                             // 审核情况更新数据
                             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                             // 文件状态不更新
                         } else {
                             $fileWhere = "id = {$id}";
                             // 更新文件状态为退回
                             $mData = array("state" => "Return");
                             // 退到初始状态
                             // 更新所有record的finish_flg为0
                             $reviewWhere = "type = 'materiel' and file_id = {$id}";
                             // 审核情况
                             $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                         }
                     }
                 }
             }
         }
         // 如果所有record的记录的finish_flg 都为1,则发布
         if ($finish_flg == 1 && $review->fetchAll("type = 'materiel' and finish_flg = 0 and file_id = {$id}")->count() == 1) {
             $publish = true;
             if (!isset($code) || !$code) {
                 // 自动生成物料编码
                 $code = $this->getCode($materielData->type, $materielData->project_no);
                 if (!$code) {
                     $result['result'] = false;
                     $result['info'] = "生成物料编码失败";
                     echo Zend_Json::encode($result);
                     exit;
                 } else {
                     if (count($ids) > 1) {
                         $newCodes[] = $code;
                         $result['info'] = "审批成功";
                     } else {
                         $result['info'] = "审批成功,系统分配物料号:{$code}";
                     }
                 }
             }
             $mData = array("state" => "Active", "code" => $code, "archive_time" => $now);
             $fileWhere = "id = {$id}";
             // 如果有ds等文件,这些文件也设置为已归档
             $data_file_id = $materielData->data_file_id;
             $tsr_id = $materielData->tsr_id;
             $first_report_id = $materielData->first_report_id;
             if ($data_file_id || $tsr_id || $first_report_id) {
                 $uploadUpdWhere = " archive = 0 and (1=0 ";
                 if ($data_file_id) {
                     $uploadUpdWhere .= " or id = " . $data_file_id;
                 }
                 if ($tsr_id) {
                     $uploadUpdWhere .= " or id = " . $tsr_id;
                 }
                 if ($first_report_id) {
                     $uploadUpdWhere .= " or id = " . $first_report_id;
                 }
                 $uploadUpdWhere .= ")";
                 $uploadUpdData = array('archive' => 1, 'archive_time' => $now);
             }
         }
         try {
             // 更新审核情况
             $review->update($reviewData, $reviewWhere);
             // 更新文件
             if (isset($fileWhere)) {
                 $materiel->update($mData, $fileWhere);
             }
             // 更新上传文件
             if (isset($uploadUpdData)) {
                 $upload = new Dcc_Model_Upload();
                 $upload->update($uploadUpdData, $uploadUpdWhere);
             }
             $this->operate("物料评审");
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         // 邮件任务
         // 文件提交者或更新人
         $owner = $materielData['create_user'];
         $dev = false;
         $type = "物料申请";
         // 发邮件的情况:
         // 1、单站审核结束 $finish_flg = 1 && $publish = false
         if ($finish_flg == 1 && !$publish) {
             $subject = $type . "审批";
             // $to = 下一站审核人
             $current = $review->getFirstNoReview("materiel", $id);
             $to = $employee->getInfosByOneLine($current['plan_user']);
             //
             $cc = $employee->getInfosByOneLine($owner);
             $cc = $cc['email'];
             $content = "你有一个" . $type . "需要审批,请登录系统查看详情!";
         }
         // 2、所有审核结束  $publish = true
         if ($publish) {
             $subject = $type . "发布";
             $to = $employee->getInfosByOneLine($owner);
             $cc = $employee->getInfosByOneLine($record->getEmployeeIds($materielData['id'], 'materiel'));
             $cc = $cc['email'];
             $config = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'production');
             if (isset($config) && isset($config->email->apply->publish)) {
                 $to_plus = $config->email->apply->publish;
                 if ($to_plus) {
                     if ($cc) {
                         $cc .= "," . $to_plus;
                     } else {
                         $cc = $to_plus;
                     }
                 }
             }
             //                 $cc = "";
             $his = "<p><b>审核记录:</b><br>" . str_replace(',', '<br>', $record->getHis($materielData['id'], 'materiel')) . "</p>";
             $content = "你申请的" . $type . "已通过审批。<p><b>物料编码:</b>" . $code . "</p><p><b>类别:</b>" . $this->getTypeByConnect($materielData['type'], '') . "</p><p><b>名称:</b>" . $materielData['name'] . "</p><p><b>描述:</b>" . $materielData['description'] . "</p><p><b>申请人:</b>" . $materielData['creater'] . "</p><p><b>申请时间:</b>" . $materielData['create_time'] . "</p>" . $his . "<p>请登录系统查看详情!</p>";
         }
         // 3、退回 isset($return)
         if (isset($return)) {
             $subject = $type . "退回";
             $to = $employee->getInfosByOneLine($owner);
             $cc = "";
             // 原审核人
             if ($reviewRow['plan_user']) {
                 $orgUser = $reviewRow['plan_user'];
                 $cc = $employee->getInfosByOneLine($orgUser);
                 $cc = $cc['email'];
             }
             $content = "你申请的" . $type . "已被退回,<p><b>退回原因:</b>" . $remark . "</p>,请登录系统查看详情!";
         }
         // 4、转审 $pass == 3
         if ($pass == 3) {
             $subject = $type . "转审";
             $toUser = str_replace('E', '', $val->transfer_id);
             $to = $employee->getInfosByOneLine($toUser);
             // 原审核人
             if ($reviewRow['plan_user']) {
                 $orgUser = $reviewRow['plan_user'];
                 $owner .= "," . $orgUser;
             }
             $cc = $employee->getInfosByOneLine($owner);
             $cc = $cc['email'];
             $content = "有新的" . $type . "被转移到你处审批,请登录系统查看详情!";
         }
         if (isset($subject)) {
             $mailData = array('type' => $type, 'subject' => $subject, 'to' => $to['email'], 'cc' => $cc, 'content' => $content, 'send_time' => $now, 'add_date' => $now);
             $mail = new Application_Model_Log_Mail();
             try {
                 $mailId = $mail->insert($mailData);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
             if ($mailId) {
                 $mail->send($mailId);
             }
         }
         $code = null;
     }
     if (count($newCodes) > 0) {
         $result['info'] .= ',系统分配物料号分别为:' . implode(',', $newCodes);
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 12
0
 /**
  * @abstract    审核
  * @return      null
  */
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => 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['employee_id'];
     $val = (object) $request;
     $materiel = new Product_Model_Materiel();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $id = $val->id;
     $remark = $val->remark1;
     $pass = $val->review_result;
     $publish = false;
     // 获取物料信息
     $materielData = $materiel->getOne($id);
     if (!$materielData) {
         $result['result'] = false;
         $result['info'] = "数据状态已改变";
         echo Zend_Json::encode($result);
         exit;
     }
     $review_id = $materielData->review_id;
     // 获取当前审核情况
     // 如果record记录被删除或状态已改变,报错
     $reviewWhere = "id = {$review_id}";
     $reviewRows = $review->getList($reviewWhere);
     if (count($reviewRows) == 0) {
         $result['result'] = false;
         $result['info'] = "非法数据";
         echo Zend_Json::encode($result);
         exit;
     }
     $reviewRow = $reviewRows[0];
     if ($reviewRow['finish_flg'] != 0) {
         $result['result'] = false;
         $result['info'] = "数据状态已改变";
         echo Zend_Json::encode($result);
         exit;
     }
     // 处理记录
     $recordData = array("type" => "materiel", "table_name" => "oa_product_materiel", "table_id" => $id, "handle_user" => $user, "handle_time" => $now, "action" => "审批", "result" => $pass == 1 ? "批准" : ($pass == 2 ? "拒绝" : "转审"), "ip" => $_SERVER['REMOTE_ADDR'], "remark" => $remark);
     // 增加记录
     $record->insert($recordData);
     if ($pass == 1) {
         // 通过方式
         $method = $reviewRow['method'];
         if ($method == 2) {
             // 任何一人处理即通过
             $finish_flg = 1;
             $actual_user = $user;
             $finish_time = $now;
         } else {
             // 所有人都需要审核,检查是否所有人都已经审核
             $plan_user = $reviewRow['plan_user'];
             $actual_user = $reviewRow['actual_user'];
             $actual_user = !$actual_user ? $user : $actual_user . "," . $user;
             // 检查计划审核人和实际审核人是否一致
             if (strlen($plan_user) == strlen($actual_user)) {
                 $finish_flg = 1;
                 $finish_time = $now;
             } else {
                 $finish_flg = 0;
                 $finish_time = null;
             }
         }
         // 审核情况
         $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
     } else {
         if ($pass == 3) {
             // 转审
             $finish_flg = 0;
             // 更改审核情况中的审核人
             $plan_users = explode(',', $reviewRow['plan_user']);
             for ($i = 0; $i < count($plan_users); $i++) {
                 if ($plan_users[$i] == $user) {
                     $plan_users[$i] = str_replace('E', '', $val->transfer_id);
                     break;
                 }
             }
             $plan_user = implode(',', $plan_users);
             // 审核情况
             $reviewData = array("plan_user" => $plan_user, "method" => 1);
         } else {
             // 退回
             $actual_user = null;
             $finish_time = null;
             $finish_flg = 0;
             // 退回选项
             $return = $reviewRow['return'];
             if ($return == 2) {
                 // 退到初始状态
                 // 需更新的审核记录: 所有
                 $reviewWhere = "type = 'materiel' and file_id = {$id}";
                 // 审核情况更新数据
                 $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                 // 文件状态不更新
             } else {
                 if ($return == 4) {
                     // 退到本阶段开始
                     // 需更新的审核记录
                     $reviewWhere = "type = 'materiel' and finish_flg = 0 and file_id = {$id}";
                     // 审核情况更新数据
                     $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                     // 文件状态不更新
                 } else {
                     if ($return == 3) {
                         // 退到上一阶段
                         // 需更新的审核记录:最后一个finish_flg为1的数据和第一个finish_flg为0的数据
                         $last_1 = $first_0 = 0;
                         foreach ($reviewRows as $r) {
                             if ($r['finish_flg'] == 1) {
                                 $last_1 = $r['id'];
                             }
                             if ($r['finish_flg'] == 0 && $first_0 == null) {
                                 $first_0 = $r['id'];
                             }
                         }
                         $reviewWhere = "id = {$last_1} or id = {$first_0}";
                         // 审核情况更新数据
                         $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                         // 文件状态不更新
                     } else {
                         $fileWhere = "id = {$id}";
                         // 更新文件状态为退回
                         $mData = array("state" => "Return");
                         // 退到初始状态
                         // 更新所有record的finish_flg为0
                         $reviewWhere = "type = 'materiel' and file_id = {$id}";
                         // 审核情况
                         $reviewData = array("actual_user" => $actual_user, "finish_time" => $finish_time, "finish_flg" => $finish_flg);
                     }
                 }
             }
         }
     }
     // 如果所有record的记录的finish_flg 都为1,则发布
     if ($finish_flg == 1 && $review->fetchAll("type = 'materiel' and finish_flg = 0 and file_id = {$id}")->count() == 1) {
         $publish = true;
         $code = $val->code;
         if (!$code) {
             // 自动生成物料编码
             $code = $this->getCode($materielData->type);
             if (!$code) {
                 $result['result'] = false;
                 $result['info'] = "生成物料编码失败";
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
         $mData = array("state" => "Active", "code" => $code, "archive_time" => $now);
         $fileWhere = "id = {$id}";
     }
     try {
         // 更新审核情况
         $review->update($reviewData, $reviewWhere);
         // 更新文件
         if (isset($fileWhere)) {
             $materiel->update($mData, $fileWhere);
         }
         $this->operate("物料评审");
     } catch (Exception $e) {
         $result['result'] = false;
         $result['info'] = $e->getMessage();
         echo Zend_Json::encode($result);
         exit;
     }
     // 邮件任务
     // 文件提交者或更新人
     $owner = $materielData['create_user'];
     $dev = false;
     $type = "物料申请";
     // 发邮件的情况:
     // 1、单站审核结束 $finish_flg = 1 && $publish = false
     if ($finish_flg == 1 && !$publish) {
         $subject = $type . "审批";
         // $to = 下一站审核人
         $current = $review->getCurrent("materiel", $id);
         $to = $employee->getInfosByOneLine($current['plan_user']);
         //
         $cc = $employee->getInfosByOneLine($owner);
         $cc = $cc['email'];
         $content = "你有一个" . $type . "需要审批,请登录系统查看详情!";
     }
     // 2、所有审核结束  $publish = true
     if ($publish) {
         $subject = $type . "发布";
         $to = $employee->getInfosByOneLine($owner);
         $cc = "";
         $content = "你申请的" . $type . "已通过审批,分配的物料编码为:" . $code . ",请登录系统查看详情!";
     }
     // 3、退回 isset($return)
     if (isset($return)) {
         $subject = $type . "退回";
         $to = $employee->getInfosByOneLine($owner);
         $cc = "";
         // 原审核人
         if ($reviewRow['plan_user']) {
             $orgUser = $reviewRow['plan_user'];
             $cc = $employee->getInfosByOneLine($orgUser);
             $cc = $cc['email'];
         }
         $content = "你申请的" . $type . "已被退回,请登录系统查看详情!";
     }
     // 4、转审 $pass == 3
     if ($pass == 3) {
         $subject = $type . "转审";
         $toUser = str_replace('E', '', $val->transfer_id);
         $to = $employee->getInfosByOneLine($toUser);
         // 原审核人
         if ($reviewRow['plan_user']) {
             $orgUser = $reviewRow['plan_user'];
             $owner .= "," . $orgUser;
         }
         $cc = $employee->getInfosByOneLine($owner);
         $cc = $cc['email'];
         $content = "有新的" . $type . "被转移到你处审批,请登录系统查看详情!";
     }
     if (isset($subject)) {
         $mailData = array('type' => $type, 'subject' => $subject, 'to' => $to['email'], 'cc' => $cc, 'content' => $content, 'send_time' => $now, 'add_date' => $now);
         $mail = new Application_Model_Log_Mail();
         try {
             $mailId = $mail->insert($mailData);
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         if ($mailId) {
             $mail->send($mailId);
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 13
0
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '审核成功');
     $request = $this->getRequest()->getParams();
     $review_type = isset($request['review_type']) ? $request['review_type'] : null;
     $review_step = isset($request['review_step']) ? $request['review_step'] : null;
     $review_id = isset($request['review_id']) ? $request['review_id'] : null;
     $review_operate = isset($request['review_operate']) ? $request['review_operate'] : null;
     $review_remark = isset($request['review_remark']) ? $request['review_remark'] : null;
     if ($review_id && $review_type) {
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         // 评审意见
         $review_info = '意见: ' . $review_remark;
         $user = new Application_Model_User();
         $review = new Dcc_Model_Review();
         $employee = new Hra_Model_Employee();
         if ($review_type == 'vacation') {
             $vacation = new Hra_Model_Attendance_Vacation();
             $vacationData = $vacation->getData(null, $review_id);
             if ($review_operate == 'no') {
                 // 拒绝
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-拒绝] [' . $review_info . ']';
                 $timeType = 'review_time_1';
                 if ($vacationData['review_time_1']) {
                     $timeType = 'review_time_2';
                 }
                 $data = array('state' => 1, $timeType => date('Y-m-d H:i:s'), 'review_info' => $vacationData['review_info'] . '<br>' . $review_info);
                 $vacation->update($data, "id = " . $review_id);
                 // 删除当前申请的审核配置
                 $review->delete("type = 'attendance_vacation' and file_id = " . $review_id);
                 // 调休假申请被拒绝后:还原对调加班时间的调休状态
                 if ($vacationData['type'] == 8) {
                     $overtimeIdArr = explode(',', $vacationData['exchange_overtime_ids']);
                     $overtime = new Hra_Model_Attendance_Overtime();
                     foreach ($overtimeIdArr as $overtimeId) {
                         $overtime->update(array('exchange' => 0), "id = " . $overtimeId);
                     }
                 }
                 // 发送邮件通知申请人
                 $reviewResult = '<font style="color: #FF0000"><b>拒绝</b></font>';
                 $mail = new Application_Model_Log_Mail();
                 $applyEmployeeData = $user->fetchRow("id = " . $vacationData['create_user'])->toArray();
                 $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                 $to = $applyEmployee['email'];
                 $mailContent = '<div>请假申请审核:</div>
                                 <div>
                                 <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>审核结果:</b>' . $reviewResult . '</p>
                                 <p><b>审核意见:</b>' . $review_remark . '</p>
                                 <p><b>申请人:</b><a style="color:#008B00;font-weight: bold;">' . $vacationData['apply_user_name'] . '</a></p>
                                 <p><b>请假类别:</b>' . $vacationData['type_name'] . '</p>
                                 <p><b>请假时间:</b><a style="color:#008B00;font-weight: bold;">' . $vacationData['time_from'] . '</a> 至 <a style="color:#008B00;font-weight: bold;">' . $vacationData['time_to'] . '</a></p>
                                 <p><b>代理人:</b>' . $vacationData['agent_name'] . '</p>
                                 <p><b>事由:</b>' . $vacationData['reason'] . '</p>
                                 <p><b>工作交接:</b>' . $vacationData['work'] . '</p>
                                 <p><b>备注:</b>' . $vacationData['remark'] . '</p>
                                 <p><b>创建人:</b>' . $vacationData['creater'] . '</p>
                                 <p><b>申请时间:</b>' . $vacationData['create_time'] . '</p>
                                 <hr>
                                 <p><b>审核日志:</b></p><p>' . $data['review_info'] . '</p>
                                 </div>';
                 $mailData = array('type' => '消息', 'subject' => '请假申请-审核', 'to' => $to, 'user_id' => $vacationData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                 try {
                     // 记录邮件日志并发送邮件
                     $mail->send($mail->insert($mailData));
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                 }
             } else {
                 // 批准
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-批准] [' . $review_info . ']';
                 $reviewResult = '<font style="color: #006400"><b>批准</b></font>';
                 $updateData = array();
                 $toArr = array();
                 $subject = '审核';
                 $mailCc = null;
                 if ($review_step == 'review_1') {
                     $step_name = '审核人1';
                     if ($vacationData['review_user_2'] > 0 && $vacationData['review_time_1'] == '') {
                         // 二级审核,当前申请批准后进入第二级审核
                         array_push($toArr, $vacationData['review_employee_2_id']);
                         $updateData = array('review_time_1' => $now, 'review_info' => $vacationData['review_info'] . '<br>' . $review_info);
                     } else {
                         // 一级审核,当前申请批准后进入HRA审核
                         $member = new Admin_Model_Member();
                         $hraAdminUserArr = $member->getMemberWithNoManagerByName('人事主管');
                         $hraEmployeeIdArr = array();
                         foreach ($hraAdminUserArr as $hra) {
                             $hra_info = $user->getEmployeeInfoById($hra['user_id']);
                             array_push($toArr, $hra_info['id']);
                         }
                         if (isset($vacationData['manager_id']) && $vacationData['manager_id'] != '') {
                             array_push($toArr, $vacationData['manager_id']);
                         }
                         $updateData = array('state' => 2, 'review_time_1' => $now, 'review_info' => $vacationData['review_info'] . '<br>' . $review_info);
                     }
                 } else {
                     if ($review_step == 'review_2') {
                         // 二级审核,当前申请批准后进入HRA审核
                         $step_name = '审核人2';
                         $member = new Admin_Model_Member();
                         $hraAdminUserArr = $member->getMemberWithNoManagerByName('人事主管');
                         $hraEmployeeIdArr = array();
                         foreach ($hraAdminUserArr as $hra) {
                             $hra_info = $user->getEmployeeInfoById($hra['user_id']);
                             array_push($toArr, $hra_info['id']);
                         }
                         if (isset($vacationData['manager_id']) && $vacationData['manager_id'] != '') {
                             array_push($toArr, $vacationData['manager_id']);
                         }
                         $updateData = array('state' => 2, 'review_time_2' => $now, 'review_info' => $vacationData['review_info'] . '<br>' . $review_info);
                     } else {
                         if ($review_step == 'review_hra') {
                             // HRA审核,当前申请批准后发布
                             $step_name = '人事审核';
                             $reviewResult = '<font style="color: #006400"><b>发布</b></font>';
                             $subject = '发布';
                             array_push($toArr, $vacationData['apply_employee_id']);
                             $updateData = array('state' => 3, 'release_time' => $now, 'release_user' => $user_id, 'review_info' => $vacationData['review_info'] . '<br>' . $review_info);
                             $mailCc = $vacationData['agent_email'];
                             if ($mailCc != '') {
                                 if ($vacationData['manager_email'] != '') {
                                     $mailCc .= ',' . $vacationData['manager_email'];
                                 }
                             } else {
                                 $mailCc = $vacationData['manager_email'];
                             }
                             if ($vacationData['type'] == 2) {
                                 // 当年假申请批准后,更新年假库的已用时间:根据员工工号以及入司年数
                                 $vacationStorage = new Hra_Model_Vacationstorage();
                                 $vacationStorage->update(array('qty_used' => new Zend_Db_Expr("qty_used + " . $vacationData['qty'])), "number = '" . $vacationData['number'] . "' and in_year_qty = " . $vacationData['in_year_qty']);
                             }
                             // 请假申请发布后,在打卡记录中按请假时间加入打卡时间,且备注请假类别
                             /* $attendance = new Hra_Model_Attendance();
                                $attendance->setClock($vacationData['number'], $vacationData['employment_type'], $vacationData['time_from'], $vacationData['time_to'], $vacationData['type_name']); */
                         }
                     }
                 }
                 // 更新Review表
                 $reviewData = array('actual_user' => $user_session->user_info['employee_id'], 'finish_time' => $now, 'finish_flg' => 1);
                 $review->update($reviewData, "type = 'attendance_vacation' and file_id = " . $review_id . " and step_name = '" . $step_name . "'");
                 // 更新请假申请
                 $vacation->update($updateData, "id = " . $review_id);
                 // 发送邮件
                 if (count($toArr)) {
                     $mailContent = '<div>请假申请审核:</div>
                                     <div>
                                     <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                                     <p><b>审核结果:</b>' . $reviewResult . '</p>
                                     <p><b>审核意见:</b>' . $review_remark . '</p>
                                     <p><b>申请人:</b><a style="color:#008B00;font-weight: bold;">' . $vacationData['apply_user_name'] . '</a></p>
                                     <p><b>请假类别:</b><a style="color:#008B00;font-weight: bold;">' . $vacationData['type_name'] . '</a></p>
                                     <p><b>请假时间:</b><a style="color:#008B00;font-weight: bold;">' . $vacationData['time_from'] . '</a> 至 <a style="color:#008B00;font-weight: bold;">' . $vacationData['time_to'] . '</a></p>
                                     <p><b>代理人:</b>' . $vacationData['agent_name'] . '</p>
                                     <p><b>事由:</b>' . $vacationData['reason'] . '</p>
                                     <p><b>工作交接:</b>' . $vacationData['work'] . '</p>
                                     <p><b>备注:</b>' . $vacationData['remark'] . '</p>
                                     <p><b>创建人:</b>' . $vacationData['creater'] . '</p>
                                     <p><b>申请时间:</b>' . $vacationData['create_time'] . '</p>
                                     <hr>
                                     <p><b>审核日志:</b></p><p>' . $updateData['review_info'] . '</p>
                                     </div>';
                     $mailData = array('type' => '消息', 'subject' => '请假申请-' . $subject, 'user_id' => $vacationData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                     if ($mailCc) {
                         $mailData['cc'] = $mailCc;
                     }
                     $help = new Application_Model_Helpers();
                     $resultMail = $help->sendMailToStep($toArr, $mailData);
                     if (!$result['success']) {
                         $result = $resultMail;
                     }
                 }
             }
         } else {
             if ($review_type == 'overtime') {
                 $overtime = new Hra_Model_Attendance_Overtime();
                 $overtimeData = $overtime->getData(null, $review_id);
                 if ($review_operate == 'no') {
                     // 拒绝
                     $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-拒绝] [' . $review_info . ']';
                     $timeType = 'review_time_1';
                     if ($overtimeData['review_time_1']) {
                         $timeType = 'review_time_2';
                     }
                     $data = array('state' => 1, $timeType => date('Y-m-d H:i:s'), 'review_info' => $overtimeData['review_info'] . '<br>' . $review_info);
                     $overtime->update($data, "id = " . $review_id);
                     // 删除当前申请的审核配置
                     $review->delete("type = 'attendance_overtime' and file_id = " . $review_id);
                     // 发送邮件通知申请人
                     $reviewResult = '<font style="color: #FF0000"><b>拒绝</b></font>';
                     $mail = new Application_Model_Log_Mail();
                     $applyEmployeeData = $user->fetchRow("id = " . $overtimeData['create_user'])->toArray();
                     $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                     $to = $applyEmployee['email'];
                     $mailContent = '<div>加班申请审核:</div>
                                 <div>
                                 <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>审核结果:</b>' . $reviewResult . '</p>
                                 <p><b>审核意见:</b>' . $review_remark . '</p>
                                 <p><b>申请人:</b><a style="color:#008B00;font-weight: bold;">' . $overtimeData['apply_user_name'] . '</a></p>
                                 <p><b>加班时间:</b><a style="color:#008B00;font-weight: bold;">' . $overtimeData['time_from'] . '</a> 至 <a style="color:#008B00;font-weight: bold;">' . $overtimeData['time_to'] . '</a></p>
                                 <p><b>事由:</b>' . $overtimeData['reason'] . '</p>
                                 <p><b>备注:</b>' . $overtimeData['remark'] . '</p>
                                 <p><b>创建人:</b>' . $overtimeData['creater'] . '</p>
                                 <p><b>申请时间:</b>' . $overtimeData['create_time'] . '</p>
                                 <hr>
                                 <p><b>审核日志:</b></p><p>' . $data['review_info'] . '</p>
                                 </div>';
                     $mailData = array('type' => '消息', 'subject' => '加班申请-审核', 'to' => $to, 'user_id' => $overtimeData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                     try {
                         // 记录邮件日志并发送邮件
                         $mail->send($mail->insert($mailData));
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                     }
                 } else {
                     // 批准
                     $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-批准] [' . $review_info . ']';
                     $reviewResult = '<font style="color: #006400"><b>批准</b></font>';
                     $updateData = array();
                     $toArr = array();
                     $subject = '审核';
                     if ($review_step == 'review_1') {
                         $step_name = '审核人1';
                         if ($overtimeData['review_user_2'] > 0 && $overtimeData['review_time_1'] == '') {
                             // 二级审核,当前申请批准后进入第二级审核
                             array_push($toArr, $overtimeData['review_employee_2_id']);
                             $updateData = array('review_time_1' => $now, 'review_info' => $overtimeData['review_info'] . '<br>' . $review_info);
                         } else {
                             // 一级审核,当前申请批准后进入HRA审核
                             $member = new Admin_Model_Member();
                             $hraAdminUserArr = $member->getMemberWithNoManagerByName('人事主管');
                             $hraEmployeeIdArr = array();
                             foreach ($hraAdminUserArr as $hra) {
                                 $hra_info = $user->getEmployeeInfoById($hra['user_id']);
                                 array_push($toArr, $hra_info['id']);
                             }
                             if (isset($overtimeData['manager_id']) && $overtimeData['manager_id'] != '') {
                                 array_push($toArr, $overtimeData['manager_id']);
                             }
                             $updateData = array('state' => 2, 'review_time_1' => $now, 'review_info' => $overtimeData['review_info'] . '<br>' . $review_info);
                         }
                     } else {
                         if ($review_step == 'review_2') {
                             // 二级审核,当前申请批准后进入HRA审核
                             $step_name = '审核人2';
                             $member = new Admin_Model_Member();
                             $hraAdminUserArr = $member->getMemberWithNoManagerByName('人事主管');
                             $hraEmployeeIdArr = array();
                             foreach ($hraAdminUserArr as $hra) {
                                 $hra_info = $user->getEmployeeInfoById($hra['user_id']);
                                 array_push($toArr, $hra_info['id']);
                             }
                             if (isset($overtimeData['manager_id']) && $overtimeData['manager_id'] != '') {
                                 array_push($toArr, $overtimeData['manager_id']);
                             }
                             $updateData = array('state' => 2, 'review_time_2' => $now, 'review_info' => $overtimeData['review_info'] . '<br>' . $review_info);
                         } else {
                             if ($review_step == 'review_hra') {
                                 // HRA审核,当前申请批准后发布
                                 $step_name = '人事审核';
                                 $reviewResult = '<font style="color: #006400"><b>发布</b></font>';
                                 $subject = '发布';
                                 array_push($toArr, $overtimeData['apply_employee_id']);
                                 $updateData = array('state' => 3, 'release_time' => $now, 'release_user' => $user_id, 'review_info' => $overtimeData['review_info'] . '<br>' . $review_info);
                             }
                         }
                     }
                     // 更新Review表
                     $reviewData = array('actual_user' => $user_session->user_info['employee_id'], 'finish_time' => $now, 'finish_flg' => 1);
                     $review->update($reviewData, "type = 'attendance_overtime' and file_id = " . $review_id . " and step_name = '" . $step_name . "'");
                     // 更新加班申请
                     $overtime->update($updateData, "id = " . $review_id);
                     // 发送邮件
                     if (count($toArr)) {
                         $mailContent = '<div>加班申请审核:</div>
                                     <div>
                                     <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                                     <p><b>审核结果:</b>' . $reviewResult . '</p>
                                     <p><b>审核意见:</b>' . $review_remark . '</p>
                                     <p><b>申请人:</b><a style="color:#008B00;font-weight: bold;">' . $overtimeData['apply_user_name'] . '</a></p>
                                     <p><b>请假时间:</b><a style="color:#008B00;font-weight: bold;">' . $overtimeData['time_from'] . '</a> 至 <a style="color:#008B00;font-weight: bold;">' . $overtimeData['time_to'] . '</a></p>
                                     <p><b>事由:</b>' . $overtimeData['reason'] . '</p>
                                     <p><b>备注:</b>' . $overtimeData['remark'] . '</p>
                                     <p><b>创建人:</b>' . $overtimeData['creater'] . '</p>
                                     <p><b>申请时间:</b>' . $overtimeData['create_time'] . '</p>
                                     <hr>
                                     <p><b>审核日志:</b></p><p>' . $updateData['review_info'] . '</p>
                                     </div>';
                         $mailData = array('type' => '消息', 'subject' => '加班申请-' . $subject, 'user_id' => $overtimeData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                         $help = new Application_Model_Helpers();
                         $resultMail = $help->sendMailToStep($toArr, $mailData);
                         if (!$result['success']) {
                             $result = $resultMail;
                         }
                     }
                 }
             }
         }
     } else {
         $result['success'] = false;
         $result['info'] = "审核失败,审核对象和操作类别不能为空!";
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 14
0
 private function send($id, $updFlg)
 {
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $user_name = $user_session->user_info['user_name'];
     $now = date('Y-m-d H:i:s');
     $employee = new Hra_Model_Employee();
     $mail = new Application_Model_Log_Mail();
     $task = new User_Model_Task();
     $process = new User_Model_Process();
     $record = $task->getJoinList("id=" . $id);
     if (!$record) {
         return;
     }
     $record = $record[0];
     if ($record['type'] == '独立') {
         $where = " task_id = {$id} and employee_id = {$user}";
     } else {
         $where = " task_id = {$id}";
     }
     $join = array('type' => INNERJOIN, 'table' => $employee, 'condition' => $employee->getName() . '.id = ' . $process->getName() . '.employee_id', 'cols' => array('cname'));
     $pro = $process->getJoinList($where, $join);
     $to_id = $record['responsible_id'];
     $cc_id = $record['follow_id'];
     // 上级
     if ($to_id == $user) {
         $up = $employee->getAdapter()->query("select manager_id from oa_employee where id = {$user}")->fetchObject();
         if ($up && $up->manager_id && $up->manager_id != $user) {
             if ($cc_id) {
                 $cc_id .= ',' . $up->manager_id;
             } else {
                 $cc_id = $up->manager_id;
             }
         }
     }
     $to = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $to_id . ")")->fetchObject();
     $ccmail = null;
     if ($cc_id) {
         $cc = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $cc_id . ")")->fetchObject();
         $ccmail = $cc->mail_to;
     }
     if ($updFlg == 'add') {
         $title = "新任务提示";
         $content = $user_name . "创建了新任务 " . $record['title'];
     } else {
         if ($updFlg == 'update') {
             $title = "任务更新提示";
             $content = $user_name . "更新了任务 " . $record['title'];
         } else {
             $title = "任务删除提示";
             $content = $user_name . "删除了任务 " . $record['title'];
         }
     }
     $content .= "<p><b>任务名称:</b>" . $record['title'] . "</p>";
     $content .= "<p><b>当前状态:</b>" . $record['state'] . "</p>";
     $content .= "<p><b>任务时间:</b>" . $record['start'] . "到" . $record['end'] . "</p>";
     $content .= "<p><b>任务描述:</b>" . $record['notes'] . "</p>";
     $content .= "<p><b>重要程度:</b>" . $record['important'] . "</p>";
     $content .= "<p><b>优先级:</b>" . $record['priority'] . "</p>";
     $content .= "<p><b>协作模式:</b>" . $record['type'] . "</p>";
     $creater = $employee->getById($record['create_user']);
     $content .= "<p><b>创建人:</b>" . $creater['cname'] . "</p>";
     $content .= "<p><b>创建时间:</b>" . $record['create_time'] . "</p>";
     $content .= "<p><b>进度</b></p>";
     foreach ($pro as $p) {
         $content .= "<p>&nbsp;&nbsp;";
         if ($record['type'] == '协作') {
             $content .= $p['cname'] . "&nbsp;&nbsp;";
         }
         $content .= $p['update_time'] . "&nbsp;&nbsp;" . $p['status'] . "&nbsp;&nbsp;" . $p['rate'] . "%&nbsp;&nbsp;" . $p['remark'] . "</p>";
     }
     $mailData = array('type' => '任务', 'subject' => $title, 'to' => $to->mail_to, 'cc' => $ccmail, 'content' => $content, 'send_time' => $now, 'add_date' => $now);
     $mailId = $mail->insert($mailData);
     if ($mailId) {
         $mail->send($mailId);
     }
 }
Exemplo n.º 15
0
 /**
  * 根据ID获取用户信息
  * @param unknown $id
  * @return Ambigous <multitype:, array>
  */
 public function getEmployeeInfoById($id)
 {
     $user = $this->fetchRow("id = " . $id)->toArray();
     $employee = new Hra_Model_Employee();
     return $employee->getInfoById($user['employee_id']);
 }
Exemplo n.º 16
0
 /**
  * 刷新员工年假库
  * 1、根据员工用功形式获取员工的其实年假设置;
  * 2、
  * @param number $employee_id
  */
 public function refreshStorage($employee_id = null, $cover = 0)
 {
     $result = array('success' => true, 'info' => '刷新成功');
     $qty = 0;
     $employee = new Hra_Model_Employee();
     $paramModel = new Hra_Model_Attendanceparams();
     // 获取所有用工形式的首年年假设置天数
     $vacationSet = $paramModel->getParamByType('vacation');
     $employeeCond = "";
     // 刷新个人或全部在职员工的最近一年的年假天数
     if ($employee_id) {
         $employeeCond = " and id = " . $employee_id;
     }
     $data = $employee->fetchAll("active = 1" . $employeeCond)->toArray();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     foreach ($data as $d) {
         // 根据转正日期
         if ($d['regularization_date'] != '') {
             // 起始年假天数(来自基础设置)
             $qtyStart = $vacationSet[$d['employment_type']];
             // 入司年数
             $in_year_qty = 0;
             // 2014-10-08之后入职的员工按入职日期开始计算,否则按转正日期计算
             if (strtotime($d['entry_date']) >= strtotime('2014-10-08')) {
                 $in_year_qty = $employee->getInCompanyYearQty($d['entry_date']);
                 //入职日期
             } else {
                 $in_year_qty = $employee->getInCompanyYearQty($d['regularization_date']);
                 //转正日期
             }
             $qty = 0;
             if ($in_year_qty > 0) {
                 // 根据入司年数计算员工最近一年应有几天年假
                 $qty = $qtyStart + $in_year_qty - 1;
             }
             if ($qty >= 0) {
                 // 当员工最近一年的年假已记录时,更新(用户选择是否覆盖)员工最近的年假天数,否则插入新数据
                 $oldDataRes = $this->fetchAll("number = '" . $d['number'] . "' and in_year_qty = " . $in_year_qty);
                 if ($oldDataRes->count() > 0 && $cover == 1) {
                     $oldData = $oldDataRes->toArray();
                     // 当员工当前入司年份有数据时,更新记录
                     $t = array('qty' => $qty, 'remark' => '刷新更新', 'update_user' => $user_id, 'update_time' => $now);
                     try {
                         $this->update($t, "id = " . $oldData[0]['id']);
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                         return $result;
                     }
                 } else {
                     if ($oldDataRes->count() == 0) {
                         // 当员工当前入司年份没有数据时,插入新记录
                         $t = array('number' => $d['number'], 'in_year_qty' => $in_year_qty, 'qty' => $qty, 'remark' => '刷新生成', 'create_user' => $user_id, 'create_time' => $now, 'update_user' => $user_id, 'update_time' => $now);
                         try {
                             $this->insert($t);
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                             return $result;
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }
Exemplo n.º 17
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;
 }
Exemplo n.º 18
0
 public function getlistAction()
 {
     $request = $this->getRequest()->getParams();
     $limit = $request['limit'];
     $start = $request['start'];
     $fa = new Product_Model_Fa();
     $db = $fa->getAdapter();
     $whereSearch = "1=1";
     //        if(isset($request['search_state']) && $request['search_state'] != 'Active') {
     //        	$whereSearch = " t1.state != 'Active'";
     //        }
     foreach ($request as $k => $v) {
         if ($v) {
             if ($k == 'search_key') {
                 $whereSearch .= " and (ifnull(t1.remark,'') like '%{$v}%' or ifnull(t3.cname,'') like '%{$v}%' or ifnull(t1.description,'') like '%{$v}%')";
             } else {
                 if ("search_fa" == $k && $v) {
                     $nid = "";
                     $faData = $db->query("select group_concat(nid) as nid from oa_product_bom_fa_dev where code like '%{$v}%'")->fetchObject();
                     if ($faData && $faData->nid) {
                         $nid = $faData->nid;
                     }
                     if (!$nid) {
                         $nid = "0";
                     }
                     $whereSearch .= " and t1.id in ({$nid})";
                 } else {
                     if ("search_son" == $k && $v) {
                         $nid = "";
                         $sonData = $db->query("select group_concat(nid) as nid from oa_product_bom_son_dev where code like '%{$v}%'")->fetchObject();
                         if ($sonData && $sonData->nid) {
                             $nid = $sonData->nid;
                         }
                         if (!$nid) {
                             $nid = "0";
                         }
                         $whereSearch .= " and t1.id in ({$nid})";
                     } else {
                         $col = str_replace('search_', '', $k);
                         if ($col != $k) {
                             // 查询条件
                             $whereSearch .= " and ifnull(t1." . $col . ",'') like '%" . $v . "%'";
                         }
                     }
                 }
             }
         }
     }
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     $materiel = new Product_Model_Materiel();
     $type = new Product_Model_Type();
     $record = new Dcc_Model_Record();
     $flow = new Admin_Model_Flow();
     $step = new Admin_Model_Step();
     $share = new Dcc_Model_Share();
     $type = new Dcc_Model_Type();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $dept = new Hra_Model_Dept();
     $updbom = new Product_Model_Updbom();
     // 查询条件
     // 类型
     $myType = "";
     if (isset($request['mytype'])) {
         $myType = $request['mytype'];
     }
     // 获取物料数据
     $data = $updbom->getMy($myType, $whereSearch, $user, $start, $limit);
     $totalCount = $updbom->getMyCount($myType, $whereSearch, $user);
     for ($i = 0; $i < count($data); $i++) {
         $upd_type = $data[$i]['upd_type'];
         if ($upd_type == 'ECO') {
             $bomflg = "ecobom";
         } else {
             if ($upd_type == 'DEV') {
                 $bomflg = "devbom";
             }
         }
         $mytype = 2;
         if ($data[$i]['create_user'] == $user) {
             $mytype = 1;
         }
         $data[$i]['create_time'] = strtotime($data[$i]['create_time']);
         $data[$i]['archive_time'] = strtotime($data[$i]['archive_time']);
         // 获取BOM
         $table = "oa_product_bom_fa_dev";
         $bomData = $updbom->getAdapter()->query("select group_concat(concat(code,' V', ver)) as bom from {$table} where type='{$upd_type}' and nid = " . $data[$i]['id'])->fetchObject();
         $data[$i]['bom'] = $bomData->bom;
         // 增加审核状态
         $reviewState = "";
         $step_name = "";
         if ($data[$i]['state'] == 'Active') {
             $reviewState = "已归档";
         } else {
             if ($data[$i]['state'] == 'Reviewing') {
                 // 查询当前审核状态
                 // 查询所有审核阶段
                 $reviewRows = $review->getList("file_id = " . $data[$i]['id'], $bomflg);
                 if (count($reviewRows) > 0) {
                     $first = true;
                     foreach ($reviewRows as $row) {
                         if ($row['finish_flg'] == 1) {
                             if ($step_name) {
                                 $step_name .= "->";
                             }
                             $step_name .= $row['step_name'];
                         } else {
                             if ($step_name) {
                                 $step_name .= "->";
                             }
                             // 第一条未审核记录就是当前待审核记录
                             if ($first) {
                                 $first = false;
                                 $step_name .= "<b>" . $row['step_name'] . "</b>";
                                 $reviewRow = $row;
                                 $actual_user = explode(',', $reviewRow['actual_user']);
                                 $planUser = $reviewRow['plan_user'];
                                 $method = $reviewRow['method'];
                                 $plan_user = explode(',', $planUser);
                                 $diff = array_diff($plan_user, $actual_user);
                                 foreach ($diff as $u) {
                                     if (!$u) {
                                         continue;
                                     }
                                     if ($u == $user) {
                                         $mytype = 3;
                                     }
                                     $e = $employee->fetchRow("id = {$u}");
                                     if ($reviewState) {
                                         $reviewState .= ", ";
                                     }
                                     $reviewState .= $e['cname'] . ":未审核";
                                 }
                                 foreach ($actual_user as $u) {
                                     if (!$u) {
                                         continue;
                                     }
                                     $e = $employee->fetchRow("id = {$u}");
                                     if ($reviewState) {
                                         $reviewState .= ", ";
                                     }
                                     $reviewState .= $e['cname'] . ":已审核";
                                 }
                             } else {
                                 $step_name .= $row['step_name'];
                             }
                         }
                     }
                 }
             } else {
                 if ($data[$i]['state'] == 'Obsolete') {
                     $reviewState = "已作废";
                 } else {
                     if ($data[$i]['state'] == 'Return') {
                         $reviewState = "退回";
                     } else {
                         if ($data[$i]['state'] == 'Draft') {
                             $reviewState = "草稿";
                         } else {
                             $reviewState = $data[$i]['state'];
                         }
                     }
                 }
             }
         }
         $data[$i]['step_name'] = $step_name;
         $data[$i]['review_state'] = $reviewState;
         $data[$i]['mytype'] = $mytype;
         $data[$i]['replacea'] = $data[$i]['replace'];
         $data[$i]['record'] = $record->getHis($data[$i]['id'], $bomflg);
     }
     // 排序
     $dataT3 = array();
     $dataT2 = array();
     $dataT1 = array();
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i]['mytype'] == 3) {
             $dataT3[] = $data[$i];
         } else {
             if ($data[$i]['mytype'] == 2) {
                 $dataT2[] = $data[$i];
             } else {
                 $dataT1[] = $data[$i];
             }
         }
     }
     $data = array_merge($dataT3, $dataT1, $dataT2);
     $resutl = array("totalCount" => $totalCount, "topics" => $data);
     // 转为json格式并输出
     echo Zend_Json::encode($resutl);
     exit;
 }
Exemplo n.º 19
0
 /**
  * 编辑用工形式信息
  */
 public function edittypeAction()
 {
     // 返回值数组
     $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_id = $user_session->user_info['user_id'];
     $json = json_decode($request['json']);
     $updated = $json->updated;
     $inserted = $json->inserted;
     $deleted = $json->deleted;
     $type = new Hra_Model_Type();
     if (count($updated) > 0) {
         foreach ($updated as $val) {
             $data = array('active' => $val->active, 'name' => $val->name, 'description' => $val->description, 'remark' => $val->remark, 'update_time' => $now, 'update_user' => $user_id);
             if ($type->fetchAll("id != " . $val->id . " and name = '" . $val->name . "'")->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = $val->name . "已存在,请勿重复添加!";
             } else {
                 try {
                     $type->update($data, "id = " . $val->id);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
     }
     if (count($inserted) > 0) {
         foreach ($inserted as $val) {
             $data = array('active' => $val->active, 'name' => $val->name, 'description' => $val->description, 'remark' => $val->remark, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
             if ($type->fetchAll("name = '" . $val->name . "'")->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = $val->name . "已存在,请勿重复添加!";
             } else {
                 try {
                     $type->insert($data);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
     }
     if (count($deleted) > 0) {
         $employee = new Hra_Model_Employee();
         foreach ($deleted as $val) {
             if ($employee->fetchAll("type_id = " . $val->id)->count() == 0) {
                 try {
                     $type->delete("id = " . $val->id);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $result['success'] = false;
                 $result['info'] = $val->id . '存在关联员工信息,不能删除';
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 20
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;
 }
Exemplo n.º 21
0
 public function editcatalogAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '编辑成功');
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $request = $this->getRequest()->getParams();
     $attribute = isset($request['attribute']) ? $request['attribute'] : false;
     $catalog = new Product_Model_Catalog();
     if ($attribute) {
         $catalog_id = isset($request['id']) ? $request['id'] : null;
         $code = isset($request['code']) ? $request['code'] : null;
         $code_old = isset($request['code_old']) ? $request['code_old'] : null;
         $stage_id = isset($request['stage_id']) && $request['stage_id'] != '' ? $request['stage_id'] : null;
         $remark = isset($request['remark']) ? $request['remark'] : null;
         $date_dvt = isset($request['date_dvt']) && $request['date_dvt'] != '' ? $request['date_dvt'] : null;
         $qa1_date = isset($request['qa1_date']) && $request['qa1_date'] != '' ? $request['qa1_date'] : null;
         $qa2_date = isset($request['qa2_date']) && $request['qa2_date'] != '' ? $request['qa2_date'] : null;
         $evt_date = isset($request['evt_date']) && $request['evt_date'] != '' ? $request['evt_date'] : null;
         $mass_production_date = isset($request['mass_production_date']) && $request['mass_production_date'] != '' ? $request['mass_production_date'] : null;
         if ($catalog_id && $code) {
             if ($catalog->fetchAll("id != " . $catalog_id . " and code = '" . $code . "'")->count() == 0) {
                 $data = array('code' => $code, 'code_old' => $code_old, 'stage_id' => $stage_id, 'remark' => $remark, 'date_dvt' => $date_dvt, 'qa1_date' => $qa1_date, 'qa2_date' => $qa2_date, 'evt_date' => $evt_date, 'mass_production_date' => $mass_production_date, 'update_time' => $now, 'update_user' => $user_id);
                 $where = "id = " . $catalog_id;
                 try {
                     $catalog->update($data, $where);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $result['success'] = false;
                 $result['info'] = '代码重复,请重新分配';
                 echo Zend_Json::encode($result);
                 exit;
             }
         } else {
             $result['success'] = false;
             $result['info'] = '信息不完整,编辑失败!';
         }
     } else {
         $operate = isset($request['operate']) ? $request['operate'] : null;
         $review = isset($request['review']) ? $request['review'] : null;
         $id = isset($request['id']) ? $request['id'] : null;
         $ids = isset($request['ids']) ? $request['ids'] : null;
         $active = isset($request['active']) ? $request['active'] : null;
         $active = $active == 'on' ? 1 : 0;
         $description = isset($request['description']) ? $request['description'] : null;
         $remark = isset($request['remark']) ? $request['remark'] : null;
         $code_customer = isset($request['code_customer']) ? trim($request['code_customer']) : null;
         $model_customer = isset($request['model_customer']) ? trim($request['model_customer']) : null;
         $description_customer = isset($request['description_customer']) ? $request['description_customer'] : null;
         $type_id = isset($request['type_id']) ? $request['type_id'] : null;
         $type_id = isset($request['type_id']) ? $request['type_id'] : null;
         $series_id = isset($request['series_id']) ? $request['series_id'] : null;
         $series_id = isset($request['series_id']) ? $request['series_id'] : null;
         $developmode_id = isset($request['developmode_id']) ? $request['developmode_id'] : null;
         $model_standard = isset($request['model_standard']) ? trim($request['model_standard']) : null;
         $model_internal = isset($request['model_internal']) ? trim($request['model_internal']) : null;
         if ($operate == 'delete' && $id) {
             // 删除
             try {
                 if ($catalog->fetchAll("id = " . $id . " and auditor_id is not null")->count() == 1) {
                     $catalogData = $catalog->fetchRow("id = " . $id)->toArray();
                     $catalog->update(array('delete' => 1, 'review_info' => $catalogData['review_info'] . '<br>' . $now . ': ' . $user_session->user_info['user_name'] . ' [删除]'), "id = " . $id);
                 } else {
                     $catalog->delete("id = " . $id);
                     $review = new Dcc_Model_Review();
                     $review->delete("type = 'product_add' and file_id = " . $id);
                 }
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         } else {
             if ($operate == 'disable' && $ids) {
                 // 作废
                 $idArr = explode(',', $ids);
                 foreach ($idArr as $id) {
                     try {
                         if ($catalog->fetchAll("id = " . $id . " and active = 1")->count() == 1) {
                             $catalogData = $catalog->fetchRow("id = " . $id)->toArray();
                             $catalog->update(array('active' => 0, 'review_info' => $catalogData['review_info'] . '<br>' . $now . ': ' . $user_session->user_info['user_name'] . ' [作废]'), "id = " . $id);
                         }
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                         echo Zend_Json::encode($result);
                         exit;
                     }
                 }
             } else {
                 if ($operate == 'enable' && $ids) {
                     // 启用
                     $idArr = explode(',', $ids);
                     foreach ($idArr as $id) {
                         try {
                             if ($catalog->fetchAll("id = " . $id . " and active = 0")->count() == 1) {
                                 $catalogData = $catalog->fetchRow("id = " . $id)->toArray();
                                 $catalog->update(array('active' => 1, 'review_info' => $catalogData['review_info'] . '<br>' . $now . ': ' . $user_session->user_info['user_name'] . ' [启用]'), "id = " . $id);
                             }
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                             echo Zend_Json::encode($result);
                             exit;
                         }
                     }
                 } else {
                     if ($operate == 'edit' && $id) {
                         // 判断是否重复
                         if ($catalog->fetchAll("id != " . $id . " and model_internal = '" . $model_internal . "'")->count() == 0) {
                             //type_id = ".$type_id." and series_id = ".$series_id." and
                             $catalogData = $catalog->fetchRow("id = " . $id)->toArray();
                             $data = array('active' => $active, 'type_id' => $type_id, 'series_id' => $series_id, 'developmode_id' => $developmode_id, 'model_standard' => $model_standard, 'model_internal' => $model_internal, 'description' => $description, 'remark' => $remark, 'review' => $review == 1 ? 0 : 2, 'code_customer' => $code_customer, 'model_customer' => $model_customer, 'description_customer' => $description_customer, 'update_time' => $now, 'update_user' => $user_id, 'review_info' => $catalogData['review_info'] . '<br>' . $now . ': ' . $user_session->user_info['user_name'] . ' [修改]');
                             $where = "id = " . $id;
                             try {
                                 $catalog->update($data, $where);
                                 if ($catalogData['review'] == 1) {
                                     // 修改
                                     $member = new Admin_Model_Member();
                                     $user = new Application_Model_User();
                                     $employee = new Hra_Model_Employee();
                                     $flow = new Admin_Model_Flow();
                                     $step = new Admin_Model_Step();
                                     $review = new Dcc_Model_Review();
                                     $flowData = $flow->fetchRow("flow_name = '产品中心-审核'")->toArray();
                                     // 获取审核阶段
                                     $stepIds = $flowData['step_ids'];
                                     $stepArr = explode(',', $stepIds);
                                     $i = 0;
                                     foreach ($stepArr as $s) {
                                         $stepData = $step->fetchRow("id = " . $s)->toArray();
                                         $step_user = $stepData['user'] != '' ? $stepData['user'] : null;
                                         $step_role = $stepData['dept'] != '' ? $stepData['dept'] : null;
                                         $reviewData = array('type' => 'product_add', 'file_id' => $id, 'step_name' => $stepData['step_name'], 'plan_user' => $step_user, 'plan_dept' => $step_role, 'method' => $stepData['method'], 'return' => $stepData['return']);
                                         $review->delete("type = 'product_add' AND file_id = " . $id);
                                         $review->insert($reviewData);
                                         // 第一阶段发送邮件通知
                                         if ($i == 0) {
                                             $employeeIdArr = array();
                                             if ($step_user) {
                                                 $tmpArr = explode(',', $stepData['user']);
                                                 foreach ($tmpArr as $t) {
                                                     if (!in_array($t, $employeeIdArr)) {
                                                         array_push($employeeIdArr, $t);
                                                     }
                                                 }
                                             }
                                             if ($step_role) {
                                                 $tmpArr = $member->getMember($stepData['dept']);
                                                 foreach ($tmpArr as $t) {
                                                     if (!in_array($t, $employeeIdArr)) {
                                                         array_push($employeeIdArr, $t['employee_id']);
                                                     }
                                                 }
                                             }
                                             $toAddress = array();
                                             $toIds = array();
                                             foreach ($employeeIdArr as $employeeId) {
                                                 $em = $employee->getInfoById($employeeId);
                                                 array_push($toAddress, $em['email']);
                                                 $u = $user->fetchRow("employee_id = " . $employeeId)->toArray();
                                                 array_push($toIds, $u['id']);
                                             }
                                             $mail = new Application_Model_Log_Mail();
                                             $mailContent = '<div>产品中心-修改产品信息,请登录系统审核:</div>
                                 <div>
                                 <p><b>标准型号:</b>' . $catalogData['model_standard'] . ' -> ' . $model_standard . '</p>
                                 <p><b>内部型号:</b>' . $catalogData['model_internal'] . ' -> ' . $model_internal . '</p>
                                 <p><b>描述:</b>' . $description . '</p>
                                 <p><b>申请人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>申请时间:</b>' . $now . '</p>
                                 </div>';
                                             $mailData = array('type' => '消息', 'subject' => '产品中心-修改', 'to' => implode(',', $toAddress), 'cc' => $user_session->user_info['user_email'], 'user_id' => implode(',', $toIds), 'content' => $mailContent, 'add_date' => $now);
                                             try {
                                                 // 记录邮件日志并发送邮件
                                                 $mail->send($mail->insert($mailData));
                                             } catch (Exception $e) {
                                                 $result['success'] = false;
                                                 $result['info'] = $e->getMessage();
                                                 echo Zend_Json::encode($result);
                                                 exit;
                                             }
                                         }
                                         $i++;
                                     }
                                 } else {
                                     // 变更
                                     $noticeMails = array();
                                     $noticeUsers = array();
                                     $user = new Application_Model_User();
                                     $employee = new Hra_Model_Employee();
                                     $member = new Admin_Model_Member();
                                     $reviewModel = new Dcc_Model_Review();
                                     $reviewerInfo = $reviewModel->getReviewUserInfo('product_add', $id);
                                     // 审核人
                                     $applyEmployeeData = $user->fetchRow("id = " . $catalogData['create_user'])->toArray();
                                     $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                                     // 申请人
                                     $noticeTo = $member->getMemberWithManagerByName('产品中心-PM');
                                     // 管理员
                                     foreach ($noticeTo as $n) {
                                         if ($n['email'] != '' && !in_array($n['user_id'], $noticeUsers)) {
                                             array_push($noticeMails, $n['email']);
                                             array_push($noticeUsers, $n['user_id']);
                                         }
                                     }
                                     foreach ($reviewerInfo as $r) {
                                         if ($r['email'] != '' && !in_array($r['user_id'], $noticeUsers)) {
                                             array_push($noticeMails, $r['email']);
                                             array_push($noticeUsers, $r['user_id']);
                                         }
                                     }
                                     if (!in_array($catalogData['create_user'], $noticeUsers)) {
                                         array_push($noticeMails, $applyEmployee['email']);
                                         array_push($noticeUsers, $catalogData['create_user']);
                                     }
                                     $mail = new Application_Model_Log_Mail();
                                     $mailContent = '<div>产品中心产品信息变更,请登录系统查看:</div>
                                 <div>
                                 <p><b>标准型号:</b>' . $catalogData['model_standard'] . ' -> ' . $model_standard . '</p>
                                 <p><b>内部型号:</b>' . $catalogData['model_internal'] . ' -> ' . $model_internal . '</p>
                                 <p><b>描述:</b>' . $description . '</p>
                                 <p><b>申请人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>申请时间:</b>' . $now . '</p>
                                 </div>';
                                     $mailData = array('type' => '消息', 'subject' => '产品中心-变更', 'cc' => $user_session->user_info['user_email'], 'to' => implode(',', $noticeMails), 'user_id' => $user_id, 'content' => $mailContent, 'add_date' => $now);
                                     try {
                                         // 记录邮件日志并发送邮件
                                         $mail->send($mail->insert($mailData));
                                     } catch (Exception $e) {
                                         $result['success'] = false;
                                         $result['info'] = $e->getMessage();
                                         echo Zend_Json::encode($result);
                                         exit;
                                     }
                                 }
                             } catch (Exception $e) {
                                 $result['success'] = false;
                                 $result['info'] = $e->getMessage();
                                 echo Zend_Json::encode($result);
                                 exit;
                             }
                         } else {
                             $result['success'] = false;
                             $result['info'] = '当前型号已存在,请勿重复添加!';
                             echo Zend_Json::encode($result);
                             exit;
                         }
                     } else {
                         if ($operate == 'add') {
                             if ($catalog->fetchAll("model_internal = '" . $model_internal . "'")->count() == 0) {
                                 //type_id = ".$type_id." and series_id = ".$series_id." and
                                 $data = array('active' => $active, 'type_id' => $type_id, 'series_id' => $series_id, 'developmode_id' => $developmode_id, 'model_standard' => $model_standard, 'model_internal' => $model_internal, 'remark' => $remark, 'description' => $description, 'code_customer' => $code_customer, 'model_customer' => $model_customer, 'description_customer' => $description_customer, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id, 'review_info' => $now . ': ' . $user_session->user_info['user_name'] . ' [添加]');
                                 try {
                                     $catalog_id = $catalog->insert($data);
                                     $member = new Admin_Model_Member();
                                     $user = new Application_Model_User();
                                     $employee = new Hra_Model_Employee();
                                     $flow = new Admin_Model_Flow();
                                     $step = new Admin_Model_Step();
                                     $review = new Dcc_Model_Review();
                                     $flowData = $flow->fetchRow("flow_name = '产品中心-审核'")->toArray();
                                     // 获取审核阶段
                                     $stepIds = $flowData['step_ids'];
                                     $stepArr = explode(',', $stepIds);
                                     $i = 0;
                                     foreach ($stepArr as $s) {
                                         $stepData = $step->fetchRow("id = " . $s)->toArray();
                                         $step_user = $stepData['user'] != '' ? $stepData['user'] : null;
                                         $step_role = $stepData['dept'] != '' ? $stepData['dept'] : null;
                                         $reviewData = array('type' => 'product_add', 'file_id' => $catalog_id, 'step_name' => $stepData['step_name'], 'plan_user' => $step_user, 'plan_dept' => $step_role, 'method' => $stepData['method'], 'return' => $stepData['return']);
                                         $review->insert($reviewData);
                                         // 第一阶段发送邮件通知
                                         if ($i == 0) {
                                             $employeeIdArr = array();
                                             if ($step_user) {
                                                 $tmpArr = explode(',', $stepData['user']);
                                                 foreach ($tmpArr as $t) {
                                                     if (!in_array($t, $employeeIdArr)) {
                                                         array_push($employeeIdArr, $t);
                                                     }
                                                 }
                                             }
                                             if ($step_role) {
                                                 $tmpArr = $member->getMember($stepData['dept']);
                                                 foreach ($tmpArr as $t) {
                                                     if (!in_array($t, $employeeIdArr)) {
                                                         array_push($employeeIdArr, $t['employee_id']);
                                                     }
                                                 }
                                             }
                                             $toAddress = array();
                                             $toIds = array();
                                             foreach ($employeeIdArr as $employeeId) {
                                                 $em = $employee->getInfoById($employeeId);
                                                 array_push($toAddress, $em['email']);
                                                 $u = $user->fetchRow("employee_id = " . $employeeId)->toArray();
                                                 array_push($toIds, $u['id']);
                                             }
                                             $mail = new Application_Model_Log_Mail();
                                             $mailContent = '<div>产品中心新增产品型号,请登录系统审核:</div>
                                 <div>
                                 <p><b>标准型号:</b>' . $model_standard . '</p>
                                 <p><b>内部型号:</b>' . $model_internal . '</p>
                                 <p><b>描述:</b>' . $description . '</p>
                                 <p><b>申请人:</b>' . $user_session->user_info['user_name'] . '</p>
                                 <p><b>申请时间:</b>' . $now . '</p>
                                 </div>';
                                             $mailData = array('type' => '消息', 'subject' => '产品中心-新建', 'to' => implode(',', $toAddress), 'user_id' => implode(',', $toIds), 'content' => $mailContent, 'add_date' => $now);
                                             try {
                                                 // 记录邮件日志并发送邮件
                                                 $mail->send($mail->insert($mailData));
                                             } catch (Exception $e) {
                                                 $result['success'] = false;
                                                 $result['info'] = $e->getMessage();
                                                 echo Zend_Json::encode($result);
                                                 exit;
                                             }
                                         }
                                         $i++;
                                     }
                                 } catch (Exception $e) {
                                     $result['success'] = false;
                                     $result['info'] = $e->getMessage();
                                     echo Zend_Json::encode($result);
                                     exit;
                                 }
                             } else {
                                 $result['success'] = false;
                                 $result['info'] = '当前型号已存在,请勿重复添加!';
                                 echo Zend_Json::encode($result);
                                 exit;
                             }
                         }
                     }
                 }
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 22
0
 /**
  * 发送邮件
  * @param number $mailId        邮件任务ID
  * @param number $activeLimit   邮件失效期限
  * @return multitype:boolean string
  */
 public function send($mailId, $activeLimit = 0, $to_name = '', $footer = '', $header = false)
 {
     set_time_limit(0);
     $errInfo = '';
     if ($mailId) {
         $send_state = 0;
         $now = date('Y-m-d H:i:s');
         // 获取邮件任务
         $where = "";
         if ($activeLimit > 0) {
             $where = " and datediff('" . date('Y-m-d') . "', add_date) < " . $activeLimit;
         }
         $data = $this->fetchRow("id = " . $mailId . $where)->toArray();
         if ($data) {
             // 检查邮件信息是否正确
             $errInfo = $this->check($data);
             if (!$errInfo) {
                 $employeeModel = new Hra_Model_Employee();
                 // 读取邮件发送配置
                 $mailServerConfig = new Zend_Config_Ini(CONFIGS_PATH . '/application.ini', 'mail');
                 $transport = new Zend_Mail_Transport_Smtp($mailServerConfig->smtp->server, $mailServerConfig->smtp->params->toArray());
                 if ($header) {
                     $mail_header = '';
                 } else {
                     $mail_header = '<div>' . $to_name . '您好,<br><br></div>';
                 }
                 if (!$footer) {
                     $mail_footer = '<div style="color:FF0000;"><br><br>系统邮件,请勿回复!</div><div>' . SYS_COPYRIGHT . '</div>';
                 } else {
                     $mail_footer = '<div style="color:FF0000;">' . $footer . '</div>';
                 }
                 $mail = new Zend_Mail('UTF-8');
                 $mail->setSubject($data['type'] . '-' . $data['subject']);
                 $mail->setBodyHtml($mail_header . '<div>' . $data['content'] . '</div>' . $mail_footer);
                 $mail->setFrom($mailServerConfig->smtp->from, $mailServerConfig->smtp->fromname);
                 $sendCnt = 0;
                 // 添加收件人
                 $toArr = explode(',', $data['to']);
                 foreach ($toArr as $toMail) {
                     // 文件外发会用到外部邮箱,不能从employee表检查
                     /*if(stripos($toMail, '@') != flase) {
                           $mail->addTo($toMail);
                           $sendCnt++;
                       }
                       if(stripos($toMail, SYS_EMAIL_SUFFIX) != flase) {
                           // 内部邮箱,检查是否在职
                           if($employeeModel->fetchAll("active = 1 and email = '".$toMail."'")->count() > 0){
                               $mail->addTo($toMail);
                               $sendCnt++;
                           }
                       } else {
                           $mail->addTo($toMail);
                           $sendCnt++;
                       }*/
                     if ($employeeModel->fetchAll("active = 1 and email = '" . $toMail . "'")->count() > 0) {
                         $mail->addTo($toMail);
                         $sendCnt++;
                     }
                 }
                 // 添加抄送人
                 if ($data['cc']) {
                     $ccArr = explode(',', $data['cc']);
                     foreach ($ccArr as $ccMail) {
                         if ($employeeModel->fetchAll("active = 1 and email = '" . $ccMail . "'")->count() > 0) {
                             $mail->addCc($ccMail);
                             $sendCnt++;
                         }
                     }
                 }
                 if ($sendCnt > 0) {
                     // 添加附件
                     if ($data['attachment_path']) {
                         $fileNameArr = explode(',', $data['attachment_name']);
                         $filePathArr = explode(',', $data['attachment_path']);
                         for ($i = 0; $i < count($filePathArr); $i++) {
                             $mail->createAttachment(file_get_contents($filePathArr[$i]), 'application/octet-stream', Zend_Mime::DISPOSITION_INLINE, Zend_Mime::ENCODING_BASE64, "=?UTF-8?B?" . base64_encode($fileNameArr[$i]) . "?=");
                         }
                     }
                     // 发送
                     try {
                         $mail->send($transport);
                         $send_state = 1;
                     } catch (Exception $e) {
                         $errInfo = $e->getMessage();
                     }
                 }
             }
             // 记录发送结果
             try {
                 $this->update(array('state' => $send_state, 'send_time' => $now, 'err_info' => $errInfo), "id = " . $mailId);
             } catch (Exception $e) {
                 $errInfo = $e->getMessage();
             }
         } else {
             $errInfo = "邮件已过期";
         }
     } else {
         $errInfo = "邮件ID为空";
     }
     $result = array('success' => $errInfo ? false : true, 'info' => $errInfo);
     return $result;
 }
Exemplo n.º 23
0
 public function getStatisticsList($condition = array())
 {
     $data = array();
     $employee = new Hra_Model_Employee();
     $sql = $employee->select()->setIntegrityCheck(false)->from(array('t1' => $this->_dbprefix . 'employee'))->joinLeft(array('t2' => $this->_dbprefix . 'employee_dept'), "t2.id = t1.dept_id", array('dept_name' => 'name'))->joinLeft(array('t3' => $this->_dbprefix . 'employee_post'), "t3.id = t1.post_id", array('post_name' => 'name'))->joinLeft(array('t4' => $this->_dbprefix . 'user'), "t4.employee_id = t1.id", array('user_id' => 'id'))->joinLeft(array('t5' => $this->_dbprefix . 'employee_type'), "t1.employment_type = t5.id", array('employment_type' => 'name'))->where("(t1.leave_date is null or (t1.leave_date is not null and t1.leave_date >= '" . $condition['date_from'] . "' and t1.leave_date <= '" . $condition['date_to'] . "'))")->order(array("t1.employment_type", "t1.number"));
     if ($condition['employment_type'] != '') {
         $sql->where("employment_type = " . $condition['employment_type']);
     }
     if ($condition['key']) {
         $sql->where("t1.ename like '" . $condition['key'] . "' or t1.cname like '" . $condition['key'] . "' or t1.number like '" . $condition['key'] . "'");
     }
     $total = $employee->fetchAll($sql)->count();
     if ($condition['type'] != 'csv') {
         $sql->limitPage($condition['page'], $condition['limit']);
     }
     $data = $employee->fetchAll($sql)->toArray();
     $workday = new Hra_Model_Workday();
     $vacation = new Hra_Model_Attendance_Vacation();
     $overtime = new Hra_Model_Attendance_Overtime();
     // 员工工作日设置(目前均按弹性员工工作日设置处理)
     $workdaySetting = $workday->getDayQtyBase(1, 1, $condition['date_from'], $condition['date_to']);
     $holidaySetting = $workday->getDayQtyBase(3, 1, $condition['date_from'], $condition['date_to']);
     for ($i = 0; $i < count($data); $i++) {
         $data[$i]['workday_qty'] = $workdaySetting['day'];
         $data[$i]['workhour_qty'] = $workdaySetting['hour'];
         $data[$i]['holiday_qty'] = $holidaySetting['day'];
         $data[$i]['attendance_qty'] = null;
         $data[$i]['attendance_hour_qty'] = 0;
         $data[$i]['v_personal_qty'] = null;
         $data[$i]['v_vacation_qty'] = null;
         $data[$i]['v_sick_qty'] = null;
         $data[$i]['v_marriage_qty'] = null;
         $data[$i]['v_funeral_qty'] = null;
         $data[$i]['v_childbirth_qty'] = null;
         $data[$i]['v_childbirth_with_qty'] = null;
         $data[$i]['v_other_qty'] = null;
         $data[$i]['o_workday_qty'] = null;
         $data[$i]['o_restday_qty'] = null;
         $data[$i]['o_holiday_qty'] = null;
         $data[$i]['late_qty'] = null;
         $data[$i]['leave_early_qty'] = null;
         $data[$i]['absence_halfday_qty'] = null;
         $data[$i]['absence_qty'] = null;
         if ($data[$i]['user_id']) {
             // 出勤天数
             $sql = $this->select()->from($this->_name)->where("number = '" . $data[$i]['number'] . "' and clock_in >= '" . $condition['date_from'] . " 00:00:00' and clock_out <= '" . $condition['date_to'] . " 23:59:59'")->group("date_format(clock_in, '%Y-%m-%d')");
             $aData = $this->fetchAll($sql)->toArray();
             foreach ($aData as $a) {
                 $data[$i]['attendance_hour_qty'] += $a['clock_hours'];
             }
             $data[$i]['attendance_qty'] = count($aData);
             // 请假天数
             $data[$i]['v_personal_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 1, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_vacation_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 2, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_sick_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 3, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_marriage_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 4, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_funeral_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 5, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_childbirth_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 6, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_childbirth_with_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 7, $condition['date_from'], $condition['date_to']);
             $data[$i]['v_other_qty'] = $vacation->getVacationQty($data[$i]['user_id'], 8, $condition['date_from'], $condition['date_to']);
             // 加班天数
             $data[$i]['o_workday_qty'] = $overtime->getOvertimeQty($data[$i]['user_id'], 1, $condition['date_from'], $condition['date_to']);
             $data[$i]['o_restday_qty'] = $overtime->getOvertimeQty($data[$i]['user_id'], 2, $condition['date_from'], $condition['date_to']);
             $data[$i]['o_holiday_qty'] = $overtime->getOvertimeQty($data[$i]['user_id'], 3, $condition['date_from'], $condition['date_to']);
             //其它统计(迟到、早退、旷工次数)
             $other = $this->getAbsenceQty($data[$i]['number'], $condition['date_from'], $condition['date_to']);
             $data[$i]['late_qty'] = $other[1];
             $data[$i]['leave_early_qty'] = $other[2];
             $data[$i]['absence_halfday_qty'] = $other[3];
             $data[$i]['absence_qty'] = $other[4];
         }
     }
     if ($condition['type'] == 'csv') {
         $data_csv = array();
         $title = array('cnt' => '#', 'employment_type' => '用工形式', 'number' => '工号', 'cname' => '中文名', 'ename' => '英文名', 'dept_name' => '部门', 'post_name' => '职位', 'active' => '状态', 'attendance' => '出勤/考勤 [天]', 'holiday_qty' => '法定假日', 'v_personal_qty' => '事假', 'v_vacation_qty' => '年假', 'v_sick_qty' => '病假', 'v_marriage_qty' => '婚假', 'v_funeral_qty' => '丧假', 'v_childbirth_qty' => '产假', 'v_childbirth_with_qty' => '陪产假', 'v_other_qty' => '调休', 'o_workday_qty' => '工作日加班', 'o_restday_qty' => '休息日加班', 'o_holiday_qty' => '法定假日加班', 'late_qty' => '迟到', 'leave_early_qty' => '早退', 'absence_halfday_qty' => '旷工半天', 'absence_qty' => '旷工一天');
         array_push($data_csv, $title);
         $i = 0;
         foreach ($data as $d) {
             $i++;
             $info = array('cnt' => $i, 'employment_type' => $d['employment_type'] == 0 ? '弹性' : '非弹性', 'number' => $d['number'], 'cname' => $d['cname'], 'ename' => $d['ename'], 'dept_name' => $d['dept_name'], 'post_name' => $d['post_name'], 'active' => $d['active'] == 1 ? '在职' : '离职', 'attendance' => $d['workday_qty'] . ' { ' . $d['attendance_qty'] . ' }', 'attendance_hours' => $d['workhour_qty'] . ' { ' . $d['attendance_hour_qty'] . ' }', 'holiday_qty' => $d['holiday_qty'], 'v_personal_qty' => $d['v_personal_qty'], 'v_vacation_qty' => $d['v_vacation_qty'], 'v_sick_qty' => $d['v_sick_qty'], 'v_marriage_qty' => $d['v_marriage_qty'], 'v_funeral_qty' => $d['v_funeral_qty'], 'v_childbirth_qty' => $d['v_childbirth_qty'], 'v_childbirth_with_qty' => $d['v_childbirth_with_qty'], 'v_other_qty' => $d['v_other_qty'], 'o_workday_qty' => $d['o_workday_qty'], 'o_restday_qty' => $d['o_restday_qty'], 'o_holiday_qty' => $d['o_holiday_qty'], 'late_qty' => $d['late_qty'], 'leave_early_qty' => $d['leave_early_qty'], 'absence_halfday_qty' => $d['absence_halfday_qty'], 'absence_qty' => $d['absence_qty']);
             array_push($data_csv, $info);
         }
         return $data_csv;
     }
     return array('total' => $total, 'rows' => $data);
 }
Exemplo n.º 24
0
 public function getcontactAction()
 {
     $data = array();
     // 请求参数
     $request = $this->getRequest()->getParams();
     $key = isset($request['key']) ? $request['key'] : null;
     $employee = new Hra_Model_Employee();
     $list = $employee->getContactList($key);
     echo Zend_Json::encode($list);
     exit;
 }
Exemplo n.º 25
0
 /**
  * @abstract    获取文件JSON数据
  * @return      null
  */
 public function getfilesAction()
 {
     // 请求参数
     $request = $this->getRequest()->getParams();
     $limit = $request['limit'];
     $start = $request['start'];
     $where = "1=1";
     foreach ($request as $k => $v) {
         if ($v) {
             if ($k == 'search_tag') {
                 $cols = array("t1.project_info", "t1.code", "t1.name", "t1.description", "t1.remark", "t2.cname", "t7.model_standard", "t7.model_internal");
                 $arr = preg_split('/\\s+/', trim($v));
                 for ($i = 0; $i < count($arr); $i++) {
                     $tmp = array();
                     foreach ($cols as $c) {
                         $tmp[] = "ifnull({$c},'')";
                     }
                     $arr[$i] = "concat(" . implode(',', $tmp) . ") like '%" . $arr[$i] . "%'";
                 }
                 $where .= " and " . join(' AND ', $arr);
                 //                     $where .= " and (ifnull(t1.project_info,'') like '%$v%' or ifnull(t1.code,'') like '%$v%' or ifnull(t1.name,'') like '%$v%' or ifnull(t1.description,'') like '%$v%' or ifnull(t1.remark,'') like '%$v%' or ifnull(t2.cname,'') like '%$v%')";
             } else {
                 if ("search_category" == $k && $v) {
                     $where .= " and t5.category = '{$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 {
                             $col = str_replace('search_', '', $k);
                             if ($col != $k) {
                                 // 查询条件
                                 $where .= " and ifnull(t1." . $col . ",'') like '%" . $v . "%'";
                             }
                         }
                     }
                 }
             }
         }
     }
     $files = new Dcc_Model_Files();
     $record = new Dcc_Model_Record();
     $flow = new Admin_Model_Flow();
     $step = new Admin_Model_Step();
     $share = new Dcc_Model_Share();
     $type = new Dcc_Model_Type();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $dept = new Hra_Model_Dept();
     $codemaster = new Admin_Model_Codemaster();
     if (isset($request['method'])) {
         $data = $files->getFilesListForEdit($where, $start, $limit);
         $count = $files->getCountForEdit($where, $start, $limit);
         $totalCount = $count;
     } else {
         $data = $files->getFilesList($where . " and (t1.state = 'Active' or t1.state = 'Obsolete')", $start, $limit);
         $count = $files->getCount($where . " and (t1.state = 'Active' or t1.state = 'Obsolete')", $start, $limit);
         $totalCount = $count;
     }
     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]['archive_time'] = strtotime($data[$i]['archive_time']);
         $data[$i]['codever'] = $data[$i]['code'] . ' V' . $data[$i]['ver'];
         $data[$i]['send_require'] = $data[$i]['send_require'] == 1 ? true : false;
         $data[$i]['description'] = $data[$i]['code_description'];
         // 增加审核状态
         $reviewState = "";
         $step_name = "";
         if ($data[$i]['state'] == 'Active') {
             $reviewState = "已发布";
         } else {
             if ($data[$i]['state'] == 'Reviewing') {
                 // 查询当前审核状态
                 // 查询所有审核阶段
                 $reviewRows = $review->getList("file_id = " . $data[$i]['id'], "files");
                 if (count($reviewRows) > 0) {
                     $first = true;
                     foreach ($reviewRows as $row) {
                         if ($row['finish_flg'] == 1) {
                             if ($step_name) {
                                 $step_name .= "->";
                             }
                             $step_name .= $row['step_name'];
                         } else {
                             if ($step_name) {
                                 $step_name .= "->";
                             }
                             // 第一条未审核记录就是当前待审核记录
                             if ($first) {
                                 $first = false;
                                 $step_name .= "<b>" . $row['step_name'] . "</b>";
                                 $reviewRow = $row;
                                 $actual_user = explode(',', $reviewRow['actual_user']);
                                 $planUser = $reviewRow['plan_user'];
                                 $method = $reviewRow['method'];
                                 $plan_dept = $reviewRow['plan_dept'];
                                 $depts = array();
                                 $plan_user = explode(',', $planUser);
                                 $diff = array_diff($plan_user, $actual_user);
                                 foreach ($diff as $u) {
                                     if (!$u) {
                                         continue;
                                     }
                                     $e = $employee->fetchRow("id = {$u}");
                                     if ($reviewState) {
                                         $reviewState .= ", ";
                                     }
                                     $reviewState .= $e['cname'] . ":未审核";
                                 }
                                 foreach ($depts as $d) {
                                     if ($reviewState) {
                                         $reviewState .= ", ";
                                     }
                                     $reviewState .= $d . ":未审核";
                                 }
                                 foreach ($actual_user as $u) {
                                     if (!$u) {
                                         continue;
                                     }
                                     $e = $employee->fetchRow("id = {$u}");
                                     if ($reviewState) {
                                         $reviewState .= ", ";
                                     }
                                     $reviewState .= $e['cname'] . ":已审核";
                                 }
                             } else {
                                 $step_name .= $row['step_name'];
                             }
                         }
                     }
                 }
             } else {
                 if ($data[$i]['state'] == 'Obsolete') {
                     $reviewState = "已作废";
                 } else {
                     if ($data[$i]['state'] == 'Return') {
                         $reviewState = "退回";
                     } else {
                         $reviewState = $data[$i]['state'];
                     }
                 }
             }
         }
         $data[$i]['step_name'] = $step_name;
         $data[$i]['review_state'] = $reviewState;
         if ($data[$i]['reason_type']) {
             $masterData = $codemaster->fetchRow("type = 5 and code = '" . $data[$i]['reason_type'] . "'");
             $reason_type_name = $masterData->text;
             $data[$i]['reason_type_name'] = $reason_type_name;
         }
     }
     $resutl = array("totalCount" => $totalCount, "topics" => $data);
     echo Zend_Json::encode($resutl);
     exit;
 }
Exemplo n.º 26
0
 /**
  * 文件发送
  */
 public function sendAction()
 {
     // 返回值数组
     $result = array('success' => true, 'result' => 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['employee_id'];
     $val = (object) $request;
     $upload = new Dcc_Model_Upload();
     $doc_ids = "";
     $doc_names = "";
     if ($val->exfile_ids) {
         // 根据文件id获取归档文件id
         $tmp = $upload->getAdapter()->query("select group_concat(id) as doc_ids, group_concat(code) as doc_names from oa_doc_files where (state = 'Active') and name != '' and file_ids in ( " . $val->exfile_ids . ")")->fetchObject();
         $doc_ids = $tmp->doc_ids;
         $doc_names = $tmp->doc_names;
         $row = $upload->getFileByIds($val->exfile_ids);
         $names = $row['name'];
         $paths = $row['path'];
     }
     if ($paths) {
         foreach (explode(',', $paths) as $path) {
             if (!is_file($path)) {
                 $result['result'] = false;
                 $result['info'] = "文件不存在";
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
         $employee = new Hra_Model_Employee();
         $to = array();
         if ($val->to_id) {
             $toUser = str_replace('E', '', $val->to_id);
             $to = $employee->getInfosByOneLine($toUser);
             $to = explode(',', $to['email']);
         }
         if (isset($val->custom_linkman) && $val->custom_linkman) {
             $to[] = $val->custom_linkman;
         }
         if (isset($val->supply_linkman) && $val->supply_linkman) {
             $to[] = $val->supply_linkman;
         }
         $dept = '';
         if (isset($val->innerdept_id) && $val->innerdept_id) {
             $dept = str_replace('D', '', $val->innerdept_id);
             $sql = "select group_concat(email) as email from oa_employee where dept_id in ({$dept})";
             $data = $employee->getAdapter()->query($sql)->fetchObject();
             if ($data && $data->email) {
                 $toemail = $data->email;
                 foreach (explode(',', $toemail) as $t) {
                     $to[] = $t;
                 }
             }
         }
         $cc = array();
         if ($val->cc_id) {
             $ccUser = str_replace('E', '', $val->cc_id);
             $cc = $employee->getInfosByOneLine($ccUser);
             $cc = explode(',', $cc['email']);
         }
         $u = $employee->getInfosByOneLine($user);
         $cc[] = $u->email;
         if (isset($val->personal_linkman) && $val->personal_linkman) {
             foreach (explode(',', $val->personal_linkman) as $m) {
                 if (strpos($m, '@') != false) {
                     $to[] = $m;
                 }
             }
         }
         $mailData = array('type' => $val->sendtype == '外发' ? "文件外发" : "文件发放", 'subject' => $val->subject, 'to' => implode(',', $to), 'cc' => implode(',', $cc), 'content' => $val->content, 'attachment_name' => $names, 'attachment_path' => $paths, 'send_time' => $now, 'add_date' => $now);
         $mail = new Application_Model_Log_Mail();
         try {
             $mailId = $mail->insert($mailData);
             if ($mailId) {
                 $sendResult = $mail->send($mailId, 0, $val->to_name, $val->footer, true);
             }
             $error_info = "";
             $success = false;
             if ($sendResult) {
                 ${$error_info} = $sendResult['info'];
                 $success = $sendResult['success'];
             }
             $result['result'] = $success;
             $result['info'] = ${$error_info};
             if (isset($val->out_sendtype)) {
                 $outsend = $val->out_sendtype;
             } else {
                 $outsend = "";
             }
             if (isset($val->out_custom)) {
                 $partner = $val->out_custom;
             } else {
                 if (isset($val->out_supply)) {
                     $partner = $val->out_supply;
                 } else {
                     $partner = '';
                 }
             }
             if (isset($val->custom_linkman)) {
                 $linkman = $val->custom_linkman;
             } else {
                 if (isset($val->supply_linkman)) {
                     $linkman = $val->supply_linkman;
                 } else {
                     $linkman = '';
                 }
             }
             // 获取发放编号
             $code = $this->getSendCode();
             // 记录
             $to = $val->to;
             if (isset($val->personal_linkman) && $val->personal_linkman) {
                 $to .= $val->personal_linkman;
             }
             $data = array('code' => $code, 'dept' => $dept, 'partner' => $partner, 'linkman' => $linkman, 'sendtype' => $val->sendtype, 'to_name' => $val->to_name, 'footer' => $val->footer, 'remark' => $val->remark, 'outsendtype' => $outsend, 'to' => $to, 'cc' => $val->cc, 'subject' => $val->subject, 'content' => $val->content, 'doc_ids' => $doc_ids, 'doc_names' => $doc_names, 'file_ids' => $val->exfile_ids, 'file_names' => $names, 'error_info' => $error_info, 'result' => $success, 'handle_time' => $now, 'handle_user' => $user);
             $send = new Dcc_Model_Send();
             $send->insert($data);
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         if (!$result['info']) {
             $result['info'] = "发送成功";
         }
         echo Zend_Json::encode($result);
         exit;
     } else {
         $result['result'] = false;
         $result['info'] = "文件不存在";
         echo Zend_Json::encode($result);
         exit;
     }
 }
Exemplo n.º 27
0
 public function sendMailToStep($mailTo, $mailData)
 {
     $result = array('success' => true, 'info' => '发送成功');
     $user = new Application_Model_User();
     $employee = new Hra_Model_Employee();
     // 检查是否有接收人
     if (count($mailTo)) {
         $toAddress = array();
         $toIds = array();
         foreach ($mailTo as $employeeId) {
             $em = $employee->getInfoById($employeeId);
             array_push($toAddress, $em['email']);
             $u = $user->fetchRow("employee_id = " . $employeeId)->toArray();
             array_push($toIds, $u['id']);
         }
         $mail = new Application_Model_Log_Mail();
         $mailData['to'] = implode(',', $toAddress);
         $mailData['user_id'] = implode(',', $toIds);
         try {
             // 记录邮件日志并发送邮件
             $mail->send($mail->insert($mailData));
         } catch (Exception $e) {
             $result['success'] = false;
             $result['info'] = $e->getMessage();
         }
     } else {
         $result['success'] = false;
         $result['info'] = '邮件通知没有接受对象';
     }
     return $result;
 }
Exemplo n.º 28
0
 /**
  * grid用
  */
 public function getstepAction()
 {
     // 请求参数
     $request = $this->getRequest()->getParams();
     $ids = $request['ids'];
     $step = new Admin_Model_Step();
     $employee = new Hra_Model_Employee();
     $where = "t1.id in ({$ids})";
     $data = $step->getListByFlow($ids);
     for ($i = 0; $i < count($data); $i++) {
         $step_user = $data[$i]['user'];
         if ($step_user) {
             $step_user_name = $employee->getInfosByOneLine($step_user);
             $data[$i]['step_user_name'] = $step_user_name['cname'];
         }
         $step_dept = $data[$i]['dept'];
         if ($step_dept) {
             $tmp = $step->getAdapter()->query("select group_concat(name) as name from oa_user_role where id in ( " . $step_dept . ")")->fetchObject();
             $step_dept_name = $tmp->name;
             $data[$i]['step_dept_name'] = $step_dept_name;
         }
     }
     echo Zend_Json::encode($data);
     exit;
 }
Exemplo n.º 29
0
 public function reviewAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '审核成功');
     $request = $this->getRequest()->getParams();
     /* echo '<pre>';
        print_r($request);
        exit; */
     $review_id = isset($request['review_id']) ? $request['review_id'] : null;
     $review_operate = isset($request['review_operate']) ? $request['review_operate'] : null;
     $review_current_step = isset($request['review_current_step']) ? $request['review_current_step'] : null;
     // 当前阶段(review表ID)
     $review_last_step = isset($request['review_last_step']) ? $request['review_last_step'] : null;
     // 是否当前阶段为最后一阶段
     $review_to_finish = isset($request['review_to_finish']) ? $request['review_to_finish'] : null;
     // 是否批准后当前阶段结束
     $review_next_step = isset($request['review_next_step']) ? $request['review_next_step'] : null;
     // 下一阶段(review表ID)
     $review_remark = isset($request['review_remark']) ? $request['review_remark'] : null;
     if ($review_id && $review_operate) {
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         // 评审意见
         $review_info = '意见: ' . $review_remark;
         $invoice = new Erp_Model_Purchse_Invoice();
         $invoiceItems = new Erp_Model_Purchse_Invoiceitems();
         $user = new Application_Model_User();
         $review = new Dcc_Model_Review();
         $employee = new Hra_Model_Employee();
         $invoiceData = $invoice->getData(null, $review_id);
         // 更新审核状态及审核意见
         if ($review_operate == 'no') {
             // 更新采购申请状态
             $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-拒绝] [' . $review_info . ']';
             $data = array('state' => 1, 'review_info' => $invoiceData['review_info'] . '<br>' . $review_info);
             // 更新订单状态
             $invoice->update($data, "id = " . $review_id);
             // 删除当前申请的审核配置
             $review->delete("type = 'purchse_invoice_add' and file_id = " . $review_id);
             // 发送邮件通知申请人
             $reviewResult = '<font style="color: #FF0000"><b>拒绝</b></font>';
             $mail = new Application_Model_Log_Mail();
             $applyEmployeeData = $user->fetchRow("id = " . $invoiceData['create_user'])->toArray();
             $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
             $to = $applyEmployee['email'];
             // 获取币种信息
             $currency = new Erp_Model_Setting_Currency();
             $currencyInfo = $currency->getInfoByCode($invoiceData['currency']);
             $total = $invoiceData['total'];
             if ($invoiceData['currency'] != 'CNY') {
                 $total = $invoiceData['forein_total'];
             }
             $mailContent = '<div>采购发票审核:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>发票号:</b>' . $invoiceData['number'] . '</p>
                             <p><b>申请人:</b>' . $invoiceData['creater'] . '</p>
                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">' . $currencyInfo['symbol'] . $total . '</a></p>
                             <p><b>备注:</b>' . $invoiceData['remark'] . '</p>
                             <p><b>申请时间:</b>' . $invoiceData['create_time'] . '</p>
                             <p><b>更新时间:</b>' . $invoiceData['update_time'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $invoiceData['review_info'] . '</p>
                             </div>';
             $mailData = array('type' => '消息', 'subject' => '采购发票-审核', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $invoiceData['create_user'], 'content' => $mailContent, 'add_date' => $now);
             try {
                 // 记录邮件日志并发送邮件
                 $mail->send($mail->insert($mailData));
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
             }
         } else {
             $help = new Application_Model_Helpers();
             $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [审核-批准] [' . $review_info . ']';
             $invoiceUpdateData = array('review_info' => $invoiceData['review_info'] . '<br>' . $review_info);
             $reviewData = $review->fetchRow("id = " . $review_current_step)->toArray();
             $actual_user = $reviewData['actual_user'] == '' ? $user_session->user_info['employee_id'] : $reviewData['actual_user'] . ',' . $user_session->user_info['employee_id'];
             $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
             // 当前审核阶段为最后一阶段
             if ($review_last_step == 1) {
                 // 当前阶段已完结
                 if ($review_to_finish == 1) {
                     $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                     $reviewResult = '<font style="color: #006400"><b>发布</b></font>';
                     // 发布
                     // 更新申请状态
                     $invoiceUpdateData['state'] = 2;
                     $invoiceUpdateData['release_time'] = $now;
                     // 更新审核记录表
                     $review->update($data, "id = " . $review_current_step);
                     $mail = new Application_Model_Log_Mail();
                     $applyEmployeeData = $user->fetchRow("id = " . $invoiceData['create_user'])->toArray();
                     $applyEmployee = $employee->fetchRow("id = " . $applyEmployeeData['employee_id'])->toArray();
                     $to = $applyEmployee['email'];
                     // 获取币种信息
                     $currency = new Erp_Model_Setting_Currency();
                     $currencyInfo = $currency->getInfoByCode($invoiceData['currency']);
                     $total = $invoiceData['total'];
                     if ($invoiceData['currency'] != 'CNY') {
                         $total = $invoiceData['forein_total'];
                     }
                     $mailContent = '<div>采购发票审核批准,请登录系统查看:</div>
                             <div>
                             <p><b>审核人:</b>' . $user_session->user_info['user_name'] . '</p>
                             <p><b>审核结果:</b>' . $reviewResult . '</p>
                             <p><b>审核意见:</b>' . $review_remark . '</p>
                             <p><b>发票号:</b>' . $invoiceData['number'] . '</p>
                             <p><b>申请人:</b>' . $invoiceData['creater'] . '</p>
                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">' . $currencyInfo['symbol'] . $total . '</a></p>
                             <p><b>备注:</b>' . $invoiceData['remark'] . '</p>
                             <p><b>申请时间:</b>' . $invoiceData['create_time'] . '</p>
                             <p><b>更新时间:</b>' . $invoiceData['update_time'] . '</p>
                             <hr>
                             <p><b>审核日志:</b></p><p>' . $invoiceUpdateData['review_info'] . '</p>
                             </div>';
                     $mailData = array('type' => '消息', 'subject' => '采购发票-发布', 'to' => $to, 'cc' => $user_session->user_info['user_email'], 'user_id' => $invoiceData['create_user'], 'content' => $mailContent, 'add_date' => $now);
                     try {
                         // 记录邮件日志并发送邮件
                         $mail->send($mail->insert($mailData));
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                     }
                 } else {
                     $data = array('actual_user' => $actual_user);
                     $review->update($data, "id = " . $review_current_step);
                 }
             } else {
                 // 当前阶段已完结
                 if ($review_to_finish == 1) {
                     $data = array('actual_user' => $actual_user, 'finish_time' => $now, 'finish_flg' => 1);
                     $reviewResult = '<font style="color: #006400"><b>批准</b></font>';
                     // 进入下一阶段
                     // 更新审核记录表
                     $review->update($data, "id = " . $review_current_step);
                     // 邮件通知下一阶段审核人
                     if ($review->fetchAll("id = " . $review_next_step)->count() > 0) {
                         $reviewNextStepData = $review->fetchRow("id = " . $review_next_step)->toArray();
                         $mailTo = explode(',', $reviewNextStepData['plan_user']);
                         if ($mailTo) {
                             // 获取币种信息
                             $currency = new Erp_Model_Setting_Currency();
                             $currencyInfo = $currency->getInfoByCode($invoiceData['currency']);
                             $total = $invoiceData['total'];
                             if ($invoiceData['currency'] != 'CNY') {
                                 $total = $invoiceData['forein_total'];
                             }
                             $mailContent = '<div>新建采购发票,请登录系统查看:</div>
                                             <div>
                                             <p><b>订单号:</b>' . $invoiceData['number'] . '</p>
                                             <p><b>申请人:</b>' . $invoiceData['creater'] . '</p>
                                             <p><b>金额:</b><a style="color: #467500;font-weight: bold;">' . $currencyInfo['symbol'] . $total . '</a></p>
                                             <p><b>备注:</b>' . $invoiceData['remark'] . '</p>
                                             <p><b>申请时间:</b>' . $invoiceData['create_time'] . '</p>
                                             <p><b>更新时间:</b>' . $invoiceData['update_time'] . '</p>
                                             <hr>
                                             <p><b>审核日志:</b></p><p>' . $invoiceUpdateData['review_info'] . '</p>
                                             </div>';
                             $mailData = array('type' => '消息', 'subject' => '采购发票-新建', 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent, 'add_date' => $now);
                             $resultMail = $help->sendMailToStep($mailTo, $mailData);
                             if (!$resultMail['success']) {
                                 $result = $resultMail;
                             }
                         }
                     }
                 } else {
                     $data = array('actual_user' => $actual_user);
                     $review->update($data, "id = " . $review_current_step);
                 }
             }
             // 更新申请状态
             $invoice->update($invoiceUpdateData, "id = " . $review_id);
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Exemplo n.º 30
0
 public function addtestdataAction()
 {
     $result = array('success' => true, 'info' => '导入成功');
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $employee = new Hra_Model_Employee();
     $eArr = $employee->fetchAll()->toArray();
     $dateStart = '2014-01-01';
     $attendance = new Hra_Model_Attendance();
     for ($i = 0; $i < 59; $i++) {
         $date = date('Y-m-d', strtotime($dateStart . "+" . $i . " day"));
         $w = date('w', strtotime($date));
         if ($w != 0 && $w != 6) {
             foreach ($eArr as $e) {
                 $data = array('number' => $e['number'], 'time' => $date . ' 08:55:12', 'type' => 1, 'remark' => '123', 'create_user' => $user_id, 'create_time' => $now, 'update_user' => $user_id, 'update_time' => $now);
                 $attendance->insert($data);
                 $data = array('number' => $e['number'], 'time' => $date . ' 18:01:33', 'type' => 2, 'remark' => '456', 'create_user' => $user_id, 'create_time' => $now, 'update_user' => $user_id, 'update_time' => $now);
                 $attendance->insert($data);
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }