X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_credit_invoice.php;h=2371574806ada508b86dd11a203cbe3b73abcd2b;hb=499e0e615d1a845c6c519754b3a213fdda0513ba;hp=85eda971ea577a638788b5e05766d6658e5ecd72;hpb=217f175953339fd10cd5aee5942cc263a4092323;p=fa-stable.git diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index 85eda971..23715748 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -1,246 +1,236 @@ . +***********************************************************************/ +//--------------------------------------------------------------------------- +// +// Entry/Modify Credit Note for selected Sales Invoice +// + +$page_security = 3; +$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 ($use_popup_windows) { $js .= get_js_open_window(900, 500); -if ($use_date_picker) +} + +if ($use_date_picker) { $js .= get_js_date_picker(); -page(_("Credit all or part of an Invoice"), false, false, "", $js); +} -//--------------------------------------------------------------------------------------------------------------- +if (isset($_GET['ModifyCredit'])) { + $_SESSION['page_title'] = sprintf(_("Modifying Credit Invoice # %d."), $_GET['ModifyCredit']); + $help_page_title =_("Modifying Credit Invoice"); + processing_start(); +} elseif (isset($_GET['InvoiceNumber'])) { + $_SESSION['page_title'] = _("Credit all or part of an Invoice"); + processing_start(); +} +page($_SESSION['page_title'], false, false, "", $js); -if (isset($_GET['AddedID'])) -{ +//----------------------------------------------------------------------------- + +if (isset($_GET['AddedID'])) { $credit_no = $_GET['AddedID']; $trans_type = 11; - 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);
+ if (isset($_POST['Line'.$line_no.'Desc'])) {
+ $line_desc = $_POST['Line'.$line_no.'Desc'];
+ if (strlen($line_desc) > 0) {
+ $_SESSION['Items']->line_items[$line_no]->item_description = $line_desc;
+ }
+ }
}
- 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
+ return $ok;
+}
+//-----------------------------------------------------------------------------
+function copy_to_cart()
+{
+ $cart = &$_SESSION['Items'];
+ $cart->ship_via = $_POST['ShipperID'];
+ $cart->freight_cost = input_num('ChargeFreightCost');
+ $cart->document_date = $_POST['CreditDate'];
+ $cart->Location = $_POST['Location'];
+ $cart->Comments = $_POST['CreditText'];
}
-else
+//-----------------------------------------------------------------------------
+
+function copy_from_cart()
{
+ $cart = &$_SESSION['Items'];
+ $_POST['ShipperID'] = $cart->ship_via;
+ $_POST['ChargeFreightCost'] = price_format($cart->freight_cost);
+ $_POST['CreditDate']= $cart->document_date;
+ $_POST['Location']= $cart->Location;
+ $_POST['CreditText']= $cart->Comments;
+ $_POST['cart_id'] = $cart->cart_id;
+}
+//-----------------------------------------------------------------------------
-/* 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)
- {
- $_SESSION['Items']->line_items[$itm->line_no]->qty_dispatched = $_POST[$itm->stock_id];
+if (isset($_POST['ProcessCredit']) && can_process()) {
- if (isset($_POST[$itm->stock_id . "Desc"]) && strlen($_POST[$itm->stock_id . "Desc"]) > 0)
- {
- $_SESSION['Items']->line_items[$itm->line_no]->item_description = $_POST[$itm->stock_id . "Desc"];
- }
- }
-}
+ $newcredit = ($_SESSION['Items']->trans_no == 0);
-//--------------------------------------------------------------------------------------
+ if (!isset($_POST['WriteOffGLCode']))
+ $_POST['WriteOffGLCode'] = 0;
-if (isset($_POST['ProcessCredit']))
-{
- process_credit();
+ copy_to_cart();
+ $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']);
+
+ processing_end();
+ if ($newcredit) {
+ meta_forward($_SERVER['PHP_SELF'], "AddedID=$credit_no");
+ } else {
+ meta_forward($_SERVER['PHP_SELF'], "UpdatedID=$credit_no");
+ }
}
-//--------------------------------------------------------------------------------------
+//-----------------------------------------------------------------------------
-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);
echo "