-//---------------------------------------------------------------------------------------------------------------
-if ($ret = context_restore()) {
- // return from supplier editor
- copy_from_trans($_SESSION['supp_trans']);
- if(isset($ret['supplier_id']))
- $_POST['supplier_id'] = $ret['supplier_id'];
-}
-if (isset($_POST['_supplier_id_editor'])) {
- copy_to_trans($_SESSION['supp_trans']);
- context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'], 'supp_trans');
+if (isset($_GET['ModifyCredit']))
+ check_is_editable(ST_SUPPINVOICE, $_GET['ModifyCredit']);
+
+//---------------------------------------------------------------------------------------------------
+
+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']);
+ }
+
+ if (isset($_GET['invoice_no']))
+ {
+ $_SESSION['supp_trans'] = new supp_trans(ST_SUPPINVOICE, $_GET['invoice_no']);
+ $_SESSION['supp_trans']->src_docs = array( $_GET['invoice_no'] => $_SESSION['supp_trans']->supp_reference);
+
+
+ $_SESSION['supp_trans']->trans_type = ST_SUPPCREDIT;
+ $_SESSION['supp_trans']->trans_no = 0;
+ $_SESSION['supp_trans']->supp_reference = '';
+ $help_context = "Supplier Credit Note";
+ $_SESSION['page_title'] = _("Supplier Credit Note");
+
+ } else {
+ $help_context = "Supplier Credit Note";
+ $_SESSION['page_title'] = _("Supplier Credit Note");
+ $_SESSION['supp_trans'] = new supp_trans(ST_SUPPCREDIT);
+ }