Jump to content

Problem with Scripting, novice in PHP is what the real problem is


Recommended Posts

Here is what this does, its to select multiple items to batch print in an Oscommerce store. It is supposed to read the Order IDs and store them. What I have done is changed this to allow for printing the invoice or the packing list, but now its not showing but the first selected order. I have a feeling that what I did was moved the code around to add the If statement for to allow selecting for Batch Packing slip printing also.  Here is the code that I messed with.
[code=php:0]
if($target_file == "packingslip") {
include('print_batch_packing_slip.php');
} else {
include('print_batch_invoice.php');
[/code]
I also moved some of the other php tags around, and I have a feeling that something is no longer in the php tags to allow it to know how many orders are actually selected and this is why it is working, but only showing the first order.  Any help would be greatly apreciated.

So somewhere in the code I have screwed up the ability of it to select multiple orders for printing. I am not sure how to fix this, if someone could please help me.
[code]
<?php
/*

batch-invoice-printing-v1.1
2004-12-18
by PandA.nl

*/

require('includes/application_top.php');
require(DIR_WS_CLASSES . 'currencies.php');
include(DIR_WS_CLASSES . 'order.php');

$target_file = $HTTP_POST_VARS['target_file'];

unset($batch_order_numbers);
if($HTTP_POST_VARS['batch_order_numbers']){
foreach($HTTP_POST_VARS['batch_order_numbers'] as $order_number => $print_order) {
$batch_order_numbers[] = $order_number;
}
}

// begin error handling
if (!(is_array($batch_order_numbers))){
exit('Error: no orders selected!');
}

//if (!(is_file($target_file))){
//exit('Error: target file does not exist!');
//}

// end error handling

sort($batch_order_numbers);
$number_of_orders = sizeof ($batch_order_numbers);


;?>
<!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><?php echo TITLE . $autostatus; ?></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">

<?php
$firstinvoice=1;


foreach ($batch_order_numbers as $order_number) {
if($firstinvoice) {
$firstinvoice = 0;
} else {
echo '<br style="page-break-before:always;">';
}
}
$oID = $order_number;
if($target_file == "packingslip") {
include('print_batch_packing_slip.php');
} else {
include('print_batch_invoice.php');
}

if($autoupdatestatus=='Yes') {
tep_db_query("insert into " . TABLE_ORDERS_STATUS_HISTORY . " (orders_id, orders_status_id, date_added, customer_notified, comments) values ('" . (int)$oID . "', '" . tep_db_input($autostatus) . "', now(), '" . tep_db_input('0') . "', '" . tep_db_input('') . "')");
tep_db_query("update orders SET orders_status='" . tep_db_input($autostatus) . "' WHERE orders_id='" .$oID . "'");
}

?>
</BODY></HTML>
<?php

require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
[/code]


Sorry but we all have to learn somewhere.  So I am trying to learn this, and working through it myself, I found out that with this one, I got a little over my head I think.

Bryan
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.