+} elseif (!check_quantities()) {
+ display_error(_("Selected quantity cannot be less than quantity credited nor more than quantity not invoiced yet."));
+}
+if (isset($_POST['Update'])) {
+ $Ajax->activate('Items');
+}
+if (isset($_POST['_InvoiceDate_changed'])) {
+ $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['InvoiceDate']);
+ $Ajax->activate('due_date');
+}
+if (list_updated('payment')) {
+ $_SESSION['Items']->payment = get_post('payment');
+ $_POST['due_date'] = get_invoice_duedate($_SESSION['Items']->payment, $_POST['InvoiceDate']);
+ $Ajax->activate('due_date');
+}
+
+//-----------------------------------------------------------------------------
+function check_quantities()
+{
+ $ok =1;