$js = "";
if ($use_popup_windows)
$js .= get_js_open_window(900, 500);
+if ($use_date_picker)
+ $js .= get_js_date_picker();
page(_("Credit all or part of an Invoice"), false, false, "", $js);
//---------------------------------------------------------------------------------------------------------------
-if (isset($_GET['AddedID']))
+if (isset($_GET['AddedID']))
{
$credit_no = $_GET['AddedID'];
$trans_type = 11;
echo "<center>";
display_notification_centered(_("Credit Note has been processed"));
display_note(get_customer_trans_view_str($trans_type, $credit_no, _("View this credit note")), 0, 0);
-
+
display_note(get_gl_view_str($trans_type, $credit_no, _("View the GL Journal Entries for this Credit Note")));
display_footer_exit();
//--------------------------------------------------------------------------------------
-if (!isset($_GET['InvoiceNumber']) && !$_SESSION['InvoiceToCredit'])
+if (!isset($_GET['InvoiceNumber']) && !$_SESSION['InvoiceToCredit'])
{
/* This page can only be called with an invoice number for crediting*/
die (_("This page can only be opened if an invoice has been selected for crediting."));
function can_process()
{
- if (!is_date($_POST['CreditDate']))
+ if (!is_date($_POST['CreditDate']))
{
display_error(_("The entered date is invalid."));;
return false;
- }
- elseif (!is_date_in_fiscalyear($_POST['CreditDate']))
+ }
+ elseif (!is_date_in_fiscalyear($_POST['CreditDate']))
{
display_error(_("The entered date is not in fiscal year."));
return false;
}
- if (!references::is_valid($_POST['ref']))
+ if (!references::is_valid($_POST['ref']))
{
display_error(_("You must enter a reference."));;
return false;
}
- if (!is_new_reference($_POST['ref'], 11))
+ if (!is_new_reference($_POST['ref'], 11))
{
display_error(_("The entered reference is already in use."));;
return false;
}
- if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0)
+ if (!is_numeric($_POST['ChargeFreightCost']) || $_POST['ChargeFreightCost'] < 0)
{
display_error(_("The entered shipping cost is invalid or less than zero."));;
return false;
function clear_globals()
{
- if (isset($_SESSION['Items']))
+ if (isset($_SESSION['Items']))
{
unset($_SESSION['Items']->line_items);
unset($_SESSION['Items']);
if (can_process())
{
$credit_no = credit_invoice($_SESSION['Items'], $_SESSION['InvoiceToCredit'],
- $_SESSION['Order'], $_POST['CreditDate'], $_POST['CreditType'],
- $_POST['tax_group_id'], $_POST['ChargeFreightCost'], $_POST['ref'],
+ $_SESSION['Order'], $_POST['CreditDate'], $_POST['CreditType'],
+ $_POST['tax_group_id'], $_POST['ChargeFreightCost'], $_POST['ref'],
$_POST['CreditText'], $_POST['WriteOffGLCode']);
clear_globals();
//--------------------------------------------------------------------------------------
-if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0)
+if (isset($_GET['InvoiceNumber']) && $_GET['InvoiceNumber'] > 0)
{
clear_globals();
- session_register("Items");
- session_register("InvoiceToCredit");
- session_Register("Order");
-
$_SESSION['InvoiceToCredit'] = $_GET['InvoiceNumber'];
$_SESSION['Items'] = new cart;
/*read in all the guff from the selected invoice into the Items cart */
- // we need a distinct here so that it only returns 1 line - becuase there can be mutliple moves
+ // we need a distinct here so that it only returns 1 line - because there can be multiple moves
// per item (for assemblies, etc)
$sql = "SELECT DISTINCT ".TB_PREF."debtor_trans.*,
".TB_PREF."cust_branch.default_location, ".TB_PREF."cust_branch.default_ship_via,
$result = db_query($sql,"The invoice details cannot be retrieved");
- if (db_num_rows($result) == 1)
+ if (db_num_rows($result) == 1)
{
$myrow = db_fetch($result);
$result = get_customer_trans_details(10, $_GET['InvoiceNumber']);
- if (db_num_rows($result) > 0)
+ if (db_num_rows($result) > 0)
{
- while ($myrow = db_fetch($result))
+ while ($myrow = db_fetch($result))
{
$_SESSION['Items']->add_to_cart($myrow["stock_id"],-$myrow["quantity"],
- $myrow["FullUnitPrice"],$myrow["discount_percent"]);
+ $myrow["FullUnitPrice"],$myrow["discount_percent"],$myrow["qty_done"],
+ $myrow["standard_cost"],$myrow["description"],$myrow["id"]);
- $_SESSION['Items']->line_items[$myrow["stock_id"]]->standard_cost = $myrow["standard_cost"];
+ $_SESSION['Items']->line_items[$_SESSION['Items']->lines_on_order]->standard_cost = $myrow["standard_cost"];
}
}*/ //end of checks on returned data set
db_free_result($result);
- }
- else
+ }
+ 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']);
exit;
} //valid invoice record returned from the entered invoice number
-}
-else
+}
+else
{
/* 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)
+ foreach ($_SESSION['Items']->line_items as $itm)
{
- $_SESSION['Items']->line_items[$itm->stock_id]->qty_dispatched = $_POST[$itm->stock_id];
+ $_SESSION['Items']->line_items[$itm->line_no]->qty_dispatched = $_POST[$itm->stock_id];
- if (isset($_POST[$itm->stock_id . "Desc"]) && strlen($_POST[$itm->stock_id . "Desc"]) > 0)
+ 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"];
+ $_SESSION['Items']->line_items[$itm->line_no]->item_description = $_POST[$itm->stock_id . "Desc"];
}
}
}
label_cells(_("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'");
end_row();
start_row();
-
+
if (!isset($_POST['ref']))
$_POST['ref'] = references::get_next(11);
if (!isset($_POST['tax_group_id']))
$_POST['tax_group_id'] = $_SESSION['Items']->tax_group_id;
- label_cell(_("Tax Group"), "class='tableheader2'");
+ label_cell(_("Tax Group"), "class='tableheader2'");
tax_groups_list_cells(null, 'tax_group_id', $_POST['tax_group_id'], false, null, true);
end_row();
end_table();
end_table();
echo "</td></tr>";
-
+
end_table(1); // outer table
start_table("$table_style width=80%");
$th = array(_("Item Code"), _("Item Description"), _("Invoiced Quantity"), _("Units"),
_("Credit Quantity"), _("Price"), _("Discount %"), _("Total"));
- table_header($th);
+ table_header($th);
$k = 0; //row colour counter
- foreach ($_SESSION['Items']->line_items as $ln_itm)
+ foreach ($_SESSION['Items']->line_items as $ln_itm)
{
alt_table_row_color($k);
function display_credit_options()
{
global $table_style2;
-
+
echo "<br>";
start_table($table_style2);
{
echo "<option value='WriteOff'>" . _("Items Written Off") . "</option>";
echo "<option selected value='Return'>" . _("Items Returned to Inventory Location") . "</option>";
- }
- else
+ }
+ else
{
echo "<option selected value='WriteOff'>" . _("Items Written Off") . "</option>";
echo "<option value='Return'>" . _("Items Returned to Inventory Location") . "</option>";
locations_list_row(_("Items Returned to Inventory Location"), 'Location', $_POST['Location']);
- }
- else
+ }
+ else
{ /* the goods are to be written off to somewhere */
gl_all_accounts_list_row(_("Write Off the Cost of the Items to"), 'WriteOffGLCode', $_POST['WriteOffGLCode']);