コード例 #1
0
 public function view_modify()
 {
     $this->smarty->assign('title', '修改运输方式名预警');
     $id = isset($_GET['id']) ? intval(trim($_GET['id'])) : 0;
     if (empty($id) || !is_numeric($id)) {
         redirect_to("index.php?mod=trackWarnCarrier&act=index");
         exit;
     }
     $trackWarnCarrier = new TrackWarnCarrierAct();
     $res = $trackWarnCarrier->actModify($id);
     $erpCarrierList = TransOpenApiAct::act_getErpCarrierList();
     $this->smarty->assign('shipErp', $erpCarrierList);
     //ERP运输方式列表
     $carrierList = TransOpenApiModel::getCarrier(2);
     $this->smarty->assign('lists', $carrierList);
     //运输方式列表
     $trackCarrierList = TransOpenApiModel::getTrackCarrierList();
     $this->smarty->assign('shipTrack', $trackCarrierList);
     //跟踪号系统运输方式列表
     $this->smarty->assign('carrier_name', $res['trackName']);
     $this->smarty->assign('ship_erp', $res['erpName']);
     $this->smarty->assign('ship_id', $res['carrierId']);
     $this->smarty->assign('id', $res['id']);
     $this->smarty->display('trackWarnCarrierModify.htm');
 }
コード例 #2
0
ファイル: trackWarnNode.view.php プロジェクト: ohjack/newErp
 public function view_add()
 {
     $erpCarrierList = TransOpenApiAct::act_getErpCarrierList();
     $this->smarty->assign('shipErp', $erpCarrierList);
     //ERP运输方式列表
     $carrierList = TransOpenApiModel::getCarrier(2);
     $this->smarty->assign('lists', $carrierList);
     //运输方式列表
     $this->smarty->assign('title', '添加运输方式节点预警');
     $this->smarty->display('trackWarnNodeAdd.htm');
 }
コード例 #3
0
ファイル: shipfeeQuery.action.php プロジェクト: ohjack/newErp
 /**
  * ShipfeeQueryAct::actBatchShipfeeQueryImport()
  * 批量运费验证信息导入导出
  * @return array 
  */
 public function actBatchShipfeeQueryImport()
 {
     $data = array();
     $uid = intval($_SESSION[C('USER_AUTH_SYS_ID')]);
     if (isset($_FILES['upfile']) && !empty($_FILES['upfile'])) {
         $fielName = $uid . "_batch_shipfee_" . date('YmdHis') . '_' . rand(1, 3009) . ".xls";
         $fileName = WEB_PATH . 'html/temp/' . $fielName;
         if (move_uploaded_file($_FILES['upfile']['tmp_name'], $fileName)) {
             $filePath = $fileName;
         }
     }
     if (substr($filePath, -3) != 'xls') {
         show_message($this->smarty, "导入的文件名格式错误!", "index.php?mod=shipfeeQuery&act=shipfeeQueryImport");
         @unlink($filePath);
         exit;
     }
     //读取导入文件
     require_once WEB_PATH . "lib/PHPExcel.php";
     //如果读取的表较大,需要调整内存和时间限制
     ini_set('memory_limit', '20M');
     // ini_set('max_execution_time', '2');
     $PHPExcel = new PHPExcel();
     $PHPReader = new PHPExcel_Reader_Excel2007();
     if (!$PHPReader->canRead($filePath)) {
         $PHPReader = new PHPExcel_Reader_Excel5();
         if (!$PHPReader->canRead($filePath)) {
             show_message($this->smarty, "文件内容无法读取!", "index.php?mod=shipfeeQuery&act=shipfeeQueryImport");
             @unlink($filePath);
             exit;
         }
     }
     $PHPExcel = $PHPReader->load($filePath);
     $currentSheet = $PHPExcel->getSheet(0);
     //取得共有多少列,若不使用此静态方法,获得的$col是文件列的最大的英文大写字母
     $cols = PHPExcel_Cell::columnIndexFromString($currentSheet->getHighestColumn());
     $rows = $currentSheet->getHighestRow();
     if ($rows > C('EXCELL_ROWS_MAX')) {
         show_message($this->smarty, "单个EXCELL文件行数超过系统处理最大值: <b>" . C('EXCELL_ROWS_MAX') . "</b> 行!", "index.php?mod=shipfeeQuery&act=shipfeeQueryImport");
         @unlink($filePath);
         exit;
     }
     $row = 1;
     $res = array();
     while (1) {
         $flag = true;
         $rowFlag = true;
         $country = '';
         $weight = 0;
         $tracknum = '';
         $carrier = '';
         $carrierId = 0;
         $fee = 0;
         $totalFee = 0;
         $carrierNew = '';
         $aa = 'A' . $row;
         $bb = 'B' . $row;
         $cc = 'C' . $row;
         $dd = 'D' . $row;
         $ee = 'E' . $row;
         $ff = 'F' . $row;
         $gg = 'G' . $row;
         $country = post_check(trim($currentSheet->getCell($aa)->getValue()));
         $tracknum = post_check(trim($currentSheet->getCell($bb)->getValue()));
         $weight = post_check(trim($currentSheet->getCell($cc)->getValue()));
         $carrier = post_check(trim($currentSheet->getCell($dd)->getValue()));
         $carrierNew = post_check(trim($currentSheet->getCell($ee)->getValue()));
         $totalFee = post_check(trim($currentSheet->getCell($ff)->getValue()));
         $fee = post_check(trim($currentSheet->getCell($gg)->getValue()));
         if (empty($country)) {
             break;
         }
         if ($row == 1) {
             if ($country != '国家' || $tracknum != '挂号条码' || $weight != '重量' || $carrier != '运输方式' || $carrierNew != '最优运输方式' || $totalFee != '总运费' || $fee != '折扣运费') {
                 show_message($this->smarty, '<font color="red">文件导入失败,导入模版内容有误,请勿修改表头</font>', "index.php?mod=shipfeeQuery&act=shipfeeQueryImport");
                 @unlink($filePath);
                 exit;
             }
             $res[] = array("国家", "挂号条码", "重量", "运输方式", "最优运输方式", "总运费", "折扣运费");
         } else {
             if (!empty($tracknum)) {
                 $carrierId = self::getErpCarrierId($carrier);
             }
             if (empty($carrierId)) {
                 $fees = TransOpenApiAct::act_getBestCarrierNew(1, $country, $weight);
             } else {
                 $fees = TransOpenApiAct::act_fixCarrierQueryNew($carrierId, $country, $weight);
             }
             if (empty($fees)) {
                 self::$errMsg .= "运费校验失败:{$carrier}==={$country}==={$weight}!<br/>";
                 $res[] = array($country, $tracknum, $weight, $carrier, '', '', '');
             } else {
                 $fee = $fees['fee'];
                 $totalFee = $fees['totalFee'];
                 $carrierNew = self::getErpCarrierId($fees['carrierId'], true);
                 $res[] = array($country, $tracknum, $weight, $carrier, $carrierNew, $totalFee, $fee);
             }
         }
         $row++;
     }
     $fileName = 'batch_shipfee_infos_' . $uid;
     $fileUrl = WEB_URL . "temp/" . date('Ymd') . "/" . $fileName . ".xls";
     $filePath = WEB_PATH . "html/temp/" . date('Ymd') . "/" . $fileName . ".xls";
     require_once WEB_PATH . "lib/php-export-data.class.php";
     $excel = new ExportDataExcel('file');
     $excel->filename = $filePath;
     $excel->initialize();
     foreach ($res as $row) {
         $excel->addRow($row);
     }
     $excel->finalize();
     unset($res);
     $data['url'] = $fileUrl;
     $data['res'] = self::$errMsg;
     return $data;
 }
コード例 #4
0
ファイル: transOpenApi.action.php プロジェクト: ohjack/newErp
 /**
  * TransOpenApiAct::act_getCountriesStandard()
  * 获取全部或部分标准国家并存入mencache
  * @param string $type ALL全部,CN中文,EN英文
  * @param string $country 国家,默认空
  * @param int $is_new 是否强制更新(默认0不强制)
  * @return  array 
  */
 public function act_getCountriesStandard()
 {
     $type = isset($_REQUEST['type']) ? post_check($_REQUEST['type']) : "ALL";
     $country = isset($_REQUEST['country']) ? post_check($_REQUEST['country']) : "";
     $is_new = isset($_REQUEST['is_new']) ? $_REQUEST['is_new'] : 0;
     if (!in_array($is_new, array(0, 1))) {
         self::$errCode = 10001;
         self::$errMsg = '强制更新参数有误!';
         return false;
     }
     if (!in_array($type, array("ALL", "EN", "CN"))) {
         self::$errCode = 309;
         self::$errMsg = '参数TYPE类型错误!';
         return false;
     }
     if ($type == "ALL") {
         $country = "";
     }
     //防止重复CACHE
     $cacheName = md5("trans_countries_standard_{$type}{$country}");
     $memc_obj = new Cache(C('CACHEGROUP'));
     $countriesInfo = $memc_obj->get_extral($cacheName);
     if (!empty($countriesInfo) && empty($is_new)) {
         return unserialize($countriesInfo);
     } else {
         if ($type == "ALL") {
             $countriesInfo = TransOpenApiModel::getCountriesStandard();
         } else {
             $countriesInfo = TransOpenApiModel::getCountriesStandard($type, $country);
         }
         $isok = $memc_obj->set_extral($cacheName, serialize($countriesInfo));
         if (!$isok) {
             self::$errCode = 308;
             self::$errMsg = 'memcache缓存出错!';
             //return false;
         }
         return $countriesInfo;
     }
 }