mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-05-24 16:28:40 -04:00
Insert Try->Catch clause (#1616)
This commit is contained in:
@@ -702,7 +702,7 @@ class Config extends Secure_Controller
|
||||
|
||||
$success &= $this->db->trans_status();
|
||||
|
||||
$message = "";
|
||||
$message = '';
|
||||
if($success && $delete_rejected)
|
||||
{
|
||||
$message = $this->lang->line('config_tax_category_used');
|
||||
|
||||
@@ -114,7 +114,7 @@ class Secure_Controller extends CI_Controller
|
||||
|
||||
foreach($this->input->get() as $str)
|
||||
{
|
||||
$result = parse_decimals($str);
|
||||
$result &= parse_decimals($str);
|
||||
}
|
||||
|
||||
echo $result !== FALSE ? 'true' : 'false';
|
||||
|
||||
@@ -59,7 +59,7 @@ function load_language($load_system_language = FALSE, array $lang_array)
|
||||
{
|
||||
if($load_system_language = TRUE)
|
||||
{
|
||||
foreach($lang_array as $language_file)
|
||||
foreach($lang_array as $language_file)
|
||||
{
|
||||
get_instance()->lang->load($language_file,current_language_code(TRUE));
|
||||
}
|
||||
@@ -75,19 +75,19 @@ function load_language($load_system_language = FALSE, array $lang_array)
|
||||
|
||||
function currency_side()
|
||||
{
|
||||
$config = get_instance()->config;
|
||||
$config = get_instance()->config;
|
||||
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), \NumberFormatter::CURRENCY);
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), \NumberFormatter::CURRENCY);
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
|
||||
return !preg_match('/^¤/', $fmt->getPattern());
|
||||
return !preg_match('/^¤/', $fmt->getPattern());
|
||||
}
|
||||
|
||||
function quantity_decimals()
|
||||
{
|
||||
$config = get_instance()->config;
|
||||
$config = get_instance()->config;
|
||||
|
||||
return $config->item('quantity_decimals') ? $config->item('quantity_decimals') : 0;
|
||||
return $config->item('quantity_decimals') ? $config->item('quantity_decimals') : 0;
|
||||
}
|
||||
|
||||
function totals_decimals()
|
||||
@@ -113,83 +113,90 @@ function tax_decimals()
|
||||
|
||||
function to_currency($number)
|
||||
{
|
||||
return to_decimals($number, 'currency_decimals', \NumberFormatter::CURRENCY);
|
||||
return to_decimals($number, 'currency_decimals', \NumberFormatter::CURRENCY);
|
||||
}
|
||||
|
||||
function to_currency_no_money($number)
|
||||
{
|
||||
return to_decimals($number, 'currency_decimals');
|
||||
return to_decimals($number, 'currency_decimals');
|
||||
}
|
||||
|
||||
function to_currency_tax($number)
|
||||
{
|
||||
$config = get_instance()->config;
|
||||
|
||||
if($config->item('customer_sales_tax_support') == '1')
|
||||
{
|
||||
if($config->item('customer_sales_tax_support') == '1')
|
||||
{
|
||||
return to_decimals($number, 'currency_decimals', \NumberFormatter::CURRENCY);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
return to_decimals($number, 'tax_decimals', \NumberFormatter::CURRENCY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function to_tax_decimals($number)
|
||||
{
|
||||
// taxes that are NULL, '' or 0 don't need to be displayed
|
||||
// NOTE: do not remove this line otherwise the items edit form will show a tax with 0 and it will save it
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
|
||||
return to_decimals($number, 'tax_decimals');
|
||||
return to_decimals($number, 'tax_decimals');
|
||||
}
|
||||
|
||||
function to_quantity_decimals($number)
|
||||
{
|
||||
return to_decimals($number, 'quantity_decimals');
|
||||
return to_decimals($number, 'quantity_decimals');
|
||||
}
|
||||
|
||||
function to_decimals($number, $decimals, $type=\NumberFormatter::DECIMAL)
|
||||
{
|
||||
// ignore empty strings and return
|
||||
// NOTE: do not change it to empty otherwise tables will show a 0 with no decimal nor currency symbol
|
||||
if(!isset($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
if(!isset($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), $type);
|
||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
|
||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item($decimals));
|
||||
if(empty($config->item('thousands_separator')))
|
||||
{
|
||||
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
|
||||
}
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
$config = get_instance()->config;
|
||||
$fmt = new \NumberFormatter($config->item('number_locale'), $type);
|
||||
$fmt->setAttribute(\NumberFormatter::MIN_FRACTION_DIGITS, $config->item($decimals));
|
||||
$fmt->setAttribute(\NumberFormatter::MAX_FRACTION_DIGITS, $config->item($decimals));
|
||||
if(empty($config->item('thousands_separator')))
|
||||
{
|
||||
$fmt->setAttribute(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL, '');
|
||||
}
|
||||
$fmt->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $config->item('currency_symbol'));
|
||||
|
||||
return $fmt->format($number);
|
||||
return $fmt->format($number);
|
||||
}
|
||||
|
||||
function parse_decimals($number)
|
||||
{
|
||||
// ignore empty strings and return
|
||||
if(empty($number))
|
||||
{
|
||||
return $number;
|
||||
}
|
||||
// ignore empty strings and return
|
||||
if(empty($number))
|
||||
{
|
||||
return $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, '');
|
||||
}
|
||||
$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);
|
||||
try
|
||||
{
|
||||
return $fmt->parse($number);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -198,88 +205,88 @@ function parse_decimals($number)
|
||||
|
||||
function dateformat_momentjs($php_format)
|
||||
{
|
||||
$SYMBOLS_MATCHING = array(
|
||||
'd' => 'DD',
|
||||
'D' => 'ddd',
|
||||
'j' => 'D',
|
||||
'l' => 'dddd',
|
||||
'N' => 'E',
|
||||
'S' => 'o',
|
||||
'w' => 'e',
|
||||
'z' => 'DDD',
|
||||
'W' => 'W',
|
||||
'F' => 'MMMM',
|
||||
'm' => 'MM',
|
||||
'M' => 'MMM',
|
||||
'n' => 'M',
|
||||
't' => '', // no equivalent
|
||||
'L' => '', // no equivalent
|
||||
'o' => 'YYYY',
|
||||
'Y' => 'YYYY',
|
||||
'y' => 'YY',
|
||||
'a' => 'a',
|
||||
'A' => 'A',
|
||||
'B' => '', // no equivalent
|
||||
'g' => 'h',
|
||||
'G' => 'H',
|
||||
'h' => 'hh',
|
||||
'H' => 'HH',
|
||||
'i' => 'mm',
|
||||
's' => 'ss',
|
||||
'u' => 'SSS',
|
||||
'e' => 'zz', // deprecated since version $1.6.0 of moment.js
|
||||
'I' => '', // no equivalent
|
||||
'O' => '', // no equivalent
|
||||
'P' => '', // no equivalent
|
||||
'T' => '', // no equivalent
|
||||
'Z' => '', // no equivalent
|
||||
'c' => '', // no equivalent
|
||||
'r' => '', // no equivalent
|
||||
'U' => 'X'
|
||||
);
|
||||
$SYMBOLS_MATCHING = array(
|
||||
'd' => 'DD',
|
||||
'D' => 'ddd',
|
||||
'j' => 'D',
|
||||
'l' => 'dddd',
|
||||
'N' => 'E',
|
||||
'S' => 'o',
|
||||
'w' => 'e',
|
||||
'z' => 'DDD',
|
||||
'W' => 'W',
|
||||
'F' => 'MMMM',
|
||||
'm' => 'MM',
|
||||
'M' => 'MMM',
|
||||
'n' => 'M',
|
||||
't' => '', // no equivalent
|
||||
'L' => '', // no equivalent
|
||||
'o' => 'YYYY',
|
||||
'Y' => 'YYYY',
|
||||
'y' => 'YY',
|
||||
'a' => 'a',
|
||||
'A' => 'A',
|
||||
'B' => '', // no equivalent
|
||||
'g' => 'h',
|
||||
'G' => 'H',
|
||||
'h' => 'hh',
|
||||
'H' => 'HH',
|
||||
'i' => 'mm',
|
||||
's' => 'ss',
|
||||
'u' => 'SSS',
|
||||
'e' => 'zz', // deprecated since version $1.6.0 of moment.js
|
||||
'I' => '', // no equivalent
|
||||
'O' => '', // no equivalent
|
||||
'P' => '', // no equivalent
|
||||
'T' => '', // no equivalent
|
||||
'Z' => '', // no equivalent
|
||||
'c' => '', // no equivalent
|
||||
'r' => '', // no equivalent
|
||||
'U' => 'X'
|
||||
);
|
||||
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
}
|
||||
|
||||
function dateformat_bootstrap($php_format)
|
||||
{
|
||||
$SYMBOLS_MATCHING = array(
|
||||
// Day
|
||||
'd' => 'dd',
|
||||
'D' => 'd',
|
||||
'j' => 'd',
|
||||
'l' => 'dd',
|
||||
'N' => '',
|
||||
'S' => '',
|
||||
'w' => '',
|
||||
'z' => '',
|
||||
// Week
|
||||
'W' => '',
|
||||
// Month
|
||||
'F' => 'MM',
|
||||
'm' => 'mm',
|
||||
'M' => 'M',
|
||||
'n' => 'm',
|
||||
't' => '',
|
||||
// Year
|
||||
'L' => '',
|
||||
'o' => '',
|
||||
'Y' => 'yyyy',
|
||||
'y' => 'yy',
|
||||
// Time
|
||||
'a' => 'p',
|
||||
'A' => 'P',
|
||||
'B' => '',
|
||||
'g' => 'H',
|
||||
'G' => 'h',
|
||||
'h' => 'HH',
|
||||
'H' => 'hh',
|
||||
'i' => 'ii',
|
||||
's' => 'ss',
|
||||
'u' => ''
|
||||
);
|
||||
$SYMBOLS_MATCHING = array(
|
||||
// Day
|
||||
'd' => 'dd',
|
||||
'D' => 'd',
|
||||
'j' => 'd',
|
||||
'l' => 'dd',
|
||||
'N' => '',
|
||||
'S' => '',
|
||||
'w' => '',
|
||||
'z' => '',
|
||||
// Week
|
||||
'W' => '',
|
||||
// Month
|
||||
'F' => 'MM',
|
||||
'm' => 'mm',
|
||||
'M' => 'M',
|
||||
'n' => 'm',
|
||||
't' => '',
|
||||
// Year
|
||||
'L' => '',
|
||||
'o' => '',
|
||||
'Y' => 'yyyy',
|
||||
'y' => 'yy',
|
||||
// Time
|
||||
'a' => 'p',
|
||||
'A' => 'P',
|
||||
'B' => '',
|
||||
'g' => 'H',
|
||||
'G' => 'h',
|
||||
'h' => 'HH',
|
||||
'H' => 'hh',
|
||||
'i' => 'ii',
|
||||
's' => 'ss',
|
||||
'u' => ''
|
||||
);
|
||||
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
return strtr($php_format, $SYMBOLS_MATCHING);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user