$tsep = $SysPrefs->thoseps[user_tho_sep()];
$dsep = $SysPrefs->decseps[user_dec_sep()];
- if ($number == '')
- $number = 0;
+ $number = (float)$number;
if($decimals==='max')
$dec = 15 - floor(log10(abs($number)));
else {
$delta = ($number < 0 ? -.0000000001 : .0000000001);
- @$number += $delta;
+ $number += $delta;
$dec = $decimals;
}
PrepaidOrders
*/
function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter,
- $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT, $show_voided = 0)
+ $stock_item='', $from='', $to='', $ref='', $location=ALL_TEXT, $customer_id=ALL_TEXT, $show_voided = 0, $by_delivery=0, $no_auto=0)
{
if ($filter=='OutstandingOnly')
$order_value = 'Sum(line.unit_price*(line.quantity-line.qty_sent)*(1-line.discount_percent))+freight_cost';
{
$date_after = date2sql($from);
$date_before = date2sql($to);
-
- $sql .= " AND sorder.ord_date >= '$date_after'"
- ." AND sorder.ord_date <= '$date_before'";
+ $by_date = $by_delivery ? 'delivery_date' : 'ord_date';
+ $sql .= " AND sorder.$by_date >= '$date_after'"
+ ." AND sorder.$by_date <= '$date_before'";
}
+ if ($no_auto)
+ $sql .= " AND sorder.reference != 'auto'";
}
if ($trans_type == ST_SALESQUOTE && !check_value('show_all'))
$sql .= " AND sorder.delivery_date >= '".date2sql(Today())."' AND line.qty_sent=0"; // show only outstanding, not realized quotes
{
global $Ajax, $SysPrefs;
- if ((!isset($SysPrefs->no_check_edit_conflicts) || $SysPrefs->no_check_edit_conflicts==0) && $cart_id && isset($_SESSION[$cartname]) && $cart_id != $_SESSION[$cartname]->cart_id) {
+ if ((!isset($SysPrefs->no_check_edit_conflicts) || $SysPrefs->no_check_edit_conflicts==0) && $cart_id && isset($_SESSION[$cartname]) && $cart_id != $_SESSION[$cartname]->cart_id) {
display_error(_('This edit session has been abandoned by opening sales document in another browser tab. You cannot edit more than one sales document at once.'));
$Ajax->activate('_page_body');
display_footer_exit();
$_POST['ref'] = $Refs->get_next(ST_CUSTCREDIT, null, array('customer' => get_post('customer_id'),
'branch' => get_post('branch_id'), 'date' => get_post('OrderDate')));
if ($order->trans_no==0)
- ref_row(_("Reference").':', 'ref');
+ ref_row(_("Reference").':', 'ref', _('Reference number unique for this document type'), null, '', $order->trans_type, array('date'=> @$_POST['OrderDate']));
else
label_row(_("Reference").':', $order->reference);
start_row();
ref_cells(_("#:"), 'OrderNumber', '',null, '', true);
ref_cells(_("Ref"), 'OrderReference', '',null, '', true);
+
+if ($show_dates)
+ yesno_list_cells('', 'by_delivery', null, ($trans_type==ST_SALESORDER ? _("Delivery date") : _("Valid until")).':',
+ ($trans_type==ST_SALESORDER ? _("Order date") : _("Quotation date")).':');
+
if ($show_dates)
{
date_cells(_("from:"), 'OrdersAfterDate', '', null, -user_transaction_days());
date_cells(_("to:"), 'OrdersToDate', '', null, 1);
}
+
locations_list_cells(_("Location:"), 'StockLocation', null, true, true);
if($show_dates) {
check_cells(_("Show All:"), 'show_all');
if ($trans_type == ST_SALESORDER)
check_cells(_("Zero values"), 'show_voided');
+if ($show_dates && $trans_type == ST_SALESORDER)
+ check_cells(_("No auto"), 'no_auto');
+
submit_cells('SearchOrders', _("Search"),'',_('Select documents'), 'default');
hidden('order_view_mode', $_POST['order_view_mode']);
hidden('type', $trans_type);
// Orders inquiry table
//
$sql = get_sql_for_sales_orders_view($trans_type, get_post('OrderNumber'), get_post('order_view_mode'),
- get_post('SelectStockFromList'), get_post('OrdersAfterDate'), get_post('OrdersToDate'), get_post('OrderReference'), get_post('StockLocation'), get_post('customer_id'), check_value('show_voided'));
+ get_post('SelectStockFromList'), get_post('OrdersAfterDate'), get_post('OrdersToDate'), get_post('OrderReference'), get_post('StockLocation'), get_post('customer_id'), check_value('show_voided'),
+ get_post('by_delivery'), get_post('no_auto'));
if ($trans_type == ST_SALESORDER)
$cols = array(
if (isset($_GET['AddedID'])) {
$order_no = $_GET['AddedID'];
+
display_notification_centered(sprintf( _("Order # %d has been entered."),$order_no));
submenu_view(_("&View This Order"), ST_SALESORDER, $order_no);
submenu_option(_("Enter a &New Order"), "/sales/sales_order_entry.php?NewOrder=0");
+ $order = get_sales_order_header($order_no, ST_SALESORDER);
+ $customer_id = $order['debtor_no'];
+ if ($order['prep_amount'] > 0)
+ {
+ $row = db_fetch(db_query(get_allocatable_sales_orders($customer_id, $order_no, ST_SALESORDER)));
+ if ($row === false)
+ submenu_option(_("Receive Customer Payment"), "/sales/customer_payments.php?customer_id=$customer_id");
+ }
submenu_option(_("Add an Attachment"), "/admin/attachments.php?filterType=".ST_SALESORDER."&trans_no=$order_no");
display_footer_exit();