2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 function oeFormatMoney($amount, $symbol=false) {
10 $s = number_format($amount,
11 $GLOBALS['currency_decimals'],
12 $GLOBALS['currency_dec_point'],
13 $GLOBALS['currency_thousands_sep']);
14 // If the currency symbol exists and is requested, prepend it.
15 if ($symbol && !empty($GLOBALS['gbl_currency_symbol']))
16 $s = $GLOBALS['gbl_currency_symbol'] . " $s";
20 function oeFormatShortDate($date='today') {
21 if ($date === 'today') $date = date('Y-m-d');
22 if (strlen($date) == 10) {
23 // assume input is yyyy-mm-dd
24 if ($GLOBALS['date_display_format'] == 1) // mm/dd/yyyy
25 $date = substr($date, 5, 2) . '/' . substr($date, 8, 2) . '/' . substr($date, 0, 4);
26 else if ($GLOBALS['date_display_format'] == 2) // dd/mm/yyyy
27 $date = substr($date, 8, 2) . '/' . substr($date, 5, 2) . '/' . substr($date, 0, 4);
32 // Format short date from time.
33 function oeFormatSDFT($time) {
34 return oeFormatShortDate(date('Y-m-d', $time));
37 // Format the body of a patient note.
38 function oeFormatPatientNote($note) {
40 while ($i !== false) {
41 if (preg_match('/^\d\d\d\d-\d\d-\d\d/', substr($note, $i))) {
42 $note = substr($note, 0, $i) . oeFormatShortDate(substr($note, $i, 10)) . substr($note, $i +
10);
44 $i = strpos("\n", $note, $i);
45 if ($i !== false) ++
$i;
50 function oeFormatClientID($id) {
56 //----------------------------------------------------
57 function DateFormatRead()
58 {//For the 3 supported date format,the javascript code also should be twicked to display the date as per it.
59 //Output of this function is given to 'ifFormat' parameter of the 'Calendar.setup'.
60 //This will show the date as per the global settings.
61 if($GLOBALS['date_display_format']==0)
65 else if($GLOBALS['date_display_format']==1)
69 else if($GLOBALS['date_display_format']==2)
74 function DateToYYYYMMDD($DateValue)
75 {//With the help of function DateFormatRead() now the user can enter date is any of the 3 formats depending upon the global setting.
76 //But in database the date can be stored only in the yyyy-mm-dd format.
77 //This function accepts a date in any of the 3 formats, and as per the global setting, converts it to the yyyy-mm-dd format.
78 if(trim($DateValue)=='')
83 if($GLOBALS['date_display_format']==0)
87 else if($GLOBALS['date_display_format']==1 ||
$GLOBALS['date_display_format']==2)
89 $DateValueArray=split('/',$DateValue);
90 if($GLOBALS['date_display_format']==1)
92 return $DateValueArray[2].'-'.$DateValueArray[0].'-'.$DateValueArray[1];
94 if($GLOBALS['date_display_format']==2)
96 return $DateValueArray[2].'-'.$DateValueArray[1].'-'.$DateValueArray[0];