! -> 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
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;
***********************************************************************/
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
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();
foreach($js_lib as $text)
echo $text;
-
echo "\n--></script>\n";
echo "</body></html>\n";
}
// 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');
}
}
+/*
+ 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
{
$_SESSION['Context'] = array();
}
-
/*
Context stack initialization
*/
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)
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;
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');
}
}
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>";
}
{
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)
// 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,
$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);
'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
}
$_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);
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,
'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
) );
$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;
}
{
$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;
}
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;
}
$app->selected_application = $_GET['application'];
$app->display();
- context_reset();
?>
\ No newline at end of file
$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");
}
//--------------------------------------------------------------------------------------------
-if (isset($_POST['select']))
-{
- context_return(array('stock_id' => $_POST['stock_id']));
-}
-
-
-//------------------------------------------------------------------------------------
-
start_form(true);
if (db_has_stock_items())
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();
//------------------------------------------------------------------------------------
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);
//--------------------------------------------------------------------------------------------------
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
*/
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() {
*/
};
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;
}
/*
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;
}
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) {
***********************************************************************/
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) {
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();
$path_to_root="../..";
include($path_to_root . "/includes/session.inc");
-page(_("Suppliers"));
+page(_("Suppliers"), @$_REQUEST['popup']);
//include($path_to_root . "/includes/date_functions.inc");
$Ajax->activate('_page_body');
} //end if Delete supplier
}
-elseif (isset($_POST['select']))
-{
- context_return(array('supplier_id' => $_POST['supplier_id']));
-}
start_form();
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);
}
submit_center('submit', _("Add New Supplier Details"), true, '', 'default');
}
div_end();
+hidden('popup', @$_REQUEST['popup']);
end_form();
end_page();
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']))
{
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']))
{
$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']))
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);
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 */
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'])) {
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']))
$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");
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')
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();
}
hidden('selected_id', $selected_id);
hidden('branch_code');
+hidden('popup', @$_REQUEST['popup']);
table_section_title(_("Name and Contact"));
$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");
}
//--------------------------------------------------------------------------------------------
-if (isset($_POST['select']))
-{
- context_return(array('customer_id' => $_POST['customer_id'],
- 'branch_id' => '')); // this fires customer history checks
-}
-//--------------------------------------------------------------------------------------------
-
if (isset($_POST['delete']))
{
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();
}
{
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();
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);
}
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'];