]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/Smarty/plugins/function.sugar_currency_format.php
Release 6.5.0
[Github/sugarcrm.git] / include / Smarty / plugins / function.sugar_currency_format.php
1 <?php
2
3 /*
4
5 Modification information for LGPL compliance
6
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
8
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
10
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
12
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3  tags and updated the build system 
14
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
16
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
18
19 r45763 - 2009-04-01 12:16:18 -0700 (Wed, 01 Apr 2009) - majed - Removed half of the require_once and include_onces in the product that were redundant or could be handled easily by the auto loader
20
21 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
22
23 r33741 - 2008-04-03 11:03:29 -0700 (Thu, 03 Apr 2008) - bsoufflet - Change the smarty function : sugar_currency_format
24 Now you can specify decimals, round, convert, currency_symbol parameters in the listview defs.
25
26 r33739 - 2008-04-03 10:58:52 -0700 (Thu, 03 Apr 2008) - bsoufflet - Change the smarty function : sugar
27
28 r28687 - 2007-10-22 17:16:54 -0700 (Mon, 22 Oct 2007) - jenny - Bug 16501: Checking in Majed's changes...
29
30 r26209 - 2007-08-28 01:19:52 -0700 (Tue, 28 Aug 2007) - clee - Fixed issue with currency symbol formatting for subtotal and line items.
31
32 r25610 - 2007-08-14 00:34:06 -0700 (Tue, 14 Aug 2007) - clee - Cleaned the code up.  Removed all the commented blocks and optimized to not include files unless needed.
33
34 r22865 - 2007-05-16 14:42:03 -0700 (Wed, 16 May 2007) - clee - Updated to user currency_format_number
35
36 r15484 - 2006-08-03 15:58:50 -0700 (Thu, 03 Aug 2006) - chris - Currency Display fixes for i18n deliverables
37
38 r14851 - 2006-07-20 17:16:45 -0700 (Thu, 20 Jul 2006) - wayne - return nothing if nothing passed in
39
40 r14718 - 2006-07-17 17:39:10 -0700 (Mon, 17 Jul 2006) - wayne - format the currency
41
42
43 */
44
45
46 /**
47  * Smarty plugin
48  * @package Smarty
49  * @subpackage plugins
50  */
51
52
53 /**
54  * Smarty {sugar_currency_format} function plugin
55  *
56  * Type:     function<br>
57  * Name:     sugar_currency_format<br>
58  * Purpose:  formats a number
59  * 
60  * @author Wayne Pan {wayne at sugarcrm.com}
61  * @param array
62  * @param Smarty
63  */
64 function smarty_function_sugar_currency_format($params, &$smarty) {
65
66     // Bug #47406 : Currency field doesn't accept 0.00 as default value
67         if(!isset($params['var']) || $params['var'] === '') {
68         return '';
69     } 
70     
71     global $locale;
72     if(empty($params['currency_id'])){
73         $params['currency_id'] = $locale->getPrecedentPreference('currency');
74         if(!isset($params['convert'])) {
75             $params['convert'] = true;
76         }
77         if(!isset($params['currency_symbol'])) {
78            $params['currency_symbol'] = $locale->getPrecedentPreference('default_currency_symbol');
79         }
80     }
81    
82     $_contents = currency_format_number($params['var'], $params);
83
84     if (!empty($params['assign'])) {
85         $smarty->assign($params['assign'], $_contents);
86     } else {
87         return $_contents;
88     }
89 }
90
91 ?>