echo "<meta http-equiv='Refresh' content='0; url=$forward_to?$params'>\n";
echo "<center><br>" . _("You should automatically be forwarded.");
echo " " . _("If this does not happen") . " " . "<a href='$forward_to?$params'>" . _("click here") . "</a> " . _("to continue") . ".<br><br></center>\n";
- $Ajax->redirect($forward_to.'?'.$params);
+ if ($params !='') $params = '?'.$params;
+ $Ajax->redirect($forward_to.$params);
exit;
}
.($title ? " title='$title'":'') .">" . _("Delete") . "</a>", "nowrap");
}
-function edit_button_cell($name, $value, $title=false)
+function edit_button($name, $value, $title=false)
{
// php silently changes dots,spaces,'[' and characters 128-159
// to underscore in POST names, to maintain compatibility with register_globals
-
- label_cell("<input type=\"submit\" class=\"editbutton\" name=\""
+ echo "<input type=\"submit\" class=\"editbutton\" name=\""
.htmlentities(strtr($name, array('.'=>'=2E',' '=>'=20','='=>'=3D','['=>'=5B')))
."\" value=\"$value\""
- .($title ? " title='$title'":'')." />\n");
+ .($title ? " title='$title'":'')." />\n";
+}
+
+function edit_button_cell($name, $value, $title=false)
+{
+ echo "<td>";
+ edit_button($name, $value, $title);
+ echo "</td>";
}
//-----------------------------------------------------------------------------------
echo "</div>";
}
}
+
+/*
+ External page call with saving current context.
+ $call - url of external page
+ $ctx - optional. name of SESSION context object or array of names of POST
+ variables saved on call
+*/
+function context_call($call, $ctx='')
+{
+ if (is_array($ctx))
+ {
+ foreach($ctx as $postname)
+ {
+ $context[$postname] = get_post($postname);
+ }
+ } else
+ $context = isset($_SESSION[$ctx]) ? $_SESSION[$ctx] : null;
+
+ array_unshift($_SESSION['Context'], array('name' => $ctx,
+ 'ctx' => $context,
+ 'caller' => $_SERVER['PHP_SELF'],
+ 'ret' => array()));
+ meta_forward($call);
+}
+/*
+ Restores context after external page call and
+ returns array of data passed by external page.
+*/
+function context_restore()
+{
+ if ( count($_SESSION['Context'])) {
+ if ($_SERVER['PHP_SELF'] == $_SESSION['Context'][0]['caller']) {
+ $ctx = array_shift($_SESSION['Context']);
+ if ($ctx) {
+ if (is_array($ctx['ctx'])) {
+ foreach($ctx['ctx'] as $name => $val)
+ {
+ $_POST[$name] = $val;
+ }
+ } else
+ if ($ctx['name']!='')
+ $_SESSION[$ctx['name']] = $ctx['ctx'];
+ return $ctx['ret'];
+ }
+ }
+ }
+ return false;
+}
+
+/*
+ Return to caller page if the page was called from external context.
+*/
+function context_return($ret)
+{
+ if ( count($_SESSION['Context'])) {
+ $ctx = &$_SESSION['Context'][0];
+ $ctx['ret'] = $ret;
+ meta_forward( $ctx['caller'] );
+ }
+}
+/*
+ Clearing context stack after page cancel.
+*/
+function context_reset()
+{
+ $_SESSION['Context'] = array();
+}
+
+/*
+ Context stack initialization
+*/
+if (!isset($_SESSION['Context'])) {
+ context_reset();
+}
+
?>
\ No newline at end of file
submit_cells($name, $value, $extra, $title, $async);
echo "</tr>\n";
}
+
+function submit_return($name, $value, $title=false, $async=false)
+{
+ if (count($_SESSION['Context'])) {
+ submit($name, $value, true, $title, $async);
+ }
+}
//---------------------------------------------------------------------------------
function button($name, $value, $onclick, $title=false)
// 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,
if(!count($opts['search'])) {
$opts['search'] = array($by_id ? $valfield : $namefield);
}
- if ($opts['sel_hint'] === null)
+ if ($opts['sel_hint'] === null)
$opts['sel_hint'] = $by_id || $search_box==false ?
'' : _('Press Space tab for search pattern entry');
if (get_post($search_submit) && ($txt === $value)) {
$selected_id = $value;
}
- if ((string)($selected_id) === $value) {
+ if (get_post($search_submit) && ($txt === $value)) {
+ $selected_id = $value;
+ }
+ if ((string)($selected_id) === $value) {
$sel = 'selected';
$found = $value;
- }
+ }
if ($first_id === false) {
$first_id = $value;
$first_opt = $descr;
$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']."' $rel>".$selector."</select>\n";
+ . $opts['sel_hint']."'$aspect $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] = $first_id;
}
+ $aspect = $opts['edit_submit'] ? " aspect='editable'" : '';
$selector = "<select $disabled name='$name' class='combo' title='"
- . $opts['sel_hint']."' >".$selector."</select>\n";
+ . $opts['sel_hint']."'$aspect >".$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') :
+ 'sel_hint' => $mode ? _('Press Space tab to filter by name fragment; F4 - entry new customer') :
_('Select customer')
) );
}
$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'")));
+ array('where'=>array("mb_flag!= 'M'"),
+ 'edit_submit' => true));
return $str;
}
if ($label != null)
echo "<td>$label</td>\n";
$str = stock_items_list($name, $selected_id, $all_option, $submit_on_change,
- array('where'=>array("mb_flag!= 'M'"), 'cells'=>true));
+ array('where'=>array("mb_flag!= 'M'"),
+ 'edit_submit' => true,
+ 'cells'=>true));
return $str;
}
if (isset($_GET['application']))
$app->selected_application = $_GET['application'];
$app->display();
+ context_reset();
?>
\ No newline at end of file
setFocus(box.name);
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: preventDefault, stopPropagation when needed
+ }
}
}