mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-04-08 17:08:04 -04:00
Add frontside support for locale dependent number validation (#788)
This commit is contained in:
@@ -99,11 +99,6 @@ class Receivings extends Secure_Controller
|
||||
$this->_reload($data);
|
||||
}
|
||||
|
||||
function numeric($str)
|
||||
{
|
||||
return parse_decimals($str, 3);
|
||||
}
|
||||
|
||||
public function edit_item($item_id)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
@@ -285,11 +285,6 @@ class Sales extends Secure_Controller
|
||||
$this->_reload($data);
|
||||
}
|
||||
|
||||
function numeric($str)
|
||||
{
|
||||
return parse_decimals($str, 3);
|
||||
}
|
||||
|
||||
public function edit_item($item_id)
|
||||
{
|
||||
$data = array();
|
||||
|
||||
@@ -50,7 +50,21 @@ class Secure_Controller extends CI_Controller
|
||||
return $this->security->xss_clean($str, $is_image);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function numeric($str)
|
||||
{
|
||||
return parse_decimals($str);
|
||||
}
|
||||
|
||||
public function check_numeric()
|
||||
{
|
||||
$result = TRUE;
|
||||
foreach($this->input->get() as $str) {
|
||||
$result = parse_decimals($str);
|
||||
}
|
||||
echo $result !== FALSE ? 'true' : 'false';
|
||||
}
|
||||
|
||||
// this is the basic set of methods most OSPOS Controllers will implement
|
||||
public function index() { return FALSE; }
|
||||
public function search() { return FALSE; }
|
||||
|
||||
@@ -82,6 +82,10 @@ function parse_decimals($number)
|
||||
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter( $config->item('number_locale'), \NumberFormatter::DECIMAL );
|
||||
if (empty($config->item('thousands_separator')))
|
||||
{
|
||||
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
|
||||
}
|
||||
return $fmt->parse($number);
|
||||
}
|
||||
|
||||
|
||||
@@ -264,18 +264,22 @@ $(document).ready(function()
|
||||
default_tax_1_rate:
|
||||
{
|
||||
required: true,
|
||||
number: true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
default_tax_1_name: "required",
|
||||
default_tax2_rate:
|
||||
{
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
lines_per_page:
|
||||
{
|
||||
required: true,
|
||||
number: true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
default_sales_discount:
|
||||
{
|
||||
required: true,
|
||||
number: true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -376,13 +376,13 @@
|
||||
},
|
||||
cost_price:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
required: true,
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
unit_price:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
<?php
|
||||
foreach($stock_locations as $key=>$location_detail)
|
||||
@@ -391,7 +391,7 @@
|
||||
<?php echo 'quantity_' . $key ?>:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
<?php
|
||||
}
|
||||
@@ -399,17 +399,17 @@
|
||||
receiving_quantity:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
reorder_level:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
},
|
||||
tax_percent:
|
||||
{
|
||||
required:true,
|
||||
number:true
|
||||
remote: "<?php echo site_url($controller_name . '/check_numeric')?>"
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user