public function refreshReqTotal($req_id) { $total = 0; if ($req_id) { $data = $this->fetchAll("req_id = " . $req_id); if ($data->count() > 0) { $items = $data->toArray(); foreach ($items as $item) { $total += $item['line_total']; } } } $req = new Erp_Model_Purchse_Req(); $req->update(array('total' => $total), "id = " . $req_id); }
public function getreqAction() { // 请求参数 $request = $this->getRequest()->getParams(); $option = isset($request['option']) ? $request['option'] : 'data'; $condition = array('key' => isset($request['key']) ? $request['key'] : '', 'state' => isset($request['state']) && is_numeric($request['state']) ? $request['state'] : null, 'applier' => isset($request['applier']) ? $request['applier'] : null, 'date_from' => isset($request['date_from']) ? $request['date_from'] : null, 'date_to' => isset($request['date_to']) ? $request['date_to'] : null, 'complete' => isset($request['complete']) && $request['complete'] != 'null' ? $request['complete'] : 1, 'type' => isset($request['type']) && $request['type'] != 'null' ? $request['type'] : null, 'dept' => isset($request['dept']) && $request['dept'] != 'null' ? $request['dept'] : null, 'page' => isset($request['page']) ? $request['page'] : 1, 'limit' => isset($request['limit']) ? $request['limit'] : 0, 'option' => $option); $reqItems = new Erp_Model_Purchse_Req(); $data = $reqItems->getReqStatistics($condition); //echo '<pre>';print_r($data);exit; if ($option == 'csv') { $this->view->layout()->disableLayout(); $this->_helper->viewRenderer->setNoRender(true); $h = new Application_Model_Helpers(); $h->exportCsv($data, '采购申请统计'); } else { echo Zend_Json::encode($data); } exit; }
public function getOrderStatistics($condition = array()) { $sql = $this->select()->setIntegrityCheck(false)->from(array('t1' => $this->_name), array('order_price_tax' => 'price_tax', 'order_state' => new Zend_Db_Expr("case when t1.state = 0 then '审核中' when t1.state = 1 then '拒绝' else '批准' end"), 'order_create_time' => 'create_time', 'order_release_time' => 'release_time', 'order_buyer_id' => 'buyer_id', 'order_supplier_id' => 'supplier_id', 'order_date', 'order_number' => 'number', 'order_remark' => 'remark', 'order_currency' => 'currency', 'order_type_id' => 'type_id'))->joinLeft(array('t2' => $this->_dbprefix . 'user'), "t1.create_user = t2.id", array())->joinLeft(array('t3' => $this->_dbprefix . 'employee'), "t2.employee_id = t3.id", array('creater' => 'cname'))->joinLeft(array('t4' => $this->_dbprefix . 'user'), "t1.update_user = t4.id", array())->joinLeft(array('t5' => $this->_dbprefix . 'employee'), "t4.employee_id = t5.id", array('updater' => 'cname'))->joinLeft(array('t7' => $this->_dbprefix . 'erp_pur_type'), "t1.type_id = t7.id", array('order_type_name' => 'name'))->joinLeft(array('t8' => $this->_dbprefix . 'erp_pur_order_items'), "t1.id = t8.order_id", array('delivery_date', 'delivery_date_remark', 'active', 'id', 'order_id', 'request_date', 'code', 'name', 'description', 'remark', 'supplier_code', 'supplier_codename', 'supplier_description', 'warehouse_code', 'price', 'qty', 'unit', 'project_info', 'req_number'))->joinLeft(array('t9' => $this->_dbprefix . 'bpartner'), "t1.supplier_id = t9.id", array('order_supplier_code' => 'code', 'order_supplier_name' => new Zend_Db_Expr("case when t9.cname != '' then t9.cname else t9.ename end")))->joinLeft(array('t10' => $this->_dbprefix . 'bpartner_contact'), "t1.supplier_contact_id = t10.id", array('order_supplier_contact' => new Zend_Db_Expr("concat(t10.name, ' [', t10.tel, ']')")))->joinLeft(array('t11' => $this->_dbprefix . 'erp_pur_order_items_req'), "t11.order_item_id = t8.id", array('req_item_ids' => new Zend_Db_Expr("group_concat(t11.req_item_id)")))->joinLeft(array('t12' => $this->_dbprefix . 'erp_pur_req_items'), "t12.id = t11.req_item_id", array('qty_req' => new Zend_Db_Expr('sum(t12.qty)'), 'order_req_num', 'customer_address', 'customer_aggrement'))->where("t1.active = 1")->group("t8.id")->order(array('t1.number desc', 't1.create_time desc')); // 状态 if ($condition['state'] != null) { $sql->where("t1.state = " . $condition['state']); } // 日前从 if ($condition['date_from']) { $sql->where("t1.create_time >= '" . $condition['date_from'] . " 00:00:00'"); } // 日期至 if ($condition['date_to']) { $sql->where("t1.create_time <= '" . $condition['date_to'] . " 23:59:59'"); } // 采购类别 if ($condition['type']) { $type = json_decode($condition['type']); if (count($type)) { $type_con = "t1.type_id = " . $type[0]; for ($i = 1; $i < count($type); $i++) { $type_con .= " or t1.type_id = " . $type[$i]; } $sql->where($type_con); } } // 需求部门 if ($condition['dept']) { $dept = json_decode($condition['dept']); if (count($dept)) { $dept_con = "t8.dept_id = " . $dept[0]; for ($i = 1; $i < count($dept); $i++) { $dept_con .= " or t8.dept_id = " . $dept[$i]; } $sql->where($dept_con); } } // 采购员 if ($condition['buyer']) { $buyer = json_decode($condition['buyer']); if (count($buyer)) { $buyer_con = "t1.buyer_id = " . $buyer[0]; for ($i = 1; $i < count($buyer); $i++) { $buyer_con .= " or t1.buyer_id = " . $buyer[$i]; } $sql->where($buyer_con); } } if ($condition['key']) { $sql->where("t9.code like '%" . $condition['key'] . "%' or t9.cname like '%" . $condition['key'] . "%' or t9.ename like '%" . $condition['key'] . "%' or t3.cname like '%" . $condition['key'] . "%' or t3.ename like '%" . $condition['key'] . "%' or t1.number like '%" . $condition['key'] . "%' or t1.remark like '%" . $condition['key'] . "%' or t3.cname like '%" . $condition['key'] . "%' or t3.ename like '%" . $condition['key'] . "%' or t7.name like '%" . $condition['key'] . "%' or t8.code like '%" . $condition['key'] . "%' or t8.name like '%" . $condition['key'] . "%' or t8.description like '%" . $condition['key'] . "%'"); } $total = $this->fetchAll($sql)->count(); /* echo $sql; exit; */ if ($condition['option'] != 'csv') { $sql->limitPage($condition['page'], $condition['limit']); } $data = $this->fetchAll($sql)->toArray(); //echo '<pre>';print_r($data);exit; $items_receive = new Erp_Model_Purchse_Receiveitemsorder(); $items_invoice = new Erp_Model_Purchse_Invoiceitems(); $buyer = new Erp_Model_Purchse_Buyer(); $req = new Erp_Model_Purchse_Req(); $operateModel = new Application_Model_Log_Operate(); $receiveModel = new Erp_Model_Purchse_Reqitemsreceived(); for ($i = 0; $i < count($data); $i++) { // 入库日志 $in_stock_info = $receiveModel->getReceivedInfo('order', $data[$i]['id']); $data[$i]['in_stock_qty'] = $in_stock_info['qty']; $data[$i]['in_stock_info'] = implode(',', $in_stock_info['info']); // 交期回复日志 if ($data[$i]['delivery_date'] != '' || $data[$i]['delivery_date_remark'] != '') { $logInfo = array(); $log = $operateModel->getLogByOperateAndTargetId('采购交期回复', $data[$i]['id']); foreach ($log as $l) { $content = Zend_Json::decode($l['content']); $logText = $content['time'] . ' [' . $content['delivery_date'] . '] [' . $content['delivery_date_remark'] . '] ' . $content['user']; array_push($logInfo, $logText); } $data[$i]['delivery_reply_log'] = implode(',', $logInfo); } // 获取采购申请数量(合并下单的申请分拆显示) $data[$i]['req_info'] = ''; if ($data[$i]['req_item_ids'] != '') { $item_ids = explode(',', $data[$i]['req_item_ids']); $req_item_data = $req->getReqQty($item_ids); $reqInfoArr = array(); foreach ($req_item_data as $req_info) { array_push($reqInfoArr, $req_info['number'] . ' [' . $req_info['qty'] . '] [' . $req_info['time'] . ']'); } $data[$i]['req_info'] = implode(',', $reqInfoArr); } $data[$i]['order_supplier'] = $data[$i]['order_supplier_code'] . $data[$i]['order_supplier_name']; $data[$i]['qty_receive'] = 0; $data[$i]['receive_info'] = ''; if ($data[$i]['id']) { if ($data[$i]['code'] != '') { // 已收货物料:从采购收货 $receiveData = $items_receive->getOrderItemReceivedQty($data[$i]['id']); $receiveInfoArr = array(); foreach ($receiveData as $r) { $data[$i]['qty_receive'] += $r['qty']; array_push($receiveInfoArr, $r['number'] . ' [' . $r['qty'] . '] [' . $r['time'] . ']'); } $data[$i]['receive_info'] = implode(',', $receiveInfoArr); } else { // 已收货非物料:从采购发票 $data[$i]['qty_receive'] = $items_invoice->getQty($data[$i]['id'], 1); } } $data[$i]['qty_left'] = $data[$i]['qty'] - $data[$i]['qty_receive']; $buyerData = $buyer->getData($data[$i]['order_buyer_id']); $data[$i]['order_buyer_name'] = isset($buyerData['cname']) ? $buyerData['cname'] : ''; } if ($condition['option'] == 'csv') { $data_csv = array(); $showPrice = false; if (Application_Model_User::checkPermissionByRoleName('系统管理员') || Application_Model_User::checkPermissionByRoleName('采购人员') || Application_Model_User::checkPermissionByRoleName('财务人员')) { $showPrice = true; } if ($showPrice) { $title = array('cnt' => '#', 'active' => '启用', 'order_number' => '订单号', 'order_state' => '订单状态', 'order_date' => '订单日期', 'order_buyer_name' => '采购员', 'order_type_name' => '类别', 'order_supplier_code' => '供应商代码', 'order_supplier_name' => '供应商名称', 'code' => '物料号', 'price' => '价格', 'order_price_tax' => '含税', 'qty' => '订单数量', 'qty_req' => '申请数量', 'qty_receive' => '到货数量', 'receive_info' => '到货信息', 'in_stock_qty' => '入库数量', 'in_stock_info' => '入库信息', 'qty_left' => '未到货数量', 'request_date' => '需求交期', 'delivery_date' => '预计交期', 'delivery_date_remark' => '交期备注', 'order_req_num' => '订货产品出库申请号', 'customer_address' => '客户收件人地址简码', 'customer_aggrement' => '客户合同号', 'name' => '名称', 'description' => '描述', 'req_info' => '申购单号', 'remark' => '备注', 'order_create_date' => '下单日期', 'order_create_time' => '下单时间', 'order_release_date' => '批准日期', 'order_release_time' => '批准时间'); } else { $title = array('cnt' => '#', 'active' => '启用', 'order_number' => '订单号', 'order_state' => '订单状态', 'order_date' => '订单日期', 'order_buyer_name' => '采购员', 'order_type_name' => '类别', 'order_supplier_code' => '供应商代码', 'order_supplier_name' => '供应商名称', 'code' => '物料号', 'qty' => '订单数量', 'qty_req' => '申请数量', 'qty_receive' => '到货数量', 'receive_info' => '到货信息', 'in_stock_qty' => '入库数量', 'in_stock_info' => '入库信息', 'qty_left' => '未到货数量', 'request_date' => '需求交期', 'delivery_date' => '预计交期', 'delivery_date_remark' => '交期备注', 'order_req_num' => '订货产品出库申请号', 'customer_address' => '客户收件人地址简码', 'customer_aggrement' => '客户合同号', 'name' => '名称', 'description' => '描述', 'req_info' => '申购单号', 'remark' => '备注', 'order_create_date' => '下单日期', 'order_create_time' => '下单时间', 'order_release_date' => '批准日期', 'order_release_time' => '批准时间'); } array_push($data_csv, $title); $i = 0; foreach ($data as $d) { $i++; if ($showPrice) { $info = array('cnt' => $i, 'active' => $d['active'] == 1 ? '是' : '否', 'order_number' => $d['order_number'], 'order_state' => $d['order_state'], 'order_date' => $d['order_date'], 'order_buyer_name' => $d['order_buyer_name'], 'order_type_name' => $d['order_type_name'], 'order_supplier_code' => $d['order_supplier_code'], 'order_supplier_name' => $d['order_supplier_name'], 'code' => $d['code'], 'price' => $d['price'], 'order_price_tax' => $d['order_price_tax'] == 1 ? '是' : '否', 'qty' => $d['qty'], 'qty_req' => $d['qty_req'], 'qty_receive' => $d['qty_receive'], 'receive_info' => $d['receive_info'], 'in_stock_qty' => $d['in_stock_qty'], 'in_stock_info' => $d['in_stock_info'], 'qty_left' => $d['qty_left'], 'request_date' => $d['request_date'], 'delivery_date' => $d['delivery_date'], 'delivery_date_remark' => $d['delivery_date_remark'], 'order_req_num' => $d['order_req_num'], 'customer_address' => $d['customer_address'], 'customer_aggrement' => $d['customer_aggrement'], 'name' => $d['name'], 'description' => $d['description'], 'req_info' => $d['req_info'], 'remark' => $d['remark'], 'order_create_date' => $d['order_create_time'] != '' ? date('Y-m-d', strtotime($d['order_create_time'])) : '', 'order_create_time' => $d['order_create_time'] != '' ? date('H:i:s', strtotime($d['order_create_time'])) : '', 'order_release_date' => $d['order_release_time'] != '' ? date('Y-m-d', strtotime($d['order_release_time'])) : '', 'order_release_time' => $d['order_release_time'] != '' ? date('H:i:s', strtotime($d['order_release_time'])) : ''); } else { $info = array('cnt' => $i, 'active' => $d['active'] == 1 ? '是' : '否', 'order_number' => $d['order_number'], 'order_state' => $d['order_state'], 'order_date' => $d['order_date'], 'order_buyer_name' => $d['order_buyer_name'], 'order_type_name' => $d['order_type_name'], 'order_supplier_code' => $d['order_supplier_code'], 'order_supplier_name' => $d['order_supplier_name'], 'code' => $d['code'], 'qty' => $d['qty'], 'qty_req' => $d['qty_req'], 'qty_receive' => $d['qty_receive'], 'receive_info' => $d['receive_info'], 'in_stock_qty' => $d['in_stock_qty'], 'in_stock_qty' => $d['in_stock_info'], 'qty_left' => $d['qty_left'], 'request_date' => $d['request_date'], 'delivery_date' => $d['delivery_date'], 'delivery_date_remark' => $d['delivery_date_remark'], 'order_req_num' => $d['order_req_num'], 'customer_address' => $d['customer_address'], 'customer_aggrement' => $d['customer_aggrement'], 'name' => $d['name'], 'description' => $d['description'], 'req_info' => $d['req_info'], 'remark' => $d['remark'], 'order_create_date' => $d['order_create_time'] != '' ? date('Y-m-d', strtotime($d['order_create_time'])) : '', 'order_create_time' => $d['order_create_time'] != '' ? date('H:i:s', strtotime($d['order_create_time'])) : '', 'order_release_date' => $d['order_release_time'] != '' ? date('Y-m-d', strtotime($d['order_release_time'])) : '', 'order_release_time' => $d['order_release_time'] != '' ? date('H:i:s', strtotime($d['order_release_time'])) : ''); } array_push($data_csv, $info); } return $data_csv; } return array('total' => $total, 'rows' => $data); }
/** * 保存采购申请表体 */ 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']); $req_id = $json->req_id; $transfer_id = $json->transfer_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_Reqitems(); $transfer_items = new Erp_Model_Purchse_Transferreqitems(); // 更新 if (count($items_updated) > 0) { foreach ($items_updated as $val) { $active = $val->items_active ? 1 : 0; $line_total = round($val->items_qty * $val->items_price, 2); $data = array('active' => $active, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'line_total' => $line_total, 'date_req' => $val->items_date_req, 'supplier' => $val->items_supplier, 'dept_id' => $val->items_dept_id, 'model' => $val->items_model, 'project_info' => $val->items_project_info, 'order_req_num' => $val->items_order_req_num, 'customer_address' => $val->items_customer_address, 'customer_aggrement' => $val->items_customer_aggrement, 'remark' => $val->items_remark); try { if ($type == 'transfer') { $data['req_id'] = $req_id; $data['transfer_id'] = $transfer_id; $data['req_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); } } 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; $line_total = round($val->items_qty * $val->items_price, 2); $data = array('req_id' => $req_id, 'active' => $active, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'line_total' => $line_total, 'date_req' => $val->items_date_req, 'supplier' => $val->items_supplier, 'dept_id' => $val->items_dept_id, 'model' => $val->items_model, 'project_info' => $val->items_project_info, 'order_req_num' => $val->items_order_req_num, 'customer_address' => $val->items_customer_address, 'customer_aggrement' => $val->items_customer_aggrement, 'remark' => $val->items_remark); try { if ($type == 'transfer') { $data['transfer_id'] = $transfer_id; $data['req_item_id'] = $val->items_id; $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; $items->insert($data); } } 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, 2); $data = array('req_id' => $req_id, 'transfer_type' => 'delete', 'transfer_id' => $transfer_id, 'req_item_id' => $val->items_id, 'active' => $active, 'code' => $val->items_code, 'name' => $val->items_name, 'description' => $val->items_description, 'qty' => $val->items_qty, 'unit' => $val->items_unit, 'price' => $val->items_price, 'line_total' => $line_total, 'date_req' => $val->items_date_req, 'supplier' => $val->items_supplier, 'dept_id' => $val->items_dept_id, 'model' => $val->items_model, 'project_info' => $val->items_project_info, 'order_req_num' => $val->items_order_req_num, 'customer_address' => $val->items_customer_address, 'customer_aggrement' => $val->items_customer_aggrement, 'remark' => $val->items_remark); $transfer_items->insert($data); } else { $items->delete("id = " . $val->items_id); } } catch (Exception $e) { $result['success'] = false; $result['info'] = $e->getMessage(); echo Zend_Json::encode($result); exit; } } } // 更新采购申请总计 if ($type != 'transfer') { $items->refreshReqTotal($req_id); } $req = new Erp_Model_Purchse_Req(); $req_data = $req->getData(null, $req_id); // 保存成功,进入审批流程 if ($result['success'] && $req_data['hand'] == 0) { // 根据流程ID获取阶段信息 $flow = new Admin_Model_Flow(); $flowData = $flow->fetchRow("id = " . $req_data['req_flow_id'])->toArray(); // 获取审核阶段 $step = new Admin_Model_Step(); $stepIds = $flowData['step_ids']; $stepArr = explode(',', $stepIds); $review = new Dcc_Model_Review(); $review->delete("type = 'purchse_req_add' and file_id = " . $req_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_req_add', 'file_id' => $req_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) { $mailContent = '<div>采购申请 - ' . $typeArr[$type] . ',请登录系统查看:</div> <div> <p><b>申请单号:</b>' . $req_data['number'] . '</p> <p><b>申请部门:</b>' . $req_data['dept'] . '</p> <p><b>申请人:</b>' . $req_data['apply_user_name'] . '</p> <p><b>制单人:</b>' . $user_session->user_info['user_name'] . '</p> <p><b>类别:</b>' . $req_data['type'] . '</p> <p><b>事由:</b>' . $req_data['reason'] . '</p> <p><b>金额:</b><a style="color: #467500;font-weight: bold;">¥' . round($req_data['total'], 2) . '</a></p> <p><b>备注:</b>' . $req_data['remark'] . '</p> <p><b>制单时间:</b>' . $req_data['create_time'] . '</p> <p><b>更新时间:</b>' . $req_data['update_time'] . '</p> </div><hr>'; $transferContent = ''; if ($type == 'transfer') { $transferContent .= '<hr><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> <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_date_req)) . '</td> <td>' . $val->items_project_info . '</td> <td>' . $val->items_order_req_num . '</td> <td>' . $val->items_customer_address . '</td> <td>' . $val->items_customer_aggrement . '</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_order . '</td> <td>' . $val->items_date_req . '</td> <td>' . $val->items_project_info . '</td> <td>' . $val->items_order_req_num . '</td> <td>' . $val->items_customer_address . '</td> <td>' . $val->items_customer_aggrement . '</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_date_req . '</td> <td>' . $val->items_project_info . '</td> <td>' . $val->items_order_req_num . '</td> <td>' . $val->items_customer_address . '</td> <td>' . $val->items_customer_aggrement . '</td> <td>' . $val->items_remark . '</td> </tr>'; $i++; } $transferContent .= '</table></div>'; } if ($transferContent != '') { $transfer = new Erp_Model_Purchse_Transfer(); $transfer->update(array('transfer_content' => $transferContent), "id = " . $transfer_id); } $mailData = array('type' => '消息', 'subject' => '采购申请-' . $typeArr[$type], 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent . $transferContent, 'add_date' => $now); $result = $help->sendMailToStep($mailTo, $mailData); } } echo Zend_Json::encode($result); exit; }