projects
/
misc
/
kostenrechnung
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
d1f218a
)
Add support for saving decimal values
author
Joey Schulze
<joey@infodrom.org>
Sun, 28 Feb 2010 16:12:39 +0000
(17:12 +0100)
committer
Joey Schulze
<joey@infodrom.org>
Sun, 28 Feb 2010 16:12:39 +0000
(17:12 +0100)
ajax/ajax.php
patch
|
blob
|
history
diff --git
a/ajax/ajax.php
b/ajax/ajax.php
index
3894be2
..
bbef0e4
100644
(file)
--- a/
ajax/ajax.php
+++ b/
ajax/ajax.php
@@
-53,6
+53,12
@@
function details($mask)
return $row;
}
return $row;
}
+function format_decimal($value)
+{
+ $value = str_replace(',','.',$value);
+ return sprintf("%.2f", $value);
+}
+
function save($mask)
{
if (empty($_POST['id']))
function save($mask)
{
if (empty($_POST['id']))
@@
-69,6
+75,11
@@
function save($mask)
$update[] = sprintf("%s=NULL", $field);
else
$update[] = sprintf("%s=%d", $field, $_POST[$field]);
$update[] = sprintf("%s=NULL", $field);
else
$update[] = sprintf("%s=%d", $field, $_POST[$field]);
+ } elseif ($info['type'] == 'decimal') {
+ if (empty($_POST[$field]) && $info['null'] === true)
+ $update[] = sprintf("%s=NULL", $field);
+ else
+ $update[] = sprintf("%s=%s", $field, format_decimal($_POST[$field]));
} elseif ($info['type'] == 'passwd') {
if (!empty($_POST[$field]))
$update[] = sprintf("%s='%s'", $field, pg_escape_string(passwd($_SESSION['sys']['login'],$_POST[$field])));
} elseif ($info['type'] == 'passwd') {
if (!empty($_POST[$field]))
$update[] = sprintf("%s='%s'", $field, pg_escape_string(passwd($_SESSION['sys']['login'],$_POST[$field])));
@@
-109,6
+120,12
@@
function insert($mask)
$values[] = 'NULL';
else
$values[] = intval($_POST[$field]);
$values[] = 'NULL';
else
$values[] = intval($_POST[$field]);
+ } elseif ($info['type'] == 'decimal') {
+ $fields[] = $field;
+ if (empty($_POST[$field]) && $info['null'] === true)
+ $values[] = 'NULL';
+ else
+ $values[] = format_decimal($_POST[$field]);
} elseif ($info['type'] == 'passwd') {
if (!empty($_POST[$field])) {
$fields[] = $field;
} elseif ($info['type'] == 'passwd') {
if (!empty($_POST[$field])) {
$fields[] = $field;