}
if (!isset($_POST['reconcile_date'])) { // init page
- $_POST['reconcile_date'] = Today();
+ $_POST['reconcile_date'] = new_doc_date();
// $_POST['bank_date'] = date2sql(Today());
}
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);
$_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_'];
$trans_type = $trans[0];
$trans_no = $trans[1];
+ new_doc_date($_POST['date_']);
$_SESSION['pay_items']->clear_items();
unset($_SESSION['pay_items']);
$_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_'];
$_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");
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%");
table_section(1);
start_row();
- date_cells(_("Date:"), 'date_');
+ date_cells(_("Date:"), 'date_', '', true);
ref_cells(_("Reference:"), 'ref', '', references::get_next(0));
end_row();
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)
{
$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();
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'];
$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']);
table_section(2, "33%");
- date_row(_("Date:"), 'AdjDate');
+ date_row(_("Date:"), 'AdjDate', '', true);
table_section(3, "33%");
ref_row(_("Reference:"), 'ref', '', references::get_next(systypes::location_transfer()));
- date_row(_("Date:"), 'AdjDate');
+ date_row(_("Date:"), 'AdjDate', '', true);
table_section(3, "33%");
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'];
$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']);
//-------------------------------------------------------------------------------------
if (!isset($_POST['date_']))
{
- $_POST['date_'] = Today();
+ $_POST['date_'] = new_doc_date();
if (!is_date_in_fiscalyear($_POST['date_']))
$_POST['date_'] = end_fiscalyear();
}
$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");
}
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");
}
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']))
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
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'];
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'];
// 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');
}
/*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");
/*read in all the selected order into the Items cart */
read_po($_SESSION['PO']->order_no, $_SESSION['PO']);
-
+
copy_from_cart();
}
$grn = add_grn($_SESSION['PO'], $_POST['DefaultReceivedDate'],
$_POST['ref'], $_POST['Location']);
+ new_doc_date($_POST['DefaultReceivedDate']);
unset($_SESSION['PO']->line_items);
unset($_SESSION['PO']);
$_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);
$_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();
}
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 "</table>";
$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']);
}
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");
$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_no<count($ci->line_items); $line_no++) {
$_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();
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();
$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();
$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();
// 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();
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 "</td></tr>";
$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();
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();
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);
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();
}
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);
$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);
{
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
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)
{
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)) {
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)) {
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'));
}
$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");
$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();