"; display_notification_centered(_("Supplier invoice has been processed.")); display_note(get_trans_view_str($trans_type, $invoice_no, _("View this Invoice"))); display_note(get_gl_view_str($trans_type, $invoice_no, _("View the GL Journal Entries for this Invoice")), 1); hyperlink_params($_SERVER['PHP_SELF'], _("Enter Another Invoice"), "New=1"); display_footer_exit(); } //-------------------------------------------------------------------------------------------------- if (isset($_GET['New'])) { if (isset( $_SESSION['supp_trans'])) { unset ($_SESSION['supp_trans']->grn_items); unset ($_SESSION['supp_trans']->gl_codes); unset ($_SESSION['supp_trans']); } //session_register("SuppInv"); session_register("supp_trans"); $_SESSION['supp_trans'] = new supp_trans; $_SESSION['supp_trans']->is_invoice = true; } //-------------------------------------------------------------------------------------------------- function check_data() { If (!$_SESSION['supp_trans']->is_valid_trans_to_post()) { display_error(_("The invoice cannot be processed because the there are no items or values on the invoice. Invoices are expected to have a charge.")); return false; } if (!references::is_valid($_SESSION['supp_trans']->reference)) { display_error(_("You must enter an invoice reference.")); set_focus('reference'); return false; } if (!is_new_reference($_SESSION['supp_trans']->reference, 20)) { display_error(_("The entered reference is already in use.")); set_focus('reference'); return false; } if (!references::is_valid($_SESSION['supp_trans']->supp_reference)) { display_error(_("You must enter a supplier's invoice reference.")); set_focus('supp_reference'); return false; } if (!is_date( $_SESSION['supp_trans']->tran_date)) { display_error(_("The invoice as entered cannot be processed because the invoice date is in an incorrect format.")); set_focus('trans_date'); return false; } elseif (!is_date_in_fiscalyear($_SESSION['supp_trans']->tran_date)) { display_error(_("The entered date is not in fiscal year.")); set_focus('trans_date'); return false; } if (!is_date( $_SESSION['supp_trans']->due_date)) { display_error(_("The invoice as entered cannot be processed because the due date is in an incorrect format.")); set_focus('due_date'); return false; } $sql = "SELECT Count(*) FROM ".TB_PREF."supp_trans WHERE supplier_id='" . $_SESSION['supp_trans']->supplier_id . "' AND supp_reference='" . $_POST['supp_reference'] . "'"; $result=db_query($sql,"The sql to check for the previous entry of the same invoice failed"); $myrow = db_fetch_row($result); if ($myrow[0] == 1) { /*Transaction reference already entered */ display_error(_("This invoice number has already been entered. It cannot be entered again." . " (" . $_POST['supp_reference'] . ")")); return false; } return true; } //-------------------------------------------------------------------------------------------------- function handle_commit_invoice() { copy_to_trans($_SESSION['supp_trans']); if (!check_data()) return; $invoice_no = add_supp_invoice($_SESSION['supp_trans']); $_SESSION['supp_trans']->clear_items(); unset($_SESSION['supp_trans']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$invoice_no"); } //-------------------------------------------------------------------------------------------------- if (isset($_POST['PostInvoice'])) { handle_commit_invoice(); } //-------------------------------------------------------------------------------------------------- start_form(false, true); start_table("$table_style2 width=80%", 8); echo ""; // outer table echo "
"; invoice_header($_SESSION['supp_trans']); if ($_POST['supplier_id']=='') display_error('No supplier found for entered search text'); else { echo ""; // outer table echo "
"; display_grn_items($_SESSION['supp_trans']); display_gl_items($_SESSION['supp_trans']); //echo ""; // outer table echo "
"; invoice_totals($_SESSION['supp_trans']); } echo ""; end_table(); // outer table echo "
"; submit_center('PostInvoice', _("Enter Invoice"), true, '', true); echo "
"; end_form(); //-------------------------------------------------------------------------------------------------- end_page(); ?>