$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\""
." name=\"$name\" id=\"$name\" value=\"$value\""
.($title ? " title='$title'" : '')
.">"
- .($icon ? "<img src='$path_to_root/themes/".user_theme()."/images/$icon'>" : '')
+ .($icon ? "<img src='$path_to_root/themes/".user_theme()."/images/$icon' height='12'>" : '')
."<span>$value</span>"
."</button>\n";
if ($echo)
'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";
}
function submit_js_confirm($name, $msg) {
add_js_source(
- "_validate.$name=function(){ return confirm('$msg');};");
+ "_validate.$name=function(){ return confirm('"
+ . strtr($msg, array("\n"=>'\\n')) . "');};");
};
//-----------------------------------------------------------------------------------
function set_icon($icon, $title=false)
{
global $path_to_root;
- return "<img src='$path_to_root/themes/".user_theme()."/images/$icon' width='14' height='14' border='0'".($title ? " title='$title'" : "")." />\n";
+ return "<img src='$path_to_root/themes/".user_theme()."/images/$icon' width='12' height='12' border='0'".($title ? " title='$title'" : "")." />\n";
}
function button($name, $value, $title=false, $icon=false, $aspect='')
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);
label_cell("<a href='mailto:$label'>$label</a>", $params, $id);
}
+function amount_decimal_cell($label, $params="", $id=null)
+{
+ $dec = 0;
+ label_cell(price_decimal_format($label, $dec), "nowrap align=right ".$params, $id);
+}
+
function amount_cell($label, $bold=false, $params="", $id=null)
{
if ($bold)
label_cell(price_format($label), "nowrap align=right ".$params, $id);
}
+//JAM Allow entered unit prices to be fractional
+function unit_amount_cell($label, $bold=false, $params="", $id=null)
+{
+ if ($bold)
+ label_cell("<b>".unit_price_format($label)."</b>", "nowrap align=right ".$params, $id);
+ else
+ label_cell(unit_price_format($label), "nowrap align=right ".$params, $id);
+}
+
+
function percent_cell($label, $bold=false, $id=null)
{
if ($bold)
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";
amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec);
}
+//JAM Allow entered unit prices to be fractional
+function unit_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ if (!isset($dec))
+ $dec = user_price_dec()+2;
+
+ amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec+2);
+}
+
function amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
echo "<tr>";