コード例 #1
0
ファイル: SendController.php プロジェクト: xindalu/evolve
 public function getprintAction()
 {
     $result = array('success' => true, 'info' => '');
     $request = $this->getRequest()->getParams();
     if (isset($request['id'])) {
         $type = $request['type'];
         $type_name = $type == 'send' ? '销售交货' : '销售退货';
         $receive = new Erp_Model_Stock_Receive();
         $data = $receive->getData(null, $request['id'], $type_name);
         $data['customer'] = '';
         if ($data['customer_id']) {
             $partnerModel = new Erp_Model_Partner();
             $customerInfo = $partnerModel->getInfoById($data['customer_id']);
             if ($customerInfo['ename'] != '') {
                 $data['customer'] = $customerInfo['code'] . ' ' . $customerInfo['ename'];
             } else {
                 $data['customer'] = $customerInfo['code'] . ' ' . $customerInfo['cname'];
             }
         }
         $items = new Erp_Model_Purchse_Receiveitems();
         $itemsData = $items->getData($request['id']);
         $tpl = new Erp_Model_Tpl();
         $tplHtmlData = $tpl->fetchRow("type = 'sale_send'")->toArray();
         $tplHtml = $tplHtmlData['html'];
         $itemsHtml = '';
         $i = 0;
         foreach ($itemsData as $item) {
             $i++;
             $itemsHtml .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td>' . $item['items_code'] . '</td>
                     <td width="100px" style="word-wrap:break-word;">' . $item['items_name'] . '</td>
                     <td width="150px" style="word-wrap:break-word;">' . $item['items_description'] . '</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $item['items_customer_code'] . '</td>
                     <td width="150px" style="word-wrap:break-word;">' . $item['items_customer_description'] . '</td>
                     <td>' . $item['items_warehouse_code'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
         }
         $orderInfo = array('title' => $type_name, 'number' => $data['number'], 'customer' => $data['customer'], 'type' => $data['transaction_type'], 'creater' => $data['creater'], 'date' => $data['date'], 'description' => $data['description'], 'remark' => $data['remark'], 'items' => $itemsHtml, 'company_logo' => HOME_PATH . '/public/images/company.png');
         foreach ($orderInfo as $key => $val) {
             $tplHtml = str_replace('<tpl_' . $key . '>', $val, $tplHtml);
         }
         $result['info'] = $tplHtml;
     } else {
         $result['success'] = false;
     }
     echo Zend_Json::encode($result);
     exit;
 }
コード例 #2
0
ファイル: OrderController.php プロジェクト: xindalu/evolve
 /**
  * 编辑采购申请(新建、更新、删除)
  */
 public function editorderAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '编辑成功', 'order_id' => 0, 'transfer_id' => 0);
     $request = $this->getRequest()->getParams();
     $typeArr = array('new' => '新建', 'edit' => '修改', 'transfer' => '变更');
     /* $result['success'] = false;
         echo '<pre>';
        print_r($request);
        exit; */
     // 操作类别(新建、更新、删除)
     $type = isset($request['operate']) ? $request['operate'] : '';
     if ($type == 'new' || $type == 'edit' || $type == 'transfer') {
         $now = date('Y-m-d H:i:s');
         $user_session = new Zend_Session_Namespace('user');
         $user_id = $user_session->user_info['user_id'];
         $order = new Erp_Model_Purchse_Order();
         $partner = new Erp_Model_Partner();
         $setting = new Erp_Model_Setting_Currencyrate();
         $price_tax = isset($request['price_tax']) ? $request['price_tax'] : null;
         $price_tax = $price_tax == 'on' ? 1 : 0;
         $tax = $partner->getTaxInfo($request['supplier_id']);
         $currency_rate = $setting->getCurrentRateByCode($request['currency']);
         $hand = 0;
         if (isset($request['hand']) && $request['hand'] == 'on') {
             $hand = 1;
         }
         $data = array('company' => $request['company'], 'currency' => $request['currency'], 'currency_rate' => $currency_rate, 'order_date' => $request['order_date'], 'buyer_id' => $request['buyer_id'], 'receiver_id' => $request['receiver_id'] != '' ? $request['receiver_id'] : null, 'customer_address_code' => $request['customer_address_code'] != '' ? $request['customer_address_code'] : null, 'request_date' => $request['request_date'], 'supplier_contact_id' => $request['supplier_contact_id'], 'supplier_id' => $request['supplier_id'], 'price_tax' => $price_tax, 'tax_id' => $tax['id'], 'tax_name' => $tax['name'], 'tax_rate' => $tax['rate'], 'tpl_id' => $request['tpl_id'], 'type_id' => $request['type_id'], 'settle_way' => $request['settle_way'], 'delvery_clause' => $request['delvery_clause'], 'remark' => $request['remark'], 'description' => $request['description'], 'manufacture' => $request['manufacture'], 'responsible' => $request['responsible'], 'update_time' => $now, 'update_user' => $user_id);
         if ($type == 'new') {
             if ($hand) {
                 $data['state'] = 2;
                 $data['hand'] = 1;
                 $data['number'] = $request['hand_number'];
                 $data['review_info'] = date('Y-m-d H:i:s') . ' 补单<br>';
                 if ($order->fetchAll("number = '" . $data['number'] . "'")->count() > 0) {
                     $result['success'] = false;
                     $result['info'] = "添加错误,订单号重复!";
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $data['hand'] = 0;
                 $data['number'] = $order->getNewNum($request['type_id'], $request['company']);
                 // 生成申订单号
             }
             $data['create_time'] = $now;
             $data['create_user'] = $user_id;
             $data['review_info'] = $now . ': ' . $user_session->user_info['user_name'] . ' [' . $typeArr[$type] . ']';
             try {
                 $order_id = $result['order_id'] = $order->insert($data);
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
             }
         } elseif ($type == 'edit' || $type == 'transfer') {
             try {
                 $review_info = $now . ': ' . $user_session->user_info['user_name'] . ' [' . $typeArr[$type] . ']';
                 $orderData = $order->getData(null, $request['id']);
                 if ($request['type_id'] != $orderData['type_id']) {
                     // 当类别发送改变时,生成订单号
                     $data['number'] = $order->getNewNum($request['type_id']);
                 }
                 $data['review_info'] = $orderData['review_info'] . '<br>' . $review_info;
                 $data['state'] = 0;
                 if ($type == 'transfer') {
                     $transfer = new Erp_Model_Purchse_Transfer();
                     $transferData = array('transfer_type' => $request['transfer_type'], 'transfer_description' => $request['transfer_description'], 'create_user' => $user_id, 'create_time' => $now);
                     $data['submit_type'] = 'transfer';
                     // 修改变更时,先清空被拒绝的修改内容列表
                     if ($request['transfer_id'] != '') {
                         $transfer_items = new Erp_Model_Purchse_Transferorderitems();
                         $transfer_items->delete("transfer_id = " . $request['transfer_id']);
                         $transferData['state'] = 0;
                         $transfer->update($transferData, "id = " . $request['transfer_id']);
                         $data['transfer_id'] = $result['transfer_id'] = $request['transfer_id'];
                     } else {
                         $transferData['type'] = 'order';
                         $transferData['target_id'] = $request['id'];
                         $data['transfer_id'] = $result['transfer_id'] = $transfer->insert($transferData);
                     }
                 }
                 $order->update($data, "id = " . $request['id']);
                 $result['order_id'] = $request['id'];
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
             }
         }
     } elseif ($type == 'delete') {
         try {
             $order->delete("id = " . $request['req_id']);
         } catch (Exception $e) {
             $result['success'] = false;
             $result['info'] = $e->getMessage();
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
コード例 #3
0
ファイル: BpartnerController.php プロジェクト: xindalu/evolve
 /**
  * 编辑付款方式信息
  */
 public function editpaymentAction()
 {
     // 返回值数组
     $result = array('success' => true, 'info' => '编辑成功');
     $request = $this->getRequest()->getParams();
     $now = date('Y-m-d H:i:s');
     $user_session = new Zend_Session_Namespace('user');
     $user_id = $user_session->user_info['user_id'];
     $json = json_decode($request['json']);
     $updated = $json->updated;
     $inserted = $json->inserted;
     $deleted = $json->deleted;
     $payment = new Erp_Model_Payment();
     if (count($updated) > 0) {
         foreach ($updated as $val) {
             $data = array('active' => $val->active, 'qty' => $val->qty, 'name' => $val->name, 'description' => $val->description, 'remark' => $val->remark, 'update_time' => $now, 'update_user' => $user_id);
             $where = "id = " . $val->id;
             try {
                 $payment->update($data, $where);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     if (count($inserted) > 0) {
         foreach ($inserted as $val) {
             $data = array('active' => $val->active, 'qty' => $val->qty, 'name' => $val->name, 'description' => $val->description, 'remark' => $val->remark, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
             try {
                 $payment->insert($data);
             } catch (Exception $e) {
                 $result['result'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     if (count($deleted) > 0) {
         $partner = new Erp_Model_Partner();
         foreach ($deleted as $val) {
             if ($partner->fetchAll("payment_id = " . $val->id)->count() == 0) {
                 try {
                     $payment->delete("id = " . $val->id);
                 } catch (Exception $e) {
                     $result['result'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             } else {
                 $result['result'] = false;
                 $result['info'] = '付款方式ID' . $val->id . '存在关联业务伙伴信息,不能删除';
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }
コード例 #4
0
ファイル: SendController.php プロジェクト: xindalu/evolve
 /**
  * 获取业务伙伴信息列表
  */
 public function getpartnerAction()
 {
     // 请求参数
     $search_code = $this->getRequest()->getParam('search_code');
     $type = $this->getRequest()->getParam('type');
     if ($type != 1) {
         $type = 0;
     }
     $partner = new Erp_Model_Partner();
     $where = "type = {$type} and (code like '{$search_code}%' or cname like '%{$search_code}%' or ename like '%{$search_code}%')";
     $data = $partner->getJoinList($where, array(), array('id', 'code', 'cname', 'ename'));
     $result = array();
     for ($i = 0; $i < count($data); $i++) {
         $row['id'] = $data[$i]['id'];
         $row['code'] = $data[$i]['code'];
         if ($data[$i]['cname']) {
             $row['name'] = $data[$i]['code'] . $data[$i]['cname'];
         } else {
             if ($data[$i]['ename']) {
                 $row['name'] = $data[$i]['code'] . $data[$i]['ename'];
             } else {
                 $row['name'] = $data[$i]['code'];
             }
         }
         $result[] = $row;
     }
     echo Zend_Json::encode($result);
     exit;
 }
コード例 #5
0
ファイル: PriceController.php プロジェクト: xindalu/evolve
    public function editAction()
    {
        $result = array('success' => true, 'info' => '');
        $request = $this->getRequest()->getParams();
        $data = isset($request['data']) ? Zend_Json::decode($request['data']) : null;
        //echo '<pre>';print_r($data);exit;
        if ($data) {
            $priceModel = new Erp_Model_Sale_Price();
            $priceItemsModel = new Erp_Model_Sale_Priceitems();
            $priceLadderModel = new Erp_Model_Sale_Priceitemladder();
            $partnerModel = new Erp_Model_Partner();
            $price_id = $data['id'];
            $now = date('Y-m-d H:i:s');
            $user_session = new Zend_Session_Namespace('user');
            $user_id = $user_session->user_info['user_id'];
            $taxData = $partnerModel->getTaxInfo($data['customer_id']);
            //echo '<pre>';print_r(Zend_Json::decode($data['items']['inserted'][1]['items_ladder']));exit;
            $priceData = array('price_date' => $data['price_date'], 'customer_id' => $data['customer_id'], 'currency' => $data['currency'], 'price_tax' => $data['price_tax'], 'tax_id' => $taxData['id'], 'description' => $data['description'], 'remark' => $data['remark'], 'update_user' => $user_id, 'update_time' => $now);
            if ($data['operate'] == 'new') {
                $priceData['number'] = $priceModel->getNewNum();
                $priceData['create_user'] = $user_id;
                $priceData['create_time'] = $now;
                try {
                    $price_id = $priceModel->insert($priceData);
                } catch (Exception $e) {
                    $result['success'] = false;
                    $result['info'] = $e->getMessage();
                    echo Zend_Json::encode($result);
                    exit;
                }
            } else {
                $priceData['state'] = 0;
                $priceData['update_user'] = $user_id;
                $priceData['update_time'] = $now;
                try {
                    $priceModel->update($priceData, "id = " . $price_id);
                } catch (Exception $e) {
                    $result['success'] = false;
                    $result['info'] = $e->getMessage();
                    echo Zend_Json::encode($result);
                    exit;
                }
            }
            if ($result['success']) {
                // 插入
                foreach ($data['items']['inserted'] as $item) {
                    $insertData = array('customer_id' => $data['customer_id'], 'type' => $item['items_type'], 'currency' => $data['currency'], 'price_id' => $price_id, 'active_date' => $item['items_active_date'], 'code' => $item['items_code'], 'price_start' => $item['items_price_start'], 'price_final' => $item['items_price_final'], 'remark' => $item['items_remark'], 'customer_code' => $item['items_customer_code'], 'customer_description' => $item['items_customer_description'], 'name' => $item['items_name'], 'description' => $item['items_description'], 'product_type' => $item['items_product_type'], 'product_series' => $item['items_product_series'], 'remark' => $item['items_remark']);
                    try {
                        $item_id = $priceItemsModel->insert($insertData);
                    } catch (Exception $e) {
                        $result['success'] = false;
                        $result['info'] = $e->getMessage();
                        echo Zend_Json::encode($result);
                        exit;
                    }
                    if ($result['success'] && $item['items_ladder'] != '') {
                        $ladderData = Zend_Json::decode($item['items_ladder']);
                        foreach ($ladderData as $ld) {
                            $ld['item_id'] = $item_id;
                            $priceLadderModel->insert($ld);
                        }
                    }
                }
                // 表体处理
                if ($data['operate'] == 'edit') {
                    foreach ($data['items']['updated'] as $item) {
                        $updateData = array('type' => $item['items_type'], 'currency' => $data['currency'], 'active_date' => $item['items_active_date'], 'code' => $item['items_code'], 'name' => $item['items_name'], 'description' => $item['items_description'], 'customer_code' => $item['items_customer_code'], 'customer_description' => $item['items_customer_description'], 'price_start' => $item['items_price_start'], 'price_final' => $item['items_price_final'], 'product_type' => $item['items_product_type'], 'product_series' => $item['items_product_series'], 'remark' => $item['items_remark']);
                        try {
                            $priceItemsModel->update($updateData, "id = " . $item['items_id']);
                        } catch (Exception $e) {
                            $result['success'] = false;
                            $result['info'] = $e->getMessage();
                            echo Zend_Json::encode($result);
                            exit;
                        }
                        $item_id = $item['items_id'];
                        if ($result['success'] && $item['items_ladder'] != '') {
                            $priceLadderModel->delete("item_id = " . $item_id);
                            $ladderData = Zend_Json::decode($item['items_ladder']);
                            foreach ($ladderData as $ld) {
                                $ld['item_id'] = $item_id;
                                $priceLadderModel->insert($ld);
                            }
                        }
                    }
                    foreach ($data['items']['deleted'] as $item) {
                        try {
                            $priceItemsModel->delete("id = " . $item['items_id']);
                        } catch (Exception $e) {
                            $result['success'] = false;
                            $result['info'] = $e->getMessage();
                            echo Zend_Json::encode($result);
                            exit;
                        }
                        if ($result['success'] && $item['ladder'] != '') {
                            $priceLadderModel->delete("item_id = " . $item_id);
                        }
                    }
                }
                // 进入审核流程
                $flow = new Admin_Model_Flow();
                $flowData = $flow->fetchRow("flow_name = '销售价格清单审核'")->toArray();
                // 获取审核阶段
                $step = new Admin_Model_Step();
                $stepIds = $flowData['step_ids'];
                $stepArr = explode(',', $stepIds);
                $review = new Dcc_Model_Review();
                $review->delete("type = 'sale_price_add' and file_id = " . $price_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' => 'sale_price_add', 'file_id' => $price_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) {
                    $customerInfo = $partnerModel->getInfoById($data['customer_id']);
                    $customerName = $customerInfo['cname'] ? $customerInfo['cname'] : $customerInfo['ename'];
                    $priceData = $priceModel->getData(null, $price_id);
                    $mailContent = '<div>销售价格申请,请登录系统查看:</div>
                            <div>
                            <p><b>申请单号:</b>' . $priceData['number'] . '</p>
                            <p><b>客户代码:</b>' . $customerInfo['code'] . '</p>
                            <p><b>客户名称:</b>' . $customerName . '</p>
                            <p><b>申请人:</b>' . $user_session->user_info['user_name'] . '</p>
                            <p><b>描述:</b>' . $data['description'] . '</p>
                            <p><b>备注:</b>' . $data['remark'] . '</p>
                            <p><b>提交时间:</b>' . $now . '</p>
                            </div><hr>';
                    $itemsContent = '<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>
                            </tr>';
                    $itemsData = $priceItemsModel->getItems($price_id);
                    $i = 0;
                    foreach ($itemsData as $item) {
                        $i++;
                        $itemType = $item['items_type'] == 'catalog' ? '内部型号' : '物料号';
                        $itemsContent .= '<tr>
                            <td>' . $i . '</td>
                            <td>' . $itemType . '</td>
                            <td>' . $item['items_code'] . '</td>
                            <td>' . $item['items_name'] . '</td>
                            <td>' . $item['items_product_type'] . '</td>
                            <td>' . $item['items_product_series'] . '</td>
                            <td>' . $item['items_description'] . '</td>
                            <td>' . $item['items_customer_code'] . '</td>
                            <td>' . $item['items_customer_description'] . '</td>
                            <td>' . $item['items_price_start'] . '</td>
                            <td>' . $item['items_price_final'] . '</td>
                            <td>' . $item['items_active_date'] . '</td>
                            <td>' . $item['items_remark'] . '</td>
                            </tr>';
                    }
                    $itemsContent .= '</table></div>';
                    $mailData = array('type' => '消息', 'subject' => '销售价格清单申请', 'cc' => $user_session->user_info['user_email'], 'content' => $mailContent . $itemsContent, 'add_date' => $now);
                    $result = $help->sendMailToStep($mailTo, $mailData);
                }
            }
        } else {
            $result['success'] = false;
            $result['info'] = '参数错误';
        }
        echo Zend_Json::encode($result);
        exit;
    }