= '$date_after'";
$sql .= " AND ".TB_PREF."debtor_trans.tran_date <= '$date_before'";
if ($selected_customer != -1)
$sql .= " AND ".TB_PREF."debtor_trans.debtor_no='" . $selected_customer . "' ";
if (isset($selected_stock_item))
$sql .= " AND ".TB_PREF."debtor_trans_details.stock_id='". $selected_stock_item ."' ";
if (isset($_POST['StockLocation']) && $_POST['StockLocation'] != reserved_words::get_all())
$sql .= " AND ".TB_PREF."sales_orders.from_stk_loc = '". $_POST['StockLocation'] . "' ";
if ($_POST['OutstandingOnly'] == true) {
$sql .= " AND ".TB_PREF."debtor_trans_details.qty_done < ".TB_PREF."debtor_trans_details.quantity ";
}
$sql .= " GROUP BY ".TB_PREF."debtor_trans.trans_no ";
// .TB_PREF."debtor_trans.debtor_no, "
// .TB_PREF."debtor_trans.branch_code, "
// ".TB_PREF."sales_orders.customer_ref, "
// .TB_PREF."debtor_trans.tran_date";
} //end no delivery number selected
$result = db_query($sql,"No deliveries were returned");
//-----------------------------------------------------------------------------------
if (isset($_SESSION['Batch']))
{
foreach($_SESSION['Batch'] as $trans=>$del)
unset($_SESSION['Batch'][$trans]);
unset($_SESSION['Batch']);
}
if ($result)
{
/*show a table of the deliveries returned by the sql */
start_table("$table_style colspan=7 width=95%");
$th = array(_("Delivery #"), _("Customer"), _("Branch"), _("Reference"), _("Delivery Date"),
_("Due By"), _("Delivery Total"), _("Currency"), submit('BatchInvoice','Batch Inv', false),
"", "", "");
table_header($th);
$j = 1;
$k = 0; //row colour counter
$overdue_items = false;
while ($myrow = db_fetch($result))
{
$_SESSION['Batch'][] = array('trans'=>$myrow["trans_no"],
'cust'=>$myrow["name"],'branch'=>$myrow["br_name"] );
$view_page = get_customer_trans_view_str(13, $myrow["trans_no"]);
$formated_del_date = sql2date($myrow["tran_date"]);
$formated_due_date = sql2date($myrow["due_date"]);
$not_closed = $myrow["Outstanding"]!=0;
// if overdue orders, then highlight as so
if (date1_greater_date2(Today(), $formated_due_date) && $not_closed )
{
start_row("class='overduebg'");
$overdue_items = true;
}
else
{
alt_table_row_color($k);
}
label_cell($view_page);
label_cell($myrow["name"]);
label_cell($myrow["br_name"]);
label_cell($myrow["reference"]);
label_cell($formated_del_date);
label_cell($formated_due_date);
amount_cell($myrow["DeliveryValue"]);
label_cell($myrow["curr_code"]);
if (!$myrow['Done'])
check_cells(null,'Sel_'. $myrow['trans_no'],0,false);
else
label_cell("");
if ($_POST['OutstandingOnly'] == true || $not_closed)
{
$modify_page = $path_to_root . "/sales/customer_delivery.php?" . SID . "ModifyDelivery=" . $myrow["trans_no"];
$invoice_page = $path_to_root . "/sales/customer_invoice.php?" . SID . "DeliveryNumber=" .$myrow["trans_no"];
label_cell("" . _("Edit") . "");
label_cell(print_document_link($myrow['trans_no'], _("Print")));
label_cell($not_closed ? "" . _("Invoice") . "" : '');
}
else
{
label_cell("");
label_cell("");
label_cell("");
}
end_row();;
$j++;
If ($j == 12)
{
$j = 1;
table_header($th);
}
//end of page full new headings if
}
//end of while loop
end_table();
if ($overdue_items)
display_note(_("Marked items are overdue."), 0, 1, "class='overduefg'");
}
echo "
";
end_form();
end_page();
?>