- processing_end();
- if ($newinvoice) {
- meta_forward($_SERVER['PHP_SELF'], "AddedID=$invoice_no");
- } else {
- meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$invoice_no");
+ if ($newinvoice)
+ new_doc_date($_SESSION['Items']->document_date);
+
+ $invoice_no = write_sales_trans($_SESSION['Items']);
+ if ($invoice_no == -1)
+ {
+ display_error(_("The entered reference is already in use."));
+ set_focus('ref');
+ }
+ else
+ {
+ processing_end();
+
+ if ($newinvoice) {
+ meta_forward($_SERVER['PHP_SELF'], "AddedID=$invoice_no");
+ } else {
+ meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$invoice_no");
+ }
+ }
+}
+
+if(list_updated('payment')) {
+ $order = &$_SESSION['Items'];
+ copy_to_cart();
+ $order->payment = get_post('payment');
+ $order->payment_terms = get_payment_terms($order->payment);
+ $_POST['due_date'] = $order->due_date = get_invoice_duedate($order->payment, $order->document_date);
+ $_POST['Comments'] = '';
+ $Ajax->activate('due_date');
+ $Ajax->activate('options');
+ if ($order->payment_terms['type'] == PTT_CASH) {
+ $_POST['Location'] = $order->Location = $order->pos['pos_location'];
+ $order->location_name = $order->pos['location_name'];