+} elseif (isset($_GET['AllocationNumber']) || isset($_GET['InvoicePrepayments'])) {
+
+ check_deferred_income_act(_("You have to set Deferred Income Account in GL Setup to entry prepayment invoices."));
+
+ if (isset($_GET['AllocationNumber']))
+ {
+ $payments = array(get_cust_allocation($_GET['AllocationNumber']));
+
+ if (!$payments || ($payments[0]['trans_type_to'] != ST_SALESORDER))
+ {
+ display_error(_("Please select correct Sales Order Prepayment to be invoiced and try again."));
+ display_footer_exit();
+ }
+ $order_no = $payments[0]['trans_no_to'];
+ }
+ else {
+ $order_no = $_GET['InvoicePrepayments'];
+ }
+ processing_start();
+
+ $_SESSION['Items'] = new cart(ST_SALESORDER, $order_no, ST_SALESINVOICE);
+ $_SESSION['Items']->order_no = $order_no;
+ $_SESSION['Items']->src_docs = array($order_no);
+ $_SESSION['Items']->trans_no = 0;
+ $_SESSION['Items']->trans_type = ST_SALESINVOICE;
+
+ $_SESSION['Items']->update_payments();
+
+ copy_from_cart();
+}
+elseif (!processing_active()) {