Asynchronous customer/supplier/item selection now use popup window.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 21 Jul 2009 21:39:41 +0000 (21:39 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Tue, 21 Jul 2009 21:39:41 +0000 (21:39 +0000)
24 files changed:
CHANGELOG.txt
gl/gl_bank.php
includes/page/footer.inc
includes/session.inc
includes/ui/ui_controls.inc
includes/ui/ui_input.inc
includes/ui/ui_lists.inc
index.php
inventory/manage/items.php
inventory/purchasing_data.php
js/inserts.js
js/utils.js
purchasing/allocations/supplier_allocation_main.php
purchasing/manage/suppliers.php
purchasing/po_entry_items.php
purchasing/supplier_credit.php
purchasing/supplier_invoice.php
purchasing/supplier_payment.php
sales/allocations/customer_allocation_main.php
sales/credit_note_entry.php
sales/customer_payments.php
sales/manage/customer_branches.php
sales/manage/customers.php
sales/sales_order_entry.php

index 48bc5722cb4c2692e42d2591d0953457eb4a04ef..6a4a8fcbd2581ccc07bf6762ae65aa7cba87b156 100644 (file)
@@ -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
index fc6c50e67f0129a5b3a6bbd3525b095b1665e087..a9d969a2ec77657f326903d63e5cb086ff2875f0 100644 (file)
@@ -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;
index 0ba9b52a1f56f18bbe0bc39890228f42c0dfd4a9..da53a925c1e93e63cdafa7b45aa078d10142f5d0 100644 (file)
@@ -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 "<script>
                _focus = '" . get_post('_focus') . "';
                _validate = " . JsHttpRequest::php2js($Validate).";
+               var editors = ".JsHttpRequest::php2js($Editors).";
        </script>";
 
        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--></script>\n";
     echo "</body></html>\n";
 }
index 65b62f55dc348d6767951f47b55594c91229eddd..d53e9b63e660cd154fd9fcdc5c49f40fb45a53eb 100644 (file)
@@ -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');
index 559d1751b9eda8fcce0de7037cd1b4507550388b..7b518e57108cb567944bd59937a8809a52c18001 100644 (file)
@@ -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
 */
index a2355cfb02ee4f34c8823d65c63a1feb6910f539..ccd62b48164f70671e26a23f2a82e587d090135f 100644 (file)
@@ -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 "</tr>\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 "<img src='$path_to_root/themes/".user_theme()."/images/$icon' width='14' height='14' border='0'".($title ? " title='$title'" : "")." />\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 "<button type='submit' class='editbutton' name='".
                        htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B'))).
-                       "' value='1'" . ($title ? " title='$title'":" title='$value'")." />".set_icon($icon)."\n";
+                       "' value='1'" . ($title ? " title='$title'":" title='$value'")
+                       . ($aspect ? " aspect='$aspect'" : '')
+                       . $rel
+                       ." />".set_icon($icon)."\n";
        }
        else
                return "<input type='submit' class='editbutton' name='"
                        .htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
                        ."' value='$value'"
-                       .($title ? " title='$title'":'')." />\n";
+                       .($title ? " title='$title'":'')
+                       . ($aspect ? " aspect='$aspect'" : '')
+                       . $rel
+                       ." />\n";
 }
 
-function button_cell($name, $value, $title=false, $icon=false)
+function button_cell($name, $value, $title=false, $icon=false, $aspect='')
 {
        echo "<td align='center'>";
-       echo button($name, $value, $title, $icon);
+       echo button($name, $value, $title, $icon, $aspect);
        echo "</td>";
 }
 
@@ -279,6 +295,11 @@ function edit_button_cell($name, $value, $title=false)
 {
        button_cell($name, $value, $title, ICON_EDIT);
 }
+
+function select_button_cell($name, $value, $title=false)
+{
+       button_cell($name, $value, $title, ICON_ADD, 'selector');
+}
 //-----------------------------------------------------------------------------------
 
 function check_value($name)
index bd411303ce3f9571ef0443882ec2f160a532f4c9..672f1950d98d518799e982399f4d9ea22ab6c52f 100644 (file)
@@ -41,7 +41,6 @@ $opts = array(                // default options
                // submit on select parameters
        'default' => '', // default value when $_POST is not set
        'select_submit' => false, //submit on select: true/false
-       'edit_submit' => false, // call editor on F4
        'async' => true,        // select update via ajax (true) vs _page_body reload
                // search box parameters
        'sel_hint' => null,
@@ -209,9 +208,8 @@ $opts = array(              // default options
                $txt = $found;
                $Ajax->addUpdate($name, $search_box, $txt ? $txt : '');
        }
-       $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
        $selector = "<select $disabled name='$name' class='$class' title='"
-               . $opts['sel_hint']."'$aspect $rel>".$selector."</select>\n";
+               . $opts['sel_hint']."' $rel>".$selector."</select>\n";
 
        $Ajax->addUpdate($name, "_{$name}_sel", $selector);
 
@@ -274,7 +272,6 @@ $opts = array(              // default options
        'spec_option'=>false,   // option text or false
        'spec_id' => 0,         // option id
        'select_submit' => false, //submit on select: true/false
-       'edit_submit' => false, // call editor on F4
        'async' => true,        // select update via ajax (true) vs _page_body reload
        'default' => '', // default value when $_POST is not set
                // search box parameters
@@ -332,9 +329,8 @@ $opts = array(              // default options
        }
        $_POST[$name] = $selected_id;
 
-       $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
        $selector = "<select $disabled name='$name' class='combo' title='"
-               . $opts['sel_hint']."'$aspect >".$selector."</select>\n";
+               . $opts['sel_hint']."'>".$selector."</select>\n";
 
        $Ajax->addUpdate($name, "_{$name}_sel", $selector);
 
@@ -378,7 +374,6 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_
        array(
                'format' => '_format_add_curr',
                'search_box' => $mode!=0,
-               'edit_submit' => true, 
                'type' => 1,
                'spec_option' => $spec_option === true ? _("All Suppliers") : $spec_option,
                'spec_id' => $all_items,
@@ -426,9 +421,8 @@ return combo_input($name, $selected_id, $sql, 'debtor_no', 'name',
                'spec_option' => $spec_option === true ? _("All Customers") : $spec_option,
                'spec_id' => $all_items,
                'select_submit'=> $submit_on_change,
-               'edit_submit' => true, // call editor on F4
                'async' => false,
-               'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
+               'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F2 - entry new customer') :
                _('Select customer'),
                'show_inactive' => $show_inactive
        ) );
@@ -776,8 +770,7 @@ function stock_manufactured_items_list($name, $selected_id=null,
        $all_option=false, $submit_on_change=false)
 {
        $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
-               array('where'=>array("mb_flag= 'M'"), 
-                       'edit_submit' => true));
+               array('where'=>array("mb_flag= 'M'")));
        return $str;            
 }
 
@@ -845,7 +838,6 @@ function stock_purchasable_items_list($name, $selected_id=null,
 {
        $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
                array('where'=>array("mb_flag!= 'M'"), 
-                       'edit_submit' => true,
                        'show_inactive'=>$all));
        return $str;
 }
@@ -857,7 +849,6 @@ function stock_purchasable_items_list_cells($label, $name, $selected_id=null,
                echo "<td>$label</td>\n";
        $str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
                array('where'=>array("mb_flag!= 'M'"), 
-                        'edit_submit' => true,
                         'cells'=>true));
        return $str;
 }
index 269636a04eedb243f8b3a786e917cee502355ff0..85dce69fedfa0bf1dc15ca4b2797559edeb6a0d4 100644 (file)
--- a/index.php
+++ b/index.php
@@ -19,5 +19,4 @@
                $app->selected_application = $_GET['application'];
 
        $app->display();
-       context_reset();
 ?>
\ No newline at end of file
index 36249813c2fbfd13b5bf3dd63f038080bd088df6..d7f806149222d1a82b9c84cca54e84aea9c1175b 100644 (file)
@@ -13,7 +13,7 @@ $page_security = 11;
 $path_to_root="../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_("Items"));
+page(_("Items"), @$_REQUEST['popup']);
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/ui.inc");
@@ -277,14 +277,6 @@ if (isset($_POST['delete']) && strlen($_POST['delete']) > 1)
 }
 //-------------------------------------------------------------------------------------------- 
 
-if (isset($_POST['select']))
-{
-       context_return(array('stock_id' => $_POST['stock_id']));
-}
-
-
-//------------------------------------------------------------------------------------
-
 start_form(true);
 
 if (db_has_stock_items()) 
@@ -455,13 +447,15 @@ if (!isset($_POST['NewStockID']) || $new_item)
 else 
 {
        submit_center_first('addupdate', _("Update Item"), '', 
-       count($_SESSION['Context']) ? true : 'default');
-       submit_return('select', _("Return"), _("Select this items and return to document entry."), 'default');
+               @$_REQUEST['popup'] ? true : 'default');
+       submit_return('select', get_post('stock_id'), 
+               _("Select this items and return to document entry."), 'default');
        submit('delete', _("Delete This Item"), true, '', true);
        submit_center_last('cancel', _("Cancel"), _("Cancel Edition"), 'cancel');
 }
 
 div_end();
+hidden('popup', @$_REQUEST['popup']);
 end_form();
 
 //------------------------------------------------------------------------------------
index 08059fe97451dbdf593808480eb4150930687d1b..20cf75366e35817bc0bcd50975e7082aad810606 100644 (file)
@@ -24,15 +24,8 @@ check_db_has_purchasable_items(_("There are no purchasable inventory items defin
 check_db_has_suppliers(_("There are no suppliers defined in the system."));
 
 //----------------------------------------------------------------------------------------
-if ($ret = context_restore()) {
-       if(isset($ret['supplier_id']))
-               $_POST['supplier_id'] = $ret['supplier_id'];
-}
-if (isset($_POST['_supplier_id_editor'])) {
-       context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'], 
-               array( 'supplier_id', 'stock_id','_stock_id_edit', 'price', 
-                       'suppliers_uom', 'supplier_description','conversion_factor'));
-}
+set_editor('supplier', 'supplier_id' , 'supplier_id');
+
 simple_page_mode(true);
 //--------------------------------------------------------------------------------------------------
 
index a6d08dd952c70fe8e264c81a6f9828d1f8f2b340..6100d2ddeca2ef1c9a6dd7f8830366d8108118c8 100644 (file)
@@ -137,15 +137,36 @@ function _set_combo_select(e) {
                                setFocus(box);
                            return false;
                         }
-                       if (this.getAttribute('aspect') == 'editable' && key==115) {
-                               // F4: call related database editor - not available in non-js fallback mode
-                               JsHttpRequest.request('_'+this.name+'_editor', this.form);
-                               return false; // prevent default binding
-                               // TODO: stopPropagation when needed
-                       }
                }
 }              
 
+function callEditor(key) {
+  var el = document.getElementsByName(editors[key][1])[0]; 
+  w = open(editors[key][0]+el.value+'&popup=1',
+         "edit","Scrollbars=0,resizable=0,width=800,height=600");
+  if (w.opener == null)
+         w.opener = self;
+  editors._call = key; // store call point for passBack 
+  w.focus();
+}
+
+function passBack(value) {
+       var o = opener;
+       if(value != false) {
+               var back = o.editors[o.editors._call]; // form input bindings
+               var to = o.document.getElementsByName(back[1])[0];
+               if (to) {
+                       if (to[0] != undefined) 
+                               to[0].value = value; // ugly hack to set selector to any value
+                       to.value = value;
+                       // update page after item selection
+                       o.JsHttpRequest.request('_'+to.name+'_update');
+               }
+               o.setFocus(back[2]);
+       }
+       close();
+}
+
 /*
  Behaviour definitions
 */
@@ -233,7 +254,13 @@ var inserts = {
                                        JsHttpRequest.request('_'+this.name+'_changed', this.form);
                                }
                        }
-               },
+       },
+       'button[aspect=selector], input[aspect=selector]': function(e) {
+               e.onclick = function() {
+                       passBack(this.getAttribute('rel'));
+                       return false;
+               }
+       },
        'select': function(e) {
                if(e.onfocus==undefined) {
                        e.onfocus = function() {
@@ -314,9 +341,14 @@ var inserts = {
 */
 };
 function stopEv(ev) {
-                       ev.returnValue = false;
-                       ev.cancelBubble = true;
-                       if(ev.preventDefault) ev.preventDefault();
+                       if(ev.preventDefault) {
+                               ev.preventDefault();
+                               ev.stopPropagation();
+                       } else {
+                               ev.returnValue = false;
+                               ev.cancelBubble = true;
+                               window.keycode = 0;
+                       }
                        return false;
 }
 /*
@@ -361,6 +393,11 @@ function setHotKeys() {
                                for (var i=0; i<form.elements.length; i++){
                                        var el = form.elements[i];
                                        var asp = el.getAttribute('aspect');
+                                       if ((asp=='selector') && (key==13 || key==27)) {
+                                               passBack(key==13 ? el.getAttribute('rel') : false);
+                                               ev.returnValue = false;
+                                               return false;
+                                       }
                                        if ((asp=='default' && key==13)||(asp=='cancel' && key==27)) {
                                                JsHttpRequest.request(el);
                                                ev.returnValue = false;
@@ -370,14 +407,18 @@ function setHotKeys() {
                        }
                        ev.returnValue = false;
                        return false;
+               }
+               if (editors && editors[key]) {
+                       callEditor(key);
+                       return stopEv(ev); // prevent default binding
                } 
                return true;
        };
        document.onkeyup = function(ev) {
-               if (_hotkeys.alt==true) {
-                       ev = ev||window.event;
-                       key = ev.keyCode||ev.which;
+               ev = ev||window.event;
+               key = ev.keyCode||ev.which;
 
+               if (_hotkeys.alt==true) {
                        if (key == 18) {
                                _hotkeys.alt = false;
                                if (_hotkeys.focus>=0) {
index 73151cf3010d2f28e6a197f35de9b96832b8642d..0fba1abb5cd2b79fe93407a5f8f1cc98d8e858fe 100644 (file)
 ***********************************************************************/
 function set_mark(img) {
        var box = document.getElementById('ajaxmark');
-       if(img) box.src = user.theme+'images/'+ img;
-       box.style.visibility = img ? 'visible' : 'hidden'
+       if(box) {
+               if(img) box.src = user.theme+'images/'+ img;
+               box.style.visibility = img ? 'visible' : 'hidden'
+       }
 }
 
 function disp_msg(msg, cl) {
index 4c731d6ebbe4551f35f2dc2a947c56557f825dc2..8c11ea9e563d11ea4b7488a399c5b38e140ae79f 100644 (file)
@@ -26,15 +26,7 @@ if ($use_popup_windows)
 page(_("Supplier Allocations"), false, false, "", $js);
 
 //--------------------------------------------------------------------------------
-if ($ret = context_restore()) {
-       if(isset($ret['supplier_id']))
-               $_POST['supplier_id'] = $ret['supplier_id'];
-}
-if (isset($_POST['_supplier_id_editor'])) {
-       context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'] );
-}
-
-//--------------------------------------------------------------------------------
+set_editor('supplier', 'supplier_id' , 'ShowSettled');
 
 start_form();
 
index 2d92edc8ec3a748d11bdac909e89f9c17c411135..45c4d1198d49039c1012d018fc765c828a8a7f12 100644 (file)
@@ -13,7 +13,7 @@ $page_security=5;
 $path_to_root="../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_("Suppliers"));
+page(_("Suppliers"), @$_REQUEST['popup']);
 
 //include($path_to_root . "/includes/date_functions.inc");
 
@@ -156,10 +156,6 @@ elseif (isset($_POST['delete']) && $_POST['delete'] != "")
                $Ajax->activate('_page_body');
        } //end if Delete supplier
 }
-elseif (isset($_POST['select']))
-{
-       context_return(array('supplier_id' => $_POST['supplier_id']));
-}
 
 start_form();
 
@@ -301,8 +297,8 @@ div_start('controls');
 if (!$new_supplier) 
 {
        submit_center_first('submit', _("Update Supplier"), 
-         _('Update supplier data'), 'default');
-       submit_return('select', _("Return"), _("Select this supplier and return to document entry."), 'cancel');
+         _('Update supplier data'), true);
+       submit_return('select', get_post('supplier_id'), _("Select this supplier and return to document entry."));
        submit_center_last('delete', _("Delete Supplier"), 
          _('Delete supplier data if have been never used'), true);
 }
@@ -311,6 +307,7 @@ else
        submit_center('submit', _("Add New Supplier Details"), true, '', 'default');
 }
 div_end();
+hidden('popup', @$_REQUEST['popup']);
 end_form();
 
 end_page();
index 2ab43bb791dd1a752fa6239751f67f640df99d63..0bf90f9b8c9d0e6535b35fd4dd707ff47eef569c 100644 (file)
@@ -38,26 +38,8 @@ check_db_has_suppliers(_("There are no suppliers defined in the system."));
 check_db_has_purchasable_items(_("There are no purchasable inventory items defined in the system."));
 
 //---------------------------------------------------------------------------------------------------------------
-if ($ret = context_restore()) {
- // return from supplier/items editors
-       copy_from_cart();
-       if(isset($ret['supplier_id']))
-               $_POST['supplier_id'] = $ret['supplier_id'];
-       if(isset($ret['stock_id'])) {
-               $_POST['stock_id'] = $_POST['_stock_id_edit'] = $ret['stock_id'];
-               set_focus('qty');
-       }
-}
-if (isset($_POST['_supplier_id_editor'])) {
-       copy_to_cart();
-       context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'], 'PO');
-}
-
-if (isset($_POST['_stock_id_editor'])) {
-       copy_to_cart();
-       context_call($path_to_root.'/inventory/manage/items.php?stock_id='.$_POST['stock_id'], 'PO');
-}
-//------------------------------------------------------------------------------
+set_editor('supplier', 'supplier_id' , 'ref');
+set_editor('item', 'stock_id' , 'qty');
 
 if (isset($_GET['AddedID'])) 
 {
index 513135fc31bd8928b1ccd1a15f5841a1dba08407..6f27aa51874fbc29c262059c9a4913101fda05d0 100644 (file)
@@ -33,18 +33,7 @@ page(_("Supplier Credit Note"), false, false, "", $js);
 check_db_has_suppliers(_("There are no suppliers defined in the system."));
 
 //---------------------------------------------------------------------------------------------------------------
-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');
-}
-
-//---------------------------------------------------------------------------------------------------------------
+set_editor('supplier', 'supplier_id' , 'reference');
 
 if (isset($_GET['AddedID'])) 
 {
index 0fad0e6eddfc06f0d06b5072da58049106f129d5..89ed41b76678fc58f012edcc9ba3e14825cd2555 100644 (file)
@@ -27,23 +27,11 @@ if ($use_date_picker)
        $js .= get_js_date_picker();
 page(_("Enter Supplier Invoice"), false, false, "", $js);
 
-
+set_editor('supplier', 'supplier_id' , 'reference');
 //----------------------------------------------------------------------------------------
 
 check_db_has_suppliers(_("There are no suppliers defined in the system."));
 
-//---------------------------------------------------------------------------------------------------------------
-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['AddedID'])) 
index 5928e56b7327de10d9925768a649650234c062ee..91db00d4e240953529578a803d662db0faa0a39a 100644 (file)
@@ -42,15 +42,7 @@ check_db_has_suppliers(_("There are no suppliers defined in the system."));
 check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));
 
 //----------------------------------------------------------------------------------------
-if ($ret = context_restore()) {
-       if(isset($ret['supplier_id']))
-               $_POST['supplier_id'] = $ret['supplier_id'];
-}
-if (isset($_POST['_supplier_id_editor'])) {
-       context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'], 
-               array( 'supplier_id', 'bank_account', 'DatePaid', 'ref', 'amount', 
-                       'discount', 'memo_') );
-}
+set_editor('supplier', 'supplier_id' , 'bank_account');
 
 if (!isset($_POST['supplier_id']))
        $_POST['supplier_id'] = get_global_supplier(false);
index ee373036ac4be6b18e9a4589063ae6b31954582a..5e7d292a872f817b2bc516412fa4fa6105f9c882 100644 (file)
@@ -22,13 +22,7 @@ if ($use_popup_windows)
 page(_("Customer Allocations"), false, false, "", $js);
 
 //--------------------------------------------------------------------------------
-if ($ret = context_restore()) {
-       if(isset($ret['customer_id']))
-               $_POST['customer_id'] = $ret['customer_id'];
-}
-if (isset($_POST['_customer_id_editor'])) {
-       context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'] );
-}
+set_editor('customer', 'customer_id' , 'ShowSettled');
 
 start_form();
        /* show all outstanding receipts and credits to be allocated */
index f27bf8f0ad8617c4c9f9f81bbb6b58179253c707..4c4617020b8ab864971be69bf50b6dfb21c47cfd 100644 (file)
@@ -51,17 +51,14 @@ check_db_has_stock_items(_("There are no items defined in the system."));
 check_db_has_customer_branches(_("There are no customers, or there are no customers with branches. Please define customers and customer branches."));
 
 //-----------------------------------------------------------------------------
-if ($ret = context_restore()) {
- // return from new customer add
-       copy_from_cn();
-       if(isset($ret['customer_id']))
-               $_POST['customer_id'] = $ret['customer_id'];
-       if(isset($ret['branch_id']))
-               $_POST['branch_id'] = $ret['branch_id'];
-}
-if (isset($_POST['_customer_id_editor'])) {
-       copy_to_cn(); //store context
-       context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], 'Items');
+set_editor('customer', 'customer_id' , 'branch_id');
+set_editor('branch', 'branch_id' , 'ref');
+
+if (list_updated('branch_id')) {
+       // when branch is selected via external editor also customer can change
+       $br = get_branch(get_post('branch_id'));
+       $_POST['customer_id'] = $br['debtor_no'];
+       $Ajax->activate('customer_id');
 }
 
 if (isset($_GET['AddedID'])) {
index 8ef48c17f92e4d2d9e41394c26e89efaf1889e70..24c6e0cd594e418c9032a918b112d218fdb5e622 100644 (file)
@@ -38,16 +38,14 @@ check_db_has_customers(_("There are no customers defined in the system."));
 check_db_has_bank_accounts(_("There are no bank accounts defined in the system."));
 
 //----------------------------------------------------------------------------------------
-if ($ret = context_restore()) {
-       if(isset($ret['customer_id']))
-               $_POST['customer_id'] = $ret['customer_id'];
-       if(isset($ret['branch_id']))
-               $_POST['BranchID'] = $ret['branch_id'];
-}
-if (isset($_POST['_customer_id_editor'])) {
-       context_call($path_to_root.'/sales/manage/customers.php?debtor_no='.$_POST['customer_id'], 
-               array( 'customer_id', 'BranchID', 'bank_account', 'DateBanked', 
-                       'ref', 'amount', 'discount', 'memo_') );
+set_editor('customer', 'customer_id' , 'sales_type');
+set_editor('branch', 'BranchID' , 'bank_account');
+
+if (list_updated('BranchID')) {
+       // when branch is selected via external editor also customer can change
+       $br = get_branch(get_post('BranchID'));
+       $_POST['customer_id'] = $br['debtor_no'];
+       $Ajax->activate('customer_id');
 }
 
 if (!isset($_POST['customer_id']))
index 25bd391543b3f5f677f438275cea64aa7d9af72e..433b0127f40de6b64f22d92951a484306e737964 100644 (file)
@@ -13,7 +13,7 @@ $page_security = 3;
 $path_to_root="../..";
 include($path_to_root . "/includes/session.inc");
 
-page(_("Customer Branches"));
+page(_("Customer Branches"), @$_REQUEST['popup']);
 
 include($path_to_root . "/includes/ui.inc");
 
@@ -40,17 +40,10 @@ $_POST['branch_code'] = $selected_id;
 
 if (isset($_GET['SelectedBranch']))
 {
-       $_POST['branch_code'] = strtoupper($_GET['SelectedBranch']);
-       $selected_id = $_GET['SelectedBranch'];
+       $br = get_branch($_GET['SelectedBranch']);
+       $_POST['customer_id'] = $br['debtor_no'];
+       $selected_id = $_POST['branch_code'] = $br['branch_code'];
 }
-
-$id = find_submit('Select');
-if ($id != -1)
-{
-       context_return(array('customer_id' => $_POST['customer_id'],
-               'branch_id' => $id)); // return to sales document
-}
-
 //-----------------------------------------------------------------------------------------------
 
 if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
@@ -219,8 +212,8 @@ if ($num_branches)
                label_cell($myrow["tax_group_name"]);
                inactive_control_cell($myrow["branch_code"], $myrow["inactive"],
                        'cust_branch', 'branch_code');
-               if (count($_SESSION['Context']))
-                       button_cell("Select".$myrow["branch_code"], _("Select"), '', ICON_ADD);
+               if (@$_REQUEST['popup'])
+                       select_button_cell("Select".$myrow["branch_code"], $myrow["branch_code"], '');
                edit_button_cell("Edit".$myrow["branch_code"], _("Edit"));
                delete_button_cell("Delete".$myrow["branch_code"], _("Delete"));
                end_row();
@@ -298,6 +291,7 @@ elseif ($Mode != 'ADD_ITEM')
 }
 hidden('selected_id', $selected_id);
 hidden('branch_code');
+hidden('popup', @$_REQUEST['popup']);
 
 table_section_title(_("Name and Contact"));
 
index 16581f55f2d5dc5f774c38e21c523a27d51b20bc..e5ea837ab7228c08f75c2ca6d5efe089d31f4017 100644 (file)
@@ -13,7 +13,7 @@ $page_security = 3;
 $path_to_root="../..";
 
 include_once($path_to_root . "/includes/session.inc");
-page(_("Customers")); 
+page(_("Customers"), @$_REQUEST['popup']); 
 
 include_once($path_to_root . "/includes/date_functions.inc");
 include_once($path_to_root . "/includes/banking.inc");
@@ -127,13 +127,6 @@ if (isset($_POST['submit']))
 }
 //-------------------------------------------------------------------------------------------- 
 
-if (isset($_POST['select']))
-{
-       context_return(array('customer_id' => $_POST['customer_id'], 
-               'branch_id' => '')); // this fires customer history checks
-}
-//-------------------------------------------------------------------------------------------- 
-
 if (isset($_POST['delete'])) 
 {
 
@@ -294,8 +287,8 @@ if (!$new_customer)  {
        start_row();
        echo '<td>'._('Customer branches').':</td>';
        hyperlink_params_td($path_to_root . "/sales/manage/customer_branches.php",
-               '<b>'. (count($_SESSION['Context']) ?  _("Select or &Add") : _("&Add or Edit ")).'</b>', 
-               "debtor_no=".$_POST['customer_id']);
+               '<b>'. (@$_REQUEST['popup'] ?  _("Select or &Add") : _("&Add or Edit ")).'</b>', 
+               "debtor_no=".$_POST['customer_id'].(@$_REQUEST['popup'] ? '&popup=1':''));
        end_row();
 
 }
@@ -312,11 +305,12 @@ else
 {
        submit_center_first('submit', _("Update Customer"), 
          _('Update customer data'), true);
-       submit_return('select', _("Return"), _("Select this customer and return to document entry."), 'default');
+       submit_return('select', get_post('customer_id'), _("Select this customer and return to document entry."));
        submit_center_last('delete', _("Delete Customer"), 
          _('Delete customer data if have been never used'), true);
 }
 div_end();
+hidden('popup', @$_REQUEST['popup']);
 end_form();
 end_page();
 
index f19b3cb6f6f9a96dc433f0ec6dcfaa40f8521eaa..40e008fdc9e87b2663c8c3d836160688c6ef5e9a 100644 (file)
@@ -28,15 +28,6 @@ include_once($path_to_root . "/sales/includes/db/sales_types_db.inc");
 include_once($path_to_root . "/reporting/includes/reporting.inc");
 $js = '';
 
-editor_redirect( array(
-       'customer_id' => $path_to_root.'/sales/manage/customers.php?debtor_no='.get_post('customer_id'),
-       'branch_id' => $path_to_root.'/sales/manage/customer_branches.php?branch_id='.get_post('branch_id'),
-       ));
-
-editor_return( array(
-       'customer_id'=>'customer_id',
-       'branch_id'=>'branch_id'));
-
 if ($use_popup_windows) {
        $js .= get_js_open_window(900, 500);
 }
@@ -69,6 +60,15 @@ if (isset($_GET['NewDelivery']) && is_numeric($_GET['NewDelivery'])) {
 
 page($_SESSION['page_title'], false, false, "", $js);
 //-----------------------------------------------------------------------------
+set_editor('customer', 'customer_id', 'sales_type');
+set_editor('branch', 'branch_id', 'sales_type');
+
+if (list_updated('branch_id')) {
+       // when branch is selected via external editor also customer can change
+       $br = get_branch(get_post('branch_id'));
+       $_POST['customer_id'] = $br['debtor_no'];
+       $Ajax->activate('customer_id');
+}
 
 if (isset($_GET['AddedID'])) {
        $order_no = $_GET['AddedID'];