set_page_security( @$_POST['order_view_mode'],
array( 'OutstandingOnly' => 'SA_SALESDELIVERY',
- 'InvoiceTemplates' => 'SA_SALESINVOICE'),
+ 'InvoiceTemplates' => 'SA_SALESINVOICE',
+ 'DeliveryTemplates' => 'SA_SALESDELIVERY',
+ 'PrepaidOrders' => 'SA_SALESINVOICE'),
array( 'OutstandingOnly' => 'SA_SALESDELIVERY',
- 'InvoiceTemplates' => 'SA_SALESINVOICE')
+ 'InvoiceTemplates' => 'SA_SALESINVOICE',
+ 'DeliveryTemplates' => 'SA_SALESDELIVERY',
+ 'PrepaidOrders' => 'SA_SALESINVOICE')
);
if (get_post('type'))
$_POST['order_view_mode'] = 'DeliveryTemplates';
$_SESSION['page_title'] = _($help_context = "Select Template for Delivery");
}
+ elseif (isset($_GET['PrepaidOrders']) && ($_GET['PrepaidOrders'] == true))
+ {
+ $_POST['order_view_mode'] = 'PrepaidOrders';
+ $_SESSION['page_title'] = _($help_context = "Invoicing Prepayment Orders");
+ }
elseif (!isset($_POST['order_view_mode']))
{
$_POST['order_view_mode'] = false;
$_SESSION['page_title'] = _($help_context = "Search All Sales Quotations");
}
-if (!@$_GET['popup'])
-{
- $js = "";
- if ($use_popup_windows)
- $js .= get_js_open_window(900, 600);
- if ($use_date_picker)
- $js .= get_js_date_picker();
- page($_SESSION['page_title'], false, false, "", $js);
-}
+$js = "";
+if ($use_popup_windows)
+ $js .= get_js_open_window(900, 600);
+if ($use_date_picker)
+ $js .= get_js_date_picker();
+page($_SESSION['page_title'], false, false, "", $js);
if (isset($_GET['selected_customer']))
{
function edit_link($row)
{
- if (@$_GET['popup'])
+ global $page_nested;
+
+ if ($page_nested)
return '';
global $trans_type;
$modify = ($trans_type == ST_SALESORDER ? "ModifyOrderNumber" : "ModifyQuotationNumber");
function dispatch_link($row)
{
global $trans_type;
+
+ if ($row['ord_payments'] + $row['inv_payments'] < $row['prep_amount'])
+ return '';
+
if ($trans_type == ST_SALESORDER)
return pager_link( _("Dispatch"),
"/sales/customer_delivery.php?OrderNumber=" .$row['order_no'], ICON_DOC);
- else
+ else
return pager_link( _("Sales Order"),
"/sales/sales_order_entry.php?OrderNumber=" .$row['order_no'], ICON_DOC);
}
function tmpl_checkbox($row)
{
- global $trans_type;
+ global $trans_type, $page_nested;
if ($trans_type == ST_SALESQUOTE)
return '';
- if (@$_GET['popup'])
+
+ if ($page_nested)
return '';
$name = "chgtpl" .$row['order_no'];
$value = $row['type'] ? 1:0;
_('Set this order as a template for direct deliveries/invoices'))
. hidden('last['.$row['order_no'].']', $value, false);
}
+
+function invoice_prep_link($row)
+{
+ // invoicing should be available only for partially allocated orders
+ return
+ $row['inv_payments'] < $row['total'] ?
+ pager_link($row['ord_payments'] ? _("Prepayment Invoice") : _("Final Invoice"),
+ "/sales/customer_invoice.php?InvoicePrepayments=" .$row['order_no'], ICON_DOC) : '';
+}
+
//---------------------------------------------------------------------------------------------
// Update db record if respective checkbox value has changed.
//
$Ajax->activate('orders_tbl');
}
-if (!@$_GET['popup'])
- start_form();
+start_form();
start_table(TABLESTYLE_NOBORDER);
start_row();
ref_cells(_("Ref"), 'OrderReference', '',null, '', true);
if ($show_dates)
{
- date_cells(_("from:"), 'OrdersAfterDate', '', null, -30);
+ date_cells(_("from:"), 'OrdersAfterDate', '', null, -$_SESSION["wa_current_user"]->prefs->transaction_days());
date_cells(_("to:"), 'OrdersToDate', '', null, 1);
}
locations_list_cells(_("Location:"), 'StockLocation', null, true, true);
start_row();
}
stock_items_list_cells(_("Item:"), 'SelectStockFromList', null, true, true);
+
if (!@$_GET['popup'])
customer_list_cells(_("Select a customer: "), 'customer_id', null, true, true);
if ($trans_type == ST_SALESQUOTE)
_("Currency") => array('align'=>'center')
);
if ($_POST['order_view_mode'] == 'OutstandingOnly') {
- //array_substitute($cols, 4, 1, _("Cust Order Ref"));
+ //array_substitute($cols, 3, 1, _("Cust Order Ref"));
array_append($cols, array(
array('insert'=>true, 'fun'=>'dispatch_link'),
array('insert'=>true, 'fun'=>'edit_link')));
array_append($cols, array(
array('insert'=>true, 'fun'=>'delivery_link'))
);
+} else if ($_POST['order_view_mode'] == 'PrepaidOrders') {
+ array_append($cols, array(
+ array('insert'=>true, 'fun'=>'invoice_prep_link'))
+ );
} elseif ($trans_type == ST_SALESQUOTE) {
array_append($cols,array(
display_db_pager($table);
submit_center('Update', _("Update"), true, '', null);
-if (!@$_GET['popup'])
-{
- end_form();
- end_page();
-}
-?>
+end_form();
+end_page();