From e91772a2716825a6aeb358d1defba47d5f3892c1 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 22 Mar 2009 17:05:09 +0000 Subject: [PATCH] Save/retrieve last document date. --- gl/bank_account_reconcile.php | 4 ++-- gl/gl_bank.php | 3 ++- gl/gl_journal.php | 3 ++- gl/includes/ui/gl_bank_ui.inc | 2 +- gl/includes/ui/gl_journal_ui.inc | 2 +- includes/date_functions.inc | 13 +++++++++++++ includes/ui/ui_view.inc | 2 ++ inventory/adjustments.php | 4 ++-- inventory/includes/item_adjustments_ui.inc | 2 +- inventory/includes/stock_transfers_ui.inc | 2 +- inventory/transfers.php | 4 ++-- manufacturing/work_order_entry.php | 10 +++++----- purchasing/includes/ui/grn_ui.inc | 4 ++-- purchasing/includes/ui/invoice_ui.inc | 2 +- purchasing/includes/ui/po_ui.inc | 4 ++-- purchasing/po_entry_items.php | 4 ++-- purchasing/po_receive_items.php | 3 ++- purchasing/supplier_payment.php | 6 +++--- sales/credit_note_entry.php | 1 + sales/customer_credit_invoice.php | 5 +++-- sales/customer_delivery.php | 9 +++++---- sales/customer_invoice.php | 8 +++++--- sales/customer_payments.php | 6 ++++-- sales/includes/cart_class.inc | 2 +- sales/includes/db/sales_order_db.inc | 2 +- sales/includes/sales_db.inc | 2 +- sales/includes/ui/sales_credit_ui.inc | 2 +- sales/includes/ui/sales_order_ui.inc | 9 ++++----- sales/sales_order_entry.php | 4 ++-- 29 files changed, 74 insertions(+), 50 deletions(-) diff --git a/gl/bank_account_reconcile.php b/gl/bank_account_reconcile.php index a195292b..f4cfeceb 100644 --- a/gl/bank_account_reconcile.php +++ b/gl/bank_account_reconcile.php @@ -131,7 +131,7 @@ function change_tpl_flag($reconcile_id) } if (!isset($_POST['reconcile_date'])) { // init page - $_POST['reconcile_date'] = Today(); + $_POST['reconcile_date'] = new_doc_date(); // $_POST['bank_date'] = date2sql(Today()); } @@ -217,7 +217,7 @@ table_header($th); start_row(); date_cells("", "reconcile_date", _('Date of bank statement to reconcile'), - null, 0, 0, 0, null, true); + get_post('bank_date')=='', 0, 0, 0, null, true); amount_cells_ex("", "beg_balance", 15); diff --git a/gl/gl_bank.php b/gl/gl_bank.php index b9ce9882..fc6c50e6 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -121,7 +121,7 @@ function handle_new_order($type) $_SESSION['pay_items'] = new items_cart($type); - $_POST['date_'] = Today(); + $_POST['date_'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['date_'])) $_POST['date_'] = end_fiscalyear(); $_SESSION['pay_items']->tran_date = $_POST['date_']; @@ -180,6 +180,7 @@ if (isset($_POST['Process'])) $trans_type = $trans[0]; $trans_no = $trans[1]; + new_doc_date($_POST['date_']); $_SESSION['pay_items']->clear_items(); unset($_SESSION['pay_items']); diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 8b178118..5a77bb84 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -66,7 +66,7 @@ function handle_new_order() $_SESSION['journal_items'] = new items_cart(systypes::journal_entry()); - $_POST['date_'] = Today(); + $_POST['date_'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['date_'])) $_POST['date_'] = end_fiscalyear(); $_SESSION['journal_items']->tran_date = $_POST['date_']; @@ -128,6 +128,7 @@ if (isset($_POST['Process'])) $_POST['date_'], $_POST['ref'], check_value('Reverse'), $_POST['memo_']); $_SESSION['journal_items']->clear_items(); + new_doc_date($_POST['date_']); unset($_SESSION['journal_items']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$trans_no"); diff --git a/gl/includes/ui/gl_bank_ui.inc b/gl/includes/ui/gl_bank_ui.inc index 561c677a..3af6202c 100644 --- a/gl/includes/ui/gl_bank_ui.inc +++ b/gl/includes/ui/gl_bank_ui.inc @@ -22,7 +22,7 @@ function display_bank_header(&$order) bank_accounts_list_row( $payment ? _("From:") : _("To:"), 'bank_account', null, true); - date_row(_("Date:"), 'date_', '', null, 0, 0, 0, null, true); + date_row(_("Date:"), 'date_', '', true, 0, 0, 0, null, true); table_section(2, "33%"); diff --git a/gl/includes/ui/gl_journal_ui.inc b/gl/includes/ui/gl_journal_ui.inc index bc68af7c..e769d36f 100644 --- a/gl/includes/ui/gl_journal_ui.inc +++ b/gl/includes/ui/gl_journal_ui.inc @@ -24,7 +24,7 @@ function display_order_header(&$Order) table_section(1); start_row(); - date_cells(_("Date:"), 'date_'); + date_cells(_("Date:"), 'date_', '', true); ref_cells(_("Reference:"), 'ref', '', references::get_next(0)); end_row(); diff --git a/includes/date_functions.inc b/includes/date_functions.inc index c6813531..227a0b34 100644 --- a/includes/date_functions.inc +++ b/includes/date_functions.inc @@ -141,6 +141,19 @@ function Now() else return date("H:i"); } +// +// Retrieve and optionaly set default date for new document. +// +function new_doc_date($date=null) +{ + if (isset($date)) + $_SESSION['_default_date'] = $date; + + if (!isset($_SESSION['_default_date']) || !sticky_doc_date()) + $_SESSION['_default_date'] = Today(); + + return $_SESSION['_default_date']; +} function is_date_in_fiscalyear($date, $convert=false) { diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index d1262f12..98af52cc 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -877,6 +877,8 @@ function CC() { $js .= " dateField.value = dateString; setFocus(dateField.name); + if(dateField.getAttribute('aspect')=='cdate') + setElementProperty('color', (dateField.value==user.date ? 'black':'red'), dateField); if (dateField.className=='searchbox') dateField.onblur(); hide(); diff --git a/inventory/adjustments.php b/inventory/adjustments.php index e1ce7024..5a9f95d6 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -70,7 +70,7 @@ function handle_new_order() session_register("adj_items"); $_SESSION['adj_items'] = new items_cart(systypes::inventory_adjustment()); - $_POST['AdjDate'] = Today(); + $_POST['AdjDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['AdjDate'])) $_POST['AdjDate'] = end_fiscalyear(); $_SESSION['adj_items']->tran_date = $_POST['AdjDate']; @@ -134,7 +134,7 @@ if (isset($_POST['Process']) && can_process()){ $trans_no = add_stock_adjustment($_SESSION['adj_items']->line_items, $_POST['StockLocation'], $_POST['AdjDate'], $_POST['type'], $_POST['Increase'], $_POST['ref'], $_POST['memo_']); - + new_doc_date($_POST['AdjDate']); $_SESSION['adj_items']->clear_items(); unset($_SESSION['adj_items']); diff --git a/inventory/includes/item_adjustments_ui.inc b/inventory/includes/item_adjustments_ui.inc index 8c115bd3..8812438e 100644 --- a/inventory/includes/item_adjustments_ui.inc +++ b/inventory/includes/item_adjustments_ui.inc @@ -36,7 +36,7 @@ function display_order_header(&$order) table_section(2, "33%"); - date_row(_("Date:"), 'AdjDate'); + date_row(_("Date:"), 'AdjDate', '', true); table_section(3, "33%"); diff --git a/inventory/includes/stock_transfers_ui.inc b/inventory/includes/stock_transfers_ui.inc index 729f8c7a..6f3d307e 100644 --- a/inventory/includes/stock_transfers_ui.inc +++ b/inventory/includes/stock_transfers_ui.inc @@ -39,7 +39,7 @@ function display_order_header(&$order) ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::location_transfer())); - date_row(_("Date:"), 'AdjDate'); + date_row(_("Date:"), 'AdjDate', '', true); table_section(3, "33%"); diff --git a/inventory/transfers.php b/inventory/transfers.php index b3d91338..b3115589 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -68,7 +68,7 @@ function handle_new_order() session_register("transfer_items"); $_SESSION['transfer_items'] = new items_cart(systypes::location_transfer()); - $_POST['AdjDate'] = Today(); + $_POST['AdjDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['AdjDate'])) $_POST['AdjDate'] = end_fiscalyear(); $_SESSION['transfer_items']->tran_date = $_POST['AdjDate']; @@ -143,7 +143,7 @@ if (isset($_POST['Process'])) $trans_no = add_stock_transfer($_SESSION['transfer_items']->line_items, $_POST['FromStockLocation'], $_POST['ToStockLocation'], $_POST['AdjDate'], $_POST['type'], $_POST['ref'], $_POST['memo_']); - + new_doc_date($_POST['AdjDate']); $_SESSION['transfer_items']->clear_items(); unset($_SESSION['transfer_items']); diff --git a/manufacturing/work_order_entry.php b/manufacturing/work_order_entry.php index bcbfd00a..a0282ed2 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -100,7 +100,7 @@ function safe_exit() //------------------------------------------------------------------------------------- if (!isset($_POST['date_'])) { - $_POST['date_'] = Today(); + $_POST['date_'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['date_'])) $_POST['date_'] = end_fiscalyear(); } @@ -239,7 +239,7 @@ if (isset($_POST['ADD_ITEM']) && can_process()) $id = add_work_order($_POST['wo_ref'], $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['type'], $_POST['date_'], $_POST['RequDate'], input_num('Costs'), $_POST['memo_']); - + new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$id"); } @@ -250,7 +250,7 @@ if (isset($_POST['UPDATE_ITEM']) && can_process()) update_work_order($selected_id, $_POST['StockLocation'], input_num('quantity'), $_POST['stock_id'], $_POST['date_'], $_POST['RequDate'], $_POST['memo_']); - + new_doc_date($_POST['date_']); meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$selected_id"); } @@ -382,13 +382,13 @@ if (get_post('type') == wo_types::advanced()) qty_row(_("Quantity Required:"), 'quantity', null, null, null, $dec); if ($_POST['released']) label_row(_("Quantity Manufactured:"), number_format($_POST['units_issued'], get_qty_dec($_POST['stock_id']))); - date_row(_("Date") . ":", 'date_'); + date_row(_("Date") . ":", 'date_', '', true); date_row(_("Date Required By") . ":", 'RequDate', '', null, sys_prefs::default_wo_required_by()); } else { qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); - date_row(_("Date") . ":", 'date_'); + date_row(_("Date") . ":", 'date_', '', true); hidden('RequDate', ''); if (!isset($_POST['Costs'])) diff --git a/purchasing/includes/ui/grn_ui.inc b/purchasing/includes/ui/grn_ui.inc index 2fe18c15..539fc5f3 100644 --- a/purchasing/includes/ui/grn_ui.inc +++ b/purchasing/includes/ui/grn_ui.inc @@ -42,9 +42,9 @@ function display_grn_summary(&$po, $editable=false) locations_list_cells(null, "Location", $_POST['Location']); if (!isset($_POST['DefaultReceivedDate'])) - $_POST['DefaultReceivedDate'] = Today(); + $_POST['DefaultReceivedDate'] = new_doc_date(); - date_cells(_("Date Items Received"), 'DefaultReceivedDate', '', null, 0, 0, 0, "class='tableheader2'"); + date_cells(_("Date Items Received"), 'DefaultReceivedDate', '', true, 0, 0, 0, "class='tableheader2'"); } else diff --git a/purchasing/includes/ui/invoice_ui.inc b/purchasing/includes/ui/invoice_ui.inc index 14d02889..d17a676d 100644 --- a/purchasing/includes/ui/invoice_ui.inc +++ b/purchasing/includes/ui/invoice_ui.inc @@ -101,7 +101,7 @@ function invoice_header(&$supp_trans) table_section(2, "33%"); - date_row(_("Date") . ":", 'tran_date', '', null, 0, 0, 0, "", true); + date_row(_("Date") . ":", 'tran_date', '', true, 0, 0, 0, "", true); if (isset($_POST['_tran_date_changed'])) { $Ajax->activate('_ex_rate'); $supp_trans->tran_date = $_POST['tran_date']; diff --git a/purchasing/includes/ui/po_ui.inc b/purchasing/includes/ui/po_ui.inc index 2b3d639b..336b8a6e 100644 --- a/purchasing/includes/ui/po_ui.inc +++ b/purchasing/includes/ui/po_ui.inc @@ -40,7 +40,7 @@ function create_new_po() session_register("PO"); $_SESSION['PO'] = new purch_order; - $_POST['OrderDate'] = Today(); + $_POST['OrderDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['OrderDate'])) $_POST['OrderDate'] = end_fiscalyear(); $_SESSION['PO']->orig_order_date = $_POST['OrderDate']; @@ -109,7 +109,7 @@ function display_po_header(&$order) // if (!is_date_in_fiscalyear($_POST['OrderDate'])) // $_POST['OrderDate'] = end_fiscalyear(); //} - date_row(_("Order Date:"), 'OrderDate', '', $_POST['OrderDate'], 0, 0, 0, null, true); + date_row(_("Order Date:"), 'OrderDate', '', true, 0, 0, 0, null, true); if (isset($_POST['_OrderDate_changed'])) { $Ajax->activate('_ex_rate'); } diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index c17dccaa..2ab43bb7 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -340,7 +340,7 @@ function handle_commit_order() /*its a new order to be inserted */ $order_no = add_po($_SESSION['PO']); - + new_doc_date($_SESSION['PO']->orig_order_date); unset($_SESSION['PO']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$order_no"); @@ -387,7 +387,7 @@ if (isset($_GET['ModifyOrderNumber']) && $_GET['ModifyOrderNumber'] != "") /*read in all the selected order into the Items cart */ read_po($_SESSION['PO']->order_no, $_SESSION['PO']); - + copy_from_cart(); } diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index 7b50b4da..4029dfc1 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -248,6 +248,7 @@ function process_receive_po() $grn = add_grn($_SESSION['PO'], $_POST['DefaultReceivedDate'], $_POST['ref'], $_POST['Location']); + new_doc_date($_POST['DefaultReceivedDate']); unset($_SESSION['PO']->line_items); unset($_SESSION['PO']); @@ -280,7 +281,7 @@ if (isset($_POST['Update']) || isset($_POST['ProcessGoodsReceived'])) $_POST[$line->line_no] = number_format2(0, get_qty_dec($line->stock_id)); if (!isset($_POST['DefaultReceivedDate']) || $_POST['DefaultReceivedDate'] == "") - $_POST['DefaultReceivedDate'] = Today(); + $_POST['DefaultReceivedDate'] = new_doc_date(); $_SESSION['PO']->line_items[$line->line_no]->receive_qty = input_num($line->line_no); diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index df057e28..30cd4bb6 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -79,7 +79,7 @@ function display_controls() $_POST['supplier_id'] = get_global_supplier(false); if (!isset($_POST['DatePaid'])) { - $_POST['DatePaid'] = Today(); + $_POST['DatePaid'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['DatePaid'])) $_POST['DatePaid'] = end_fiscalyear(); } @@ -95,7 +95,7 @@ function display_controls() amount_row(_("Amount of Payment:"), 'amount'); amount_row(_("Amount of Discount:"), 'discount'); - date_row(_("Date Paid") . ":", 'DatePaid', '', null, 0, 0, 0, null, true); + date_row(_("Date Paid") . ":", 'DatePaid', '', true, 0, 0, 0, null, true); table_section(2); //echo ""; @@ -218,7 +218,7 @@ function handle_add_payment() $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['bank_account'], input_num('amount'), input_num('discount'), $_POST['ref'], $_POST['memo_'], $rate); - + new_doc_date($_POST['DatePaid']); //unset($_POST['supplier_id']); unset($_POST['bank_account']); unset($_POST['DatePaid']); diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index a33f3407..f27bf8f0 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -180,6 +180,7 @@ if (isset($_POST['ProcessCredit']) && can_process()) { } copy_to_cn(); $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']); + new_doc_date($_SESSION['Items']->document_date); processing_end(); meta_forward($_SERVER['PHP_SELF'], "AddedID=$credit_no"); diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index 2d13e547..70f244fa 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -126,7 +126,7 @@ if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0) { $ci->src_docs = $ci->trans_no; $ci->src_date = $ci->document_date; $ci->trans_no = 0; - $ci->document_date = Today(); + $ci->document_date = new_doc_date(); $ci->reference = references::get_next(11); for ($line_no=0; $line_noline_items); $line_no++) { @@ -207,6 +207,7 @@ if (isset($_POST['ProcessCredit']) && can_process()) { $_POST['WriteOffGLCode'] = 0; copy_to_cart(); + if ($new_credit) new_doc_date($_SESSION['Items']->document_date); $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']); processing_end(); @@ -273,7 +274,7 @@ function display_credit_items() label_row(_("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'"); - date_row(_("Credit Note Date"), 'CreditDate', '', null, 0, 0, 0, "class='tableheader2'"); + date_row(_("Credit Note Date"), 'CreditDate', '', $_SESSION['Items']->trans_no==0, 0, 0, 0, "class='tableheader2'"); end_table(); diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index f7793338..9d710729 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -96,7 +96,7 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { $ord->order_no = key($ord->trans_no); $ord->trans_no = 0; $ord->reference = references::get_next(13); - $ord->document_date = Today(); + $ord->document_date = new_doc_date(); $_SESSION['Items'] = $ord; copy_from_cart(); @@ -293,6 +293,7 @@ if (isset($_POST['process_delivery']) && check_data() && check_qoh()) { $newdelivery = ($dn->trans_no == 0); copy_to_cart(); + if ($new_delivery) new_doc_date($dn->document_date); $delivery_no = $dn->write($bo_policy); processing_end(); @@ -350,12 +351,12 @@ shippers_list_cells(null, 'ship_via', $_POST['ship_via']); // set this up here cuz it's used to calc qoh if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) { - $_POST['DispatchDate'] = Today(); + $_POST['DispatchDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['DispatchDate'])) { $_POST['DispatchDate'] = end_fiscalyear(); } } -date_cells(_("Date"), 'DispatchDate', '', $_POST['DispatchDate'], 0, 0, 0, "class='tableheader2'"); +date_cells(_("Date"), 'DispatchDate', '', $_SESSION['Items']->trans_no==0, 0, 0, 0, "class='tableheader2'"); end_row(); end_table(); @@ -367,7 +368,7 @@ start_table("$table_style width=90%"); if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->customer_id, $_POST['DispatchDate']); } -date_row(_("Invoice Dead-line"), 'due_date', '', $_POST['due_date'], 0, 0, 0, "class='tableheader2'"); +date_row(_("Invoice Dead-line"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'"); end_table(); echo ""; diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index 6c43ef22..b0bdbd65 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -298,6 +298,7 @@ if (isset($_POST['process_invoice']) && check_data()) { $newinvoice= $_SESSION['Items']->trans_no == 0; copy_to_cart(); + if ($new_invoice) new_doc_date($_SESSION['Items']->document_date); $invoice_no = $_SESSION['Items']->write(); processing_end(); @@ -367,19 +368,20 @@ label_cell(_("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ship_via', $_POST['ship_via']); if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) { - $_POST['InvoiceDate'] = Today(); + $_POST['InvoiceDate'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['InvoiceDate'])) { $_POST['InvoiceDate'] = end_fiscalyear(); } } -date_cells(_("Date"), 'InvoiceDate', '', $_POST['InvoiceDate'], 0, 0, 0, "class='tableheader2'", true); +date_cells(_("Date"), 'InvoiceDate', '', $_SESSION['Items']->trans_no == 0, + 0, 0, 0, "class='tableheader2'", true); if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->customer_id, $_POST['InvoiceDate']); } -date_cells(_("Due Date"), 'due_date', '', $_POST['due_date'], 0, 0, 0, "class='tableheader2'"); +date_cells(_("Due Date"), 'due_date', '', null, 0, 0, 0, "class='tableheader2'"); end_row(); end_table(); diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 4f232a9a..cd7d7dc3 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -148,6 +148,8 @@ if (isset($_POST['AddPaymentItem'])) { else $rate = input_num('_ex_rate'); + new_doc_date($_POST['DateBanked']); + $payment_no = write_customer_payment(0, $_POST['customer_id'], $_POST['BranchID'], $_POST['bank_account'], $_POST['DateBanked'], $_POST['ref'], input_num('amount'), input_num('discount'), $_POST['memo_'], $rate); @@ -185,7 +187,7 @@ function display_item_form() if (!isset($_POST['customer_id'])) $_POST['customer_id'] = get_global_customer(false); if (!isset($_POST['DateBanked'])) { - $_POST['DateBanked'] = Today(); + $_POST['DateBanked'] = new_doc_date(); if (!is_date_in_fiscalyear($_POST['DateBanked'])) { $_POST['DateBanked'] = end_fiscalyear(); } @@ -212,7 +214,7 @@ function display_item_form() label_row(_("Customer prompt payment discount :"), $display_discount_percent); - date_row(_("Date of Deposit:"), 'DateBanked','',null, 0, 0, 0, null, true); + date_row(_("Date of Deposit:"), 'DateBanked', '', true, 0, 0, 0, null, true); table_section(2); diff --git a/sales/includes/cart_class.inc b/sales/includes/cart_class.inc index 286ada11..f388b54c 100644 --- a/sales/includes/cart_class.inc +++ b/sales/includes/cart_class.inc @@ -151,7 +151,7 @@ class cart $this->customer_id = get_global_customer(); else $this->customer_id = ''; - $this->document_date = Today(); + $this->document_date = new_doc_date(); if (!is_date_in_fiscalyear($this->document_date)) $this->document_date = end_fiscalyear(); $this->reference = references::get_next($this->trans_type); diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index 7d650280..ef66b0b7 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -434,7 +434,7 @@ function get_invoice_duedate($debtorno, $invdate) { if (!is_date($invdate)) { - return Today(); + return new_doc_date(); } $sql = "SELECT ".TB_PREF."debtors_master.debtor_no, ".TB_PREF."debtors_master.payment_terms, ".TB_PREF."payment_terms.* FROM ".TB_PREF."debtors_master, ".TB_PREF."payment_terms WHERE ".TB_PREF."debtors_master.payment_terms = ".TB_PREF."payment_terms.terms_indicator AND diff --git a/sales/includes/sales_db.inc b/sales/includes/sales_db.inc index 4a746940..0533babe 100644 --- a/sales/includes/sales_db.inc +++ b/sales/includes/sales_db.inc @@ -60,7 +60,7 @@ function add_gl_trans_customer($type, $type_no, $date_, $account, $dimension, $d function get_price ($stock_id, $currency, $sales_type_id, $factor=null, $date=null) { if ($date == null) - $date = Today(); + $date = new_doc_date(); if ($factor === null) { diff --git a/sales/includes/ui/sales_credit_ui.inc b/sales/includes/ui/sales_credit_ui.inc index d27fd0a9..dba384df 100644 --- a/sales/includes/ui/sales_credit_ui.inc +++ b/sales/includes/ui/sales_credit_ui.inc @@ -120,7 +120,7 @@ function display_credit_header(&$order) if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") $_POST['OrderDate'] = $order->document_date; - date_row(_("Date:"), 'OrderDate', '', null, 0, 0, 0, null, true); + date_row(_("Date:"), 'OrderDate', '', $order->trans_no==0, 0, 0, 0, null, true); if (isset($_POST['_OrderDate_changed'])) { if (!is_company_currency($order->customer_currency) && (get_base_sales_type()>0)) { diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 28b079cd..6665f468 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -375,8 +375,8 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group if (!isset($_POST['OrderDate']) || $_POST['OrderDate'] == "") $_POST['OrderDate'] = $order->document_date; - date_row($date_text, 'OrderDate', - _('Date of order receive'), null, 0, 0, 0, null, true); + date_row($date_text, 'OrderDate', _('Date of order receive'), + $order->trans_no==0, 0, 0, 0, null, true); if (isset($_POST['_OrderDate_changed'])) { if (!is_company_currency($order->customer_currency) && (get_base_sales_type()>0)) { @@ -553,10 +553,9 @@ function display_delivery_details(&$order) false, true); if (list_updated('Location')) check_qoh($order); - +// $_POST['delivery_date'] = get_post('delivery_date', $order->due_date); date_row($delname, 'delivery_date', - $order->trans_type==30 ? _('Enter requested day of delivery') : '', - $order->due_date, 0, 0, 0); + $order->trans_type==30 ? _('Enter requested day of delivery') : ''); text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 40, 40, _('Additional identifier for delivery e.g. name of receiving person')); diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index fcec49da..c63e0f2f 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -307,7 +307,7 @@ if (isset($_POST['ProcessOrder']) && can_process()) { } $trans_no = key($_SESSION['Items']->trans_no); $trans_type = $_SESSION['Items']->trans_type; - + new_doc_date($_SESSION['Items']->document_date); processing_end(); if ($modified) { meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$trans_no"); @@ -445,7 +445,7 @@ function create_cart($type, $trans_no) $doc = new Cart(30, array($trans_no)); $doc->trans_type = $type; $doc->trans_no = 0; - $doc->document_date = Today(); // 2006-06-15. Added so Invoices and Deliveries get current day + $doc->document_date = new_doc_date(); if ($type == 10) { $doc->due_date = get_invoice_duedate($doc->customer_id, $doc->document_date); $doc->pos = user_pos(); -- 2.30.2