Esempio n. 1
0
 public function getlistAction()
 {
     $review = new Dcc_Model_Review();
     $user_session = new Zend_Session_Namespace('user');
     $user = $user_session->user_info['employee_id'];
     // 清理无效数据
     $where1 = " type='files' and file_id in (select id from oa_doc_files where state = 'Return' or state = 'Delete')";
     $review->delete($where1);
     $where2 = " type='materiel' and file_id in (select id from oa_product_materiel where state = 'Return' or state = 'Delete')";
     $review->delete($where2);
     $where3 = " type='bom' and file_id in (select id from oa_product_bom_new where state = 'Return' or state = 'Delete')";
     $review->delete($where3);
     $where4 = " type='devbom' and file_id in (select id from oa_product_bom_upd where state = 'Return' or state = 'Delete')";
     $review->delete($where4);
     $where5 = " type='ecobom' and file_id in (select id from oa_product_bom_upd where state = 'Return' or state = 'Delete')";
     $review->delete($where5);
     $where6 = " type='materiel_desc' and file_id in (select id from oa_product_materiel_desc where state = 'Return' or state = 'Delete')";
     $review->delete($where6);
     $data = $review->getBacklogList($user);
     $updcount = 0;
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i]['type'] == 'devbom') {
             $updcount += $data[$i]['count'];
         } else {
             if ($data[$i]['type'] == 'ecobom') {
                 $updcount += $data[$i]['count'];
             } else {
                 if ($data[$i]['type'] == 'updbom') {
                     $updcount += $data[$i]['count'];
                 }
             }
         }
     }
     $result = array();
     for ($i = 0; $i < count($data); $i++) {
         if ($data[$i]['type'] != 'devbom' && $data[$i]['type'] != 'ecobom' && $data[$i]['type'] != 'updbom') {
             $result[] = $data[$i];
         }
     }
     if ($updcount > 0) {
         $result[] = array("count" => $updcount, "type" => "updbom");
     }
     echo Zend_Json::encode($result);
     exit;
 }
Esempio n. 2
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;
 }
Esempio n. 3
0
    /**
     * 保存采购申请表体
     */
    public function edititemsAction()
    {
        // 返回值数组
        $result = array('success' => true, 'info' => '编辑成功');
        $request = $this->getRequest()->getParams();
        $type = isset($request['operate']) ? $request['operate'] : '';
        // 操作类别
        $typeArr = array('new' => '新建', 'edit' => '修改', 'transfer' => '变更');
        $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']);
        $order_id = $json->order_id;
        $transfer_id = $json->transfer_id;
        $order_id = $json->order_id;
        $json_items = $json->items;
        $items_updated = $json_items->updated;
        $items_inserted = $json_items->inserted;
        $items_deleted = $json_items->deleted;
        $items = new Erp_Model_Purchse_Orderitems();
        $itemsreq = new Erp_Model_Purchse_Orderitemsreq();
        $transfer_items = new Erp_Model_Purchse_Transferorderitems();
        // 更新
        if (count($items_updated) > 0) {
            foreach ($items_updated as $val) {
                $active = $val->items_active ? 1 : 0;
                $total = round($val->items_qty * $val->items_price, 4);
                $data = array('active' => $active, 'req_number' => $val->items_req_number, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'supplier_code' => $val->items_supplier_code, 'supplier_codename' => $val->items_supplier_codename, 'supplier_description' => $val->items_supplier_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'total' => $total, 'warehouse_code' => $val->items_warehouse_code, 'request_date' => $val->items_request_date, 'dept_id' => $val->items_dept_id, 'project_info' => $val->items_project_info, 'remark' => $val->items_remark);
                try {
                    if ($type == 'transfer') {
                        $data['req_item_id'] = $val->items_req_item_id;
                        $data['order_id'] = $order_id;
                        $data['transfer_id'] = $transfer_id;
                        $data['order_item_id'] = $val->items_id;
                        $data['transfer_type'] = 'update';
                        $transfer_items->insert($data);
                    } else {
                        $data['update_user'] = $user_id;
                        $data['update_time'] = $now;
                        $items->update($data, "id = " . $val->items_id);
                        // 保存分拆订单项信息
                        $this->saveSplitItem('update', $val->items_id, $val->items_req_item_id, $val->items_qty, $val->items_code, $active);
                    }
                } catch (Exception $e) {
                    $result['success'] = false;
                    $result['info'] = $e->getMessage();
                    echo Zend_Json::encode($result);
                    exit;
                }
            }
        }
        // 插入
        if (count($items_inserted) > 0) {
            foreach ($items_inserted as $val) {
                $active = $val->items_active ? 1 : 0;
                $total = round($val->items_qty * $val->items_price, 4);
                $data = array('order_id' => $order_id, 'active' => $active, 'req_number' => $val->items_req_number, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'supplier_code' => $val->items_supplier_code, 'supplier_codename' => $val->items_supplier_codename, 'supplier_description' => $val->items_supplier_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'total' => $total, 'warehouse_code' => $val->items_warehouse_code, 'request_date' => $val->items_request_date, 'dept_id' => $val->items_dept_id, 'project_info' => $val->items_project_info, 'remark' => $val->items_remark);
                try {
                    if ($type == 'transfer') {
                        $data['transfer_id'] = $transfer_id;
                        $data['order_item_id'] = $val->items_id;
                        $data['req_item_id'] = $val->items_req_item_id;
                        $data['req_qty'] = $val->items_req_qty;
                        $data['transfer_type'] = 'add';
                        $transfer_items->insert($data);
                    } else {
                        $data['create_user'] = $user_id;
                        $data['create_time'] = $now;
                        $data['update_user'] = $user_id;
                        $data['update_time'] = $now;
                        $order_item_id = $items->insert($data);
                        $this->saveSplitItem('insert', $order_item_id, $val->items_req_item_id, $val->items_req_qty, $val->items_code);
                    }
                } catch (Exception $e) {
                    $result['success'] = false;
                    $result['info'] = $e->getMessage();
                    echo Zend_Json::encode($result);
                    exit;
                }
            }
        }
        // 删除
        if (count($items_deleted) > 0) {
            foreach ($items_deleted as $val) {
                try {
                    if ($type == 'transfer') {
                        $active = $val->items_active ? 1 : 0;
                        $line_total = round($val->items_qty * $val->items_price, 4);
                        $data = array('active' => $active, 'transfer_type' => 'delete', 'transfer_id' => $transfer_id, 'order_item_id' => $val->items_id, 'req_number' => $val->items_req_number, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'supplier_code' => $val->items_supplier_code, 'supplier_codename' => $val->items_supplier_codename, 'supplier_description' => $val->items_supplier_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'total' => $total, 'warehouse_code' => $val->items_warehouse_code, 'request_date' => $val->items_request_date, 'dept_id' => $val->items_dept_id, 'project_info' => $val->items_project_info, 'remark' => $val->items_remark);
                        $transfer_items->insert($data);
                    } else {
                        $items->delete("id = " . $val->items_id);
                        // 清除订单项对应的申请项数据
                        $itemsreq->delete("order_item_id = " . $val->items_id);
                        $this->saveSplitItem('delete', $val->items_id, $val->items_req_item_id, $val->items_req_qty, $val->items_code);
                    }
                } catch (Exception $e) {
                    $result['success'] = false;
                    $result['info'] = $e->getMessage();
                    echo Zend_Json::encode($result);
                    exit;
                }
            }
        }
        // 更新订单项状态
        $activeItemsRes = $items->fetchAll("active = 1 and order_id = " . $order_id);
        if ($activeItemsRes->count() > 0) {
            $activeItems = $activeItemsRes->toArray();
            for ($j = 0; $j < count($activeItems); $j++) {
                $itemsreq->update(array('active' => 1), "order_item_id = " . $activeItems[$j]['id']);
            }
        }
        // 更新采购申请总计
        if ($type != 'transfer') {
            $items->refreshOrderTotal($order_id);
        }
        $order = new Erp_Model_Purchse_Order();
        $order_data = $order->getData(null, $order_id);
        // 保存成功,进入审批流程
        if ($result['success']) {
            // 根据流程ID获取阶段信息
            $flow = new Admin_Model_Flow();
            $flowData = $flow->fetchRow("id = " . $order_data['order_flow_id'])->toArray();
            // 获取审核阶段
            $step = new Admin_Model_Step();
            $stepIds = $flowData['step_ids'];
            $stepArr = explode(',', $stepIds);
            $review = new Dcc_Model_Review();
            $review->delete("type = 'purchse_order_add' and file_id = " . $order_id);
            $mailTo = null;
            $i = 0;
            $help = new Application_Model_Helpers();
            // 根据阶段信息初始化审批流程,并向第一阶段审核人发送邮件
            foreach ($stepArr as $s) {
                $stepData = $step->fetchRow("id = " . $s)->toArray();
                $step_user = $stepData['user'] != '' ? $stepData['user'] : null;
                $step_role = $stepData['dept'] != '' ? $stepData['dept'] : null;
                $employeeArr = $help->getReviewEmployee($step_user, $step_role);
                $employeeIdArr = $employeeArr['id'];
                $employeeIds = implode(',', $employeeIdArr);
                $reviewData = array('type' => 'purchse_order_add', 'file_id' => $order_id, 'step_name' => $stepData['step_name'], 'plan_user' => $employeeIds, 'plan_dept' => $step_role, 'method' => $stepData['method'], 'return' => $stepData['return']);
                $review->insert($reviewData);
                // 第一阶段发送邮件通知
                if ($i == 0) {
                    $mailTo = $employeeIdArr;
                }
                $i++;
            }
            if ($mailTo) {
                // 获取币种信息
                $currency = new Erp_Model_Setting_Currency();
                $currencyInfo = $currency->getInfoByCode($order_data['currency']);
                $total = $order_data['total'];
                if ($order_data['currency_rate'] != 1) {
                    $total = $order_data['forein_total'];
                }
                $mailContent = '<div>新建采购订单,请登录系统查看:</div>
                            <div>
                            <p><b>订单号:</b>' . $order_data['number'] . '</p>
                            <p><b>采购员:</b>' . $user_session->user_info['user_name'] . '</p>
                            <p><b>类别:</b>' . $order_data['type'] . '</p>
                            <p><b>金额:</b><a style="color: #467500;font-weight: bold;">' . $currencyInfo['symbol'] . $total . '</a></p>
                            <p><b>描述:</b>' . $order_data['description'] . '</p>
                            <p><b>备注:</b>' . $order_data['remark'] . '</p>
                            <p><b>申请时间:</b>' . $order_data['create_time'] . '</p>
                            <p><b>更新时间:</b>' . $order_data['update_time'] . '</p>
                            </div><hr>';
                $transferContent = '';
                if ($type == 'transfer') {
                    $transferContent .= '<div><style type="text/css">
table.gridtable {
	font-family: verdana,arial,sans-serif;
	font-size:12px;
	color:#333333;
	border-width: 1px;
	border-color: #666666;
	border-collapse: collapse;
}
table.gridtable th {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #dedede;
}
table.gridtable td {
	border-width: 1px;
	padding: 8px;
	border-style: solid;
	border-color: #666666;
	background-color: #ffffff;
}
.delete{
	text-decoration: line-through;
	color: #FF0000;
}
.update{
	font-weight: bold;
	color: #000093;
}
.inactive{
	font-weight: bold;
	color: #999999;
}
</style><table class="gridtable">
                			<tr>
                			<th>#</th>
                			<th>操作类别</th>
                			<th>启用</th>
                			<th>物料号</th>
                			<th>名称</th>
                			<th>描述</th>
                			<th>数量</th>
                			<th>已收货</th>
                			<th>需求日期</th>
                			<th>项目信息</th>
                			<th>备注</th>
                			</tr>';
                    $i = 1;
                    foreach ($items_inserted as $val) {
                        $active = $val->items_active ? '是' : '否';
                        $transferContent .= '<tr>
                			<td>' . $i . '</td>
                			<td>新增</td>
                			<td>' . $active . '</td>
                			<td>' . $val->items_code . '</td>
                			<td>' . $val->items_name . '</td>
                			<td>' . $val->items_description . '</td>
                			<td>' . $val->items_qty . '</td>
                			<td>0</td>
                			<td>' . date('Y-m-d', strtotime($val->items_request_date)) . '</td>
                			<td>' . $val->items_project_info . '</td>
                			<td>' . $val->items_remark . '</td>
                			</tr>';
                        $i++;
                    }
                    foreach ($items_updated as $val) {
                        $tr = '<tr>';
                        if (!$val->items_active) {
                            $tr = '<tr class="inactive">';
                        } else {
                            $tr = '<tr class="update">';
                        }
                        $active = $val->items_active ? '是' : '否';
                        $transferContent .= $tr . '
                			<td>' . $i . '</td>
                			<td>更新</td>
                			<td>' . $active . '</td>
                			<td>' . $val->items_code . '</td>
                			<td>' . $val->items_name . '</td>
                			<td>' . $val->items_description . '</td>
                			<td>' . $val->items_qty . '</td>
                			<td>' . $val->items_qty_receive . '</td>
                			<td>' . $val->items_request_date . '</td>
                			<td>' . $val->items_project_info . '</td>
                			<td>' . $val->items_remark . '</td>
                			</tr>';
                        $i++;
                    }
                    foreach ($items_deleted as $val) {
                        $active = $val->items_active ? '是' : '否';
                        $transferContent .= '<tr class="delete">
                			<td>' . $i . '</td>
                			<td>删除</td>
                			<td>' . $active . '</td>
                			<td>' . $val->items_code . '</td>
                			<td>' . $val->items_name . '</td>
                			<td>' . $val->items_description . '</td>
                			<td>' . $val->items_qty . '</td>
                			<td>0</td>
                			<td>' . $val->items_request_date . '</td>
                			<td>' . $val->items_project_info . '</td>
                			<td>' . $val->items_remark . '</td>
                			</tr>';
                        $i++;
                    }
                    $transferContent .= '</table></div>';
                }
                $mailData = array('type' => '消息', 'subject' => '采购订单-' . $typeArr[$type], 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent . $transferContent, 'add_date' => $now);
                if ($transferContent != '') {
                    $transfer = new Erp_Model_Purchse_Transfer();
                    $transfer->update(array('transfer_content' => $transferContent), "id = " . $transfer_id);
                }
                $result = $help->sendMailToStep($mailTo, $mailData);
            }
        }
        echo Zend_Json::encode($result);
        exit;
    }
Esempio n. 4
0
 /**
  * @abstract    删除
  * @return      null
  */
 public function removeAction()
 {
     // 返回值数组
     $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'];
     $json = json_decode($request['json']);
     $deleted = $json->deleted;
     $updbom = new Product_Model_Updbom();
     $fadev = new Product_Model_Fadev();
     $sondev = new Product_Model_Sondev();
     $fa = new Product_Model_Fa();
     $son = new Product_Model_Son();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             $id = $val->id;
             $upd_type = $val->upd_type;
             if ($upd_type == 'ECO') {
                 $bomflg = "ecobom";
                 $table = "oa_product_bom_eco";
             } else {
                 if ($upd_type == 'DEV') {
                     $bomflg = "devbom";
                     $table = "oa_product_bom_dev";
                 }
             }
             // 操作记录
             $data = array('type' => $bomflg, 'table_name' => $table, 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "删除", 'ip' => $_SERVER['REMOTE_ADDR']);
             // 获取bom fa表的recordkey
             $sql = "select recordkey from oa_product_bom_fa_dev where nid={$id} and (type='DEV' or type='ECO')";
             $keys = $fa->getAdapter()->query($sql)->fetchObject();
             if ($keys && $keys->recordkey) {
                 $recordkey = $keys->recordkey;
             } else {
                 $sql = "select recordkey from oa_product_bom_fa where nid={$id} and (type='DEV' or type='ECO')";
                 $keys = $fa->getAdapter()->query($sql)->fetchObject();
                 if ($keys && $keys->recordkey) {
                     $recordkey = $keys->recordkey;
                 }
             }
             try {
                 // 增加record记录
                 $record->insert($data);
                 // 删除review记录
                 $review->delete("type = '{$bomflg}' and file_id = {$id}");
                 // 删除bom表
                 $updbom->delete("id = {$id}");
                 if (isset($recordkey) && $recordkey) {
                     $where = "recordkey = {$recordkey}";
                     $fadev->delete($where);
                     $sondev->delete($where);
                     $fa->delete($where);
                     $son->delete($where);
                 }
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Esempio n. 5
0
 /**
  * @abstract    删除
  * @return      null
  */
 public function removeAction()
 {
     // 返回值数组
     $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'];
     $json = json_decode($request['json']);
     $deleted = $json->deleted;
     $desc = new Product_Model_Desc();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             $id = $val->id;
             // 操作记录
             $data = array('type' => "materiel_desc", 'table_name' => "oa_product_materiel_desc", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "删除", 'ip' => $_SERVER['REMOTE_ADDR']);
             try {
                 // 增加record记录
                 $record->insert($data);
                 // 删除review记录
                 $review->delete("type = 'materiel_desc' and file_id = {$id}");
                 // 更新物料状态
                 $desc->update(array('state' => 'Deleted'), "id = {$id}");
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Esempio n. 6
0
 public function overtimeAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '提交成功');
     // 请求参数
     $request = $this->getRequest()->getParams();
     // 操作类型
     $operate = array('new' => '新建', 'edit' => '编辑', 'delete' => '删除');
     // 操作类别(新建、更新、删除)
     $operate_type = isset($request['operate']) ? $request['operate'] : '';
     $overtime = new Hra_Model_Attendance_Overtime();
     if ($operate_type == 'new_hra' || $operate_type == 'new' || $operate_type == 'edit') {
         $time_from = str_replace('T', ' ', $request['time_from']);
         $time_to = str_replace('T', ' ', $request['time_to']);
         if (date('Y-m', strtotime($time_from)) != date('Y-m', strtotime($time_to))) {
             $result['success'] = false;
             $request['info'] = '不允许跨月申请,请重新填写时间!';
             echo Zend_Json::encode($result);
             exit;
         }
         // 获取加班人员的用工形式(0:弹性,1:非弹性)
         $user = new Application_Model_User();
         $userInfo = $user->getEmployeeInfoById($request['apply_user']);
         $userType = $userInfo['employment_type'];
         $workday = new Hra_Model_Workday();
         // 获取请假区间包含的工作日天数
         $overtimeInfo = $workday->getOvertimeQtyByTimeRange($userType, $request['time_from'], $request['time_to']);
         $overtimeQty = $overtimeInfo['qty'];
         $overtimeQty_hours = $overtimeInfo['qty_hours'];
         /* echo $overtimeQty;
            exit; */
         // 加班类别按起始日期获取
         $overtimeType = $workday->getWorkdayType($userType, date('Y-m-d', strtotime($request['time_from'])));
         if ($overtimeType == 0) {
             $result['success'] = false;
             $request['info'] = '工作日设置错误,请检查工作日设置!';
             echo Zend_Json::encode($result);
             exit;
         }
         // 当编辑请假申请时,检查时间是否重叠需要过滤当前加班申请ID
         $filter_id = null;
         if ($operate_type == 'edit') {
             $filter_id = $request['id'];
         }
         // 检查加班时间范围是否正确
         if ($overtimeQty > 0) {
             // 检查加班时间范围是否跟已有申请(包括已审核和审核中的申请)重叠
             if ($overtime->checkTimeOverlap($request['apply_user'], $request['time_from'], $request['time_to'], $filter_id)) {
                 $result['success'] = false;
                 $result['info'] = '时间设置错误,加班时间重叠,请优先处理未审申请。';
             } else {
                 $now = date('Y-m-d H:i:s');
                 $user_session = new Zend_Session_Namespace('user');
                 $user_id = $user_session->user_info['user_id'];
                 // 当前申请为代申请时,获取申请人真实部门主管
                 if ($request['apply_user'] != $user_id) {
                     // 获取部门主管
                     $manager = $user->getManagerUser($request['apply_user']);
                     $request['review_user_1'] = $manager[0]['id'];
                 }
                 if ($request['review_user_1'] >= 0) {
                     $data = array('type' => $overtimeType, 'apply_user' => $request['apply_user'], 'review_user_1' => $request['review_user_1'], 'time_from' => $request['time_from'], 'time_to' => $request['time_to'], 'qty' => $overtimeQty, 'qty_hours' => $overtimeQty_hours, 'reason' => $request['reason'], 'remark' => $request['remark'], 'update_time' => $now, 'update_user' => $user_id);
                     /* echo '<pre>';
                        print_r($data);
                        exit; */
                     if ($operate_type == 'new_hra') {
                         // HRA手动添加
                         $data['state'] = 3;
                         $data['create_time'] = $now;
                         $data['create_user'] = $user_id;
                         $data['review_info'] = $now . ': ' . $user_session->user_info['user_name'] . ' [手动添加]';
                         try {
                             $overtime_id = $overtime->insert($data);
                             echo Zend_Json::encode($result);
                             exit;
                         } catch (Exception $e) {
                             $result['success'] = false;
                             $result['info'] = $e->getMessage();
                         }
                     } else {
                         if ($operate_type == 'new') {
                             $data['create_time'] = $now;
                             $data['create_user'] = $user_id;
                             $data['review_info'] = $now . ': ' . $user_session->user_info['user_name'] . ' [新建]';
                             try {
                                 $overtime_id = $overtime->insert($data);
                             } catch (Exception $e) {
                                 $result['success'] = false;
                                 $result['info'] = $e->getMessage();
                             }
                         } else {
                             $overtime_id = $request['id'];
                             $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [修改]';
                             $overtimeData = $overtime->getData(null, $overtime_id);
                             $data['review_info'] = $overtimeData['review_info'] . '<br>' . $review_info;
                             $data['state'] = 0;
                             $data['review_time_1'] = null;
                             //$data['review_time_2'] = null;
                             $data['release_time'] = null;
                             try {
                                 $overtime->update($data, "id = " . $overtime_id);
                             } catch (Exception $e) {
                                 $result['success'] = false;
                                 $result['info'] = $e->getMessage();
                             }
                         }
                     }
                     $overtimeData = $overtime->getData(null, $overtime_id);
                     $review = new Dcc_Model_Review();
                     $user = new Application_Model_User();
                     $help = new Application_Model_Helpers();
                     // 记录审核日志:审核人1
                     $apply_user_info = $user->getEmployeeInfoById($request['apply_user']);
                     $review_user_1_info = $user->getEmployeeInfoById($request['review_user_1']);
                     $reviewData = array('type' => 'attendance_overtime', 'file_id' => $overtime_id, 'step_name' => '审核人1', 'plan_user' => $overtimeData['review_employee_1_id'], 'method' => 1, 'return' => 1);
                     $review->insert($reviewData);
                     // 如果存在审核人2记录审核日志:审核人2
                     /* if($request['review_user_2']){
                            $review_user_2_info = $user->getEmployeeInfoById($request['review_user_2']);
                            
                            $reviewData = array(
                                    'type'      => 'attendance_overtime',
                                    'file_id'   => $overtime_id,
                                    'step_name' => '审核人2',
                                    'plan_user' => $overtimeData['review_employee_2_id'],
                                    'method'    => 1,
                                    'return'    => 1
                            );
                            
                            $review->insert($reviewData);
                        } */
                     // 记录审核日志:人事主管
                     $member = new Admin_Model_Member();
                     $hraAdminUserArr = $member->getMemberWithNoManagerByName('人事主管');
                     $hraEmployeeIdArr = array();
                     foreach ($hraAdminUserArr as $hra) {
                         $hra_info = $user->getEmployeeInfoById($hra['user_id']);
                         array_push($hraEmployeeIdArr, $hra_info['id']);
                     }
                     $hraIds = implode(',', $hraEmployeeIdArr);
                     $reviewData = array('type' => 'attendance_overtime', 'file_id' => $overtime_id, 'step_name' => '人事审核', 'plan_user' => $hraIds, 'method' => 1, 'return' => 1);
                     $review->insert($reviewData);
                     // 向审核人1发送邮件
                     $mailContent = '<div>你有一个新的加班申请等待审核,请登录系统查看:</div>
                                     <div>
                                     <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' => '加班申请-新申请', 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent, 'add_date' => $now);
                     $result = $help->sendMailToStep(array($review_user_1_info['id']), $mailData);
                 } else {
                     $result['success'] = false;
                     $result['info'] = '申请失败,当前申请人未设置部门主管。';
                 }
             }
         } else {
             $result['success'] = false;
             $result['info'] = '时间设置错误,请确认时间范围是否正确。';
         }
     } else {
         if ($operate_type == 'delete') {
             if (isset($request['id']) && count(Zend_Json::decode($request['id'])) > 0) {
                 $ids = Zend_Json::decode($request['id']);
                 // 多条申请逐条删除
                 foreach ($ids as $id) {
                     try {
                         $review = new Dcc_Model_Review();
                         // 删除审核日志
                         $review->delete("type = 'attendance_overtime' and file_id = " . $id);
                         $overtime->delete("id = " . $id);
                     } catch (Exception $e) {
                         $result['success'] = false;
                         $result['info'] = $e->getMessage();
                     }
                 }
             } else {
                 $result['success'] = false;
                 $result['info'] = '参数错误,没有删除对象。';
             }
         } else {
             $result['success'] = false;
             $result['info'] = '参数错误,没有操作类别。';
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
Esempio n. 7
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;
 }
Esempio n. 8
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;
 }
Esempio n. 9
0
 /**
  * @abstract    文件升版
  * @return      null
  */
 public function upgradeAction()
 {
     // 返回值数组
     $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'];
     $user_name = $user_session->user_info['user_name'];
     $val = (object) $request;
     $json = json_decode($request['json']);
     $code_file_code_id = $json->code_id;
     $code_file_code = $json->code;
     $code_file_file_id = $json->file_id;
     $code_file_file = $json->file;
     $code_file_desc = isset($json->code_file_desc) ? $json->code_file_desc : '';
     $code_file_project_no = isset($json->code_file_project_no) ? $json->code_file_project_no : '';
     $files = new Dcc_Model_Files();
     $upload = new Dcc_Model_Upload();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     $upgrade = new Dcc_Model_Upgrade();
     $employee = new Hra_Model_Employee();
     $mail = new Application_Model_Log_Mail();
     $member = new Admin_Model_Member();
     $code = $code_file_code[0];
     $stepRows = array();
     if (count($code) > 0 && $code) {
         $codeModel = new Dcc_Model_Code();
         // 获取当前文件类别对应的流程ID
         $row = $codeModel->getTypeInfo("t1.code = '{$code}'");
         $flow_id = $row['dev_flow_id'];
         if ($flow_id) {
             // 根据流程ID获取阶段
             $flow = new Admin_Model_Flow();
             $step = new Admin_Model_Step();
             $flowRow = $flow->getRow($flow_id);
             $step_ids = $flowRow['step_ids'];
             if ($step_ids) {
                 $stepRows = $step->getListByFlow($step_ids);
                 $state = $stepRows[0]['step_name'];
             }
         }
     }
     // 获取所有文件的版本号
     $vers = array();
     foreach ($code_file_code as $c) {
         $d = $files->getAdapter()->query("select max(ver)+0.1 as ver from oa_doc_files where code = :code and state = 'Active' and del_flg = 0", array('code' => $c))->fetch();
         $v = round($d['ver'], 1);
         if (strcmp($v, (int) $v) === 0) {
             $v .= ".0";
         }
         $vers[] = $v;
     }
     // 新增还是编辑
     if ($val->id) {
         $result['info'] = '修改成功';
         $data = array('state' => isset($state) ? 'Reviewing' : 'Active', 'code' => implode(',', $code_file_code), 'name' => implode(',', $code_file_file), 'file_ids' => implode(',', $code_file_file_id), 'ver' => implode(',', $vers), 'description' => $code_file_desc, 'project_info' => implode(',', $code_file_project_no), 'remark' => $val->remark, 'tag' => $val->tag, 'update_time' => $now, 'update_user' => $user);
         $id = $val->id;
         $where = "id = " . $id;
         // 修改升版记录
         $upgradeData = array('reason' => $val->reason, 'reason_type' => $val->reason_type, 'update_time' => $now, 'update_user' => $user);
         $upgradeWhere = "file_id = {$id}";
         try {
             if ($id) {
                 $upgrade->update($upgradeData, $upgradeWhere);
                 $files->update($data, $where);
                 $attrval = new Admin_Model_Formval();
                 // 自定义字段
                 foreach ($request as $field => $value) {
                     if (stripos($field, "intelligenceField") !== false) {
                         $attrId = str_replace("intelligenceField", "", $field);
                         $menu = 'oa_doc_files_' . $id;
                         $formval = array('attrid' => $attrId, 'value' => $value, 'menu' => $menu);
                         $where = "attrid = " . $attrId . " and menu = '" . $menu . "'";
                         if ($attrval->fetchAll($where)->count() > 0) {
                             // 更新
                             $attrval->update($formval, $where);
                         } else {
                             $attrval->insert($formval);
                         }
                     }
                 }
                 // 操作记录
                 $data = array('type' => "files", 'table_name' => "oa_doc_files", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "编辑", 'ip' => $_SERVER['REMOTE_ADDR']);
                 $record->insert($data);
                 // 审核流程
                 // 删除已存在的审核记录
                 $review->delete("type='files' and file_id = " . $id);
                 // 把阶段信息插入review记录
                 $first = true;
                 foreach ($stepRows as $s) {
                     $plan_user = $s['user'];
                     if ($s['dept']) {
                         $plan_dept = $s['dept'];
                         // 根据角色id和项目号获取用户成员列表
                         $roleid = $s['dept'];
                         $codeTmp = $employee->getAdapter()->query("select project_no from oa_doc_code where code = '{$code}'")->fetchObject();
                         $projectno = $codeTmp->project_no;
                         // 如果不存在项目号,则直接取角色中的用户 否则根据角色id和项目号获取roleset id
                         $tmpUser = array();
                         $tmpBool = true;
                         if ($projectno) {
                             // 根据角色id和项目号获取roleset id
                             $rolesetTmp = $employee->getAdapter()->query("select group_concat(id) as id from oa_product_catalog_roleset where active=1 and catalog_id='{$projectno}' and role_id in ( " . $roleid . ")")->fetchObject();
                             $rolesetid = $rolesetTmp->id;
                             if ($rolesetid) {
                                 $tmpBool = false;
                                 $userTmp = $employee->getAdapter()->query("select group_concat(user_id) as ids from oa_product_catalog_roleset_member where roleset_id in ( " . $rolesetid . ")")->fetchObject();
                                 $tmpUser = explode(',', $userTmp->ids);
                                 // 如果没有取到用户,还是使用默认用户
                                 if (count($tmpUser) == 0) {
                                     $tmpBool = true;
                                 }
                             }
                         }
                         if ($tmpBool) {
                             foreach (explode(',', $plan_dept) as $role) {
                                 $tmpRole = $member->getMemberWithNoManager($role);
                                 foreach ($tmpRole as $m) {
                                     $tmpUser[] = $m['user_id'];
                                 }
                             }
                         }
                         if (count($tmpUser) == 0 && !$plan_user) {
                             $tmpUser = $member->getUserids("系统管理员");
                         }
                         // user id 转换成employee id
                         if (count($tmpUser) > 0) {
                             $tmpUser = $employee->getAdapter()->query("select group_concat(employee_id) as users from oa_user where active = 1 and id in ( " . implode(',', $tmpUser) . ")")->fetchObject();
                             $users = $tmpUser->users;
                         }
                         // 获取角色所有人员
                         //                            $tmpUser = $employee->getAdapter()->query("select group_concat(id) as ids from oa_employee where dept_id in ( " . $plan_dept . ")")->fetchObject();
                         if ($users) {
                             if ($plan_user) {
                                 $plan_user .= ",";
                             }
                             $plan_user .= $users;
                         }
                         $repeatUser = explode(',', $plan_user);
                         $repeatUser = array_unique($repeatUser);
                         $plan_user = implode(',', $repeatUser);
                     }
                     $reviewData = array('type' => "files", 'file_id' => $id, 'plan_dept' => $s['dept'], 'plan_user' => $plan_user, 'method' => $s['method'], 'return' => $s['return'], 'step_name' => $s['step_name'], 'step_ename' => $s['step_ename']);
                     $review->insert($reviewData);
                     // 邮件任务
                     if ($first) {
                         $to = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $plan_user . ")")->fetchObject();
                         $content = "你有文件升版需要审核,<p><b>文件号:</b>" . implode(',', $code_file_code) . "</p><p><b>版本:</b>" . implode(',', $vers) . "</p><p><b>升版原因:</b>" . $val->reason . "</p><p><b>备注:</b>" . $val->remark . "</p><p><b>申请人:</b>" . $user_name . "</p><p><b>申请时间:</b>" . $now . "</p><p>请登录系统查看详情!</p>";
                         $mailData = array('type' => '升版文件', 'subject' => '升版文件评审', 'to' => $to->mail_to, 'cc' => '', 'content' => $content, 'send_time' => $now, 'add_date' => $now);
                         $mailId = $mail->insert($mailData);
                         if ($mailId) {
                             $mail->send($mailId);
                         }
                     }
                     $first = false;
                 }
                 // 没有审批流程,旧版文件自动作废
                 if (!isset($state)) {
                     $sids = array($id);
                     if (isset($sids) && count($sids) > 0) {
                         if (count($code_file_code) > 0) {
                             $codes = array();
                             foreach ($code_file_code as $c) {
                                 $codes[] = $c;
                             }
                         }
                         if (isset($codes) && count($codes) > 0) {
                             for ($i = 0; $i < count($codes); $i++) {
                                 $codes[$i] = "'" . $codes[$i] . "'";
                             }
                         }
                         $obsoluteWhere = " id not in (" . implode(',', $sids) . ") and code in (" . implode(',', $codes) . ")";
                     }
                     $obsoluteData = array("state" => "Obsolete");
                     if (isset($obsoluteWhere)) {
                         $files->update($obsoluteData, $obsoluteWhere);
                     }
                     // 更改文件状态为归档
                     $uploadData = array("archive" => 1, "archive_time" => $now);
                     $uploadWhere = "id in (" . implode(',', $code_file_file_id) . ")";
                     // 更新文件
                     $upload->update($uploadData, $uploadWhere);
                 }
             }
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         echo Zend_Json::encode($result);
         exit;
     } else {
         $data = array('state' => isset($state) ? 'Reviewing' : 'Active', 'code' => implode(',', $code_file_code), 'name' => implode(',', $code_file_file), 'file_ids' => implode(',', $code_file_file_id), 'ver' => implode(',', $vers), 'description' => $code_file_desc, 'project_info' => implode(',', $code_file_project_no), 'remark' => $val->remark, 'tag' => $val->tag, 'create_time' => $now, 'create_user' => $user, 'update_time' => $now, 'update_user' => $user);
         try {
             $id = $files->insert($data);
             if ($id) {
                 // 升版记录
                 $upgradeData = array('file_id' => $id, 'reason' => $val->reason, 'reason_type' => $val->reason_type, 'create_time' => $now, 'create_user' => $user, 'update_time' => $now, 'update_user' => $user);
                 $upgrade->insert($upgradeData);
                 // 自定义字段
                 $attrval = new Admin_Model_Formval();
                 foreach ($request as $field => $value) {
                     if (stripos($field, "intelligenceField") !== false && $value) {
                         $attrId = str_replace("intelligenceField", "", $field);
                         $menu = 'oa_doc_files_' . $id;
                         $formval = array('attrid' => $attrId, 'value' => $value, 'menu' => $menu);
                         $attrval->insert($formval);
                     }
                 }
                 // 操作记录
                 $data = array('type' => "files", 'table_name' => "oa_doc_files", 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => "申请", 'ip' => $_SERVER['REMOTE_ADDR']);
                 $record->insert($data);
                 // 审核流程
                 // 把阶段信息插入review记录
                 $first = true;
                 foreach ($stepRows as $s) {
                     $plan_user = $s['user'];
                     if ($s['dept']) {
                         $plan_dept = $s['dept'];
                         // 根据角色id和项目号获取用户成员列表
                         $roleid = $s['dept'];
                         $codeTmp = $employee->getAdapter()->query("select project_no from oa_doc_code where code = '{$code}'")->fetchObject();
                         $projectno = $codeTmp->project_no;
                         // 如果不存在项目号,则直接取角色中的用户 否则根据角色id和项目号获取roleset id
                         $tmpUser = array();
                         $tmpBool = true;
                         if ($projectno) {
                             // 根据角色id和项目号获取roleset id
                             $rolesetTmp = $employee->getAdapter()->query("select group_concat(id) as id from oa_product_catalog_roleset where active=1 and catalog_id='{$projectno}' and role_id in ( " . $roleid . ")")->fetchObject();
                             $rolesetid = $rolesetTmp->id;
                             if ($rolesetid) {
                                 $tmpBool = false;
                                 $userTmp = $employee->getAdapter()->query("select group_concat(user_id) as ids from oa_product_catalog_roleset_member where roleset_id in ( " . $rolesetid . ")")->fetchObject();
                                 $tmpUser = explode(',', $userTmp->ids);
                                 // 如果没有取到用户,还是使用默认用户
                                 if (count($tmpUser) == 0) {
                                     $tmpBool = true;
                                 }
                             }
                         }
                         if ($tmpBool) {
                             foreach (explode(',', $plan_dept) as $role) {
                                 $tmpRole = $member->getMemberWithNoManager($role);
                                 foreach ($tmpRole as $m) {
                                     $tmpUser[] = $m['user_id'];
                                 }
                             }
                         }
                         if (count($tmpUser) == 0 && !$plan_user) {
                             $tmpUser = $member->getUserids("系统管理员");
                         }
                         // user id 转换成employee id
                         if (count($tmpUser) > 0) {
                             $tmpUser = $employee->getAdapter()->query("select group_concat(employee_id) as users from oa_user where active = 1 and id in ( " . implode(',', $tmpUser) . ")")->fetchObject();
                             $users = $tmpUser->users;
                         }
                         // 获取角色所有人员
                         //                            $tmpUser = $employee->getAdapter()->query("select group_concat(id) as ids from oa_employee where dept_id in ( " . $plan_dept . ")")->fetchObject();
                         if ($users) {
                             if ($plan_user) {
                                 $plan_user .= ",";
                             }
                             $plan_user .= $users;
                         }
                         $repeatUser = explode(',', $plan_user);
                         $repeatUser = array_unique($repeatUser);
                         $plan_user = implode(',', $repeatUser);
                     }
                     $reviewData = array('type' => "files", 'file_id' => $id, 'plan_dept' => $s['dept'], 'plan_user' => $plan_user, 'method' => $s['method'], 'return' => $s['return'], 'step_name' => $s['step_name'], 'step_ename' => $s['step_ename']);
                     $review->insert($reviewData);
                     // 邮件任务
                     if ($first) {
                         $to = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $plan_user . ")")->fetchObject();
                         $content = "你有文件升版需要审核,<p><b>文件号:</b>" . implode(',', $code_file_code) . "</p><p><b>版本:</b>" . implode(',', $vers) . "</p><p><b>升版原因:</b>" . $val->reason . "</p><p><b>备注:</b>" . $val->remark . "</p><p><b>申请人:</b>" . $user_name . "</p><p><b>申请时间:</b>" . $now . "</p><p>请登录系统查看详情!</p>";
                         $mailData = array('type' => '升版文件', 'subject' => '升版文件评审', 'to' => $to->mail_to, 'cc' => '', 'content' => $content, 'send_time' => $now, 'add_date' => $now);
                         $mailId = $mail->insert($mailData);
                         if ($mailId) {
                             $mail->send($mailId);
                         }
                     }
                     $first = false;
                 }
                 // 没有审批流程,旧版文件自动作废
                 if (!isset($state)) {
                     $sids = array($id);
                     if (isset($sids) && count($sids) > 0) {
                         if (count($code_file_code) > 0) {
                             $codes = array();
                             foreach ($code_file_code as $c) {
                                 $codes[] = $c;
                             }
                         }
                         if (isset($codes) && count($codes) > 0) {
                             for ($i = 0; $i < count($codes); $i++) {
                                 $codes[$i] = "'" . $codes[$i] . "'";
                             }
                         }
                         $obsoluteWhere = " id not in (" . implode(',', $sids) . ") and code in (" . implode(',', $codes) . ")";
                     }
                     $obsoluteData = array("state" => "Obsolete");
                     if (isset($obsoluteWhere)) {
                         $files->update($obsoluteData, $obsoluteWhere);
                     }
                     // 更改文件状态为归档
                     $uploadData = array("archive" => 1, "archive_time" => $now);
                     $uploadWhere = "id in (" . implode(',', $code_file_file_id) . ")";
                     // 更新文件
                     $upload->update($uploadData, $uploadWhere);
                 }
             }
         } catch (Exception $e) {
             $result['result'] = false;
             $result['info'] = $e->getMessage();
             echo Zend_Json::encode($result);
             exit;
         }
         echo Zend_Json::encode($result);
         exit;
     }
 }
Esempio n. 10
0
 /**
  * @abstract    保存
  * @return      null
  */
 public function saveAction()
 {
     // 返回值数组
     $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'];
     $user_name = $user_session->user_info['user_name'];
     $val = (object) $request;
     $materiel = new Product_Model_Materiel();
     $record = new Dcc_Model_Record();
     $review = new Dcc_Model_Review();
     $employee = new Hra_Model_Employee();
     $mail = new Application_Model_Log_Mail();
     $member = new Admin_Model_Member();
     $fadev = new Product_Model_Fadev();
     $faModel = new Product_Model_Fa();
     $sondev = new Product_Model_Sondev();
     $flow = new Admin_Model_Flow();
     $step = new Admin_Model_Step();
     $db = $fadev->getAdapter();
     $type = $val->upd_type;
     if ($type == 'new') {
         $bomModel = new Product_Model_Newbom();
     } else {
         $bomModel = new Product_Model_Updbom();
     }
     // 检查BOM信息是否完整
     if (!isset($val->id) || !$val->id) {
         $result['result'] = false;
         $result['info'] = "BOM信息不完整,请重新编辑";
         echo Zend_Json::encode($result);
         exit;
     }
     $id = $val->id;
     $ismanager = "";
     if (isset($val->ismanager) && $val->ismanager == '1') {
         $ismanager = "1";
         $managerState = $val->state;
     }
     // BOM完整:存在上级物料和下级物料,每个上级物料都有下级物料,替代料都存在
     $bomFinishFlg = true;
     $facount = 0;
     $faData = $fadev->fetchAll("type = '{$type}' and nid = " . $id)->toArray();
     if (count($faData) > 0) {
         $files = new Dcc_Model_Files();
         foreach ($faData as $farow) {
             if ($farow['bom_file']) {
                 $fileArr = explode(',', $farow['bom_file']);
                 foreach ($fileArr as $filecode) {
                     if ($files->fetchAll("code='{$filecode}' and state ='Active'")->count() == 0) {
                         $result['result'] = false;
                         $result['info'] = "BOM " . $farow['code'] . "的关联文件:“<b>" . $filecode . "</b>”不存在!";
                         echo Zend_Json::encode($result);
                         exit;
                     }
                 }
             }
         }
     }
     $sonData = $sondev->fetchAll("nid = " . $id)->toArray();
     if (count($faData) > 0 && count($sonData) > 0) {
         foreach ($sonData as $son) {
             if ($son['replace'] == "") {
                 continue;
             }
             $replace = explode(',', $son['replace']);
             foreach ($replace as $r) {
                 if ($materiel->fetchAll("code='{$r}'")->count() == 0) {
                     $result['result'] = false;
                     $result['info'] = "物料" . $son['code'] . "的替代料:<b>" . $r . "</b>不存在!";
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
         foreach ($faData as $fa) {
             foreach ($sonData as $son) {
                 if ($fa['recordkey'] == $son['recordkey']) {
                     $facount++;
                     break;
                 }
             }
         }
         if ($facount != count($faData)) {
             $bomFinishFlg = false;
         }
     } else {
         $bomFinishFlg = false;
     }
     if (!$bomFinishFlg) {
         $result['result'] = false;
         $result['info'] = "BOM信息不完整,请重新编辑";
         echo Zend_Json::encode($result);
         exit;
     }
     // 下级BOM未归档
     $materielType = new Product_Model_Type();
     $bomArr = array();
     foreach ($faData as $fa) {
         if ($type == 'new') {
             // 检查上级bom是否已经存在,或者正在申请
             $join = array(array('type' => INNERJOIN, 'table' => $bomModel->getName(), 'condition' => $fadev->getName() . '.nid = ' . $bomModel->getName() . '.id'));
             $jwhere = $fadev->getName() . ".code = '" . $fa['code'] . "' and (" . $bomModel->getName() . ".state = 'Active' or " . $bomModel->getName() . ".state = 'Reviewing')";
             if ($fadev->getJoinCount($jwhere, $join)) {
                 $result['result'] = false;
                 $result['info'] = "BOM“" . $fa['code'] . "”已存在或正在申请";
                 echo Zend_Json::encode($result);
                 exit;
             }
             // 检查bom的状态,不能是作废或者删除
             $bomMateriel = $materiel->getMaterielByCode($fa['code']);
             if (!$bomMateriel) {
                 $result['result'] = false;
                 $result['info'] = "物料“" . $fa['code'] . "”不存在";
                 echo Zend_Json::encode($result);
                 exit;
             }
             if ($bomMateriel['state'] == 'Obsolete' || $bomMateriel['state'] == 'Deleted') {
                 $result['result'] = false;
                 $result['info'] = "物料“" . $fa['code'] . "”已作废";
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
         // 检查下级bom是否归档
         foreach ($sonData as $son) {
             if (isset($bomArr[$son['id']]) && $bomArr[$son['id']]) {
                 $isbom = true;
             } else {
                 if (isset($bomArr[$son['id']]) && !$bomArr[$son['id']]) {
                     $isbom = false;
                 } else {
                     $d = $materiel->fetchRow('id = ' . $son['id']);
                     $d = $materielType->fetchRow('id = ' . $d['type']);
                     $bomArr[$son['id']] = $d['bom'];
                     $isbom = false;
                 }
             }
             if ($isbom) {
                 if ($faModel->fetchAll("id = '" . $son['id'] . "'")->count() == 0) {
                     $result['result'] = false;
                     $result['info'] = "子BOM“" . $son['code'] . "”未归档";
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
     }
     // 根据BOM获取审批流
     $flow_id = "";
     if (isset($val->review_flow)) {
         $flow_id = $val->review_flow;
         $flowRow = $db->query("select t1.* from oa_admin_flow t1 where t1.id='{$flow_id}'")->fetchObject();
     }
     if (!$flow_id) {
         $flowRow = $db->query("select t1.* from oa_admin_flow t1 inner join oa_product_bom_config t2 on t1.flow_name=t2.flow where t2.type='{$type}'")->fetchObject();
         if ($flowRow) {
             $flow_id = $flowRow->id;
         }
     }
     if (!$flow_id) {
         $result['result'] = false;
         $result['info'] = "还没有配置BOM审核流程,请联系管理员配置";
         echo Zend_Json::encode($result);
         exit;
     }
     // 根据流程ID获取阶段
     $step_ids = $flowRow->step_ids;
     if ($step_ids) {
         $stepRows = $step->getListByFlow($step_ids);
         $state = "Reviewing";
     }
     $state = "Reviewing";
     if (isset($managerState) && $managerState) {
         $state = $managerState;
     }
     if ($type == 'new') {
         $data = array("description" => isset($val->description) ? $val->description : "", "state" => $state, "remark" => isset($val->remark) ? $val->remark : "", "update_time" => $now, "update_user" => $user);
     } else {
         $data = array("upd_type" => isset($val->upd_type) ? $val->upd_type : "", "replace_flg" => isset($val->replace_flg) ? 1 : 0, "description" => isset($val->description) ? $val->description : "", "upd_reason" => isset($val->upd_reason) ? $val->upd_reason : "", "reason_type" => isset($val->reason_type) ? $val->reason_type : "", "state" => $state, "remark" => isset($val->remark) ? $val->remark : "", "update_time" => $now, "update_user" => $user);
     }
     if (isset($managerState) && $managerState == 'Active') {
         $data['archive_time'] = $now;
     }
     try {
         $bomModel->update($data, "id=" . $id);
         // 自定义字段
         $attrval = new Admin_Model_Formval();
         if ($type == 'new') {
             $table = "oa_product_bom_new";
             $recordType = "bom";
         } else {
             if ($type == 'ECO') {
                 $table = "oa_product_bom_eco";
                 $recordType = "ecobom";
             } else {
                 if ($type == 'DEV') {
                     $table = "oa_product_bom_dev";
                     $recordType = "devbom";
                 }
             }
         }
         $menu = $table . '_' . $id;
         $attrval->delete("menu = '" . $menu . "'");
         foreach ($request as $field => $value) {
             if (stripos($field, "intelligenceField") !== false && $value) {
                 $attrId = str_replace("intelligenceField", "", $field);
                 $formval = array('attrid' => $attrId, 'value' => $value, 'menu' => $menu);
                 $attrval->insert($formval);
             }
         }
         $action = "申请";
         if ($record->fetchAll("type='{$recordType}' and table_id={$id}")->count() > 0) {
             $action = "编辑";
         }
         // 操作记录
         $data = array('type' => $recordType, 'table_name' => $table, 'table_id' => $id, 'handle_user' => $user, 'handle_time' => $now, 'action' => $action, 'ip' => $_SERVER['REMOTE_ADDR']);
         $record->insert($data);
         // 管理员将状态改为审核中也会触发审批流程
         if (!$ismanager || isset($managerState) && $managerState == 'Reviewing') {
             // 审核流程
             // 把阶段信息插入review记录
             // 删除已有流程
             $review->delete("type='{$recordType}' and file_id = {$id}");
             $first = true;
             foreach ($stepRows as $s) {
                 $plan_user = $s['user'];
                 if ($s['dept']) {
                     $tmpUser = array();
                     $plan_dept = $s['dept'];
                     foreach (explode(',', $plan_dept) as $role) {
                         $tmpRole = $member->getMemberWithNoManager($role);
                         foreach ($tmpRole as $m) {
                             $tmpUser[] = $m['user_id'];
                         }
                     }
                     if (count($tmpUser) > 0) {
                         $tmpUser = $employee->getAdapter()->query("select group_concat(employee_id) as users from oa_user where active = 1 and id in ( " . implode(',', $tmpUser) . ")")->fetchObject();
                         $users = $tmpUser->users;
                     }
                     if (isset($users) && $users) {
                         if ($plan_user) {
                             $plan_user .= ",";
                         }
                         $plan_user .= $users;
                     }
                 }
                 $repeatUser = explode(',', $plan_user);
                 $repeatUser = array_unique($repeatUser);
                 $plan_user = implode(',', $repeatUser);
                 $reviewData = array('type' => "{$recordType}", 'file_id' => $id, 'plan_user' => $plan_user, 'method' => $s['method'], 'return' => $s['return'], 'step_name' => $s['step_name'], 'step_ename' => $s['step_ename']);
                 $review->insert($reviewData);
                 // 邮件任务
                 if ($first) {
                     $to = $employee->getAdapter()->query("select group_concat(email) as mail_to from oa_employee where id in ( " . $plan_user . ")")->fetchObject();
                     $boms = array();
                     foreach ($faData as $fa) {
                         if ($type == 'new') {
                             $boms[] = $fa['code'];
                         } else {
                             $boms[] = $fa['code'] . " V" . $fa['ver'];
                         }
                     }
                     if ($type == 'new') {
                         $content = "你有新BOM归档申请需要审核,<p>" . "<b>BOM号:</b>" . implode(',', $boms) . "</p>" . "<p><b>描述:</b>" . $val->description . "</p>" . "<p><b>备注:</b>" . $val->remark . "</p>" . "<p><b>申请人:</b>" . $user_name . "</p>" . "<p><b>申请时间:</b>" . $now . "</p>" . "<p>请登录系统查看详情!</p>";
                     } else {
                         $reson_type = "";
                         if ($val->reason_type) {
                             $codemaster = new Admin_Model_Codemaster();
                             $mstData = $codemaster->getList("type=6 and code='" . $val->reason_type . "'");
                             if ($mstData && count($mstData) > 0) {
                                 $reson_type = $mstData[0]['text'];
                             }
                         }
                         $content = "你有新BOM升版申请需要审核,<p>" . "<b>BOM号:</b>" . implode(',', $boms) . "</p>" . "<p><b>升版类型:</b>" . $val->upd_type . "</p>" . "<p><b>升版原因分类:</b>" . $reson_type . "</p>" . "<p><b>升版原因:</b>" . $val->upd_reason . "</p>" . "<p><b>升版描述:</b>" . $val->description . "</p>" . "<p><b>备注:</b>" . $val->remark . "</p>" . "<p><b>申请人:</b>" . $user_name . "</p>" . "<p><b>申请时间:</b>" . $now . "</p>" . "<p>请登录系统查看详情!</p>";
                     }
                     $mailData = array('type' => 'BOM归档审批', 'subject' => 'BOM归档审批', 'to' => $to->mail_to, 'cc' => '', 'content' => $content, 'send_time' => $now, 'add_date' => $now);
                     $mailId = $mail->insert($mailData);
                     if ($mailId) {
                         $mail->send($mailId);
                     }
                 }
                 $first = false;
             }
         } else {
             if (isset($managerState) && $managerState == 'Active') {
                 $bomfaData = $fadev->fetchAll("type = '{$type}' and nid=" . $id)->toArray();
                 // 如果是多个BOM,需要拆分
                 foreach ($bomfaData as $bomfa) {
                     // 升版的情况,旧版作废
                     $facode = $bomfa['code'];
                     if ($type != 'new') {
                         $obsoleteData = array("state" => "Obsolete");
                         $obsoleteWhere = "code = '{$facode}'";
                         $faModel->update($obsoleteData, $obsoleteWhere);
                     }
                     $recordkey = $bomfa['recordkey'];
                     $sql = "insert into oa_product_bom_fa (nid, recordkey, id, code, project_no, bom_file, qty, state, ver, type, remark) select nid, recordkey, id, code, project_no, bom_file, qty, 'EBOM', ver, type, remark from oa_product_bom_fa_dev where recordkey = {$recordkey}";
                     $db->query($sql);
                     $sql = "insert into oa_product_bom_son (nid, recordkey, pid, id, code, qty, partposition, `replace`, remark) select nid, recordkey, pid, id, code, qty, partposition, `replace`, remark from oa_product_bom_son_dev where recordkey = {$recordkey}";
                     $db->query($sql);
                 }
                 // 更新所有record的finish_flg为0
                 $reviewWhere = "type = '{$recordType}' and file_id = {$id}";
                 // 审核情况
                 $reviewData = array("actual_user" => $user, "finish_time" => $now, "finish_flg" => '1');
                 // 更新审核情况
                 $review->update($reviewData, $reviewWhere);
             }
         }
     } catch (Exception $e) {
         $result['result'] = false;
         $result['info'] = $e->getMessage();
         echo Zend_Json::encode($result);
         exit;
     }
     echo Zend_Json::encode($result);
     exit;
 }