Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Batch Print Center (support thread)


blurb

Recommended Posts

Ok here is a quick dirty little hack that will change the order number on your

order.php into a button which takes you past the batch print form straight to

the batch print download pdf page. This hack will mean when your on the orders

page showing you the list of orders the left column becomes buttons to batch print.

 

Now this is providing your using the same orders.php as me but basically find

<?php echo '#' . $orders['orders_id']; ?>

and replace with

<FORM action="batch_print.php?act=1" method="post">
<INPUT type=hidden name=file_type value=Invoice.php>
<INPUT type=hidden value="<?php echo $orders['orders_id']; ?>" name=invoicenumbers> 
<INPUT title=" Batch Print " type=submit value="<?php echo $orders['orders_id']; ?>">
</FORM>

Taking care to change the above so where it says Invoice.php change to the name of your php template you wish to use.

Let me know how you go.

Im sure there is a easier way to do this by passing the values via the url but the

above works and I hope its what your after.

cheers

shaun

 

Hi there,

 

I'm trying to achieve a simialr sort of thing to this. Sometimes we do a batch print and once it's complete we have the odd order come in which we would like to dispatch with the batch we have just processed.

 

Ideally I'd like to link the existing OSC invoice and packing slip buttons to link to the batch print template we use.

 

I've installed the code above which looked like it would do the job, but unfortunately it doesn't work on the most recent order for some reason.

 

Does anyone have any ideas, suggestions?

 

Thanks

 

Dave

Link to comment
Share on other sites

  • Replies 224
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

What a great contrib!

 

I'm working on the invoice template and the only thing I can't get to fixed is the alignment (right) of the amounts.

It's both the product table amounts (price, total) but even more important it's the subtotal=>total section including any optional inserted rows like VAT and shipping.

 

Does anyone know how to align these amounts to the right?

Someone raised the question before in the forum but could not see any answer to it.

 

It's the following section I believe:

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

 

$pdf->addText (LEFT_MARGINX ,$pos -= PRODUCT_TOTALS_LEADING,PRODUCT_TOTALS_FONT_SIZE, str_replace($vilains , $cools ,$order->totals[$i]['title']), array('justification'=>'right'));

$pdf->addText($x,$pos,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text'], $order->info['currency_value'], array('justification'=>'right'));

 

} //EOFOR

 

The , array('justification'=>'right') part I inserted myself but doesn't seem to work.

 

THANKS !

Link to comment
Share on other sites

I don't think $pdf->addText accepts a parameter for justification.

function addText($x,$y,$size,$text,$angle=0,$wordSpaceAdjust=0)

Check the file 'class.pdf.php'. There is another similar function which does.

function addTextWrap($x,$y,$width,$size,$text,$justification='right',$angle=0,$test=0)

Link to comment
Share on other sites

Wow

 

Just found this .. where has it been hiding.

 

works superbly after a few mods (date etc)

Link to comment
Share on other sites

Thanks for the suggestion Radders!

 

However, I've tried it (see below) and doesn't seem to work. Is the function populated wrongly or will it just not work?

Have you used this / don't you want to align amounts to the right so the characters are nice under each other?

 

$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->addTextWrap($x += PRICING_COLUMN_SIZES,9,$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']),$justification='right',$angle=0);

Link to comment
Share on other sites

Thanks for the suggestion Radders!

 

However, I've tried it (see below) and doesn't seem to work. Is the function populated wrongly or will it just not work?

Have you used this / don't you want to align amounts to the right so the characters are nice under each other?

 

$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->addTextWrap($x += PRICING_COLUMN_SIZES,9,$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']),$justification='right',$angle=0);

 

Can someone help me with the right alignment please?

It looks a little bit more professional to have the amounts right aligned.

Link to comment
Share on other sites

What I had in mind was

  $pdf->addTextWrap($x += PRICING_COLUMN_SIZES,$pos, RIGHT_COL,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']),'right');

 

where RIGHT_COL has a value of 24.

 

Unfortunately it still seems to left justify.

Link to comment
Share on other sites

For the order totals what worked for me was replacing:

$pdf->addText($x,$pos,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text'], $order->info['currency_value']);

with:

$pdf->addTextWrap($x,$pos,RIGHT_COL,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text'],$justification='right');

 

I am conscious that I have missed out what I believe to be a scaling factor so this approach should fail in JPY etc.

Before using this test carefully and check also that the size of the column is large enough to contain your biggest order. YMMV

Link to comment
Share on other sites

For the order totals what worked for me was replacing:

$pdf->addText($x,$pos,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text'], $order->info['currency_value']);

with:

$pdf->addTextWrap($x,$pos,RIGHT_COL,PRODUCT_TOTALS_FONT_SIZE,$order->totals[$i]['text'],$justification='right');

 

I am conscious that I have missed out what I believe to be a scaling factor so this approach should fail in JPY etc.

Before using this test carefully and check also that the size of the column is large enough to contain your biggest order. YMMV

 

 

THANKS!

This works for both total by product and order total section. Ít's just the currency symbol that is not displayed nice below each other, but I think it's either way.

For me this is acceptable so thanks again!

Link to comment
Share on other sites

  • 3 months later...

Hi,

 

Quick question over here. I have finished my template for printing my invoices, but now I have found out that there is no easy way to show the customer tax_id number.

 

I have searched the full database, and I have seen that the tax_id is stored only on the 'address_book' table for the given customer. It is not used anywhere else, and it is not stored on 'orders' with the rest of the order information. I guess that might be that in many countries the tax_id will only be used to track the customer (if he is allowed to have wholesale prices or something like that), but in Spain we have to put the company tax_id whenever we make them an invoice.

 

I guess that won't be solved easily, since I could check the 'customers_id' from the 'orders' table, but the same customer might have different addresses, each one related to a different business and a different tax_id, so I still would not know how to pull this out (my SQL knowledge wouldn't allow me to do it either...)

 

Any hints? Anyone around here who has added the tax_id to one of their templates and can bring me some light?

 

Thanks!

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

Ok, I feel quite stupid right now since I just noticed that this tax_id problem is one of the installed modules, and not from a normal OSC installation :(

Oh well, any hints on how I could solve my problem are welcome...

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

I have found the solution to put my address. I have looked at the contribution "print sticky labels" and I have added the coded mentionned there to put the store address before the customer address.

 

In print sticky label, the first label is printed without any problems. I have looked in the code to find how we could modify batch print center to solve the problems but I haven't found :( I guess that the solution is in print sticky label but I am not good enough to fid the solution :(

 

I have now an additionnal question: how does "labelwriter" work? I will need to use it for other kind of labels. In "templates", there is only a html file and no php. Moreover, in my admin, I can't choose "labelwriter"

Link to comment
Share on other sites

I have now an additionnal question: how does "labelwriter" work? I will need to use it for other kind of labels. In "templates", there is only a html file and no php. Moreover, in my admin, I can't choose "labelwriter"

 

I have transformed the ".html" into ".php"

Now, the "labelwritter" template is in the list proposed in the admin. I have made some tests and I think that there are some bugs in the code. Indeed, no address is written on the label.

 

Here is the code of the template:

 

<?php
// TWEAK THE SETTINGS TO SUIT YOUR LABELWRITER.
// set paper type and size
if ($pageloop == "0") {


define('PAGE_WIDTH', '8.9');
define('PAGE_HEIGHT', '3.6');
$pdf = new Cezpdf(array(PAGE_WIDTH, PAGE_HEIGHT));
} else {
$currencies = new currencies();

$pdf->selectFont(BATCH_PDF_DIR . 'Helvetica.afm');
$pdf->setFontFamily(BATCH_PDF_DIR . 'Helvetica.afm');

$pdf->selectFont(LABEL_PDF_DIR . 'Helvetica.afm');
$pdf->setFontFamily(LABEL_PDF_DIR . 'Helvetica.afm');

//These Determine the Locations of the Labels, I think dimensions are (72 * inches)
// 2.54cm = 1 inch
define('SHIP_FROM_COUNTRY',  '');   // eg. 'United Kingdom'
define('BOX_WIDTH', '300');
define('LABEL_WIDTH', '200'); //Controls the second column
define('LABEL_HEIGHT', '90'); // controls the space between the labels
define('LEFT_MARGIN','10');
define('STARTX', '15'); //controls the first column
define('STARTY', '5'); // controls the space at the top of the file



if ($HTTP_POST_VARS['pull_status']){ $pull_w_status = " and o.orders_status = ". $HTTP_POST_VARS['pull_status']; }
if ($HTTP_POST_VARS['startpos']){ $startpos = $HTTP_POST_VARS['startpos']; }
else { $startpos = 0; }

if ($HTTP_POST_VARS['endpos']){ $endpos = $HTTP_POST_VARS['endpos']; }
else { $endpos = NUM_LABELS_PER_PAGE; }


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

change_color(LABEL_FONT_COLOR);
//if ($num != 0)  $pdf->EzNewPage();
$x=STARTX;
$y=LABEL_HEIGHT;
$pos = $y;
//if ($orders = tep_db_fetch_array($orders_query)){
//$order = new order($orders['orders_id']);

$address_array=explode('<br>', str_replace("\r\n", "<br>", STORE_NAME_ADDRESS));

//The first $key number is the number of lines in your store name and address excluding the telephone number at the bottom.
//The second $key number is the number of lines in your store name and address excluding telephone number and country.
foreach ($address_array as $key=>$value)  {
if (((SHIP_FROM_COUNTRY != $order->delivery['country']) && ($key < 5)) || ($key < 4))
{
  switch ($key)
  {
  case 0:
 $store_address_array[$key] = $value;
 break;
  case 1:
 $store_address_array[1] = $value;
 break;
	case 2:
 $store_address_array[2] = $value;
 break;
	case 3:
 $store_address_array[3] = $value;
 break;
	case 4:
 $store_address_array[4] = $value;
 break;
  default:
$store_address_array[4] .= ', ';
$store_address_array[4] .= $value;
break;
  }

}
}
$pdf->setStrokeColor(0,0,0);
$pdf->setLineStyle(1);
$pdf->roundedRectangle(10,5,170,90,10,$f=0);
  $pos=$y - (2*GENERAL_LEADING);

//  $address_array=explode('<br>', str_replace("\r\n", "<br>", STORE_NAME_ADDRESS));
foreach ($store_address_array as $key=>$value)  {
// echo $value.'<br>';
$pdf->addText(LEFT_MARGIN,$pos -= SMALL_LEADING,SENDER_SMALL_FONT_SIZE,$value);
}
$pdf->addText(LEFT_MARGIN,$pos -= LABEL_LINE_SPACING,ORDERIDFONTSIZE,'Order '.$orders['orders_id']);
$pos =$y;

if ($billing == true)
 $address_array=explode('<br>',tep_address_format($order->delivery['format_id'], $order->billing, 1, '', '<br>'));
else
 $address_array=explode('<br>',tep_address_format($order->delivery['format_id'], $order->delivery, 1, '', '<br>'));

if (SHIP_FROM_COUNTRY == $address_array[count($address_array)-1]) {
$address_array[count($address_array)-1] = '';
}
$print_address_array = array();
foreach ($address_array as $key => $value) {
 if ((!is_null($value))&& ($value !== "")) {
$fontsize = LABEL_FONT_SIZE;
while ($pdf->getTextWidth($fontsize, $value) > 160){
	$fontsize--;
}
$pdf->addText($x,$pos -= LABEL_LINE_SPACING,$fontsize,'<b>'.$value.'</b>');
 }
 }


}
?>

 

What is the problem???

Thanks for your help

Link to comment
Share on other sites

I have the following message:

 

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ordre automatique. ')' at line 2

 

insert into orders_status_history (orders_id, orders_status_id, date_added, customer_notified, comments) values ('1980', '3', now(), '1', 'Les commentaires de votre commande sont Avis de mise à jour d'ordre automatique. ')

 

When I select the automatic update of status. The first order is correctly updated but not the others (the message "batch update status" appears but the status remains the same and no email is sent)

 

Can you help me please?

Link to comment
Share on other sites

I have the following message:

When I select the automatic update of status. The first order is correctly updated but not the others (the message "batch update status" appears but the status remains the same and no email is sent)

 

Can you help me please?

 

no idea to solve this problem? It is quite embarrassing to have a contribution that does nto work correctly :(

Link to comment
Share on other sites

  • 3 weeks later...

I have been using the Batch Print Center, and find it to be a great tool. However, I wonder if someone may be able to help with the following:

 

We have modified the Picking Slip template to our needs, but would like to build in a little code, only into the template, that will only include Products (with their attributes) from a particular Manufacturer (say manufacturers_id == 2). If not that, then perhaps only include products from an order which have particular item numbers (2,3,4 and 9, for example) (that is less preferred).

 

This would basically create a Purchase Order Template, so I can see it would be useful to a great many stores.

 

Thanks in advance,

 

 

JM

Link to comment
Share on other sites

  • 1 month later...

So, does anyone use Batch Print center for printing their labels...?

 

I have noticed that there appears to be a mistake when printing labels (with the labels template), where the first label will be skipped. Just in case I just downloaded v3.12 which seems to be the last version I can find, installed from scratch, and tried it, and it is still behaving this way (I thought that maybe I had messed up too much with my templates or with Batch Print Center itself).

 

For example, if I try to print labels 448-453 (6 labels), on the created PDF I only have labels for 449-453. The lowest order is always skipped. If I try to print labels for 448,449,450,451,452,453, same thing, I will get 5 labels and 448 will be missing. If I try 449,450,448,451,452,453, 448 will still be missing. The number with the lowest number will always be skipped.

 

Could anyone with Batch Print Center confirm this please? The solution I am using at the moment is to add order 1 whenever I print labels (1,448-453, so 1 will be skipped). I have checked out the template and batch_print.php and I am unable to see where the mistake might be, I do not see anything wrong with the template and I would say that whatever is wrong should be on batch_print.php , but then when printing other templates like invoices the lowest order would also be skipped, which is not the case... :(

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

Ops, one more thing. Actually, it is not the lowest order that gets skipped... but the first one on each page. If you print let's say 4 pages of labels, you will be missing 4 labels, since the one that should go on the first place on each page will be skipped

(if you have 10 labels on each page, 44 labels for oders 1-44 would actually take 4 pages to print; labels for orders 1-12-23-34 will be missing)

MindTwist of Twisted Reality and Twisted Tienda

Link to comment
Share on other sites

I have just installed Batch Print Center and on first run I have this printed on the page below the title:

 

$orders_status['orders_status_id'], 'text' => $orders_status['orders_status_name']); $orders_status_array[$orders_status['orders_status_id']] = $orders_status['orders_status_name']; } ?> $file,'text' => $filename); } } ?>

 

The rest of the page displays but the pull-down menus are empty. I have traced it to the batch_print_body.php file where the order status array is developed, but I can't for the life of me get past it.

 

Any help or suggestions would be greatley appreciated.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...