PHP Code:
function draw_packing_slip_master_list_customer($orderArray, &$pdf){
$order = $orderArray[0];
$customerName = $order->delivery['name'];
if($order->delivery['street_address'] == ''){ /* this is to match the merged packingslips record */
$customerName = $order->customer['name'];
}
$totalQty = 0;
foreach($orderArray as $order){
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
$totalQty = $totalQty + $order->products[$i]['qty'];
}
}
if ($totalQty == 1){
$headingLine = $customerName . ' (' . $totalQty . ' piece)';
}
else{
$headingLine = $customerName . ' (' . $totalQty . ' pieces)';
}
//sort out the header address line
$shipTo = zen_address_format($order->delivery['format_id'], $order->delivery, 0, '', "\n");
if($order->delivery['street_address'] == ''){
$shipTo = zen_address_format($order->customer['format_id'], $order->customer, 0, '', "\n");
}
$orderRightBox = $shipTo;
$pdf->SetFontSize('6');
$pdf->Cell('580','10',$orderRightBox,'','','R');
$pdf->Line(18,$pdf->GetY(),594,$pdf->GetY());
$pdf->Ln(2);
$pdf->SetFontSize('10');
$pdf->Cell(10, 10, '', 'LRTB');
$pdf->Cell(200, 12, $headingLine,'','0');
$pdf->Ln(10);
$pdf->MultiCell(566,2,'');
foreach($orderArray as $order){
$orderText = '';
for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
if ($orderText != ''){
$orderText = '';
}
$pdf->Ln(4);
$pdf->Cell(27, 10, '');
$pdf->Cell(8, 8, '', 'LRTB');
$pdf->Cell(5, 0, '');
$pdf->SetFontSize('6');
$multiAtt = false;
if(sizeof($order->products[$i]['attributes']) >0){
$attribCount=(sizeof($order->products[$i]['attributes']));
if($attribCount>1){
$aC=0;
while($aC < $attribCount){
$attribText = ' - ' . $order->products[$i]['attributes'][$aC]['value'];
if($aC==0){
$orderText .= ' ' . $order->products[$i]['qty'] . 'x ' . $order->products[$i]['name'] . '/' . $order->products[$i]['model'] . $attribText;
$pdf->Cell(380,10,$orderText,0,0);
$dateId = zen_date_short($order->info['date_purchased']) . ' #' . $order->info[id];
$pdf->SetFontSize('10');
$pdf->Cell('140','10',$dateId,'0','1','R');
$multiAtt=true;
$pdf->SetFontSize('6');
}else{
$widthTest = (' ' . $order->products[$i]['qty'] . 'x ' . $order->products[$i]['name'] . '/' . $order->products[$i]['model']);
$spaceWidth = $pdf->GetStringWidth($widthTest) + 40;
$orderText = $attribText;
$pdf->Ln(0);
$pdf->Cell($spaceWidth,10,'');
$pdf->Cell(20,12,$orderText,0,0);
}
$aC++;
}
}else{
$attribText = (!$order->products[$i]['attributes'][0]['value']) ? '' : (' - ' . $order->products[$i]['attributes'][0]['value']) ;
$orderText .= ' ' . $order->products[$i]['qty'] . 'x ' . $order->products[$i]['name'] . '/' . $order->products[$i]['model'] . $attribText;
$pdf->Cell(380,10,$orderText);
}
}else{
$orderText .= ' ' . $order->products[$i]['qty'] . 'x ' . $order->products[$i]['name'] . '/' . $order->products[$i]['model'];
$pdf->Cell(380,10,$orderText);
}
$attribText = '' ;
$orderIdText = $order->info[id];
if ($orderIdText == $previousOrderId){
$pdf->MultiCell('580','10',' ','','','R');
}else{
if (!$multiAtt){
$pdf->SetFontSize('10');
$dateId = zen_date_short($order->info['date_purchased']) . ' #' . $order->info[id];
$pdf->Cell('140','10',$dateId,'0','1','R');
$pdf->Ln(0);
$previousOrderId = $order->info[id];
}
}
}
$pdf->Ln(8);
}
}
Again, I hope this helps.
Bookmarks