page($_SESSION['page_title'], false, false, "", $js);
+if (isset($_GET['ModifyOrderNumber']) && is_prepaid_order_open($_GET['ModifyOrderNumber']))
+{
+ display_error(_("This order cannot be edited because there are invoices or payments related to it, and prepayment terms were used."));
+ end_page(); exit;
+}
if (isset($_GET['ModifyOrderNumber']))
check_is_editable(ST_SALESORDER, $_GET['ModifyOrderNumber']);
elseif (isset($_GET['ModifyQuotationNumber']))
submenu_option(_("Enter a &New Order"), "/sales/sales_order_entry.php?NewOrder=0");
+ submenu_option(_("Add an Attachment"), "/admin/attachments.php?filterType=".ST_SALESORDER."&trans_no=$order_no");
+
display_footer_exit();
} elseif (isset($_GET['UpdatedID'])) {
submenu_option(_("Enter a New &Quotation"), "/sales/sales_order_entry.php?NewQuotation=0");
+ submenu_option(_("Add an Attachment"), "/admin/attachments.php?filterType=".ST_SALESQUOTE."&trans_no=$order_no");
+
display_footer_exit();
} elseif (isset($_GET['UpdatedQU'])) {
submenu_option(_("Enter a &New Delivery"),
"/sales/sales_order_entry.php?NewDelivery=0");
+ submenu_option(_("Add an Attachment"), "/admin/attachments.php?filterType=".ST_CUSTDELIVERY."&trans_no=$delivery");
+
display_footer_exit();
} elseif (isset($_GET['AddedDI'])) {
return false;
}
if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) {
- if (!$_SESSION['Items']->is_started() && ($_SESSION['Items']->payment_terms['days_before_due'] < 0) && ((input_num('prep_amount')<=0) ||
+ if (!$_SESSION['Items']->is_started() && ($_SESSION['Items']->payment_terms['days_before_due'] == -1) && ((input_num('prep_amount')<=0) ||
input_num('prep_amount')>$_SESSION['Items']->get_trans_total())) {
display_error(_("Pre-payment required have to be positive and less than total amount."));
set_focus('prep_amount');
display_error("Invoice total amount cannot be less than zero.");
return false;
}
+
+ if ($_SESSION['Items']->payment_terms['cash_sale'] &&
+ ($_SESSION['Items']->trans_type == ST_CUSTDELIVERY || $_SESSION['Items']->trans_type == ST_SALESINVOICE))
+ $_SESSION['Items']->due_date = $_SESSION['Items']->document_date;
return true;
}
$ref = $Refs->get_next($_SESSION['Items']->trans_type, null, array('date' => Today()));
if ($ref != $_SESSION['Items']->reference)
{
+ unset($_POST['ref']); // force refresh reference
display_error(_("The reference number field has been increased. Please save the document again."));
- $_POST['ref'] = $_SESSION['Items']->reference = $ref;
- $Ajax->activate('ref');
- }
+ }
set_focus('ref');
}
else