Exemple #1
0
 public function getprintAction()
 {
     $result = array('success' => true, 'info' => '');
     $request = $this->getRequest()->getParams();
     if (isset($request['id']) && isset($request['tpl_id'])) {
         $order = new Erp_Model_Purchse_Order();
         $buyer = new Erp_Model_Purchse_Buyer();
         $items = new Erp_Model_Purchse_Orderitems();
         $helper = new Application_Model_Helpers();
         $supplier_contact = new Erp_Model_Contact();
         $tax = new Erp_Model_Setting_Tax();
         $currency = new Erp_Model_Setting_Currency();
         $orderData = $order->getData(null, $request['id']);
         $itemsData = $items->getData($request['id']);
         $buyerData = $buyer->getData($orderData['buyer_id']);
         $supplierContactData = $supplier_contact->getData($orderData['supplier_contact_id']);
         $taxData = $tax->getData($orderData['supplier_tax_id']);
         $currencyData = $currency->getInfoByCode($orderData['currency']);
         $tpl = new Erp_Model_Tpl();
         $tplHtmlData = $tpl->fetchRow("id = " . $request['tpl_id'])->toArray();
         $tplHtml = $tplHtmlData['html'];
         $itemsHtml = '';
         $itemsHtml_en = '';
         $itemsHtml_other = '';
         $i = 0;
         foreach ($itemsData as $item) {
             $i++;
             $req_number = str_replace(',', '<br>', $item['items_req_number']);
             $itemsHtml .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td>' . $item['items_code'] . '</td>
                     <td width="100px">' . $item['items_name'] . '</td>
                     <td width="150px">' . $item['items_description'] . '</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $currencyData['symbol'] . $item['items_price'] . '</td>
                     <td>' . $currencyData['symbol'] . $item['items_total'] . '</td>
                     <td>' . $req_number . '</td>
                     <td>' . $item['items_request_date'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
             $itemsHtml_en .= '
                 <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>' . $currencyData['symbol'] . $item['items_price'] . '</td>
                     <td>' . $currencyData['symbol'] . $item['items_total'] . '</td>
                     <td>' . $req_number . '</td>
                     <td>' . $item['items_request_date'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
             $itemsHtml_other .= '
                 <tr>
                     <td>' . $i . '</td>
                     <td>' . $item['items_code'] . '</td>
                     <td width="250px" style="word-wrap:break-word;">' . $item['items_name'] . ' [' . $item['items_description'] . ']</td>
                     <td>' . $item['items_qty'] . '</td>
                     <td>' . $item['items_unit'] . '</td>
                     <td>' . $currencyData['symbol'] . $item['items_price'] . '</td>
                     <td>' . $currencyData['symbol'] . $item['items_total'] . '</td>
                     <td>' . $req_number . '</td>
                     <td>' . $item['items_request_date'] . '</td>
                     <td>' . $item['items_remark'] . '</td>
                 </tr>';
         }
         $receive = array();
         if ($orderData['receiver_id']) {
             // 公司收货人
             $receiver = new Erp_Model_Warehouse_Warehousereceiver();
             $receiverData = $receiver->getData($orderData['receiver_id']);
             $receive['address'] = $receiverData['address'];
             $receive['address_en'] = $receiverData['address_en'];
             $receive['cname'] = $receiverData['cname'];
             $receive['ename'] = $receiverData['ename'];
             $receive['tel'] = $receiverData['tel'];
             $receive['fax'] = $receiverData['fax'];
         } else {
             // 客户收货人
             $receiverData = $supplier_contact->getDataByCode($orderData['customer_address_code']);
             $receive['address'] = $receiverData['address'];
             $receive['address_en'] = $receiverData['address'];
             $receive['cname'] = $receiverData['name'];
             $receive['ename'] = $receiverData['name'];
             $receive['tel'] = $receiverData['tel'];
             $receive['fax'] = $receiverData['fax'];
         }
         $orderInfo = array('order_symbol' => $currencyData['symbol'], 'company_name' => '成都欧飞凌通讯技术有限公司', 'company_tel' => '028-85161178', 'company_fax' => '028-85161176', 'company_address' => '成都市高新区云华路333号1-5栋 3层', 'company_logo' => HOME_PATH . '/public/images/company.png', 'company_tax' => '510198698882411', 'company_account' => '128904731510811', 'company_bank' => '招商银行成都分行高新支行', 'order_title' => '采 购 合 同', 'type' => ' - 物料原材料', 'number' => $orderData['number'], 'date' => date('Y-m-d', strtotime($orderData['create_time'])), 'contact_name' => $buyerData['cname'], 'contact_ename' => $buyerData['ename'], 'contact_tel' => $buyerData['tel'], 'contact_fax' => $buyerData['fax'], 'supplier_cname' => $orderData['supplier_cname'], 'supplier_ename' => $orderData['supplier_ename'], 'supplier_code' => $orderData['supplier_code'], 'supplier_bank_type' => $orderData['supplier_bank_type'], 'supplier_bank_account' => $orderData['supplier_bank_account'], 'supplier_address' => $supplierContactData['address'], 'supplier_contact_name' => $supplierContactData['name'], 'supplier_contact_tel' => $supplierContactData['tel'], 'supplier_contact_fax' => $supplierContactData['fax'], 'receive_address' => $receive['address'], 'receive_address_en' => $receive['address_en'], 'receive_cname' => $receive['cname'], 'receive_ename' => $receive['ename'], 'receive_tel' => $receive['tel'], 'receive_fax' => $receive['fax'], 'total_upper' => $helper->num2rmb($orderData['total']), 'total_lower' => $orderData['currency_rate'] != 1 ? $orderData['forein_total'] : $orderData['total'], 'supplier_tax' => $orderData['supplier_tax_num'], 'supplier_tax_name' => $taxData['name'], 'supplier_tax_rate' => $taxData['rate'], 'supplier_payment_days' => $orderData['supplier_payment'], 'settle_way' => $orderData['settle_way'], 'delvery_clause' => $orderData['delvery_clause'], 'manufacture' => $orderData['manufacture'], 'responsible' => $orderData['responsible'], 'table' => $itemsHtml, 'table_en' => $itemsHtml_en, 'table_other' => $itemsHtml_other, 'order_other_info' => $orderData['remark'], 'responsible' => $orderData['responsible'], 'order_title_en' => 'Purchase Order', 'order_title_other' => '设 备 类 采 购 合 同', 'company_name_en' => 'OPhylink Communication Technology Inc.');
         foreach ($orderInfo as $key => $val) {
             $tplHtml = str_replace('<tpl_' . $key . '>', $val, $tplHtml);
         }
         $result['info'] = $tplHtml;
     } else {
         $result['success'] = false;
     }
     /* echo $tplHtml;
        exit; */
     echo Zend_Json::encode($result);
     exit;
 }
Exemple #2
0
 public function editreceiverAction()
 {
     // 返回值数组
     $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;
     $receiver = new Erp_Model_Warehouse_Warehousereceiver();
     if (count($updated) > 0) {
         foreach ($updated as $val) {
             $data = array('active' => $val->active, 'user_id' => $val->user_id, 'address' => $val->address, 'address_en' => $val->address_en, 'tel' => $val->tel, 'fax' => $val->fax, 'remark' => $val->remark, 'update_time' => $now, 'update_user' => $user_id);
             if ($receiver->fetchAll("id != " . $val->id . " and user_id = " . $val->user_id)->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = "收货人已存在,请勿重复添加!";
             } else {
                 try {
                     $receiver->update($data, "id = " . $val->id);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
     }
     if (count($inserted) > 0) {
         foreach ($inserted as $val) {
             $data = array('active' => $val->active, 'user_id' => $val->user_id, 'address' => $val->address, 'address_en' => $val->address_en, 'tel' => $val->tel, 'fax' => $val->fax, 'remark' => $val->remark, 'create_time' => $now, 'create_user' => $user_id, 'update_time' => $now, 'update_user' => $user_id);
             if ($receiver->fetchAll("user_id = " . $val->user_id)->count() > 0) {
                 $result['success'] = false;
                 $result['info'] = "收货人已存在,请勿重复添加!";
             } else {
                 try {
                     $receiver->insert($data);
                 } catch (Exception $e) {
                     $result['success'] = false;
                     $result['info'] = $e->getMessage();
                     echo Zend_Json::encode($result);
                     exit;
                 }
             }
         }
     }
     if (count($deleted) > 0) {
         foreach ($deleted as $val) {
             try {
                 $receiver->delete("id = " . $val->id);
             } catch (Exception $e) {
                 $result['success'] = false;
                 $result['info'] = $e->getMessage();
                 echo Zend_Json::encode($result);
                 exit;
             }
         }
     }
     echo Zend_Json::encode($result);
     exit;
 }