From f018643dc04ce130f1729e16a65458af443308a0 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Tue, 21 Jul 2009 21:39:41 +0000 Subject: [PATCH] Asynchronous customer/supplier/item selection now use popup window. --- CHANGELOG.txt | 26 +++++++ gl/gl_bank.php | 31 +++------ includes/page/footer.inc | 5 +- includes/session.inc | 2 + includes/ui/ui_controls.inc | 39 ++++++++++- includes/ui/ui_input.inc | 37 +++++++--- includes/ui/ui_lists.inc | 17 ++--- index.php | 1 - inventory/manage/items.php | 16 ++--- inventory/purchasing_data.php | 11 +-- js/inserts.js | 67 +++++++++++++++---- js/utils.js | 6 +- .../allocations/supplier_allocation_main.php | 10 +-- purchasing/manage/suppliers.php | 11 ++- purchasing/po_entry_items.php | 22 +----- purchasing/supplier_credit.php | 13 +--- purchasing/supplier_invoice.php | 14 +--- purchasing/supplier_payment.php | 10 +-- .../allocations/customer_allocation_main.php | 8 +-- sales/credit_note_entry.php | 19 +++--- sales/customer_payments.php | 18 +++-- sales/manage/customer_branches.php | 20 ++---- sales/manage/customers.php | 16 ++--- sales/sales_order_entry.php | 18 ++--- 24 files changed, 224 insertions(+), 213 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 48bc5722..6a4a8fcb 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -19,6 +19,32 @@ Legend: ! -> Note $ -> Affected files +21-Jul-2009 Janusz Dobrowolski +! Asynchronous customer/supplier/item selection now use popup window. +$ /index.php + /gl/gl_bank.php + /includes/session.inc + /includes/page/footer.inc + /includes/ui/ui_controls.inc + /includes/ui/ui_input.inc + /includes/ui/ui_lists.inc + /inventory/purchasing_data.php + /inventory/manage/items.php + /js/inserts.js + /js/utils.js + /purchasing/po_entry_items.php + /purchasing/supplier_credit.php + /purchasing/supplier_invoice.php + /purchasing/supplier_payment.php + /purchasing/allocations/supplier_allocation_main.php + /purchasing/manage/suppliers.php + /sales/credit_note_entry.php + /sales/customer_payments.php + /sales/sales_order_entry.php + /sales/allocations/customer_allocation_main.php + /sales/manage/customer_branches.php + /sales/manage/customers.php + 15-Jul-2009 Joe Hunt ! Replaced sys_types names from table to systypes::name in reports Now the English names in table are never used in inquiries or reports diff --git a/gl/gl_bank.php b/gl/gl_bank.php index fc6c50e6..a9d969a2 100644 --- a/gl/gl_bank.php +++ b/gl/gl_bank.php @@ -41,29 +41,16 @@ page($_SESSION['page_title'], false, false, '', $js); check_db_has_bank_accounts(_("There are no bank accounts defined in the system.")); //---------------------------------------------------------------------------------------- -if ($ret = context_restore()) { - if(isset($ret['supplier_id'])) - $_POST['person_id'] = $ret['supplier_id']; - if(isset($ret['customer_id'])) - $_POST['person_id'] = $ret['customer_id']; - set_focus('person_id'); - if(isset($ret['branch_id'])) { - $_POST['PersonDetailID'] = $ret['branch_id']; - set_focus('PersonDetailID'); - } -} -if (isset($_POST['_person_id_editor'])) { - if ($_POST['PayType']==payment_person_types::supplier()) - $editor = '/purchasing/manage/suppliers.php?supplier_id='; - else - $editor = '/sales/manage/customers.php?debtor_no='; - -// $_SESSION['pay_items'] should stay unchanged during call -// -context_call($path_to_root.$editor.$_POST['person_id'], - array('bank_account', 'date_', 'PayType', 'person_id', - 'PersonDetailID', 'ref', 'memo_') ); +set_editor('supplier', 'person_id' , 'ref'); +set_editor('customer', 'person_id' , 'ref'); +set_editor('branch', 'PersonDetailID' , 'ref'); + +if (list_updated('PersonDetailID')) { + $br = get_branch(get_post('PersonDetailID')); + $_POST['person_id'] = $br['debtor_no']; + $Ajax->activate('person_id'); } + //-------------------------------------------------------------------------------------------------- function line_start_focus() { global $Ajax; diff --git a/includes/page/footer.inc b/includes/page/footer.inc index 0ba9b52a..da53a925 100644 --- a/includes/page/footer.inc +++ b/includes/page/footer.inc @@ -11,7 +11,7 @@ ***********************************************************************/ function page_footer($no_menu=false, $is_index=false) { - global $path_to_root, $js_lib, $Validate; + global $path_to_root, $js_lib, $Validate, $Editors; if (in_ajax()) return;// just for speed up @@ -21,9 +21,11 @@ function page_footer($no_menu=false, $is_index=false) include_once($path_to_root."/themes/".user_theme()."/renderer.php"); $rend = new renderer(); $rend->menu_footer($no_menu, $is_index); + echo ""; add_user_js_data(); @@ -31,7 +33,6 @@ function page_footer($no_menu=false, $is_index=false) foreach($js_lib as $text) echo $text; - echo "\n-->\n"; echo "\n"; } diff --git a/includes/session.inc b/includes/session.inc index 65b62f55..d53e9b63 100644 --- a/includes/session.inc +++ b/includes/session.inc @@ -143,6 +143,8 @@ $Ajax =& new Ajax(); // js/php validation rules container $Validate = array(); +// bindings for editors +$Editors = array(); // intercept all output to destroy it in case of ajax call register_shutdown_function('end_flush'); diff --git a/includes/ui/ui_controls.inc b/includes/ui/ui_controls.inc index 559d1751..7b518e57 100644 --- a/includes/ui/ui_controls.inc +++ b/includes/ui/ui_controls.inc @@ -322,6 +322,44 @@ function div_end() } } +/* + Bind editors for various selectors. + $type - type of editor + $input - array org_input => editor_input + $focus - focus after selection +*/ +function set_editor($type, $input, $focus=null) +{ + global $path_to_root, $Editors; + // table of table editor interfaces. + // key is editor type, values contain: + // 0 => url of editor page + // 1 => array of names of parameters returned back from editor interface + // 2 => hotkey code + + if($focus === null) { + $focus = $caller; + } + $urls = array( + 'customer' => array('/sales/manage/customers.php?debtor_no=', + 113, _("F2 - Customers")), + 'branch' => array('/sales/manage/customer_branches.php?SelectedBranch=', + 114, _("F3 - Branches")), + 'supplier' => array('/purchasing/manage/suppliers.php?supplier_id=', + 113, _("F2 - Suppliers")), + 'item' => array('/inventory/manage/items.php?stock_id=', + 115, _("F4 - Items")) + ); + $back = array(); + $caller = $urls[$type][1]; + $Editors[$caller] = array( $path_to_root . $urls[$type][0], $input, $focus); + +// FIX status comments + +} +//------------------------------------------------------------------------------ +// Procedures below are now obsolete. Preserved for eventual future use. + /* External page call with saving current context. $call - url of external page @@ -388,7 +426,6 @@ function context_reset() { $_SESSION['Context'] = array(); } - /* Context stack initialization */ diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc index a2355cfb..ccd62b48 100644 --- a/includes/ui/ui_input.inc +++ b/includes/ui/ui_input.inc @@ -108,6 +108,7 @@ function hidden($name, $value=null, $echo=true) true - standard button; optional icon 'process' - displays progress bar during call; optional icon 'default' - default form submit on Ctrl-Enter press; dflt ICON_OK icon + 'selector' - ditto with closing current popup editor window 'cancel' - cancel form entry on Escape press; dflt ICON_CANCEL */ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=false) @@ -119,6 +120,10 @@ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=fal switch($atype) { case 'process': $aspect = " aspect='process'"; break; + case 'selector': + $aspect = " aspect='selector' rel = '$value'"; + $value = _("Select"); + if ($icon===false) $icon=ICON_SUBMIT; break; case 'default': $aspect = " aspect='default'"; if ($icon===false) $icon=ICON_SUBMIT; break; @@ -225,10 +230,10 @@ function submit_row($name, $value, $right=true, $extra="", $title=false, $async= echo "\n"; } -function submit_return($name, $value, $title=false, $async=false) +function submit_return($name, $value, $title=false) { - if (count($_SESSION['Context'])) { - submit($name, $value, true, $title, $async); + if (@$_REQUEST['popup']) { + submit($name, $value, true, $title, 'selector'); } } @@ -244,29 +249,40 @@ function set_icon($icon, $title=false) return "\n"; } -function button($name, $value, $title=false, $icon=false) +function button($name, $value, $title=false, $icon=false, $aspect='') { // php silently changes dots,spaces,'[' and characters 128-159 // to underscore in POST names, to maintain compatibility with register_globals + $rel = ''; + if ($aspect == 'selector') { + $rel = " rel='$value'"; + $value = _("Select"); + } if (user_graphic_links() && $icon) { if ($value == _("Delete")) // Helper during implementation $icon = ICON_DELETE; return "