<?php
+//------------------------------------------------------------------------------
+// Seek for _POST variable with $prefix.
+// If var is found returns variable name with prefix stripped,
+// and null or -1 otherwise.
+//
+function find_submit($prefix, $numeric=true) {
+
+ foreach($_POST as $postkey=>$postval ) {
+ if (strpos($postkey, $prefix) === 0) {
+ $id = substr($postkey, strlen($prefix));
+ return $numeric ? (int)$id : $id;
+ }
+ }
+ return $numeric ? -1 : null;
+}
+
+//------------------------------------------------------------------------------
+//
+// Read numeric value from user formatted input
+//
+function input_num($postname=null) {
+ if (!isset($_POST[$postname]))
+ return null;
+
+ return user_numeric($_POST[$postname]);
+}
+
//---------------------------------------------------------------------------------
function hidden($name, $value)
function submit($name, $value, $echo=true)
{
+ default_focus($name);
$submit_str = "<input type=\"submit\" class=\"inputsubmit\" name=\"$name\" value=\"$value\">\n";
if ($echo)
echo $submit_str;
echo "<td> </td>\n";
submit_cells($name, $value, $extra);
echo "</tr>\n";
-}
+}
+//---------------------------------------------------------------------------------
+
+function button($name, $value, $onclick)
+{
+ default_focus($name);
+ echo "<input type=\"button\" class=\"inputsubmit\" name=\"$name\" value=\"$value\" onclick=\"$onclick\" />\n";
+}
+
+function button_cell($name, $value, $onclick)
+{
+ echo "<td>";
+ button($name, $value, $onclick);
+ echo "</td>\n";
+}
+
//-----------------------------------------------------------------------------------
-function check_value($name)
+function check_value($name)
{
if (!isset($_POST[$name]))
return 0;
- return 1;
+ return 1;
}
function check($label, $name, $value, $submit_on_change=false)
{
+ default_focus($name);
if ($label)
echo $label . " ";
//-----------------------------------------------------------------------------------
-function labelheader_cell($label, $params="")
+function labelheader_cell($label, $params="")
{
echo "<td class='tableheader' $params>$label</td>\n";
}
-function label_cell($label, $params="")
+function label_cell($label, $params="")
{
echo "<td $params>$label</td>\n";
}
function amount_cell($label, $bold=false)
{
if ($bold)
- label_cell("<b>".number_format2($label,user_price_dec())."</b>", "nowrap align=right");
- else
- label_cell(number_format2($label,user_price_dec()), "nowrap align=right");
+ label_cell("<b>".price_format($label)."</b>", "nowrap align=right");
+ else
+ label_cell(price_format($label), "nowrap align=right");
+}
+
+function percent_cell($label, $bold=false)
+{
+ if ($bold)
+ label_cell("<b>".percent_format($label)."</b>", "nowrap align=right");
+ else
+ label_cell(percent_format($label), "nowrap align=right");
}
-function qty_cell($label, $bold=false)
+function qty_cell($label, $bold=false, $dec=null)
{
if ($bold)
- label_cell("<b>".number_format2($label,user_qty_dec())."</b>", "nowrap align=right");
- else
- label_cell(number_format2($label,user_qty_dec()), "nowrap align=right");
+ label_cell("<b>".qty_format($label, $dec)."</b>", "nowrap align=right");
+ else
+ label_cell(qty_format($label, $dec), "nowrap align=right");
}
function label_cells($label, $value, $params="", $params2="")
echo "<td $params2>$value</td>\n";
}
-function label_row($label, $value, $params="", $params2="")
+function label_row($label, $value, $params="", $params2="", $leftfill=0)
{
echo "<tr>";
label_cells($label, $value, $params, $params2);
+ if($leftfill!=0)
+ echo "<td colspan=$leftfill></td>";
echo "</tr>\n";
}
function text_cells($label, $name, $value, $size="", $max="", $params="", $post_label="", $disabled="")
{
+ default_focus($name);
if ($label != null)
label_cell($label, $params);
echo "<td>";
function text_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null)
{
- if (!isset($_POST[$name]) || $_POST[$name] == "")
+ default_focus($name);
+ if (!isset($_POST[$name]) || $_POST[$name] == "")
{
if ($init)
$_POST[$name] = $init;
function date_cells($label, $name, $init=null, $inc_days=0, $inc_months=0, $inc_years=0, $params=null)
{
global $use_date_picker, $path_to_root;
- if (!isset($_POST[$name]) || $_POST[$name] == "")
+ if (!isset($_POST[$name]) || $_POST[$name] == "")
{
if (!$init)
{
if ($inc_years == 1001)
$_POST[$name] = null;
- else
- $_POST[$name] = date(user_date_display(), Mktime(0,0,0,date("m") + $inc_months,date("d") + $inc_days,date("Y") + $inc_years));
- }
+ else
+ {
+ $dd = Today();
+ if ($inc_days != 0)
+ $dd = add_days($dd, $inc_days);
+ if ($inc_months != 0)
+ $dd = add_months($dd, $inc_months);
+ if ($inc_years != 0)
+ $dd = add_years($dd, $inc_years);
+ $_POST[$name] = $dd;
+ }
+ }
else
$_POST[$name] = $init;
}
if ($use_date_picker)
- $post_label = "<a href=\"javascript:date_picker(document.forms[0].$name);\">"
+ $post_label = "<a tabindex='-1' href=\"javascript:date_picker(document.forms[0].$name);\">"
. " <img src='$path_to_root/themes/default/images/cal.gif' width='16' height='16' border='0' alt='"._('Click Here to Pick up the date')."'></a>\n";
else
$post_label = "";
function percent_row($label, $name, $init=null)
{
- if (!isset($_POST[$name]) || $_POST[$name]=="")
+ if (!isset($_POST[$name]) || $_POST[$name]=="")
+ {
+ $_POST[$name] = $init== null ? '' : $init;
+ }
+
+ small_amount_row($label, $name, $_POST[$name], null, "%", user_percent_dec());
+}
+
+function amount_cells_ex($label, $name, $size, $max=null, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ if (!isset($dec))
+ $dec = user_price_dec();
+ if (!isset($_POST[$name]) || $_POST[$name] == "")
{
if ($init)
$_POST[$name] = $init;
+ else
+ $_POST[$name] = '';
}
+ if ($label != null)
+ label_cell($label, $params);
+
+ if (!isset($max))
+ $max = $size;
- text_row($label, $name, $_POST[$name], 6, 6, "", "%");
+ echo "<td>";
+
+ echo "<input class='amount' type=\"text\" name=\"$name\" size=\"$size\" maxlength=\"$max\" dec=\"$dec\" value=\"" . $_POST[$name]. "\">";
+
+ if ($post_label)
+ echo " " . $post_label;
+
+ echo "</td>\n";
+}
+
+
+//-----------------------------------------------------------------------------------
+
+function amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec);
+}
+
+function amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ echo "<tr>";
+ amount_cells($label, $name, $init, $params, $post_label, $dec);
+ echo "</tr>\n";
+}
+
+function small_amount_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ echo "<tr>";
+ small_amount_cells($label, $name, $init, $params, $post_label, $dec);
+ echo "</tr>\n";
}
//-----------------------------------------------------------------------------------
-function amount_cells($label, $name, $init=null, $params=null, $post_label=null)
+function qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ if(!isset($dec))
+ $dec = user_qty_dec();
+
+ amount_cells_ex($label, $name, 15, 15, $init, $params, $post_label, $dec);
+}
+
+function qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
- text_cells_ex($label, $name, 15, 15, $init, $params, $post_label);
+ if(!isset($dec))
+ $dec = user_qty_dec();
+
+ echo "<tr>";
+ amount_cells($label, $name, $init, $params, $post_label, $dec);
+ echo "</tr>\n";
}
-function amount_row($label, $name, $init=null, $params=null, $post_label=null)
+function small_qty_row($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
+ if(!isset($dec))
+ $dec = user_qty_dec();
+
echo "<tr>";
- amount_cells($label, $name, $init, $params, $post_label);
+ small_amount_cells($label, $name, $init, $params, $post_label, $dec);
echo "</tr>\n";
}
//-----------------------------------------------------------------------------------
-function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null)
+function small_amount_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
+{
+ amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec);
+}
+
+//-----------------------------------------------------------------------------------
+
+function small_qty_cells($label, $name, $init=null, $params=null, $post_label=null, $dec=null)
{
- text_cells_ex($label, $name, 7, 12, $init, $params, $post_label);
+ if (!isset($dec))
+ $dec = user_qty_dec();
+ amount_cells_ex($label, $name, 7, 12, $init, $params, $post_label, $dec);
}
//-----------------------------------------------------------------------------------
function textarea_cells($label, $name, $value, $cols, $rows, $params="")
{
+ default_focus($name);
if ($label != null)
echo "<td $params>$label</td>\n";
if ($value == null)
function text_row_with_submit($label, $name, $value, $size, $max, $input_name, $input_value)
{
+ default_focus($name);
echo "<tr><td>$label</td>\n";
echo "<td>";