php 打印小票模板

时间:2021-04-08 12:29:13
if(!empty($set['print_top'])){
$content="%10".$set['print_top']."\n";
}else{
$content='';
}
$content.='%00单号:'.$item['ordersn']."\n";
//$content.='总数:'.$item['totalnum'].' 总价:'.$item['totalprice']."\n";
///$content.='配送方式:'.$express[$item['sendtype']]['express_name']."\n";
if($item['ispay']==1){
$item['paystr']='[已支付]';
}else{
$item['paystr']='[未支付]';
}
if ($item['paytype'] == 1){
$content.='付款:余额支付'.$item['paystr']."\n";
}elseif ($item['paytype'] == 2){
$content.='付款:在线支付'.$item['paystr']."\n";
}elseif ($item['paytype'] == 3){
$content.='付款:货到付款'.$item['paystr']."\n";
}
$content.='下单日期:'.date('Y-m-d H:i:s', $item['createtime'])."\n";
$content.='预约时间:'.$item['time_day'].'日'.$item['time_hour'].'时'.$item['time_second']."分\n";
if(!empty($item['remark'])){
$content.='备注:'.$item['remark']."\n";
}

$content.="%00\n名称 数量 单价 \n";
$content.="----------------------------\n";

$content=iconv("UTF-8","GB2312//IGNORE",$content);
foreach($item['goods'] as $v){
$content1.=$this->_formatstr($v['title'],16).$this->_formatstr($goodsid[$v['id']]['total'],4,false).$this->_formatstr(number_format($v['marketprice'],1),7,false)."\n";
}
$content2="----------------------------\n";
$content2.="%10总数量:".$item['totalnum']." 总价:".number_format($item['totalprice'],1)."元\n%00";
if(!empty($item['guest_name'])){
$content2.='姓名:'.$item['guest_name']."\n";
}
if(!empty($item['tel'])){
$content2.='手机:'.$item['tel']."\n";
}
if(!empty($item['guest_address'])){
$content2.='地址:'.$item['guest_address']."\n";
}
if(!empty($item['desk'])){
$content2.='桌号:'.$item['desk']."\n";
}
if(!empty($set['print_bottom'])){
$content2.="%10".$set['print_bottom']."\n%00";
}
$content2=iconv("UTF-8","GB2312//IGNORE",$content2);

$setting='<setting>124:'.$set['print_nums'].'|134:0</setting>';
$setting=iconv("UTF-8","GB2312//IGNORE",$setting);
echo '<?xml version="1.0" encoding="GBK"?><r><id>'.$item['id'].'</id><time>'.date('Y-m-d H:i:s', $item['createtime']).'</time><content>'.$content.$content1.$content2.'</content>'.$setting.'</r>';