Jump to content
Sign in to follow this  
defender39

Batch Order Center Update 1.1

Recommended Posts

On line 44 it reads

if ($HTTP_POST_VARS['show_comments']) { $get_customer_comments = ' and h.orders_status_id = ' . DEFAULT_ORDERS_STATUS_ID; }
if ($HTTP_POST_VARS['pull_status']){ $pull_w_status = " and o.orders_status = ". $HTTP_POST_VARS['pull_status']; }

$orders_query = tep_db_query("select o.orders_id,h.comments,MIN(h.date_added) from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS_HISTORY . " h where o.date_purchased between '" . tep_db_input($startdate) . "' and '" . tep_db_input($enddate) . "23:59:59'  and h.orders_id = o.orders_id" . $pull_w_status . $get_customer_comments . ' group by o.orders_id');

At around line 239 it reads

$pos -= SECTION_DIVIDER;
if ($orders['comments']) {
$pdf->ezSetY($pos);
$pdf->ezText("<b>Comments:</b>\n" . $orders['comments'],GENERAL_FONT_SIZE);
}

 

This seems to be getting the data from the Orders table. I just don't know enough about funneling data from the database to the php file. I would be willing to pay for help on this.

 

Thanks!

 

Bobby


Jared Geesey

Share this post


Link to post
Share on other sites

Hey David!

 

I got it to work!!!

 

I changed one letter in the code

 

h.comments is now o.comments

 

And it works great!

 

Thanks for such a great contribution!

 

Bobby


Jared Geesey

Share this post


Link to post
Share on other sites

Hi - This is a great contribution. Here's my dilemma, and we'll see if anyone is able to help me out. I'm using a custom invoice.php right now & integrated labels, which is a sheet of paper with a mailing label built in, so that i just print the one sheet & ta da!

 

Anyways, I need the .pdf output files to come out in the same layout as my invoice.php file, (or at least the address fields to match up exactly!) - as i have 2500 sheets of integrated labels sitting on my desk! i need to get this to work! <grin>

 

That being said - i need some help with this. Is any kind soul willing to lend a hand? Here's a copy of my invoice.php.

 

<?php
/*
$Id: invoice.php,v 1.4 2003/02/16 13:40:33 thomasamoulton Exp $

osCommerce, Open Source E-Commerce Solutions
http://www.oscommerce.com

Copyright (c) 2002 osCommerce

Released under the GNU General Public License
*/

require('includes/application_top.php');

require(DIR_WS_CLASSES . 'currencies.php');
$currencies = new currencies();

$oID = tep_db_prepare_input($HTTP_GET_VARS['oID']);
$orders_query = tep_db_query("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . tep_db_input($oID) . "'");

include(DIR_WS_CLASSES . 'order.php');
$order = new order($oID);
?>
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html <?php echo HTML_PARAMS; ?>>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
<title>pocketGEAR.ca Invoice: Order <?php echo $oID; ?></title>
<link rel="stylesheet" type="text/css" href="includes/stylesheet.css">
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" bgcolor="#FFFFFF">

<!-- body_text //-->
<table border="0" width="100%" cellspacing="0" cellpadding="2">
<tr>
  <table border="0" width="100%" cellspacing="0" cellpadding="2">
  <tr>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '150'); ?></td>
    <!-- shipping label //-->
    <td valign="top">
      <table border="0" width="300" cellspacing="0" cellpadding="2">
      <tr><td class="smallText"> </td></tr>
      <tr><td class="main"><br><?php echo nl2br(STORE_NAME_ADDRESS); ?></td></tr>
      <tr><td colspan="2"><img src="images/dash.gif" border="0"></td></tr>
      <tr><td class="main"><?php echo "<br><b>TO:<dl><dd>"; echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); echo "</dl>" ?></td></tr>
      <tr><td class="smallText" align="right"><br><br>Order Number: <?php echo $oID; ?></td></tr>
      </table>
    </td>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '50', '1'); ?></td>
    <!-- return label //-->
    <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '150'); ?></td>
    <td valign="top">
      <table border="0" width="300" cellspacing="0" cellpadding="2">
      <tr><td class="smallText"> </td></tr>
      <tr><td class="main"><?php echo "<br>"; echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td></tr>
      <tr><td colspan="2"><img src="images/dash.gif" border="0"></td></tr>
      <tr><td class="main"><br><b>TO:<dl><dd><?php echo nl2br(STORE_NAME_ADDRESS); ?></dl></td></tr>
      <tr><td class="smallText" align="right"><br><br>Order Number: <?php echo $oID; ?></td></tr>
      </table>
    </td>
    <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '150'); ?></td>
  </tr>
  <tr><td class="smallText" colspan="5">                                                                                                       <br><br><i>For your convenience, we've provided a return label in the event you are not satisfied with our product. Please see our shipping and returns policy by visiting <u>http://pocketgear.ca/catalog/shipping.php</u></i><br></td></tr>
  </table>
</tr>
<tr>
  <td><table width="100%" border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td colspan="2"><?php echo tep_draw_separator(); ?></td>
    </tr>
    <tr>
      <td class="pageHeading">Order Number: <?php echo $oID; ?></td>
    </tr>
    <tr>
      <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td class="main"><b><?php echo ENTRY_SOLD_TO; ?></b></td>
        </tr>
        <tr>
          <td class="main"><?php echo tep_address_format($order->customer['format_id'], $order->customer, 1, ' ', '<br>'); ?></td>
        </tr>
        <tr>
          <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '5'); ?></td>
        </tr>
        <tr>
          <td class="main"><?php echo $order->customer['telephone']; ?></td>
        </tr>
        <tr>
          <td class="main"><?php echo '<a href="mailto:' . $order->customer['email_address'] . '"><u>' . $order->customer['email_address'] . '</u></a>'; ?></td>
        </tr>
      </table></td>
      <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
          <td class="main"><b><?php echo ENTRY_SHIP_TO; ?></b></td>
        </tr>
        <tr>
          <td class="main"><?php echo tep_address_format($order->delivery['format_id'], $order->delivery, 1, ' ', '<br>'); ?></td>
        </tr>
      </table></td>
    </tr>
  </table></td>
</tr>
<tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
  <td><table border="0" cellspacing="0" cellpadding="2">
    <tr>
      <td class="main"><b><?php echo ENTRY_PAYMENT_METHOD; ?></b></td>
      <td class="main"><?php echo $order->info['payment_method']; ?></td>
    </tr>
  </table></td>
</tr>
<tr>
  <td><?php echo tep_draw_separator('pixel_trans.gif', '1', '10'); ?></td>
</tr>
<tr>
  <td><table border="0" width="100%" cellspacing="0" cellpadding="2">
    <tr class="dataTableHeadingRow">
      <td class="dataTableHeadingContent" colspan="2"><?php echo TABLE_HEADING_PRODUCTS; ?></td>
      <td class="dataTableHeadingContent"><?php echo TABLE_HEADING_PRODUCTS_MODEL; ?></td>
      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TAX; ?></td>
      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_EXCLUDING_TAX; ?></td>
      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_PRICE_INCLUDING_TAX; ?></td>
      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_EXCLUDING_TAX; ?></td>
      <td class="dataTableHeadingContent" align="right"><?php echo TABLE_HEADING_TOTAL_INCLUDING_TAX; ?></td>
    </tr>
<?php
  for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {
    echo '      <tr class="dataTableRow">' . "\n" .
         '        <td class="dataTableContent" valign="top" align="right">' . $order->products[$i]['qty'] . ' x</td>' . "\n" .
         '        <td class="dataTableContent" valign="top">' . $order->products[$i]['name'];

    if ( ($k = sizeof($order->products[$i]['attributes'])) > 0) {
      for ($j = 0; $j < $k; $j++) {
        echo '<br><nobr><small> <i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
        if ($order->products[$i]['attributes'][$j]['price'] != '0') echo ' (' . $order->products[$i]['attributes'][$j]['prefix'] . $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')';
        echo '</i></small></nobr>';
      }
    }

    echo '        </td>' . "\n" .
         '        <td class="dataTableContent" valign="top">' . $order->products[$i]['model'] . '</td>' . "\n";
    echo '        <td class="dataTableContent" align="right" valign="top">' . tep_display_tax_value($order->products[$i]['tax']) . '%</td>' . "\n" .
         '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
         '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
         '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n" .
         '        <td class="dataTableContent" align="right" valign="top"><b>' . $currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . '</b></td>' . "\n";
    echo '      </tr>' . "\n";
  }
?>
    <tr>
      <td align="right" colspan="8"><table border="0" cellspacing="0" cellpadding="2">
<?php
for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {
  echo '          <tr>' . "\n" .
       '            <td align="right" class="smallText">' . $order->totals[$i]['title'] . '</td>' . "\n" .
       '            <td align="right" class="smallText">' . $order->totals[$i]['text'] . '</td>' . "\n" .
       '          </tr>' . "\n";
}
?>
      </table></td>
    </tr>
    <tr><table border="0" width="500" cellspacing="0" cellpadding="2">
        <tr class="dataTableHeadingRow"><td colspan="3" class="dataTableHeadingContent"><b>Order Comments</td></tr>
<?php
  $orders_history_query = tep_db_query("select orders_status_id, date_added, customer_notified, comments from " . TABLE_ORDERS_STATUS_HISTORY . " where orders_id = '" . tep_db_input($oID) . "' order by date_added");
  if (tep_db_num_rows($orders_history_query)) {
    while ($orders_history = tep_db_fetch_array($orders_history_query)) {
      echo '          <tr valign=\"top\">' . "\n" .
           '            <td class="smallText" align="left" width="140">' . tep_datetime_short($orders_history['date_added']) . '</td>' . "\n" .
           '            <td class="smallText">' . nl2br(tep_db_output($orders_history['comments'])) . ' </td>' . "\n" .
           '          </tr>' . "\n";
    }
  }
?>
    </table>
    </tr>
  </table></td>
</tr>
</table>
<!-- body_text_eof //-->

<br>

</body>
</html>
<?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>

 

And just in case you don't have it on you, here's the Batch_Print.php file.

 

<?php

require('includes/application_top.php');

if ($HTTP_GET_VARS['mkey']) {

$key = $HTTP_GET_VARS['mkey']; 
$message = $error[$key]; 
$HTTP_GET_VARS['act'] = 0; 

}

if ($HTTP_GET_VARS['act'] == '') { $HTTP_GET_VARS['act'] = 0; }

if (strlen($HTTP_GET_VARS['act']) == 1 && is_numeric($HTTP_GET_VARS['act']))
{

switch ($HTTP_GET_VARS['act']) {

case 1:

// CHECK DATE ENTERED, GRAB ALL ORDERS FROM THAT DATE, AND CREATE PDF FOR ORDERS
if (!isset($HTTP_POST_VARS['startdate'])) { message_handler(); }
if ((strlen($HTTP_POST_VARS['startdate']) != 10) || verify_date($HTTP_POST_VARS['startdate'])) { message_handler('ERROR_BAD_DATE'); }
if (!is_writeable(BATCH_PDF_DIR)) { message_handler('SET_PERMISSIONS'); }
$time0   = time();
$startdate = tep_db_prepare_input($HTTP_POST_VARS['startdate']);

if (!isset($HTTP_POST_VARS['enddate'])) { message_handler(); }
if ((strlen($HTTP_POST_VARS['enddate']) != 10) || verify_date($HTTP_POST_VARS['enddate'])) { message_handler('ERROR_BAD_DATE'); }
if (!is_writeable(BATCH_PDF_DIR)) { message_handler('SET_PERMISSIONS'); }
$time0   = time();
$enddate = tep_db_prepare_input($HTTP_POST_VARS['enddate']);

require(DIR_WS_CLASSES . 'currencies.php');
require(BATCH_PRINT_INC . 'class.ezpdf.php');
require(DIR_WS_CLASSES . 'order.php');

$pdf = new Cezpdf(PAGE);
$currencies = new currencies();

$pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
$pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');
if ($HTTP_POST_VARS['show_comments']) { $get_customer_comments = ' and h.orders_status_id = ' . DEFAULT_ORDERS_STATUS_ID; }
if ($HTTP_POST_VARS['pull_status']){ $pull_w_status = " and o.orders_status = ". $HTTP_POST_VARS['pull_status']; }

$orders_query = tep_db_query("select o.orders_id,h.comments,MIN(h.date_added) from " . TABLE_ORDERS . " o, " . TABLE_ORDERS_STATUS_HISTORY . " h where o.date_purchased between '" . tep_db_input($startdate) . "' and '" . tep_db_input($enddate) . "23:59:59'  and h.orders_id = o.orders_id" . $pull_w_status . $get_customer_comments . ' group by o.orders_id');

if (!tep_db_num_rows($orders_query) > 0) { message_handler('NO_ORDERS'); }
$num = 0;

while ($orders = tep_db_fetch_array($orders_query)) {

 $order = new order($orders['orders_id']);
 
if ($num != 0) { $pdf->EzNewPage(); }

$y = $pdf->ezText(STORE_NAME_ADDRESS,COMPANY_HEADER_FONT_SIZE);
$y -= 10; 

$pdf->setLineStyle(1);
$pdf->line(LEFT_MARGIN,$y,LINE_LENGTH,$y);
$pdf->ezSetY($y);
$dup_y = $y;

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

if ($HTTP_POST_VARS['show_order_date']) { 
$pdf->ezSetY($dup_y);
$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'));
}
 

$pdf->addText(LEFT_MARGIN,$y,SUB_HEADING_FONT_SIZE,"<b>" . ENTRY_SOLD_TO . "</b>");

$pos = $y;
$indent = LEFT_MARGIN + TEXT_BLOCK_INDENT;

$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['name']);
if ($order->billing['company'] && $order->billing['company'] != 'NULL') {
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['company']);
}
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['street_address']);

if ($order->billing['suburb'] && $order->billing['suburb'] != 'NULL') {
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->billing['suburb']);
}

$cty_st_zip = $order->billing['city'] . " " . $order->billing['state'] . ", " . $order->billing['postcode'];
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$cty_st_zip);


$pdf->addText(SHIP_TO_COLUMN_START,$y,SUB_HEADING_FONT_SIZE,"<b>" . ENTRY_SHIP_TO . "</b>");

$pos = $y;
$indent = SHIP_TO_COLUMN_START + TEXT_BLOCK_INDENT;

$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['name']);
if ($order->delivery['company'] && $order->delivery['company'] != 'NULL') {
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['company']);
}
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['street_address']);

if ($order->delivery['suburb'] && $order->delivery['suburb'] != 'NULL') {
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$order->delivery['suburb']);
}

$cty_st_zip = $order->delivery['city'] . " " . $order->delivery['state'] . ", " . $order->delivery['postcode'];
$pdf->addText($indent,$pos -= GENERAL_LEADING,GENERAL_FONT_SIZE,$cty_st_zip);

if ($HTTP_POST_VARS['show_phone'] || $HTTP_POST_VARS['show_email'] ) {

$pos -= SECTION_DIVIDER;
$pdf->ezSetY($pos);

if ($HTTP_POST_VARS['show_phone']) {
$pos = $pdf->ezText("<b>" . ENTRY_PHONE . "</b> " . $order->customer['telephone'],GENERAL_FONT_SIZE);

}  if ($HTTP_POST_VARS['show_email']) {
$pos = $pdf->ezText("<b>" . ENTRY_EMAIL . "</b> " .$order->customer['email_address'],GENERAL_FONT_SIZE);

}
} 

$pos -= SECTION_DIVIDER;
$pdf->ezSetY($pos);

if ($HTTP_POST_VARS['show_pay_method']) {
$pos = $pdf->ezText("<b>" . ENTRY_PAYMENT_METHOD . "</b> " . $order->info['payment_method'],GENERAL_FONT_SIZE);

if ($order->info['payment_method'] == PAYMENT_TYPE) {
$pos = $pdf->ezText("<b>" . ENTRY_PAYMENT_TYPE . "</b> " . $order->info['cc_type'],GENERAL_FONT_SIZE);
$pos = $pdf->ezText("<b>" . ENTRY_CC_OWNER . "</b> " . $order->info['cc_owner'],GENERAL_FONT_SIZE);
 if ($HTTP_POST_VARS['show_cc']) {
 $pos = $pdf->ezText("<b>" . ENTRY_CC_NUMBER . "</b> " . $order->info['cc_number'],GENERAL_FONT_SIZE);
 }
 
 $pos = $pdf->ezText("<b>" . ENTRY_CC_EXP . "</b> " . $order->info['cc_expires'],GENERAL_FONT_SIZE);
}

}
$pos -= SECTION_DIVIDER;

change_color(TABLE_HEADER_BKGD_COLOR);
$pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);

$x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
$pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;

change_color(GENERAL_FONT_COLOR);

$pdf->addText($x,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRODUCTS);
$pdf->addText($x += PRODUCTS_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRODUCTS_MODEL);
$pdf->addText($x += MODEL_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_TAX);
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRICE_EXCLUDING_TAX);
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_PRICE_INCLUDING_TAX);
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_TOTAL_EXCLUDING_TAX);
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,TABLE_HEADING_TOTAL_INCLUDING_TAX);

$pos -= PRODUCT_TABLE_BOTTOM_MARGIN;

// Sort through the products

for ($i = 0, $n = sizeof($order->products); $i < $n; $i++) {

$prod_str = $order->products[$i]['qty'] . " x " . $order->products[$i]['name'];

change_color(PRODUCT_LISTING_BKGD_COLOR);
$pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);

$x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
$pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;

change_color(GENERAL_FONT_COLOR);
$truncated_str = $pdf->addTextWrap($x,$pos,PRODUCTS_COLUMN_SIZE,TABLE_HEADER_FONT_SIZE,$prod_str);
$pdf->addText($x += PRODUCTS_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,$order->products[$i]['model']);
$pdf->addText($x += MODEL_COLUMN_SIZE,$pos,TABLE_HEADER_FONT_SIZE,$order->products[$i]['tax']);
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,$currencies->format($order->products[$i]['final_price'], true, $order->info['currency'], $order->info['currency_value']));
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']), true, $order->info['currency'], $order->info['currency_value']));
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,$currencies->format($order->products[$i]['final_price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']));
$pdf->addText($x += PRICING_COLUMN_SIZES,$pos,TABLE_HEADER_FONT_SIZE,$currencies->format(tep_add_tax($order->products[$i]['final_price'], $order->products[$i]['tax']) * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']));
$pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
if ($truncated_str) { 

change_color(PRODUCT_LISTING_BKGD_COLOR);
$pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
$pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
change_color(GENERAL_FONT_COLOR);
$reset_x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
$pdf->addText($reset_x,$pos,TABLE_HEADER_FONT_SIZE,$truncated_str);
$pos -= PRODUCT_TABLE_BOTTOM_MARGIN;

}

if ( ($k = sizeof($order->products[$i]['attributes'])) > 0) {
       for ($j = 0; $j < $k; $j++) {
 $attrib_string = '<i> - ' . $order->products[$i]['attributes'][$j]['option'] . ': ' . $order->products[$i]['attributes'][$j]['value'];
 if ($order->products[$i]['attributes'][$j]['price'] != '0') { 
 $attrib_string .= ' (' . $order->products[$i]['attributes'][$j]['prefix'] . 
 $currencies->format($order->products[$i]['attributes'][$j]['price'] * $order->products[$i]['qty'], true, $order->info['currency'], $order->info['currency_value']) . ')'; 
 
 }
 
 $attrib_string .= '</i>';
 change_color(PRODUCT_LISTING_BKGD_COLOR);
 $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
 $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
 change_color(GENERAL_FONT_COLOR);
 $reset_x = LEFT_MARGIN + PRODUCT_TABLE_LEFT_MARGIN;
 if (PRODUCT_ATTRIBUTES_TEXT_WRAP) {
 $wrapped_str = $pdf->addTextWrap($reset_x,$pos,PRODUCTS_COLUMN_SIZE,PRODUCT_ATTRIBUTES_FONT_SIZE,$attrib_string);
 } else { 
 $pdf->addText($reset_x,$pos,PRODUCT_ATTRIBUTES_FONT_SIZE,$attrib_string);
 }
 $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
     
  	 if ($wrapped_str) { 
  	 change_color(PRODUCT_LISTING_BKGD_COLOR);
  	 $pdf->filledRectangle(LEFT_MARGIN,$pos-PRODUCT_TABLE_ROW_HEIGHT,PRODUCT_TABLE_HEADER_WIDTH,PRODUCT_TABLE_ROW_HEIGHT);
  	 $pos = ($pos-PRODUCT_TABLE_ROW_HEIGHT) + PRODUCT_TABLE_BOTTOM_MARGIN;
  	 change_color(GENERAL_FONT_COLOR);
  	 $pdf->addText($reset_x,$pos,PRODUCT_ATTRIBUTES_FONT_SIZE,$wrapped_str);
  	 $pos -= PRODUCT_TABLE_BOTTOM_MARGIN;
  	 }
   }
	 }
 } //EOFOR

$pos -= PRODUCT_TABLE_BOTTOM_MARGIN;

for ($i = 0, $n = sizeof($order->totals); $i < $n; $i++) {

$pdf->addText(LEFT_MARGIN + 200,$pos -= PRODUCT_TOTALS_LEADING,PRODUCT_TOTALS_FONT_SIZE,"<b>" . $order->totals[$i]['title'] . "</b>");
$pdf->addText($x,$pos,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text']);
 
 } //EOFOR

$pos -= SECTION_DIVIDER;
if ($orders['comments']) {
$pdf->ezSetY($pos);
$pdf->ezText("<b>Comments:</b>\n" . $orders['comments'],GENERAL_FONT_SIZE);
}

if ($HTTP_POST_VARS['status'] && ($HTTP_POST_VARS['status'] != $order->info['orders_status'])){
$customer_notified = 0; 
$status = tep_db_prepare_input($HTTP_POST_VARS['status']);
$notify_comments = sprintf(EMAIL_TEXT_COMMENTS_UPDATE, BATCH_COMMENTS) . "\n\n";

if ($HTTP_POST_VARS['notify']) {
$status_query = tep_db_query("select orders_status_name as name from " . TABLE_ORDERS_STATUS . " where language_id = '" . $languages_id . "' and orders_status_id = " . tep_db_input($status));
$status_name = tep_db_fetch_array($status_query);

$email = STORE_NAME . "\n" . EMAIL_SEPARATOR . "\n" . EMAIL_TEXT_ORDER_NUMBER . ' ' . $orders['orders_id'] . "\n" . EMAIL_TEXT_INVOICE_URL . ' ' . tep_catalog_href_link(FILENAME_CATALOG_ACCOUNT_HISTORY_INFO, 'order_id=' . $orders['orders_id'], 'SSL') . "\n" . EMAIL_TEXT_DATE_ORDERED . ' ' . tep_date_long($order->info['date_purchased']) . "\n\n" . $notify_comments . sprintf(EMAIL_TEXT_STATUS_UPDATE, $status_name['name']);
tep_mail($order->customer['name'], $order->customer['email_address'], EMAIL_TEXT_SUBJECT, nl2br($email), STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
         $customer_notified = '1';
}

tep_db_query("update " . TABLE_ORDERS . " set orders_status = '" . tep_db_input($status) . "', last_modified = now() where orders_id = '" . $orders['orders_id'] . "'");
tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) 
values ('" . $orders['orders_id'] . "', '" . tep_db_input($status) . "', now(), '" . $customer_notified . "', '" . $notify_comments  . "')");
}
$num++;
// Send fake header to avoid timeout, got this trick from phpMyAdmin
 $time1  = time();
       if ($time1 >= $time0 + 30) {
           $time0 = $time1;
           header('X-bpPing: Pong');
	 }
}// EOWHILE

$pdf_code = $pdf->output();

$fname = BATCH_PDF_DIR . BATCH_PDF_FILE;
if ($fp = fopen($fname,'w')) {
fwrite($fp,$pdf_code);
fclose($fp);
} else { message_handler('FAILED_TO_OPEN'); }

$message =  'A PDF of ' . $num . ' order(s) was successful! 
<a href="'.$fname.'"><b>Click here</b></a> to download the order file.';

case 0:

require(BATCH_PRINT_INC . 'batch_print_header.php');
require(BATCH_PRINT_INC . 'batch_print_body.php');
require(BATCH_PRINT_INC . 'batch_print_footer.php');

break;
default:

message_handler();

}//EOSWITCH


} else {

message_handler('ERROR_INVALID_INPUT');

}

// FUNCTION AREA
function message_handler($message=''){

if ($message) {
header("Location: " . tep_href_link(BATCH_PRINT_FILE, 'mkey=' . $message));
} else {
header("Location: " . tep_href_link(BATCH_PRINT_FILE));
}
exit(0);
}

function change_color($color) {
global $pdf;

list($r,$g,$b) = explode(',', $color);
$pdf->setColor($r,$g,$b);
}

function verify_date($startdate) {
$error = 0;
list($year,$month,$day) = explode('-', $startdate);

if ((strlen($year) != 4) || !is_numeric($year)) {
$error++;
}
if ((strlen($month) != 2) || !is_numeric($month)) {
$error++;
}
if ((strlen($day) != 2) || !is_numeric($day)) {
$error++;
}

return $error;

}


function verify_date($enddate) {
$error = 0;
list($year,$month,$day) = explode('-', $enddate);

if ((strlen($year) != 4) || !is_numeric($year)) {
$error++;
}
if ((strlen($month) != 2) || !is_numeric($month)) {
$error++;
}
if ((strlen($day) != 2) || !is_numeric($day)) {
$error++;
}

return $error;

}
?>

 

Any help would be greatly appreciated.

Share this post


Link to post
Share on other sites

Hi Tim,

Yes I could also use some help in getting shipping labels added to the top of the form. WHen I tried it last week I kept getting form feeds but no labels. Let me know what progess you make. Maybe we can sorT it out between us!

Share this post


Link to post
Share on other sites

Sure - the output to the .PDF doesn't look that difficult, i think it will just take time making changes, then seeing if it aligns, then making changes, then see if it aligns, then making ch.... you get the point <grin>

 

I will definatly keep you updated if i get anywhere with this.

 

Tim.

Share this post


Link to post
Share on other sites

I'm trying to add the customers_id to the pdf output. I not sure how you're calling that from the DB. any suggestions?


----------------------------

Long Island, New York

Share this post


Link to post
Share on other sites

The font files (.afm) are in admin/includes/modules/batch_print/temp

I'm not sure whether they are copied there automatically or if you might need to copy the ariel font family there manually.

Share this post


Link to post
Share on other sites

I'm trying to add the customers_id to the pdf output. I not sure how you're calling that from the DB. any suggestions?


----------------------------

Long Island, New York

Share this post


Link to post
Share on other sites

This is a great mod, just wondering is it possible to go by order numbers.

 

Just thought of a case, if you're doing drop shipping and lets say order 1-10 paid via paypal, and there actions are completed, and order 11-13 are money order and have not been paid, but 14-20 have been paid with cc and have been approved. How would you send this batch print order to your drop shipper? Skipping 11-13 since they haven't paid. But all of these purchases were on the same date.

 

Or lets say at 10am u get 20 orders, now u sent this to your drop shipper, and at 1pm u check again and got another 20 orders, but they are all the same day.

 

Thanks

Share this post


Link to post
Share on other sites

Yes you can. I've send the changes to a couple of people for trsting and they seem to work. I'd add them to the package but can't see how to make a zip file under xp.

Share this post


Link to post
Share on other sites
Yes you can. I've send the changes to a couple of people for trsting and they seem to work. I'd add them to the package but can't see how to make a zip file under xp.

Thanks for the info, you could use winzip to zip the files, or you could also send the files to me and i can zip them for u and help you upload it.

Share this post


Link to post
Share on other sites

Yes I was looking for winzip but couldn't find it. xp unzips files automatically but doesn't seem to zip them up again. Maybe you have to purchase winzip separately. If you find this little adaptation works for you, feel free to add it to the package!

Edited by radders

Share this post


Link to post
Share on other sites

With XP you should be able to Right click a single file or group of files, select "Send to...", and then select Compressed File. The "compressed file" is ZIP format...

 

Apologies if that doesn't work properly, but that's how I've created ZIP files ever since I switched to XP. I don't have Winzip installed on my computer...

 

Also, Radders, sent you a PM, but I'll post it here as well: Can you send me the order number modification to the contrib?

 

Thanks in advance!

Share this post


Link to post
Share on other sites

It is true that WinXP's build-in zip management leaves much to be desired.

 

There are many many free replacements for WinZip. Some are better than others.

 

Some freeware zip utils I've tried and liked (all are findable on Google):

Enzip

UltimateZip

FreeZip

 

See http://freewarehome.com/System_Utilities/F...IP_Tools_t.html for many more.

 

-jared

Share this post


Link to post
Share on other sites

Radders: Thanks for the files, but I just noticed that my pdf files aren't printing correctly the Ship Address is overlapping the Sold To address, so you see double info ontop of each other.

 

Does this happen to anyone else?

Share this post


Link to post
Share on other sites

That happens occasionally. Try changing the font size. As a thought (untested), you might try changing the paper size if that doesn't work. I think it comes set up as 'Letter' format but that hasn't caused me any problems yet printing on A4.

Share this post


Link to post
Share on other sites

Wow your fast at answering. LOL. I'll try changing that i found that my sold to is not giving a br for the phone number and state, while for some reason my ship to is not displaying.

Share this post


Link to post
Share on other sites

Can you show what have been added ie // -- added batch_print

there is no proper instructions.

 

ie

define('FILENAME_BATCH_PRINT', 'batch_print.php'); //-- New batch_print

so we can see what was modified

 

Can you make clear install instructions

rather then a replace the files.

Share this post


Link to post
Share on other sites

Nearly works in admin

 

2 problem

first i get the error

Fatal error: Cannot redeclare verify_date() (previously declared in /*/batch_print.php:320) in /*/batch_print.php on line 339

I replaced the path with *

this message is displayed in admin/tool/Batch Order Center after the send button.

it refers to this section:

 

function verify_date($enddate) {

$error = 0;

list($year,$month,$day) = explode('-', $enddate);

 

if ((strlen($year) != 4) || !is_numeric($year)) {

$error++;

}

if ((strlen($month) != 2) || !is_numeric($month)) {

$error++;

}

if ((strlen($day) != 2) || !is_numeric($day)) {

$error++;

}

 

return $error;

 

also

 

I get this message after submitting a date, I used right format

 

Invalid date, Please enter a valid date in Year-Month-Day (0000-00-00) format.

 

I tried inputting date format has stated, it did not work, why is this the date not in a standard format i.e month-day-year or uk day-month -year

 

I think this could be improved with a drop menu

today - yesterday -last 7 day so on

or drop down with month - date - year

Share this post


Link to post
Share on other sites

Great mod

Fixed some problem for ms2

 

cannot get the country to appear any idea's

 

also how do you make a spacer if you take out the taxtotal stuff

i just want the totals

 

also i'd like to repoduce the shipping to at the bottom of the pdf

 

Thanks

Share this post


Link to post
Share on other sites

To be honest, making formatting changes to this is a nightmare unless you know what you are doing. Far simpler if you need a custom formatted output to set it all up in html and just print it to a .pdf file instead of a printer. There's a free package to do that on sourceforge.

Share this post


Link to post
Share on other sites

Thanks radders, Do you have a link for that?

 

I found another problem

When a customer has many items ordered , Its just crops the items list at the bottom of the page, its does not continue to page 2 so - on; Any idea?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×