X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Fui%2Fui_input.inc;h=1b73f1a40397d848dca2c422dbc123c4637e6a96;hb=a8c6e7e820741388aca1e6c42aed7f899b38c188;hp=ccd62b48164f70671e26a23f2a82e587d090135f;hpb=f018643dc04ce130f1729e16a65458af443308a0;p=fa-stable.git
diff --git a/includes/ui/ui_input.inc b/includes/ui/ui_input.inc
index ccd62b48..1b73f1a4 100644
--- a/includes/ui/ui_input.inc
+++ b/includes/ui/ui_input.inc
@@ -47,11 +47,12 @@ function simple_page_mode($numeric_id = true)
$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;
}
}
@@ -135,7 +136,6 @@ function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=fal
" aspect='fallback'" : " style='display:none;'"; break;
}
- default_focus($name);
$submit_str = "\n";
if ($echo)
@@ -177,7 +177,7 @@ function submit_center_last($name, $value, $title=false, $async=false, $icon=fal
'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;
@@ -192,25 +192,27 @@ function submit_add_or_update($add=true, $title=false, $async=false)
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 "
";
- submit_add_or_update($add, $title, $async);
+ submit_add_or_update($add, $title, $async, $clone);
echo "";
}
-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 "";
if ($right)
echo " | \n";
echo "";
- submit_add_or_update($add, $title, $async);
+ submit_add_or_update($add, $title, $async, $clone);
echo " |
\n";
}
@@ -239,14 +241,15 @@ function submit_return($name, $value, $title=false)
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 "\n";
+ return "\n";
}
function button($name, $value, $title=false, $icon=false, $aspect='')
@@ -314,7 +317,7 @@ function checkbox($label, $name, $value=null, $submit_on_change=false, $title=fa
global $Ajax;
$str = '';
- default_focus($name);
+
if ($label)
$str .= $label . " ";
if ($submit_on_change !== false) {
@@ -341,7 +344,7 @@ function check($label, $name, $value=null, $submit_on_change=false, $title=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)
@@ -351,7 +354,7 @@ function check_cells($label, $name, $value, $submit_on_change=false, $title=fals
echo "";
}
-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 "";
echo check_cells($label, $name, $value, $submit_on_change, $title);
@@ -384,6 +387,12 @@ function email_cell($label, $params="", $id=null)
label_cell("$label", $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)
@@ -392,6 +401,16 @@ function amount_cell($label, $bold=false, $params="", $id=null)
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("".unit_price_format($label)."", "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)
@@ -583,6 +602,8 @@ function date_cells($label, $name, $title = null, $check=null, $inc_days=0,
if ($check && (get_post($name) != Today()))
$aspect .= ' style="color:#FF0000"';
+ default_focus($name);
+
echo " $post_label";
@@ -671,6 +692,15 @@ function amount_cells($label, $name, $init=null, $params=null, $post_label=null,
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 "
";