$default = $numeric_id ? -1 : '';
$selected_id = get_post('selected_id', $default);
- foreach (array('ADD_ITEM', 'UPDATE_ITEM', 'RESET') as $m) {
+ foreach (array('ADD_ITEM', 'UPDATE_ITEM', 'RESET', 'CLONE') as $m) {
if (isset($_POST[$m])) {
$Ajax->activate('_page_body');
- if ($m == 'RESET')
+ if ($m == 'RESET' || $m == 'CLONE')
$selected_id = $default;
+ unset($_POST['_focus']);
$Mode = $m; return;
}
}
" aspect='fallback'" : " style='display:none;'"; break;
}
- default_focus($name);
$submit_str = "<button class=\""
.($atype ? 'ajaxsubmit' : 'inputsubmit')
."\" type=\"submit\""
'both' - use both Ctrl-Enter and Escape hotkeys
'cancel' - apply to 'RESET' button
*/
-function submit_add_or_update($add=true, $title=false, $async=false)
+function submit_add_or_update($add=true, $title=false, $async=false, $clone=false)
{
$cancel = $async;
if ($add)
submit('ADD_ITEM', _("Add new"), true, $title, $async);
else {
- submit('UPDATE_ITEM', _("Update"), true, $title, $async);
- submit('RESET', _("Cancel"), true, $title, $cancel);
+ submit('UPDATE_ITEM', _("Update"), true, _('Submit changes'), $async);
+ if ($clone) submit('CLONE', _("Clone"), true,
+ _('Edit new record with current data'), $async);
+ submit('RESET', _("Cancel"), true, _('Cancel edition'), $cancel);
}
}
-function submit_add_or_update_center($add=true, $title=false, $async=false)
+function submit_add_or_update_center($add=true, $title=false, $async=false, $clone=false)
{
echo "<center>";
- submit_add_or_update($add, $title, $async);
+ submit_add_or_update($add, $title, $async, $clone);
echo "</center>";
}
-function submit_add_or_update_row($add=true, $right=true, $extra="", $title=false, $async=false)
+function submit_add_or_update_row($add=true, $right=true, $extra="", $title=false, $async=false, $clone = false)
{
echo "<tr>";
if ($right)
echo "<td> </td>\n";
echo "<td $extra>";
- submit_add_or_update($add, $title, $async);
+ submit_add_or_update($add, $title, $async, $clone);
echo "</td></tr>\n";
}
global $Ajax;
$str = '';
- default_focus($name);
+
if ($label)
$str .= $label . " ";
if ($submit_on_change !== false) {
echo checkbox($label, $name, $value, $submit_on_change, $title);
}
-function check_cells($label, $name, $value, $submit_on_change=false, $title=false,
+function check_cells($label, $name, $value=null, $submit_on_change=false, $title=false,
$params='')
{
if ($label != null)
echo "</td>";
}
-function check_row($label, $name, $value, $submit_on_change=false, $title=false)
+function check_row($label, $name, $value=null, $submit_on_change=false, $title=false)
{
echo "<tr>";
echo check_cells($label, $name, $value, $submit_on_change, $title);
if ($check && (get_post($name) != Today()))
$aspect .= ' style="color:#FF0000"';
+ default_focus($name);
+
echo "<input type=\"text\" name=\"$name\" $class $aspect size=\"9\" maxlength=\"12\" value=\""
. $_POST[$name]. "\""
.($title ? " title='$title'": '')." > $post_label";