X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_credit_invoice.php;h=af42db4c0378e497a870c5c8fb567cfb38c48e77;hb=refs%2Fheads%2Fphp7;hp=b64f8019bde9cc524f58307eaa2d16fad0b3da02;hpb=da8311619dd73feae101d246a1957b972e00cbd2;p=fa-stable.git diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index b64f8019..af42db4c 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -1,396 +1,385 @@ . +***********************************************************************/ +//--------------------------------------------------------------------------- +// +// Entry/Modify Credit Note for selected Sales Invoice +// + +$page_security = 'SA_SALESCREDITINV'; +$path_to_root = ".."; include_once($path_to_root . "/sales/includes/cart_class.inc"); include_once($path_to_root . "/includes/session.inc"); - include_once($path_to_root . "/includes/data_checks.inc"); - -include_once($path_to_root . "/includes/manufacturing.inc"); include_once($path_to_root . "/sales/includes/sales_db.inc"); include_once($path_to_root . "/sales/includes/sales_ui.inc"); +include_once($path_to_root . "/reporting/includes/reporting.inc"); + $js = ""; -if ($use_popup_windows) +if ($SysPrefs->use_popup_windows) { $js .= get_js_open_window(900, 500); -page(_("Credit all or part of an Invoice"), false, false, "", $js); +} -//--------------------------------------------------------------------------------------------------------------- +if (user_use_date_picker()) { + $js .= get_js_date_picker(); +} -if (isset($_GET['AddedID'])) -{ +if (isset($_GET['ModifyCredit'])) { + $_SESSION['page_title'] = sprintf(_("Modifying Credit Invoice # %d."), $_GET['ModifyCredit']); + $help_context = "Modifying Credit Invoice"; + processing_start(); +} elseif (isset($_GET['InvoiceNumber'])) { + $_SESSION['page_title'] = _($help_context = "Credit all or part of an Invoice"); + processing_start(); +} +page($_SESSION['page_title'], false, false, "", $js); + +//----------------------------------------------------------------------------- + +if (isset($_GET['AddedID'])) { $credit_no = $_GET['AddedID']; - $trans_type = 11; + $trans_type = ST_CUSTCREDIT; - echo "
" . _("There are no line items that were retrieved for this invoice. A credit note cannot be created from this invoice."). "
";
- end_page();
- exit;
-
- }*/ //end of checks on returned data set
- db_free_result($result);
- }
- else
- {
- display_error(_("This invoice can not be credited using the automatic facility."));
- display_error("Please report that a duplicate debtor_trans header record was found for invoice " . $SESSION['InvoiceToCredit']);
- echo "
";
- exit;
- } //valid invoice record returned from the entered invoice number
-
-}
-else
-{
+ if (!isset($_POST['WriteOffGLCode']))
+ $_POST['WriteOffGLCode'] = 0;
-/* if processing, the page has been called and ${$StkItm->stock_id} would have been set from the post */
- foreach ($_SESSION['Items']->line_items as $itm)
+ copy_to_cart();
+ if ($new_credit)
+ new_doc_date($_SESSION['Items']->document_date);
+ $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']);
+ if ($credit_no == -1)
{
- $_SESSION['Items']->line_items[$itm->stock_id]->qty_dispatched = $_POST[$itm->stock_id];
-
- if (isset($_POST[$itm->stock_id . "Desc"]) && strlen($_POST[$itm->stock_id . "Desc"]) > 0)
- {
- $_SESSION['Items']->line_items[$itm->stock_id]->item_description = $_POST[$itm->stock_id . "Desc"];
+ display_error(_("The entered reference is already in use."));
+ set_focus('ref');
+ } elseif($credit_no) {
+ processing_end();
+ if ($new_credit) {
+ meta_forward($_SERVER['PHP_SELF'], "AddedID=$credit_no");
+ } else {
+ meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$credit_no");
}
}
}
-//--------------------------------------------------------------------------------------
-
-if (isset($_POST['ProcessCredit']))
-{
- process_credit();
-}
+//-----------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------
-
-if (isset($_POST['Location']))
-{
+if (isset($_POST['Location'])) {
$_SESSION['Items']->Location = $_POST['Location'];
}
-//--------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
function display_credit_items()
{
- global $table_style, $table_style2;
-
- start_form(false, true);
+ start_form();
+ hidden('cart_id');
- start_table("$table_style2 width=80%", 5);
+ start_table(TABLESTYLE2, "width='80%'", 5);
echo "