Allows nominal currency with decimal fractions

Write here for anything about bibliography module in SLiMS.

Moderators: wynerst, buitenzorg812, purwoko, sutriadi, ido, Dicarve, ridorido

Post Reply
User avatar
heru_subekti
Posts: 58
Joined: 04 Oct 2012, 00:02
Location: Trenggalek, Jawa Timur
Contact:

Allows nominal currency with decimal fractions

Post by heru_subekti » 19 Oct 2017, 09:19

Hello, this time I will share tips to change the currency value for the item of copies. In standard setting, the format of currency field using a round value.
Then how to several countries that use the currency value with fractional cents?
A first step, you must change the data type for the currency in the table of items (I assume you can use the mysql manager, for example phpMyAdmin), then run the following query

Code: Select all

ALTER TABLE `item` CHANGE `price` `price` DECIMAL( 10, 2 ) NULL DEFAULT NULL ;
then open the file slims_folder / admin / modules / bibliography / item.php, find the line contains

Code: Select all

$data['price'] = preg_replace('@[.,\-a­-z ]@i', '', strip_tags($_POST['p­rice']));

Code: Select all

[.,\-a­-z ]
look at this script, the characters in the parameter will be omitted. that means you have to remove the dot within the parameters so that these characters are not deleted when saved to the database.
after edit

Code: Select all

$data['price'] = preg_replace('@[,\-a­-z ]@i', '', strip_tags($_POST['p­rice']));
and then save.

image preview :
currency.jpg
currency.jpg (61.36 KiB) Viewed 1745 times

Post Reply