时间:2021-07-01 10:21:17 帮助过:3人阅读
$id=$_GET['number'];
$uploaddir = 'download/';
$Date = date("YmdHis");
$filenamepdf = $uploaddir."Label_print".$Date.".pdf";
require_once('tcpdf/config/lang/eng.php');
require_once('tcpdf/tcpdf.php');
include("conn.php");
$pdf = new TCPDF('L', 'mm', 'BUSINESS_CARD_JP', true, 'UTF-8', false);
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->SetMargins(1,1,2,false);
$pdf->setFooterMargin(1);
$pdf->SetAutoPageBreak( true, 1 );
$Sql_hkpdf = "SELECT * , group_concat(' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , if(`quantity-purchased`> 1, '****' , ' ') ),group_concat(' ' , `order_id` , ' ') FROM ( select * from `sale_orders` order by `sku`) T WHERE `shipments` =0 AND `number` =$id GROUP BY `recipient-name` , `ship-address-1` ORDER BY length(group_concat( ' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , ' ' )) DESC,`sku`";
$Result = mysql_query($Sql_hkpdf);
while($rs = mysql_fetch_array($Result) ){
$ship_address=$rs['ship-address-1'].$rs['ship-address-2'].$rs['ship-address-3'];
$sku=$rs["group_concat(' ' , concat_ws( ' X ', `sku` , `quantity-purchased` ) , if(`quantity-purchased`> 1, '****' , ' ') )"];
$ship_postal_code="〒".$rs['ship-postal-code'];
$ship_city="日本 ".$rs['ship-state']." ".$rs['ship-city'];
$recipient_name=$rs['recipient-name']." 樣";
$buyer_phone_number="電話番號:".$rs['buyer-phone-number'];
//$hkdizhi='From : Unit A1 , 7/F,Cheung Kong Factory Bldg , 6 Cheung Yee Street , Lai Chi Kok , Hong Kong';
$pdf->AddPage();
$pdf->SetFont('arialunicid0', '', 8);
$pdf->Write(0, $sku, '', 0, 'R', true, 0, false, false, 0);
$yy=$pdf->GetY();
$xx=$pdf->GetX();
$style = array('width' => 0.2, 'cap' => 'butt', 'join' => 'miter', 'dash' => 0, 'color' => array(0, 0, 0));
$pdf->Line(2, $yy+0.3, 89, $yy+0.3, $style);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->Write(0, $ship_postal_code, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, $ship_city, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, $ship_address, '', 0, 'L', true, 0, false, false, 0);
$pdf->Write(0, "\n", '', 0, 'L', true, 0, false, false, 0);
$pdf->SetFont('arialunicid0', '', 12);
$pdf->Write(0, $recipient_name, '', 0, 'C', true, 0, false, false, 0);
$pdf->SetFont('arialunicid0', '', 10);
$pdf->Write(0, $buyer_phone_number, '', 0, 'C', true, 0, false, false, 0);