예제 #1
0
 public function editorderstatusAction()
 {
     $result = array('success' => true, 'info' => '');
     $request = $this->getRequest()->getParams();
     $id = isset($request['id']) ? $request['id'] : null;
     $order_status = isset($request['order_status']) ? $request['order_status'] : null;
     if ($id && $order_status) {
         $order = new Erp_Model_Sale_Order();
         $order->update(array('order_status' => $order_status), "id = " . $id);
     } else {
         $result['success'] = false;
         $result['info'] = '参数错误';
     }
     echo Zend_Json::encode($result);
     exit;
 }
예제 #2
0
 public function refreshOrderTotal($order_id)
 {
     $data = array('total' => 0, 'forein_total' => 0);
     if ($order_id) {
         $dataTmp = $this->fetchAll("order_id = " . $order_id);
         if ($dataTmp->count() > 0) {
             $items = $dataTmp->toArray();
             foreach ($items as $item) {
                 $data['total'] += $item['total'];
             }
         }
     }
     $order = new Erp_Model_Sale_Order();
     $orderData = $order->getData(null, $order_id);
     // 如果不是本币(汇率不为1),则需要将外币换算为本币
     if ($orderData['currency_rate'] != 1) {
         $data['forein_total'] = $data['total'];
         $data['total'] = $data['forein_total'] * $orderData['currency_rate'];
     }
     $order->update($data, "id = " . $order_id);
 }
예제 #3
0
 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_Sale_Order();
         $setting = new Erp_Model_Setting_Currencyrate();
         $price_tax = isset($request['price_tax']) ? $request['price_tax'] : null;
         $price_tax = $price_tax == 'on' ? 1 : 0;
         $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'], 'sales_id' => $request['sales_id'], 'customer_address_code' => $request['customer_address_code'] != '' ? $request['customer_address_code'] : null, 'request_date' => $request['request_date'], 'customer_id' => $request['customer_id'], 'price_tax' => $price_tax, 'tax_id' => $request['tax_id'], 'tax_name' => $request['tax_name'], 'tax_rate' => $request['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'], '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] . ']';
             //echo '<pre>';print_r($data);exit;
             try {
                 $order_id = $result['order_id'] = $order->insert($data);
                 //echo $order_id;exit;
             } 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_Sale_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'] = 'sale_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;
 }