X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=sales%2Fcustomer_credit_invoice.php;h=af42db4c0378e497a870c5c8fb567cfb38c48e77;hb=2bcdab793e406bb5a44d2c4e079ec7cc2a1aa857;hp=c97930ee7cfd032462329e03caa0f5407704f8f5;hpb=a1e1eb5f69391bf58de97795390399535bfc2532;p=fa-stable.git diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index c97930ee..af42db4c 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -1,247 +1,235 @@ . +***********************************************************************/ +//--------------------------------------------------------------------------- +// +// 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); -if ($use_date_picker) +} + +if (user_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_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'])) -{ +//----------------------------------------------------------------------------- + +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);
+ 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 = (isset($_POST['Location']) ? $_POST['Location'] : "");
+ $cart->Comments = $_POST['CreditText'];
+ if ($_SESSION['Items']->trans_no == 0)
+ $cart->reference = $_POST['ref'];
}
-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;
+ $_POST['ref'] = $cart->reference;
+}
+//-----------------------------------------------------------------------------
-/* 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()) {
+ $new_credit = ($_SESSION['Items']->trans_no == 0);
- 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"];
+ if (!isset($_POST['WriteOffGLCode']))
+ $_POST['WriteOffGLCode'] = 0;
+
+ copy_to_cart();
+ if ($new_credit)
+ new_doc_date($_SESSION['Items']->document_date);
+ $credit_no = $_SESSION['Items']->write($_POST['WriteOffGLCode']);
+ if ($credit_no == -1)
+ {
+ 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();
+ hidden('cart_id');
- start_form(false, true);
-
- start_table("$table_style2 width=80%", 5);
+ start_table(TABLESTYLE2, "width='80%'", 5);
echo "