From c8145b03ed9754bd9552ccdac38b41b73550a69f Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Fri, 9 Jan 2015 19:50:36 +0100 Subject: [PATCH] Added trans_editor_link helper. --- gl/inquiry/journal_inquiry.php | 32 ++------------------ includes/ui/ui_input.inc | 20 ------------- includes/ui/ui_view.inc | 34 ++++++++++++++++++++++ manufacturing/search_work_orders.php | 3 +- purchasing/inquiry/po_search.php | 3 +- purchasing/inquiry/po_search_completed.php | 7 ++--- purchasing/inquiry/supplier_inquiry.php | 2 +- sales/includes/db/sales_order_db.inc | 3 +- sales/inquiry/customer_inquiry.php | 8 ++--- sales/inquiry/sales_deliveries_view.php | 3 +- sales/inquiry/sales_orders_view.php | 7 +---- 11 files changed, 49 insertions(+), 73 deletions(-) diff --git a/gl/inquiry/journal_inquiry.php b/gl/inquiry/journal_inquiry.php index 61cb255f..88e36a91 100644 --- a/gl/inquiry/journal_inquiry.php +++ b/gl/inquiry/journal_inquiry.php @@ -79,33 +79,8 @@ function gl_link($row) return get_gl_view_str($row["type"], $row["type_no"]); } -$editors = array( - ST_JOURNAL => "/gl/gl_journal.php?ModifyGL=Yes&trans_no=%d&trans_type=%d", - ST_BANKPAYMENT => "/gl/gl_bank.php?ModifyPayment=Yes&trans_no=%d&trans_type=%d", - ST_BANKDEPOSIT => "/gl/gl_bank.php?ModifyDeposit=Yes&trans_no=%d&trans_type=%d", -// 4=> Funds Transfer, - ST_SALESINVOICE => "/sales/customer_invoice.php?ModifyInvoice=%d", -// 11=> -// free hand (debtors_trans.order_==0) -// "/sales/credit_note_entry.php?ModifyCredit=%d" -// credit invoice -// "/sales/customer_credit_invoice.php?ModifyCredit=%d" -// 12=> Customer Payment, - ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d", -// 16=> Location Transfer, -// 17=> Inventory Adjustment, -// 20=> Supplier Invoice, -// 21=> Supplier Credit Note, -// 22=> Supplier Payment, -// 25=> Purchase Order Delivery, -// 28=> Work Order Issue, -// 29=> Work Order Production", -// 35=> Cost Update, -); - function edit_link($row) { - global $editors; $ok = true; if ($row['type'] == ST_SALESINVOICE) @@ -113,11 +88,8 @@ function edit_link($row) $myrow = get_customer_trans($row["type_no"], $row["type"]); if ($myrow['alloc'] != 0 || get_voided_entry(ST_SALESINVOICE, $row["type_no"]) !== false) $ok = false; - } - return isset($editors[$row["type"]]) && !is_closed_trans($row["type"], $row["type_no"]) && $ok ? - pager_link(_("Edit"), - sprintf($editors[$row["type"]], $row["type_no"], $row["type"]), - ICON_EDIT) : ''; + } + return $ok ? trans_editor_link($row["type"], $row["type_no"]) : ''; } $sql = get_sql_for_journal_inquiry(get_post('filterType', -1), get_post('FromDate'), diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index d72b8b18..b3cb79b1 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -943,26 +943,6 @@ function supplier_credit_row($supplier, $credit, $parms='') ."", $parms); } -/* - Edit transaction link to be used in transaction inquires -*/ -function edit_trans_link($trans_type, $trans_no, $url='') -{ - global $path_to_root, $trans_editors; - - if (!$url) $url = @$trans_editors[$trans_type]; - - if (!$trans_no || !$url) - return ''; - - if (is_closed_trans($trans_type, $trans_no)) { - return set_icon(ICON_CLOSED, _('Closed')); - } else { - $link_text = user_graphic_links() ? set_icon(ICON_EDIT, _('Edit')) : _('Edit'); - return "$link_text"; - } -} - function bank_balance_row($bank_acc, $parms='') { global $path_to_root; diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index 768447bc..0b4f3113 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -1431,3 +1431,37 @@ function payment_link($name, $options) return strtr($link, $patterns); } + +function trans_editor_link($type, $trans_no) +{ + global $path_to_root; + + $editor_url = array( + ST_JOURNAL => "/gl/gl_journal.php?ModifyGL=Yes&trans_no=%d&trans_type=%d", + ST_BANKPAYMENT => "/gl/gl_bank.php?ModifyPayment=Yes&trans_no=%d&trans_type=%d", + ST_BANKDEPOSIT => "/gl/gl_bank.php?ModifyDeposit=Yes&trans_no=%d&trans_type=%d", + ST_BANKTRANSFER => "/gl/bank_transfer.php?ModifyTransfer=Yes&trans_no=%d&trans_type=%d", + ST_SALESINVOICE => "/sales/customer_invoice.php?ModifyInvoice=%d", + ST_CUSTCREDIT => "/sales/credit_note_entry.php?ModifyCredit=%d", // only for free hand credit notes (debtors_trans.order_==0) + ST_CUSTPAYMENT => "/sales/customer_payments.php?trans_no=%d", + ST_CUSTDELIVERY => "/sales/customer_delivery.php?ModifyDelivery=%d", +// 16=> Location Transfer, +// 17=> Inventory Adjustment, + ST_SUPPINVOICE => "/purchasing/supplier_invoice.php?ModifyInvoice=%d", + ST_SUPPCREDIT => "/purchasing/supplier_credit.php?ModifyCredit=%d", +// 21=> Supplier Credit Note, +// 22=> Supplier Payment, +// 25=> Purchase Order Delivery, + ST_PURCHORDER => "/purchasing/po_entry_items.php?ModifyOrderNumber=%d", +// 28=> Work Order Issue, +// 29=> Work Order Production", + ST_WORKORDER => "/manufacturing/work_order_entry.php?trans_no=%d", + ST_SALESORDER => "/sales/sales_order_entry.php?ModifyOrderNumber=%d", + ST_SALESQUOTE => "/sales/sales_order_entry.php?ModifyQuotationNumber=%d", + // 35=> Cost Update, + ); + + return !isset($editor_url[$type]) ? '' : + (is_closed_trans($type, $trans_no) ? set_icon(ICON_CLOSED, _('Closed')) : + pager_link(_("Edit"), sprintf($editor_url[$type], $trans_no, $type), ICON_EDIT)); +} diff --git a/manufacturing/search_work_orders.php b/manufacturing/search_work_orders.php index 106114af..b0c8688e 100644 --- a/manufacturing/search_work_orders.php +++ b/manufacturing/search_work_orders.php @@ -106,8 +106,7 @@ function wo_type_name($dummy, $type) function edit_link($row) { return $row['closed'] ? ''._('Closed').'' : - pager_link(_("Edit"), - "/manufacturing/work_order_entry.php?trans_no=" . $row["id"], ICON_EDIT); + trans_editor_link(ST_WORKORDER, $row["id"]); } function release_link($row) diff --git a/purchasing/inquiry/po_search.php b/purchasing/inquiry/po_search.php index f3203f63..5aa19b4e 100644 --- a/purchasing/inquiry/po_search.php +++ b/purchasing/inquiry/po_search.php @@ -86,8 +86,7 @@ function trans_view($trans) function edit_link($row) { - return pager_link( _("Edit"), - "/purchasing/po_entry_items.php?ModifyOrderNumber=" . $row["order_no"], ICON_EDIT); + return trans_editor_link(ST_PURCHORDER, $trans["order_no"]); } function prt_link($row) diff --git a/purchasing/inquiry/po_search_completed.php b/purchasing/inquiry/po_search_completed.php index cb67ab7d..7a89e4eb 100644 --- a/purchasing/inquiry/po_search_completed.php +++ b/purchasing/inquiry/po_search_completed.php @@ -104,11 +104,8 @@ function edit_link($row) { global $page_nested; - if ($page_nested) - return ''; - return pager_link( _("Edit"), - "/purchasing/po_entry_items.php?" . SID - . "ModifyOrderNumber=" . $row["order_no"], ICON_EDIT); + return $page_nested ? '' + trans_editor_link(ST_PURCHORDER, $trans["order_no"]); } function prt_link($row) diff --git a/purchasing/inquiry/supplier_inquiry.php b/purchasing/inquiry/supplier_inquiry.php index d89d5d35..4abd0000 100644 --- a/purchasing/inquiry/supplier_inquiry.php +++ b/purchasing/inquiry/supplier_inquiry.php @@ -163,7 +163,7 @@ function check_overdue($row) function edit_link($row) { - return edit_trans_link($row['type'], $row['trans_no']); + return trans_editor_link($row['type'], $row['trans_no']); } //------------------------------------------------------------------------------------------------ diff --git a/sales/includes/db/sales_order_db.inc b/sales/includes/db/sales_order_db.inc index e851f747..ff61aaa5 100644 --- a/sales/includes/db/sales_order_db.inc +++ b/sales/includes/db/sales_order_db.inc @@ -489,7 +489,8 @@ function get_sql_for_sales_orders_view($trans_type, $trans_no, $filter, prep_amount, allocs.ord_payments, inv.inv_payments, - sorder.total + sorder.total, + sorder.trans_type FROM ".TB_PREF."sales_orders as sorder LEFT JOIN (SELECT trans_no_to, sum(amt) ord_payments FROM ".TB_PREF."cust_allocations WHERE trans_type_to=".ST_SALESORDER." GROUP BY trans_no_to) allocs ON sorder.trans_type=".ST_SALESORDER." AND allocs.trans_no_to=sorder.order_no diff --git a/sales/inquiry/customer_inquiry.php b/sales/inquiry/customer_inquiry.php index 50e4e73b..123066ed 100644 --- a/sales/inquiry/customer_inquiry.php +++ b/sales/inquiry/customer_inquiry.php @@ -155,7 +155,7 @@ function fmt_credit($row) function credit_link($row) { global $page_nested; - + if ($page_nested) return ''; return $row['type'] == ST_SALESINVOICE && $row["Outstanding"] > 0 ? @@ -171,8 +171,8 @@ function edit_link($row) if ($page_nested) return ''; - return edit_trans_link($row['type'], $row['trans_no'], $row['type']==ST_CUSTCREDIT && $row['order_']==0 ? - "/sales/credit_note_entry.php?ModifyCredit=%d" : 0); + return $row['type'] == ST_CUSTCREDIT && $row['order_'] ? '' : // allow only free hand credit notes edition + trans_editor_link($row['type'], $row['trans_no']); } function prt_link($row) @@ -181,7 +181,7 @@ function prt_link($row) return print_document_link($row['trans_no']."-".$row['type'], _("Print Receipt"), true, ST_CUSTPAYMENT, ICON_PRINT); elseif ($row['type'] == ST_BANKPAYMENT) // bank payment printout not defined yet. return ''; - else + else return print_document_link($row['trans_no']."-".$row['type'], _("Print"), true, $row['type'], ICON_PRINT); } diff --git a/sales/inquiry/sales_deliveries_view.php b/sales/inquiry/sales_deliveries_view.php index bc1f3a99..b9ed9b6e 100644 --- a/sales/inquiry/sales_deliveries_view.php +++ b/sales/inquiry/sales_deliveries_view.php @@ -140,8 +140,7 @@ function batch_checkbox($row) function edit_link($row) { return $row["Outstanding"]==0 ? '' : - pager_link(_('Edit'), "/sales/customer_delivery.php?ModifyDelivery=" - .$row['trans_no'], ICON_EDIT); + trans_editor_link(ST_CUSTDELIVERY, $row['trans_no']); } function prt_link($row) diff --git a/sales/inquiry/sales_orders_view.php b/sales/inquiry/sales_orders_view.php index a9f8cf75..f5977aa7 100644 --- a/sales/inquiry/sales_orders_view.php +++ b/sales/inquiry/sales_orders_view.php @@ -106,12 +106,7 @@ function edit_link($row) { global $page_nested; - if ($page_nested) - return ''; - global $trans_type; - $modify = ($trans_type == ST_SALESORDER ? "ModifyOrderNumber" : "ModifyQuotationNumber"); - return pager_link( _("Edit"), - "/sales/sales_order_entry.php?$modify=" . $row['order_no'], ICON_EDIT); + return $page_nested ? '' : trans_editor_link($row['trans_type'], $row['order_no']); } function dispatch_link($row) -- 2.30.2