From d79955724a5808af20c6b256d1ba4c1b41e818ef Mon Sep 17 00:00:00 2001 From: Joe Hunt Date: Wed, 4 Jan 2012 11:19:40 +0100 Subject: [PATCH] Added graphic edit/add icons in lists with $editkey. --- includes/session.inc | 4 +-- includes/ui/ui_lists.inc | 57 +++++++++++++++++++++++++++--- inventory/manage/items.php | 2 +- purchasing/manage/suppliers.php | 2 +- sales/manage/customer_branches.php | 2 +- sales/manage/customers.php | 2 +- 6 files changed, 59 insertions(+), 10 deletions(-) diff --git a/includes/session.inc b/includes/session.inc index fd343ecb..6407e6e0 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -162,7 +162,7 @@ function check_page_security($page_security) if ($msg){ display_error($msg); - end_page(); + end_page(@$_REQUEST['popup']); kill_login(); exit; } @@ -174,7 +174,7 @@ function check_page_security($page_security) echo _("The security settings on your account do not permit you to access this function"); echo ""; echo "



"; - end_page(); + end_page(@$_REQUEST['popup']); exit; } if (!$_SESSION['SysPrefs']->db_ok diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 592b49a0..df6e4b17 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -417,6 +417,28 @@ function _format_add_curr($row) '' : (" - " . $row[2])); } +function add_edit_combo($combo_name,$url,$key_param='',$restrict_pages='') +{ + global $path_to_root, $page_security; + + // Derive theme path + $theme_path = $path_to_root . '/themes/' . user_theme(); + + // Check if $url already has other parameters + if ($key_param) { + $key_param = ((strpos($url,'?')) ? '&' : '?') . $key_param; + } + + $return_url = ($key_param) ? "Add/Edit" : "Add/Edit"; + + // Don't pass edit button code If restrict_pages contains instructions but fails security check + if ($restrict_pages && strpos($restrict_pages, $page_security) === false) { + return ''; + } + + return $return_url; +} + function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, $all=false, $editkey = false) { @@ -429,7 +451,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ if ($editkey) set_editor('supplier', $name, $editkey); - return combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name', + $ret = combo_input($name, $selected_id, $sql, 'supplier_id', 'supp_name', array( 'format' => '_format_add_curr', 'order' => array('supp_ref'), @@ -443,6 +465,12 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select supplier'), 'show_inactive'=>$all )); + if ($editkey) + { + global $path_to_root; + $ret .= add_edit_combo('supplier_id',"$path_to_root/purchasing/manage/suppliers.php?popup=1",'supplier_id'); + } + return $ret; } function supplier_list_cells($label, $name, $selected_id=null, $all_option=false, @@ -477,7 +505,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ if ($editkey) set_editor('customer', $name, $editkey); - return combo_input($name, $selected_id, $sql, 'debtor_no', 'debtor_ref', + $ret = combo_input($name, $selected_id, $sql, 'debtor_no', 'debtor_ref', array( 'format' => '_format_add_curr', 'order' => array('debtor_ref'), @@ -492,6 +520,12 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ _('Select customer'), 'show_inactive' => $show_inactive ) ); + if ($editkey) + { + global $path_to_root; + $ret .= add_edit_combo('customer_id',"$path_to_root/sales/manage/customers.php?popup=1", "debtor_no"); + } + return $ret; } function customer_list_cells($label, $name, $selected_id=null, $all_option=false, @@ -508,6 +542,8 @@ function customer_list_cells($label, $name, $selected_id=null, $all_option=false function customer_list_row($label, $name, $selected_id=null, $all_option = false, $submit_on_change=false, $show_inactive=false, $editkey = false) { + global $path_to_root; + echo "$label"; echo customer_list($name, $selected_id, $all_option, $submit_on_change, $show_inactive, $editkey); @@ -528,7 +564,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, set_editor('branch', $name, $editkey); $where = $enabled ? array("disable_trans = 0") : array(); - return combo_input($name, $selected_id, $sql, 'branch_code', 'branch_ref', + $ret = combo_input($name, $selected_id, $sql, 'branch_code', 'branch_ref', array( 'where' => $where, 'order' => array('branch_ref'), @@ -537,6 +573,12 @@ function customer_branches_list($customer_id, $name, $selected_id=null, 'select_submit'=> $submit_on_change, 'sel_hint' => _('Select customer branch') ) ); + if ($editkey) + { + global $path_to_root; + $ret .= add_edit_combo('branch_id',"$path_to_root/sales/manage/customer_branches.php?popup=1",'SelectedBranch'); + } + return $ret; } //------------------------------------------------------------------------------------------------ @@ -718,7 +760,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, if ($editkey) set_editor('item', $name, $editkey); - return combo_input($name, $selected_id, $sql, 'stock_id', 's.description', + $ret = combo_input($name, $selected_id, $sql, 'stock_id', 's.description', array_merge( array( 'format' => '_format_stock_items', @@ -732,6 +774,13 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'category' => 2, 'order' => array('c.description','stock_id') ), $opts) ); + if ($editkey) + { + global $path_to_root; + $ret .= add_edit_combo('stock_id',"$path_to_root/inventory/manage/items.php?popup=1",'stock_id'); + } + return $ret; + } function _format_stock_items($row) diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 43495e0f..666486f0 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -483,5 +483,5 @@ end_form(); //------------------------------------------------------------------------------------ -end_page(); +end_page(@$_REQUEST['popup']); ?> diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index b545115e..edfad13a 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -334,6 +334,6 @@ tabbed_content_end(); hidden('popup', @$_REQUEST['popup']); end_form(); -end_page(); +end_page(@$_REQUEST['popup']); ?> diff --git a/sales/manage/customer_branches.php b/sales/manage/customer_branches.php index 5ab27166..e3b1565f 100644 --- a/sales/manage/customer_branches.php +++ b/sales/manage/customer_branches.php @@ -343,6 +343,6 @@ tabbed_content_end(); end_form(); -end_page(); +end_page(@$_REQUEST['popup']); ?> diff --git a/sales/manage/customers.php b/sales/manage/customers.php index 006d4b90..41c642ac 100644 --- a/sales/manage/customers.php +++ b/sales/manage/customers.php @@ -370,6 +370,6 @@ tabbed_content_end(); hidden('popup', @$_REQUEST['popup']); end_form(); -end_page(); +end_page(@$_REQUEST['popup']); ?> -- 2.30.2