Changed so Customer's Reference is printed on all sales documents (you can f.i. enter...
[fa-stable.git] / taxes / tax_types.php
index d70493c847080d206d2442149a834f9f5bd1dd01..55e40950d43ff4534c5a5272aae4d9c21087507b 100644 (file)
@@ -23,16 +23,13 @@ function can_process()
        if (strlen($_POST['name']) == 0)
        {
                display_error(_("The tax type name cannot be empty."));
+               set_focus('name');
                return false;
        }
-       elseif (!is_numeric($_POST['rate']))
+       elseif (!check_num('rate', 0))
        {
-               display_error( _("The default tax rate must be numeric."));
-               return false;
-       }
-       elseif ($_POST['rate'] < 0)
-       {
-               display_error( _("The default tax rate cannot be less than zero."));
+               display_error( _("The default tax rate must be numeric and not less than zero."));
+               set_focus('rate');
                return false;
        }
 
@@ -45,7 +42,7 @@ if (isset($_POST['ADD_ITEM']) && can_process())
 {
 
        add_tax_type($_POST['name'], $_POST['sales_gl_code'],
-               $_POST['purchasing_gl_code'], $_POST['rate']);
+               $_POST['purchasing_gl_code'], input_num('rate'));
        meta_forward($_SERVER['PHP_SELF']);
 }
 
@@ -55,7 +52,7 @@ if (isset($_POST['UPDATE_ITEM']) && can_process())
 {
 
        update_tax_type($selected_id, $_POST['name'],
-       $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], $_POST['rate']);
+       $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], input_num('rate'));
        meta_forward($_SERVER['PHP_SELF']);
 }
 
@@ -69,6 +66,7 @@ function can_delete($selected_id)
        if ($myrow[0] > 0)
        {
                display_error(_("Cannot delete this tax type because tax groups been created referring to it."));
+
                return false;
        }
 
@@ -105,7 +103,7 @@ while ($myrow = db_fetch($result))
        alt_table_row_color($k);
 
        label_cell($myrow["name"]);
-       label_cell(number_format2($myrow["rate"],user_percent_dec()), "align=right");
+       label_cell(percent_format($myrow["rate"]), "align=right");
        label_cell($myrow["sales_gl_code"] . "&nbsp;" . $myrow["SalesAccountName"]);
        label_cell($myrow["purchasing_gl_code"] . "&nbsp;" . $myrow["PurchasingAccountName"]);
 
@@ -134,14 +132,14 @@ if (isset($selected_id))
        $myrow = get_tax_type($selected_id);
 
        $_POST['name']  = $myrow["name"];
-       $_POST['rate']  = $myrow["rate"];
+       $_POST['rate']  = percent_format($myrow["rate"]);
        $_POST['sales_gl_code']  = $myrow["sales_gl_code"];
        $_POST['purchasing_gl_code']  = $myrow["purchasing_gl_code"];
 
        hidden('selected_id', $selected_id);
 }
 text_row_ex(_("Description:"), 'name', 50);
-text_row_ex(_("Default Rate:"), 'rate', 10, 10, "", "%");
+small_amount_row(_("Default Rate:"), 'rate', '', "", "%", user_percent_dec());
 
 gl_all_accounts_list_row(_("Sales GL Account:"), 'sales_gl_code', null);
 gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null);