Files
OMS/app/wms/lib/print/tmpl/express.php
2026-01-04 19:08:31 +08:00

115 lines
4.0 KiB
PHP

<?php
/**
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class wms_print_tmpl_express{
public $smarty = null;
static $singleton = null;
static $logi_list = array('amazon','dangdang');//需要根据物流公司自定义快递单输入信息列表
static function instance($logi,$controller){
$logi = strtolower($logi);
if(self::$singleton[$logi] === null){
if(in_array($logi,self::$logi_list)){
self::$singleton[$logi] = kernel::single('wms_print_tmpl_logi_'.$logi,$controller);
}else{
self::$singleton[$logi] = kernel::single('wms_print_tmpl_express',$controller);
}
}
return self::$singleton[$logi];
}
/**
* __construct
* @param mixed $controller controller
* @return mixed 返回值
*/
public function __construct($controller){
$this->smarty = $controller;
}
public function setParams( $params = array() ){
return $this;
}
/**
* 获取Tmpl
* @return mixed 返回结果
*/
public function getTmpl(){
$this->smarty->pagedata['userAgent'] = $this->getUserAgent();
//新版快递单打印
if (app::get('logisticsmanager')->is_installed()) {
if($this->smarty->pagedata['printTmpl']['template_type']=='normal') {
$this->smarty->singlepage("admin/delivery/express_print_normal.html");
}elseif($this->smarty->pagedata['printTmpl']['template_type']=='cainiao'){
$this->smarty->singlepage("admin/delivery/express_print_cainiao.html");
} else {
$this->smarty->singlepage("admin/delivery/express_print_electron.html");
}
} else {
$this->smarty->singlepage("admin/delivery/express_print.html");
}
}
/**
* 获得浏览器版本
* Enter description here ...
*/
public function getUserAgent() {
$agent = $_SERVER["HTTP_USER_AGENT"];
$brower = array('brower' => 'Other', 'ver' => '0', 'type' => 2);
if (strpos($agent, "MSIE 10.0")) {
$brower = array('brower' => 'Ie', 'ver' => '10.0', 'type' => 1);
}
elseif (strpos($agent, "MSIE 9.0")) {
$brower = array('brower' => 'Ie', 'ver' => '9.0', 'type' => 1);
}
elseif (strpos($agent, "MSIE 8.0")) {
$brower = array('brower' => 'Ie', 'ver' => '8.0', 'type' => 1);
}
elseif (strpos($agent, "MSIE 7.0")) {
$brower = array('brower' => 'Ie', 'ver' => '7.0', 'type' => 1);
}
elseif (strpos($agent, "MSIE 6.0")) {
$brower = array('brower' => 'Ie', 'ver' => '6.0', 'type' => 1);
}
elseif (strpos($agent, "Trident")) {
//IE11以后的版本
$str = substr($agent, strpos($agent, 'rv:') + strlen('rv:'));
$ver = substr($str, 0, strpos($str, ')'));
$brower = array('brower' => 'Ie', 'ver' => $ver, 'type' => 1);
}
elseif (strpos($agent, "Chrome")) {
$str = substr($agent, strpos($agent, 'Chrome/') + strlen('Chrome/'));
$verInfo = explode(" ", $str);
$brower = array('brower' => 'Chrome', 'ver' => $verInfo[0], 'type' => 2);
}
elseif (strpos($agent, "Firefox")) {
$str = substr($agent, strpos($agent, 'Firefox/') + strlen('Firefox/'));
$brower = array('brower' => 'Firefox', 'ver' => $str, 'type' => 2);
}
return $brower;
}
}