Sales/purchase terms update after document date change [0000058].
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 21 Sep 2008 14:50:16 +0000 (14:50 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 21 Sep 2008 14:50:16 +0000 (14:50 +0000)
purchasing/includes/ui/invoice_ui.inc
purchasing/includes/ui/po_ui.inc
sales/customer_invoice.php

index 85ef98d053a6db3c9dec4c2cfd72551621bdb8dd..2b60ae37386a6048156a610d3788a3981048bfeb 100644 (file)
@@ -44,6 +44,8 @@ function copy_to_trans(&$supp_trans)
 
 function invoice_header(&$supp_trans)
 {
+       global $Ajax;
+       
        // if vars have been lost, recopy
        if (!isset($_POST['tran_date']))
                copy_from_trans($supp_trans);
@@ -83,6 +85,13 @@ function invoice_header(&$supp_trans)
        echo "<table width=100%>";
 
        date_row(_("Date") . ":", 'tran_date', '', null, 0, 0, 0, "", true);
+       if (isset($_POST['_tran_date_changed'])) {
+               $Ajax->activate('_ex_rate');
+               $supp_trans->tran_date = $_POST['tran_date'];
+               get_duedate_from_terms($supp_trans);
+               $_POST['due_date'] = $supp_trans->due_date;
+               $Ajax->activate('due_date');
+       }
 
     date_row(_("Due Date") . ":", 'due_date');
 
index b4438da608d7f066c1ee9797521bb9d6f75645d9..f9e820b9c97012d576db0020c41dc33950183dbe 100644 (file)
@@ -104,7 +104,10 @@ 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);
+       date_row(_("Order Date:"), 'OrderDate', '', $_POST['OrderDate'], 0, 0, 0, null, true);
+       if (isset($_POST['_OrderDate_changed'])) {
+               $Ajax->activate('_ex_rate');
+       }
 
        text_row(_("Supplier's Reference:"), 'Requisition', null, 16, 15);
 
index ac2e75e5096942524f1cee56fe985376a7cb241b..35d59fb78a7fff8c205169bb834ca1b7c0fa2aa8 100644 (file)
@@ -142,6 +142,11 @@ if ( (isset($_GET['DeliveryNumber']) && ($_GET['DeliveryNumber'] > 0) )
 if (isset($_POST['Update'])) {
        $Ajax->activate('Items');
 }
+if (isset($_POST['_InvoiceDate_changed'])) {
+       $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->customer_id, 
+               $_POST['InvoiceDate']);
+       $Ajax->activate('due_date');
+}
 //-----------------------------------------------------------------------------
 function check_quantities()
 {
@@ -333,7 +338,7 @@ if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) {
        }
 }
 
-date_cells(_("Date"), 'InvoiceDate', '', $_POST['InvoiceDate'], 0, 0, 0, "class='tableheader2'");
+date_cells(_("Date"), 'InvoiceDate', '', $_POST['InvoiceDate'], 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']);