PHP 8 rerun of number_format fix. master github/master
authorJoe <joe.hunt.consulting@gmail.com>
Thu, 16 May 2024 08:07:55 +0000 (10:07 +0200)
committerJoe <joe.hunt.consulting@gmail.com>
Thu, 16 May 2024 08:07:55 +0000 (10:07 +0200)
includes/current_user.inc
sales/includes/db/sales_order_db.inc
sales/includes/sales_ui.inc
sales/includes/ui/sales_credit_ui.inc
sales/inquiry/sales_orders_view.php
sales/sales_order_entry.php

index ac5f943e49c36db9d6b74c30dd71056ccf56021d..bb7478cd119b348bd8fcd819065b6a9f8d73c7e8 100644 (file)
@@ -313,13 +313,12 @@ function number_format2($number, $decimals=0)
        $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;
        }
 
index f2c62840cc8d7fb7ef9c34789a6136a0295b3d9d..a8be2045f062878dc77b9b87f93c87292792c63f 100644 (file)
@@ -465,7 +465,7 @@ function get_branch_to_order($customer_id, $branch_id) {
        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';
@@ -530,10 +530,12 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter,
                {
                        $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
index 9b7626218bbba6ac8d8c94ecfaa1732ab8679b5a..5da08723429a547eaa8d3527459f545e20ab0974 100644 (file)
@@ -46,7 +46,7 @@ function check_edit_conflicts($cart_id, $cartname='Items')
 {
        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();
index 9d9223f405e79dbbdcef86c8f8862963da57e180..19b76c6d843a9406f8a7080c6d4e9c43fa89d2bb 100644 (file)
@@ -78,7 +78,7 @@ function display_credit_header(&$order)
                $_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);
 
index c3e63ab5ff839e51bafe30bfeb1859ce56a23f4a..3873114bc167b3417216385d8c220791c744ddce 100644 (file)
@@ -232,11 +232,17 @@ start_table(TABLESTYLE_NOBORDER);
 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) {
@@ -254,6 +260,9 @@ if ($trans_type == ST_SALESQUOTE)
        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);
@@ -265,7 +274,8 @@ end_table(1);
 //     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(
index 85985fb11a7c1b9cbed5188bc92879d04dc7fa20..6318b4fd216a597b9c22054df30402cd43912c48 100644 (file)
@@ -122,6 +122,7 @@ if (list_updated('branch_id')) {
 
 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);
@@ -137,6 +138,14 @@ if (isset($_GET['AddedID'])) {
 
        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();