diff --git a/application/controllers/Taxes.php b/application/controllers/Taxes.php
index c85ced7ba..873bb7b95 100644
--- a/application/controllers/Taxes.php
+++ b/application/controllers/Taxes.php
@@ -15,9 +15,21 @@ class Taxes extends Secure_Controller
public function index()
{
- $data['tax_codes'] = $this->Tax_code->get_all()->result_array();
- $data['tax_categories'] = $this->Tax_category->get_all()->result_array();
- $data['tax_jurisdictions'] = $this->Tax_jurisdiction->get_all()->result_array();
+ $data['tax_codes'] = $this->xss_clean($this->Tax_code->get_all()->result_array());
+ if (count($data['tax_codes']) == 0)
+ {
+ $data['tax_codes'] = $this->Tax_code->get_empty_row();
+ }
+ $data['tax_categories'] = $this->xss_clean($this->Tax_category->get_all()->result_array());
+ if (count($data['tax_categories']) == 0)
+ {
+ $data['tax_categories'] = $this->Tax_category->get_empty_row();
+ }
+ $data['tax_jurisdictions'] = $this->xss_clean($this->Tax_jurisdiction->get_all()->result_array());
+ if (count($data['tax_jurisdictions']) == 0)
+ {
+ $data['tax_jurisdictions'] = $this->Tax_jurisdiction->get_empty_row();
+ }
$data['tax_rate_table_headers'] = $this->xss_clean(get_tax_rates_manage_table_headers());
$data['tax_categories_table_headers'] = $this->xss_clean(get_tax_categories_table_headers());
$data['tax_types'] = $this->tax_lib->get_tax_types();
@@ -396,39 +408,19 @@ class Taxes extends Secure_Controller
public function save_tax_codes()
{
- $array_save= array();
+ $tax_code_id = $this->input->post('tax_code_id');
+ $tax_code = $this->input->post('tax_code');
+ $tax_code_name = $this->input->post('tax_code_name');
+ $tax_code_id = $this->input->post('tax_code_id');
+ $city = $this->input->post('city');
+ $state = $this->input->post('state');
- foreach($this->input->post() as $key => $value)
+ $array_save = array();
+ foreach($tax_code_id as $key=>$val)
{
- if(!(strstr($key, 'tax_code_name_')=== FALSE))
- {
- $tax_code_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $array_save[$tax_code_id]['tax_code_name'] = $value;
- }
- elseif(!(strstr($key, 'tax_code_id_') === FALSE))
- {
- $tax_code_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$tax_code_id]['tax_code_id'] = strtoupper($value);
- }
- elseif(!(strstr($key, 'tax_code_') === FALSE))
- {
- $tax_code_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$tax_code_id]['tax_code'] = strtoupper($value);
- }
- elseif(!(strstr($key, 'city_') === FALSE))
- {
- $tax_code_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$tax_code_id]['city'] = $value;
- }
- elseif(!(strstr($key, 'state_') === FALSE))
- {
- $tax_code_id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$tax_code_id]['state'] = $value;
- }
+ $array_save[] = array('tax_code_id'=>$this->xss_clean($val), 'tax_code'=>$this->xss_clean($tax_code[$key]),
+ 'tax_code_name'=>$this->xss_clean($tax_code_name[$key]), 'tax_code_id'=>$this->xss_clean($tax_code_id[$key]),
+ 'city'=>$this->xss_clean($city[$key]), 'state'=>$this->xss_clean($state[$key]));
}
$success = $this->Tax_code->save_tax_codes($array_save);
@@ -441,60 +433,30 @@ class Taxes extends Secure_Controller
public function save_tax_jurisdictions()
{
+ $jurisdiction_id = $this->input->post('jurisdiction_id');
+ $jurisdiction_name = $this->input->post('jurisdiction_name');
+ $tax_group = $this->input->post('tax_group');
+ $tax_type = $this->input->post('tax_type');
+ $reporting_authority = $this->input->post('reporting_authority');
+ $tax_group_sequence = $this->input->post('tax_group_sequence');
+ $cascade_sequence = $this->input->post('cascade_sequence');
+
$array_save = array();
- foreach($this->input->post() as $key => $value)
+ foreach($jurisdiction_id as $key => $val)
{
-
- if(!(strstr($key, 'jurisdiction_id_')=== FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $array_save[$id]['jurisdiction_id'] = $value;
- }
- elseif(!(strstr($key, 'jurisdiction_name_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['jurisdiction_name'] = $value;
- }
- elseif(!(strstr($key, 'tax_type_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['tax_type'] = $value;
- }
- elseif(!(strstr($key, 'reporting_authority_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['reporting_authority'] = $value;
- }
- elseif(!(strstr($key, 'tax_group_sequence_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['tax_group_sequence'] = $value;
- }
- elseif(!(strstr($key, 'tax_group_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['tax_group'] = $value;
- }
- elseif(!(strstr($key, 'cascade_sequence_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['cascade_sequence'] = $value;
- }
+ $array_save[] = array(
+ 'jurisdiction_id'=>$this->xss_clean($val),
+ 'jurisdiction_name'=>$this->xss_clean($jurisdiction_name[$key]),
+ 'tax_group'=>$this->xss_clean($tax_group[$key]),
+ 'tax_type'=>$this->xss_clean($tax_type[$key]),
+ 'reporting_authority'=>$this->xss_clean($reporting_authority[$key]),
+ 'tax_group_sequence'=>$this->xss_clean($tax_group_sequence[$key]),
+ 'cascade_sequence'=>$this->xss_clean($cascade_sequence[$key]));
}
$success = $this->Tax_jurisdiction->save_jurisdictions($array_save);
-// if(!empty($array_save))
-// {
-// }
-
echo json_encode(array(
'success' => $success,
'message' => $this->lang->line('taxes_tax_jurisdictions_saved_' . ($success ? '' : 'un') . 'successfully')
@@ -503,28 +465,18 @@ class Taxes extends Secure_Controller
public function save_tax_categories()
{
+ $tax_category_id = $this->input->post('tax_category_id');
+ $tax_category = $this->input->post('tax_category');
+ $tax_group_sequence = $this->input->post('tax_group_sequence');
+
$array_save= array();
- foreach($this->input->post() as $key => $value)
+ foreach($tax_category_id as $key => $val)
{
- // Note that for proper select tax_category_id and tax_category_code must precede tax_category
- if(!(strstr($key, 'tax_category_id_')=== FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $array_save[$id]['tax_category_id'] = $value;
- }
- elseif(!(strstr($key, 'tax_category_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['tax_category'] = $value;
- }
- elseif(!(strstr($key, 'tax_group_sequence_') === FALSE))
- {
- $id = preg_replace("/.*?_(\d+)$/", "$1", $key);
- $value = isset($value) ? $value : '';
- $array_save[$id]['tax_group_sequence'] = $value;
- }
+ $array_save[] = array(
+ 'tax_category_id'=>$this->xss_clean($val),
+ 'tax_category'=>$this->xss_clean($tax_category[$key]),
+ 'tax_group_sequence'=>$this->xss_clean($tax_group_sequence[$key]));
}
$success = $this->Tax_category->save_categories($array_save);
diff --git a/application/language/en-GB/common_lang.php b/application/language/en-GB/common_lang.php
index 048e0de7f..5bc48eb03 100644
--- a/application/language/en-GB/common_lang.php
+++ b/application/language/en-GB/common_lang.php
@@ -6,6 +6,7 @@ $lang["common_city"] = "City";
$lang["common_close"] = "Close";
$lang["common_comments"] = "Comments";
$lang["common_common"] = "common";
+$lang["common_correct_errors"] = "Please correct identified errors before saving";
$lang["common_confirm_search"] = "You have selected one or more rows, these will no longer be selected after your search. Are you sure you want to submit this search?";
$lang["common_country"] = "Country";
$lang["common_date"] = "Date";
diff --git a/application/language/en-GB/taxes_lang.php b/application/language/en-GB/taxes_lang.php
index ac6fc750f..c15469d9b 100644
--- a/application/language/en-GB/taxes_lang.php
+++ b/application/language/en-GB/taxes_lang.php
@@ -32,10 +32,15 @@ $lang["taxes_tax_categories_saved_successfully"] = "Tax Categories changes saved
$lang["taxes_tax_categories_saved_unsuccessfully"] = "Tax Categories changes not saved";
$lang["taxes_tax_category"] = "Tax Category";
$lang["taxes_tax_category_code"] = "Tax Category Code";
+$lang["taxes_tax_category_duplicate"] = "Duplicate tax category";
+$lang["taxes_tax_category_invalid_chars"] = "Invalid characters in tax category name";
$lang["taxes_tax_category_name"] = "Tax Category Name";
$lang["taxes_tax_category_new"] = "New Tax Category";
+$lang["taxes_tax_category_required"] = "Tax category is required";
$lang["taxes_tax_code"] = "Tax Code";
$lang["taxes_tax_code_cannot_be_deleted"] = "Tax Code delete failed";
+$lang["taxes_tax_code_duplicate"] = "Duplicate tax code";
+$lang["taxes_tax_code_invalid_chars"] = "Invalid characters in tax code";
$lang["taxes_tax_code_name"] = "Tax Code Name";
$lang["taxes_tax_code_required"] = "Tax Code is a required field";
$lang["taxes_tax_code_successful_deleted"] = "You have successfully deleted Tax Code";
@@ -52,11 +57,15 @@ $lang["taxes_tax_group"] = "Tax Group";
$lang["taxes_tax_group_sequence"] = "Tax Group Sequence";
$lang["taxes_tax_included"] = "Tax included";
$lang["taxes_tax_jurisdiction"] = "Tax Jurisdiction";
+$lang["taxes_tax_jurisdiction_duplicate"] = "Duplicate tax jurisdiction";
+$lang["taxes_tax_jurisdiction_invalid_chars"] = "Invalid characters in jurisdiction name";
+$lang["taxes_tax_jurisdiction_required"] = "Tax jurisdiction is required";
$lang["taxes_tax_jurisdictions"] = "Tax Jurisdictions";
$lang["taxes_tax_jurisdictions_configuration"] = "Tax Jurisdictions Configuration";
$lang["taxes_tax_jurisdictions_saved_successfully"] = "Tax Jurisdiction changes saved";
$lang["taxes_tax_jurisdictions_saved_unsuccessfully"] = "Tax Jurisdiction changes not saved";
$lang["taxes_tax_rate"] = "Tax Rate";
+$lang["taxes_tax_rate_configuration"] = "Tax Rate Configuration";
$lang["taxes_tax_rate_error_adding_updating"] = "Tax Rate add or update failed";
$lang["taxes_tax_rate_numeric"] = "Tax Rate must be a number";
$lang["taxes_tax_rate_required"] = "Tax Rate is a required field";
diff --git a/application/language/en-US/common_lang.php b/application/language/en-US/common_lang.php
index d88c26d58..e4ce3b0b4 100644
--- a/application/language/en-US/common_lang.php
+++ b/application/language/en-US/common_lang.php
@@ -6,6 +6,7 @@ $lang["common_city"] = "City";
$lang["common_close"] = "Close";
$lang["common_comments"] = "Comments";
$lang["common_common"] = "common";
+$lang["common_correct_errors"] = "Please correct identified errors before saving";
$lang["common_confirm_search"] = "You have selected one or more rows, these will no longer be selected after your search. Are you sure you want to submit this search?";
$lang["common_country"] = "Country";
$lang["common_date"] = "Date";
diff --git a/application/language/en-US/taxes_lang.php b/application/language/en-US/taxes_lang.php
index a2aeb0d96..c15469d9b 100644
--- a/application/language/en-US/taxes_lang.php
+++ b/application/language/en-US/taxes_lang.php
@@ -22,7 +22,7 @@ $lang["taxes_round_half_odd"] = "Half Odd";
$lang["taxes_round_half_up"] = "Half Up";
$lang["taxes_rounding_code"] = "Rounding Code";
$lang["taxes_sales_tax"] = "Sales Tax";
-$lang["taxes_sales_tax_by_invoice"] = "";
+$lang["taxes_sales_tax_by_invoice"] = "Sales Tax by Invoice";
$lang["taxes_sequence"] = "Seq.";
$lang["taxes_state"] = "State";
$lang["taxes_successful_deleted"] = "You have successfully deleted";
@@ -32,10 +32,15 @@ $lang["taxes_tax_categories_saved_successfully"] = "Tax Categories changes saved
$lang["taxes_tax_categories_saved_unsuccessfully"] = "Tax Categories changes not saved";
$lang["taxes_tax_category"] = "Tax Category";
$lang["taxes_tax_category_code"] = "Tax Category Code";
+$lang["taxes_tax_category_duplicate"] = "Duplicate tax category";
+$lang["taxes_tax_category_invalid_chars"] = "Invalid characters in tax category name";
$lang["taxes_tax_category_name"] = "Tax Category Name";
$lang["taxes_tax_category_new"] = "New Tax Category";
+$lang["taxes_tax_category_required"] = "Tax category is required";
$lang["taxes_tax_code"] = "Tax Code";
$lang["taxes_tax_code_cannot_be_deleted"] = "Tax Code delete failed";
+$lang["taxes_tax_code_duplicate"] = "Duplicate tax code";
+$lang["taxes_tax_code_invalid_chars"] = "Invalid characters in tax code";
$lang["taxes_tax_code_name"] = "Tax Code Name";
$lang["taxes_tax_code_required"] = "Tax Code is a required field";
$lang["taxes_tax_code_successful_deleted"] = "You have successfully deleted Tax Code";
@@ -52,11 +57,15 @@ $lang["taxes_tax_group"] = "Tax Group";
$lang["taxes_tax_group_sequence"] = "Tax Group Sequence";
$lang["taxes_tax_included"] = "Tax included";
$lang["taxes_tax_jurisdiction"] = "Tax Jurisdiction";
+$lang["taxes_tax_jurisdiction_duplicate"] = "Duplicate tax jurisdiction";
+$lang["taxes_tax_jurisdiction_invalid_chars"] = "Invalid characters in jurisdiction name";
+$lang["taxes_tax_jurisdiction_required"] = "Tax jurisdiction is required";
$lang["taxes_tax_jurisdictions"] = "Tax Jurisdictions";
$lang["taxes_tax_jurisdictions_configuration"] = "Tax Jurisdictions Configuration";
$lang["taxes_tax_jurisdictions_saved_successfully"] = "Tax Jurisdiction changes saved";
$lang["taxes_tax_jurisdictions_saved_unsuccessfully"] = "Tax Jurisdiction changes not saved";
$lang["taxes_tax_rate"] = "Tax Rate";
+$lang["taxes_tax_rate_configuration"] = "Tax Rate Configuration";
$lang["taxes_tax_rate_error_adding_updating"] = "Tax Rate add or update failed";
$lang["taxes_tax_rate_numeric"] = "Tax Rate must be a number";
$lang["taxes_tax_rate_required"] = "Tax Rate is a required field";
diff --git a/application/migrations/sqlscripts/3.3.0_indiagst.sql b/application/migrations/sqlscripts/3.3.0_indiagst.sql
index fe9c68ee4..f17bb2ea8 100644
--- a/application/migrations/sqlscripts/3.3.0_indiagst.sql
+++ b/application/migrations/sqlscripts/3.3.0_indiagst.sql
@@ -29,9 +29,7 @@ CREATE TABLE IF NOT EXISTS `ospos_tax_codes` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE `ospos_customers`
- ADD COLUMN `tax_id` varchar(32) NOT NULL DEFAULT '' AFTER `taxable`;
-
-ALTER TABLE `ospos_customers`
+ ADD COLUMN `tax_id` varchar(32) NOT NULL DEFAULT '' AFTER `taxable`,
ADD COLUMN `sales_tax_code_id` int(11) DEFAULT NULL AFTER `tax_id`;
ALTER TABLE `ospos_items`
diff --git a/application/models/Tax_category.php b/application/models/Tax_category.php
index e18817630..76939609b 100644
--- a/application/models/Tax_category.php
+++ b/application/models/Tax_category.php
@@ -230,6 +230,14 @@ class Tax_category extends CI_Model
return $suggestions;
}
+ public function get_empty_row()
+ {
+ return array('0' => array(
+ 'tax_category_id' => -1,
+ 'tax_category' => '',
+ 'tax_group_sequence' => 0,
+ 'deleted' => 0));
+ }
}
?>
diff --git a/application/models/Tax_code.php b/application/models/Tax_code.php
index 81d8e7975..16b09b025 100644
--- a/application/models/Tax_code.php
+++ b/application/models/Tax_code.php
@@ -269,5 +269,15 @@ class Tax_code extends CI_Model
return $suggestions;
}
+ public function get_empty_row()
+ {
+ return array('0' => array(
+ 'tax_code_id' => -1,
+ 'tax_code' => '',
+ 'tax_code_name' => '',
+ 'city' => '',
+ 'state' => '',
+ 'deleted' => 0));
+ }
}
?>
diff --git a/application/models/Tax_jurisdiction.php b/application/models/Tax_jurisdiction.php
index 7f3e38cf2..e27ba46b4 100644
--- a/application/models/Tax_jurisdiction.php
+++ b/application/models/Tax_jurisdiction.php
@@ -210,5 +210,19 @@ class Tax_jurisdiction extends CI_Model
return $this->db->get();
}
+
+ public function get_empty_row()
+ {
+ return array('0' => array(
+ 'jurisdiction_id' => -1,
+ 'jurisdiction_name' => '',
+ 'tax_group' => '',
+ 'tax_type' => '1',
+ 'reporting_authority' => '',
+ 'tax_group_sequence' => 0,
+ 'cascade_sequence' => 0,
+ 'deleted' => 0));
+ }
+
}
?>
diff --git a/application/views/partial/tax_categories.php b/application/views/partial/tax_categories.php
index ee6b586cb..a1ee13352 100644
--- a/application/views/partial/tax_categories.php
+++ b/application/views/partial/tax_categories.php
@@ -12,9 +12,9 @@ foreach($tax_categories as $key => $category)
lang->line('taxes_tax_category') . ' ' . $i, 'tax_category_' . $i, array('class' => 'control-label col-xs-2')); ?>
'tax_category_' . $i,
+ 'name' => 'tax_category[]',
'id' => 'tax_category_' . $i,
- 'class' => 'valid_chars form-control input-sm required',
+ 'class' => 'valid_chars form-control input-sm',
'placeholder' => $this->lang->line('taxes_tax_category_name'),
'value' => $tax_category
);
@@ -23,8 +23,7 @@ foreach($tax_categories as $key => $category)
'tax_group_sequence_' . $i,
- 'id' => 'tax_group_sequence_' . $i,
+ 'name' => 'tax_group_sequence[]',
'class' => 'valid_chars form-control input-sm',
'placeholder' => $this->lang->line('taxes_sequence'),
'value' => $tax_group_sequence
@@ -35,42 +34,8 @@ foreach($tax_categories as $key => $category)
-
+
-
-
-
diff --git a/application/views/partial/tax_codes.php b/application/views/partial/tax_codes.php
index 3db8fcce0..fa37117a5 100644
--- a/application/views/partial/tax_codes.php
+++ b/application/views/partial/tax_codes.php
@@ -14,9 +14,9 @@ foreach($tax_codes as $tax_code => $tax_code_data)
lang->line('taxes_tax_code') . ' ' . $i, 'tax_code_' . $i, array('class'=>'control-label col-xs-2')); ?>
'tax_code_' . $i,
+ 'name'=>'tax_code[]',
'id'=>'tax_code_' . $i,
- 'class'=>'valid_chars text-uppercase form-control input-sm required',
+ 'class'=>'valid_chars text-uppercase form-control input-sm',
'placeholder'=>$this->lang->line('taxes_code'),
'value'=>$tax_code
);
@@ -25,9 +25,8 @@ foreach($tax_codes as $tax_code => $tax_code_data)
'tax_code_name_' . $i,
- 'id'=>'tax_code_name_' . $i,
- 'class'=>'valid_chars form-control input-sm required',
+ 'name'=>'tax_code_name[]',
+ 'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_name'),
'value'=>$tax_code_name
);
@@ -36,8 +35,7 @@ foreach($tax_codes as $tax_code => $tax_code_data)
'city_' . $i,
- 'id'=>'city_' . $i,
+ 'name'=>'city[]',
'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_city'),
'value'=>$city
@@ -47,8 +45,7 @@ foreach($tax_codes as $tax_code => $tax_code_data)
'state_' . $i,
- 'id'=>'state_' . $i,
+ 'name'=>'state[]',
'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_state'),
'value'=>$state
@@ -60,64 +57,7 @@ foreach($tax_codes as $tax_code => $tax_code_data)
-
-
-
-
$jurisdiction)
lang->line('taxes_tax_jurisdiction') . ' ' . $i, 'jurisdiction_name_' . $i, array('class'=>'control-label col-xs-2')); ?>
'jurisdiction_name_' . $i,
+ 'name'=>'jurisdiction_name[]',
'id'=>'jurisdiction_name_' . $i,
- 'class'=>'valid_chars form-control input-sm required',
+ 'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_jurisdiction_name'),
'value'=>$jurisdiction_name
);
@@ -28,9 +28,8 @@ foreach($tax_jurisdictions as $tax_jurisdiction => $jurisdiction)
'tax_group_' . $i,
- 'id'=>'tax_group_' . $i,
- 'class'=>'valid_chars form-control input-sm required',
+ 'name'=>'tax_group[]',
+ 'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_tax_group'),
'value'=>$tax_group
);
@@ -39,13 +38,12 @@ foreach($tax_jurisdictions as $tax_jurisdiction => $jurisdiction)
- 'form-control')); ?>
+ 'form-control')); ?>
'reporting_authority_' . $i,
- 'id'=>'reporting_authority_' . $i,
+ 'name'=>'reporting_authority[]',
'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_reporting_authority'),
'value'=>$reporting_authority
@@ -56,8 +54,7 @@ foreach($tax_jurisdictions as $tax_jurisdiction => $jurisdiction)
'tax_group_sequence_' . $i,
- 'id'=>'tax_group_sequence_' . $i,
+ 'name'=>'tax_group_sequence[]',
'class'=>'valid_chars form-control input-sm',
'placeholder' => $this->lang->line('taxes_sequence'),
'value'=>$tax_group_sequence
@@ -68,8 +65,7 @@ foreach($tax_jurisdictions as $tax_jurisdiction => $jurisdiction)
'cascade_sequence_' . $i,
- 'id'=>'cascade_sequence_' . $i,
+ 'name'=>'cascade_sequence[]',
'class'=>'valid_chars form-control input-sm',
'placeholder'=>$this->lang->line('taxes_cascade_sequence'),
'value'=>$cascade_sequence
@@ -80,77 +76,7 @@ foreach($tax_jurisdictions as $tax_jurisdiction => $jurisdiction)
-
-
-
-
- lang->line('taxes_tax_jurisdiction') . ' 1', 'jurisdiction_name_1', array('class'=>'control-label col-xs-2')); ?>
-
- 'jurisdiction_name_1',
- 'id'=>'jurisdiction_name_1',
- 'class'=>'valid_chars form-control input-sm required',
- 'placeholder'=>$this->lang->line('taxes_jurisdiction_name'),
- 'value'=>''
- );
- echo form_input($form_data);
- ?>
-
-
- 'tax_group_1',
- 'id'=>'tax_group_1',
- 'class'=>'valid_chars form-control input-sm required',
- 'placeholder'=>$this->lang->line('taxes_tax_group'),
- 'value'=>''
- );
- echo form_input($form_data);
- ?>
-
-
- 'form-control')); ?>
-
-
- 'reporting_authority_1',
- 'id'=>'reporting_authority_1',
- 'class'=>'valid_chars form-control input-sm',
- 'placeholder'=>$this->lang->line('taxes_reporting_authority'),
- 'value'=>''
- );
- echo form_input($form_data);
- ?>
-
-
- 'tax_group_sequence_1',
- 'id'=>'tax_group_sequence_1',
- 'class'=>'valid_chars form-control input-sm',
- 'placeholder' => $this->lang->line('taxes_sequence'),
- 'value'=>''
- );
- echo form_input($form_data);
- ?>
-
-
- 'cascade_sequence_1',
- 'id'=>'cascade_sequence_1',
- 'class'=>'valid_chars form-control input-sm',
- 'placeholder'=>$this->lang->line('taxes_cascade_sequence'),
- 'value'=>''
- );
- echo form_input($form_data);
- ?>
-
-
-
-
-
+
1)
{
$(".remove_tax_category").show();
@@ -41,51 +41,59 @@
var id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
- var previous_tax_category_id_id = 'tax_category_id_' + id;
var previous_tax_category_id = 'tax_category_' + id;
- var previous_default_tax_rate_id = 'default_tax_rate_' + id;
- var previous_tax_group_sequence_id = 'tax_group_sequence_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
- var new_tax_category_id_id = 'tax_category_id_' + ++tax_categories_count;
+ ++tax_categories_count;
var new_tax_category_id = 'tax_category_' + tax_categories_count;
- var new_default_tax_rate_id = 'default_tax_rate_' + tax_categories_count;
- var new_tax_group_sequence_id = 'tax_group_sequence_' + tax_categories_count;
$(new_block).find('label').html("lang->line('taxes_tax_category'); ?> " + tax_categories_count).attr('for', new_tax_category_id).attr('class', 'control-label col-xs-2');
- $(new_block).find("input[name='"+previous_tax_category_id_id+"']").attr('name', new_tax_category_id_id).val('-1');
- $(new_block).find("input[id='"+previous_tax_category_id+"']").attr('id', new_tax_category_id).removeAttr('disabled').attr('name', new_tax_category_id).attr('class', 'form-control input-sm').val('');
- $(new_block).find("input[id='"+previous_default_tax_rate_id+"']").attr('id', new_default_tax_rate_id).removeAttr('disabled').attr('name', new_default_tax_rate_id).attr('class', 'form-control input-sm').val('');
- $(new_block).find("input[id='"+previous_tax_group_sequence_id+"']").attr('id', new_tax_group_sequence_id).removeAttr('disabled').attr('name', new_tax_group_sequence_id).attr('class', 'form-control input-sm').val('');
- hide_show_remove();
+ $(new_block).find("input[name='tax_category[]']").attr('id', new_tax_category_id).removeAttr('disabled').attr('class', 'form-control input-sm required').val('');
+ $(new_block).find("input[name='tax_group_sequence[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='tax_category_id[]']").val('-1');
+ hide_show_remove_tax_category();
};
var remove_tax_category = function() {
$(this).parent().remove();
- hide_show_remove();
+ hide_show_remove_tax_category();
};
var init_add_remove_tax_categories = function() {
$('.add_tax_category').click(add_tax_category);
$('.remove_tax_category').click(remove_tax_category);
- hide_show_remove();
+ hide_show_remove_tax_category();
};
init_add_remove_tax_categories();
var duplicate_found = false;
+
// run validator once for all fields
- $.validator.addMethod('tax_category' , function(value, element) {
+ $.validator.addMethod("check4TaxCategoryDups" , function(value, element) {
var value_count = 0;
- $("input[name*='tax_category']").each(function() {
+ $('input[name="tax_category[]"]').each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
- return value_count < 2;
+ if (value_count > 1) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_category_duplicate'); ?>");
- $.validator.addMethod('valid_chars', function(value, element) {
- return value.indexOf('_') === -1;
+ $.validator.addMethod('validateTaxCategoryCharacters', function(value, element) {
+ if ((value.indexOf('_') != -1)) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_category_invalid_chars'); ?>");
+ $.validator.addMethod('requireTaxCategory', function(value, element) {
+ if (value .trim() == '') {
+ return false;
+ }
+ return true;
+ }, "lang->line('taxes_tax_category_required'); ?>");
+
$('#tax_categories_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {
$(form).ajaxSubmit({
@@ -96,41 +104,25 @@
dataType: 'json'
});
},
-
- errorLabelContainer: "#tax_category_error_message_box",
-
- rules:
- {
- $tax_category_data)
- {
- ?>
- :
- {
- required: true,
- tax_category: true,
- valid_chars: true
+ invalidHandler: function(event, validator) {
+ $.notify("lang->line('common_correct_errors'); ?>");
},
-
- },
-
- messages:
- {
- $tax_category_data)
- {
- ?>
- : "lang->line('taxes_tax_category_required'); ?>",
-
- }
+ errorLabelContainer: "#tax_category_error_message_box"
}));
+
+ $tax_category_data)
+ {
+ ?>
+ $('').rules( "add", {
+ requireTaxCategory: true,
+ check4TaxCategoryDups: true,
+ validateTaxCategoryCharacters: true
+ });
+
+
});
diff --git a/application/views/taxes/tax_codes.php b/application/views/taxes/tax_codes.php
index ad2bd7220..d061fb500 100644
--- a/application/views/taxes/tax_codes.php
+++ b/application/views/taxes/tax_codes.php
@@ -26,7 +26,7 @@
tax_code_count = 1;
}
- var hide_show_remove = function() {
+ var hide_show_remove_tax_code = function() {
if ($("input[name*='tax_code']:enabled").length > 1)
{
$(".remove_tax_code").show();
@@ -38,59 +38,64 @@
};
var add_tax_code = function() {
- var id = $(this).parent().find('input').attr('id');
+ var id = $(this).parent().find("input[name='tax_code[]']").attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
- var previous_tax_code_id_id = 'tax_code_id_' + id;
var previous_tax_code_id = 'tax_code_' + id;
- var previous_tax_code_name_id = 'tax_code_name_' + id;
- var previous_city_id = 'city_' + id;
- var previous_statte_id = 'state_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
++tax_code_count;
- var new_tax_code_id_id = 'tax_code_id_' + tax_code_count;
var new_tax_code_id = 'tax_code_' + tax_code_count;
- var new_tax_code_name_id = 'tax_code_name_' + tax_code_count;
- var new_city_id = 'city_' + tax_code_count;
- var new_state_id = 'state_' + tax_code_count;
$(new_block).find('label').html("lang->line('taxes_tax_code'); ?> " + tax_code_count).attr('for', new_tax_code_id).attr('class', 'control-label col-xs-2');
- $(new_block).find("input[id='"+previous_tax_code_id+"']").attr('id', new_tax_code_id).removeAttr('disabled').attr('name', new_tax_code_id).attr('class', 'form-control text-uppercase required input-sm').val('');
- $(new_block).find("input[id='"+previous_tax_code_name_id+"']").attr('id', new_tax_code_name_id).removeAttr('disabled').attr('name', new_tax_code_name_id).attr('class', 'form-control required input-sm').val('');
- $(new_block).find("input[id='"+previous_city_id+"']").attr('id', new_city_id).removeAttr('disabled').attr('name', new_city_id).attr('class', 'form-control input-sm').val('');
- $(new_block).find("input[id='"+previous_statte_id+"']").attr('id', new_state_id).removeAttr('disabled').attr('name', new_state_id).attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='tax_code[]']").attr('id', new_tax_code_id).removeAttr('disabled').attr('class', 'form-control text-uppercase required input-sm').val('');
+ $(new_block).find("input[name='tax_code_name[]']").removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
+ $(new_block).find("input[name='city[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='state[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='tax_code_id[]']").val('-1');
- hide_show_remove();
+ hide_show_remove_tax_code();
};
var remove_tax_code = function() {
$(this).parent().remove();
- hide_show_remove();
+ hide_show_remove_tax_code();
};
var init_add_remove_tax_codes = function() {
$('.add_tax_code').click(add_tax_code);
$('.remove_tax_code').click(remove_tax_code);
- hide_show_remove();
+ hide_show_remove_tax_code();
};
init_add_remove_tax_codes();
- var duplicate_found = false;
// run validator once for all fields
- $.validator.addMethod('tax_code' , function(value, element) {
+ $.validator.addMethod('check4TaxCodeDups' , function(value, element) {
var value_count = 0;
- $("input[name*='tax_code']").each(function() {
+ $("input[name='tax_code[]']").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
- return value_count < 2;
+ if (value_count > 1) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_code_duplicate'); ?>");
- $.validator.addMethod('valid_chars', function(value, element) {
- return value.indexOf('_') === -1;
+ $.validator.addMethod('validateTaxCodeCharacters', function(value, element) {
+ if ((value.indexOf('_') != -1)) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_code_invalid_chars'); ?>");
+ $.validator.addMethod('requireTaxCode', function(value, element) {
+ if (value .trim() == '') {
+ return false;
+ }
+ return true;
+ }, "lang->line('taxes_tax_code_required'); ?>");
+
$('#tax_codes_form').validate($.extend(form_support.handler, {
- submitHandler: function(form) {
+ submitHandler: function(form, event) {
$(form).ajaxSubmit({
success: function(response) {
$.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'});
@@ -99,41 +104,25 @@
dataType: 'json'
});
},
-
- errorLabelContainer: "#tax_code_error_message_box",
-
- rules:
- {
- $tax_code_data)
- {
- ?>
- :
- {
- required: true,
- tax_code: true,
- valid_chars: true
- },
-
+ invalidHandler: function(event, validator) {
+ $.notify("lang->line('common_correct_errors'); ?>");
},
-
- messages:
- {
- $tax_code_data)
- {
- ?>
- : "lang->line('taxes_tax_code_required'); ?>",
-
- }
+ errorLabelContainer: "#tax_code_error_message_box"
}));
+
+ $tax_code_data)
+ {
+ ?>
+ $('').rules( "add", {
+ requireTaxCode: true,
+ check4TaxCodeDups: true,
+ validateTaxCodeCharacters: true
+ });
+
+
});
diff --git a/application/views/taxes/tax_jurisdictions.php b/application/views/taxes/tax_jurisdictions.php
index e72c98dd0..1327c54f6 100644
--- a/application/views/taxes/tax_jurisdictions.php
+++ b/application/views/taxes/tax_jurisdictions.php
@@ -27,7 +27,7 @@
}
var tax_type_options = '';
- var hide_show_remove = function() {
+ var hide_show_remove_tax_jurisdiction = function() {
if ($("input[name*='tax_jurisdiction']:enabled").length > 1)
{
$(".remove_tax_jurisdiction").show();
@@ -42,61 +42,61 @@
var id = $(this).parent().find('input').attr('id');
id = id.replace(/.*?_(\d+)$/g, "$1");
- var previous_jurisdiction_id = 'jurisdiction_id_' + id;
var previous_jurisdiction_name_id = 'jurisdiction_name_' + id;
- var previous_tax_group_id = 'tax_group_' + id;
- var previous_tax_type_id = 'tax_type_' + id;
- var previous_reporting_authority_id = 'reporting_authority_' + id;
- var previous_tax_group_sequence_id = 'tax_group_sequence_' + id;
- var previous_cascade_sequence_id = 'cascade_sequence_' + id;
var block = $(this).parent().clone(true);
var new_block = block.insertAfter($(this).parent());
++tax_jurisdictions_count;
- var new_jurisdiction_id = 'jurisdiction_id_' + tax_jurisdictions_count;
var new_jurisdiction_name_id = 'jurisdiction_name_' + tax_jurisdictions_count;
- var new_tax_group_id = 'tax_group_' + tax_jurisdictions_count;
- var new_tax_type_id = 'tax_type_' + tax_jurisdictions_count;
- var new_reporting_authority_id = 'reporting_authority_' + tax_jurisdictions_count;
- var new_tax_group_sequence_id = 'tax_group_sequence_' + tax_jurisdictions_count;
- var new_cascade_sequence_id = 'cascade_sequence_' + tax_jurisdictions_count;
$(new_block).find('label').html("lang->line('taxes_tax_jurisdiction'); ?> " + tax_jurisdictions_count).attr('for', new_jurisdiction_name_id).attr('class', 'control-label col-xs-2');
- $(new_block).find("input[name='"+previous_jurisdiction_id+"']").attr('name', new_jurisdiction_id).val('-1');
- $(new_block).find("input[id='"+previous_jurisdiction_name_id+"']").attr('id', new_jurisdiction_name_id).removeAttr('disabled').attr('name', new_jurisdiction_name_id).attr('class', 'form-control required input-sm').val('');
- $(new_block).find("input[id='"+previous_tax_group_id+"']").attr('id', new_tax_group_id).removeAttr('disabled').attr('name', new_tax_group_id).attr('class', 'form-control required input-sm').val('');
- $(new_block).find("select[name='"+previous_tax_type_id+"']").attr('name', new_tax_type_id).removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
- $(new_block).find("input[id='"+previous_reporting_authority_id+"']").attr('id', new_reporting_authority_id).removeAttr('disabled').attr('name', new_reporting_authority_id).attr('class', 'form-control input-sm').val('');
- $(new_block).find("input[id='"+previous_tax_group_sequence_id+"']").attr('id', new_tax_group_sequence_id).removeAttr('disabled').attr('name', new_tax_group_sequence_id).attr('class', 'form-control input-sm').val('');
- $(new_block).find("input[id='"+previous_cascade_sequence_id+"']").attr('id', new_cascade_sequence_id).removeAttr('disabled').attr('name', new_cascade_sequence_id).attr('class', 'form-control input-sm').val('');
- hide_show_remove();
+ $(new_block).find("input[name='jurisdiction_name[]']").attr('id', new_jurisdiction_name_id).removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
+ $(new_block).find("input[name='tax_group[]']").removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
+ $(new_block).find("select[name='tax_type[]']").removeAttr('disabled').attr('class', 'form-control required input-sm').val('');
+ $(new_block).find("input[name='reporting_authority[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='tax_group_sequence[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='cascade_sequence[]']").removeAttr('disabled').attr('class', 'form-control input-sm').val('');
+ $(new_block).find("input[name='jurisdiction_id[]']").val('-1');
+ hide_show_remove_tax_jurisdiction();
};
var remove_tax_jurisdiction = function() {
$(this).parent().remove();
- hide_show_remove();
+ hide_show_remove_tax_jurisdiction();
};
var init_add_remove_tax_jurisdiction = function() {
$('.add_tax_jurisdiction').click(add_tax_jurisdiction);
$('.remove_tax_jurisdiction').click(remove_tax_jurisdiction);
- hide_show_remove();
+ hide_show_remove_tax_jurisdiction();
};
init_add_remove_tax_jurisdiction();
- var duplicate_found = false;
// run validator once for all fields
- $.validator.addMethod('tax_jurisdiction' , function(value, element) {
+ $.validator.addMethod('check4TaxJurisdictionDups' , function(value, element) {
var value_count = 0;
- $("input[name*='tax_jurisdiction']").each(function() {
+ $("input[name='jurisdiction_name[]']").each(function() {
value_count = $(this).val() == value ? value_count + 1 : value_count;
});
- return value_count < 2;
+ if (value_count > 1) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_jurisdiction_duplicate'); ?>");
- $.validator.addMethod('valid_chars', function(value, element) {
- return value.indexOf('_') === -1;
+ $.validator.addMethod('validateTaxJurisdictionCharacters', function(value, element) {
+ if ((value.indexOf('_') != -1)) {
+ return false;
+ }
+ return true;
}, "lang->line('taxes_tax_jurisdiction_invalid_chars'); ?>");
+ $.validator.addMethod('requireTaxJurisdiction', function(value, element) {
+ if (value .trim() == '') {
+ return false;
+ }
+ return true;
+ }, "lang->line('taxes_tax_jurisdiction_required'); ?>");
+
$('#tax_jurisdictions_form').validate($.extend(form_support.handler, {
submitHandler: function(form) {
$(form).ajaxSubmit({
@@ -107,41 +107,24 @@
dataType: 'json'
});
},
-
- errorLabelContainer: "#tax_jurisdiction_error_message_box",
-
- rules:
- {
- $tax_jurisdiction_data)
- {
- ?>
- :
- {
- required: true,
- tax_jurisdiction: true,
- valid_chars: true
- },
-
+ invalidHandler: function(event, validator) {
+ $.notify("lang->line('common_correct_errors'); ?>");
},
-
- messages:
- {
- $tax_jurisdiction_data)
- {
- ?>
- : "lang->line('taxes_tax_jurisdiction_required'); ?>",
-
- }
+ errorLabelContainer: "#tax_jurisdiction_error_message_box"
}));
+
+ $tax_jurisdiction_data)
+ {
+ ?>
+ $('').rules( "add", {
+ requireTaxJurisdiction: true,
+ check4TaxJurisdictionDups: true,
+ validateTaxJurisdictionCharacters: true
+ });
+
});