Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 1375 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
115 lars 1
<?php
2
    /*
3
    * Smarty plugin
4
    *
5
    -------------------------------------------------------------
6
    * File:     modifier.money_format.php
7
    * Type:     modifier
8
    * Name:     money_format
1371 lars 9
    * Version:  1.1
10
    * Date:     Oct 12th, 2022
115 lars 11
    * Purpose:  pass value to PHP money_format() and return result
12
    * Install:  Drop into the plugin directory.
13
    * Author:   Michael L. Fladischer <mfladischer@abis.co.at>
1371 lars 14
    * Author:   Lars Tiefland Weban UG <l.tiefland@webn.de>
115 lars 15
    *
16
    -------------------------------------------------------------
17
    */
1371 lars 18
    function smarty_modifier_money_format_red( $string, $places = 2, $locale = "de_DE", $onlySymbol = false, $incSymbol = true, $shortSymbol = false )
115 lars 19
    {
20
        if ( !$locale )
21
        {
1375 lars 22
            $locale = "de_DE.UTF-8";
115 lars 23
        }
1371 lars 24
 
25
        $fmt = new NumberFormatter( $locale, NumberFormatter::CURRENCY );
26
        if ( $incSymbol === false )
115 lars 27
        {
1371 lars 28
            $fmt->setPattern( "#,##0.00" );
115 lars 29
        }
1371 lars 30
        if ( $shortSymbol === false )
115 lars 31
        {
1376 lars 32
            //$fmt->setSymbol( NumberFormatter::CURRENCY_SYMBOL, NumberFormatter::CURRENCY_CODE );
115 lars 33
        }
1371 lars 34
        $fmt->setAttribute( NumberFormatter::FRACTION_DIGITS, $places );
35
        return $fmt->format( $string );
115 lars 36
    }
1371 lars 37
 
38
    /* vim: set expandtab: */