[ Index ]

PHP Cross Reference of osCMax 2.0.4

title

Body

[close]

/admin/includes/modules/batch_print/templates/ -> Packing-Slip.php (source)

   1  <?php
   2  // set paper type and size

   3  if ($pageloop == "0") {
   4  $pdf = new Cezpdf(A4,portrait);
   5  } else {
   6  
   7  define('LEFT_MARGIN','30');
   8  // The small indents in the Sold to: Ship to: Text blocks

   9  define('TEXT_BLOCK_INDENT', '5');
  10  define('SHIP_TO_COLUMN_START','300');
  11  // This changes the 'Total', 'Sub-Total', 'Tax', and 'Shipping Method' text block

  12  // position, for example if you choose to make the text a bigger font size you need to 

  13  // tweak this value in order to prevent the text from clashing together

  14  define('PRODUCT_TOTAL_TITLE_COLUMN_START','400');
  15  define('RIGHT_MARGIN','30');
  16  
  17  
  18  define('LINE_LENGTH', '552');
  19  // If you have attributes for certain products, you can have the text wrap

  20  // or just be written completely on one line, with the text wrap disabled

  21  // it makes the tables smaller appear much better, of course that is only my opinion

  22  // so I made this variable if anyone would like it to wrap.

  23  define('PRODUCT_ATTRIBUTES_TEXT_WRAP', false);
  24  // This sets the space size between sections

  25  define('SECTION_DIVIDER', '15');
  26  // Product table Settings

  27  define('TABLE_HEADER_FONT_SIZE', '9');
  28  define('TABLE_HEADER_BKGD_COLOR', DARK_GREY);
  29  define('PRODUCT_TABLE_HEADER_WIDTH', '530');
  30  // This is more like cell padding, it moves the text the number

  31  // of points specified to make the rectangle appear padded

  32  define('PRODUCT_TABLE_BOTTOM_MARGIN', '2');
  33  // Tiny indent right before the product name, again more like

  34  // the cell padding effect

  35  define('PRODUCT_TABLE_LEFT_MARGIN', '2');
  36  // Height of the product listing rectangles

  37  define('PRODUCT_TABLE_ROW_HEIGHT', '11');
  38  // The column sizes are where the product listing columns start on the

  39  // PDF page, if you make the TABLE HEADER FONT SIZE any larger you will

  40  // need to tweak these values to prevent text from clashing together

  41  define('PRODUCTS_COLUMN_SIZE', '172');
  42  define('PRODUCT_LISTING_BKGD_COLOR',GREY);
  43  define('MODEL_COLUMN_SIZE', '37');
  44  define('PRICING_COLUMN_SIZES', '67');
  45  $vilains = array("&#224;", "&#225;",  "&#226;", "&#227;", "&#228;", "&#229;", "&#230;", "&#231;", "&#232;", "&#233;", "&#234;", "&#235;", "&#236;", "&#237;", "&#238;", "&#239;", "&#240;", "&#241;", "&#242;", "&#243;", "&#244;", "&#245;", "&#246;", "&#247;", "&#248;", "&#249;", "&#250;", "&#251;", "&#252;", "&#253;", "&#254;", "&#255;", "&#223;","&#39;", "&nbsp;", "&agrave;", "&aacute;", "&atilde;","&auml;", "&Arond;", "&egrave;", "&aelig;", "&ecirc;", "&euml;", "&igrave;", "&iacute;", "&Iacute;", "&icirc;", "&iuml;", "&ograve;", "&oacute;", "&ocirc;", "&otilde;", "&ouml;", "&oslash;", "&ugrave;", "&uacute;", "&ucirc;", "&uuml;", "&ntilde;", "&ccedil;", "&yacute;", "&lt;","&gt;", "&amp;");
  46  $cools = array('','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','','\'', ' ','','','','','','','','','','','','','','','','','','','','','','','','','','','','<','>','&');
  47  
  48  $currencies = new currencies();
  49  //$pdf->setPreferences(array("HideToolbar" => 'false', "HideWindowUI" => 'false'));

  50  $pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
  51  $pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
  52  
  53  // company name and details pulled from the my store address and phone number

  54  // in admin configuration mystore 

  55  $y = $pdf->ezText(STORE_NAME_ADDRESS,COMPANY_HEADER_FONT_SIZE);
  56  $y -= 10; 
  57  
  58  // logo image  set to right of the above .. change first number to move sideways    

  59  //$pdf->addJpegFromFile(BATCH_PRINT_INC . 'templates/' . 'invoicelogo.jpg',365,730,85,85); 

  60  
  61  // extra info boxs to be used by staff

  62  $pdf->setStrokeColor(0,0,0);
  63  $pdf->setLineStyle(1);
  64  $pdf->roundedRectangle(300,730,255,85,10,$f=0);
  65  //$pdf->rectangle(535,748,10,10);

  66  //$pdf->rectangle(535,769,10,10);

  67  //$pdf->rectangle(535,790,10,10);

  68  //$pdf->addText(310,790,GENERAL_FONT_SIZE,'In Stock');

  69  $pdf->addText(310,769,GENERAL_FONT_SIZE, TEXT_PACKED_BY );
  70  $pdf->addText(310,748,GENERAL_FONT_SIZE, TEXT_VERIFIED_BY );
  71  
  72  
  73  // line between header order number and order date

  74  $pdf->setLineStyle(1);
  75  $pdf->line(LEFT_MARGIN,$y,LINE_LENGTH,$y);
  76  $pdf->ezSetY($y);
  77  $dup_y = $y;
  78  
  79  // order number

  80  $y = $pdf->ezText("<b>" . TEXT_ORDER_NUMBER . " </b>" . $orders['orders_prefix'] . $orders['orders_id'] ."\n\n",SUB_HEADING_FONT_SIZE);
  81  
  82  // order date

  83  if ($HTTP_POST_VARS['show_order_date']) { 
  84      $pdf->ezSetY($dup_y);
  85      $pdf->ezText("<b>" . TEXT_ORDER_DATE . " </b>" . date(TEXT_ORDER_FORMAT, strtotime($order->info['date_purchased'])) ."\n\n",SUB_HEADING_FONT_SIZE,array('justification'=>'right'));
  86      }
  87  
  88  
  89  
  90  
  91  //left rounded rectangle around sold to info

  92  $pdf->setStrokeColor(0,0,0);
  93  $pdf->setLineStyle(1);
  94  $pdf->roundedRectangle(28,580,260,120,10,$f=0);
  95  
  96  
  97  // sold to info in left rectangle    

  98  $pdf->addText(LEFT_MARGIN,$y,SUB_HEADING_FONT_SIZE,"<b>" . ENTRY_SOLD_TO . "</b>");
  99  
 100  $pos = $y;
 101  $indent = LEFT_MARGIN + TEXT_BLOCK_INDENT;
 102  
 103  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['name']);
 104  if ($order->billing['company'] && $order->billing['company'] != 'NULL') {
 105  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['company']);
 106  }
 107  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['street_address']);
 108  
 109  if ($order->billing['suburb'] && $order->billing['suburb'] != 'NULL') {
 110  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['suburb']);
 111  }
 112  
 113  $cty_st_zip = $order->billing['city'] . " " . $order->billing['state'] . ", " . $order->billing['postcode'];
 114  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$cty_st_zip);
 115  
 116  
 117  // right rounded rectangle around ship to info

 118  $pdf->setStrokeColor(0,0,0);
 119  $pdf->setLineStyle(1);
 120  $pdf->roundedRectangle(298,580,260,120,10,$f=0);
 121  
 122  
 123  // ship to info in right column

 124  $pdf->addText(SHIP_TO_COLUMN_START,$y,SUB_HEADING_FONT_SIZE,"<b>" . ENTRY_SHIP_TO . "</b>");
 125  
 126  $pos = $y;
 127  $indent = SHIP_TO_COLUMN_START + TEXT_BLOCK_INDENT;
 128  
 129  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['name']);
 130  if ($order->delivery['company'] && $order->delivery['company'] != 'NULL') {
 131  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['company']);
 132  }
 133  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['street_address']);
 134  
 135  if ($order->delivery['suburb'] && $order->delivery['suburb'] != 'NULL') {
 136  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['suburb']);
 137  }
 138  
 139  $cty_st_zip = $order->delivery['city'] . " " . $order->delivery['state'] . ", " . $order->delivery['postcode'];
 140  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$cty_st_zip);
 141  
 142  $country =  $order->delivery['country'];
 143  $pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$country);
 144  
 145  
 146  // phone and email statments .. 

 147  $pos -= SECTION_DIVIDER;
 148  $pdf->ezSetY($pos - 40 );
 149  $pos = $pdf->ezText("<b>" . ENTRY_PHONE . "</b> " . $order->customer['telephone'],GENERAL_FONT_SIZE);
 150  $pos = $pdf->ezText("<b>" . ENTRY_EMAIL . "</b> " .$order->customer['email_address'],GENERAL_FONT_SIZE);
 151  
 152  // divider between email and payment method 

 153   $pos -= SECTION_DIVIDER;
 154   $pdf->ezSetY($pos);
 155  
 156  // payment method  and type

 157  $pos = $pdf->ezText("<b>" . ENTRY_PAYMENT_METHOD . "</b> " . str_replace($vilains , $cools, $order->info['payment_method']),GENERAL_FONT_SIZE);
 158  // shipping method - I don't use this so this code is a guess for those that do

 159  //$pos = $pdf->ezText("<b>" . ENTRY_SHIPPING_METHOD . "</b> " . $order->info['shipping_method'],GENERAL_FONT_SIZE);

 160  
 161  //$pdf->ezNewPage();

 162  
 163  $pos -= SECTION_DIVIDER;
 164   
 165  // products , model etc table layout 

 166  change_color(TABLE_HEADER_BKGD_COLOR);
 167  $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 168  
 169  $x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
 170  $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 171  
 172  change_color(GENERAL_FONT_COLOR);
 173  
 174  $pdf->addText($x,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRODUCTS);
 175  $pdf->addText($x += PRODUCTS_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRODUCTS_MODEL);
 176  $pdf->addText($x += MODEL_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,'');
 177  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 178  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 179  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 180  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 181  
 182  $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
 183  
 184  // Sort through the products

 185  
 186  for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
 187  
 188  $prod_str = $order->products[$i]['qty'] . " x " . $order->products[$i]['name'];
 189  
 190  change_color(PRODUCT_LISTING_BKGD_COLOR);
 191  $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 192  
 193  $x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
 194  $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 195  
 196  change_color(GENERAL_FONT_COLOR);
 197  $truncated_str = $pdf->addTextWrap($x,$pos,PRODUCTS_COLUMN_SIZE,TABLE_HEADER_FONT_SIZE,$prod_str);
 198  $pdf->addText($x += PRODUCTS_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,$order->products[$i]['model']);
 199  $pdf->addText($x += MODEL_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,'');
 200  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 201  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 202  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 203  $pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,'');
 204  $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
 205  if ($truncated_str) { 
 206      
 207      change_color(PRODUCT_LISTING_BKGD_COLOR);
 208      $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 209      $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 210      change_color(GENERAL_FONT_COLOR);
 211      $reset_x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
 212      $pdf->addText($reset_x,$pos,TABLE_HEADER_FONT_SIZE,$truncated_str);
 213      $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
 214      
 215      }
 216      
 217      if ( ($k = sizeof($order->products[$i]['attributes'])) > 0) {
 218          for ($j = 0; $j < $k; $j++) {
 219          $attrib_string = '<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
 220          if ($order->products[$i]['attributes'][$j]['price'] != '0') { 
 221          $attrib_string .= ' (' . $order->products[$i]['attributes'][$j]['prefix'] . 
 222          $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; 
 223          
 224          }
 225          
 226          $attrib_string .= '</i>';
 227          change_color(PRODUCT_LISTING_BKGD_COLOR);
 228          $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 229          $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 230          change_color(GENERAL_FONT_COLOR);
 231          $reset_x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
 232          if (PRODUCT_ATTRIBUTES_TEXT_WRAP) {
 233          $wrapped_str = $pdf->addTextWrap($reset_x,$pos,PRODUCTS_COLUMN_SIZE,PRODUCT_ATTRIBUTES_FONT_SIZE,$attrib_string);
 234          } else { 
 235          $pdf->addText($reset_x,$pos,PRODUCT_ATTRIBUTES_FONT_SIZE,$attrib_string);
 236          }
 237          $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
 238                    
 239                      if ($wrapped_str) { 
 240                      change_color(PRODUCT_LISTING_BKGD_COLOR);
 241                      $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 242                      $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 243                      change_color(GENERAL_FONT_COLOR);
 244                      $pdf->addText($reset_x,$pos,PRODUCT_ATTRIBUTES_FONT_SIZE,$wrapped_str);
 245                      $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
 246                      }
 247                  }
 248              }
 249    } //EOFOR

 250  
 251  $pos -= SECTION_DIVIDER;
 252  if ($orders['comments']) {
 253  $pdf->ezSetY($pos);
 254  $pdf->ezText("<b>Comments:</b>\n" . $orders['comments'],GENERAL_FONT_SIZE);
 255  }
 256  }
 257  ?>


Generated: Fri Jan 1 13:43:16 2010 Cross-referenced by PHPXref 0.7