Annoyance 5683: Allow attachments from most needed post-creation option screens.
[fa-stable.git] / sales / sales_order_entry.php
index 58958eb15ecd70b72e2b11137d0c8a472486867d..362723d7845af2967281eac6e8a38790d721e0fe 100644 (file)
@@ -137,6 +137,8 @@ if (isset($_GET['AddedID'])) {
 
        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'])) {
@@ -173,6 +175,8 @@ if (isset($_GET['AddedID'])) {
 
        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'])) {
@@ -218,6 +222,8 @@ if (isset($_GET['AddedID'])) {
                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'])) {
@@ -453,6 +459,10 @@ function can_process() {
                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;
 }
 
@@ -475,10 +485,9 @@ if (isset($_POST['ProcessOrder']) && can_process()) {
                $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