Integrate adodb binding functionality to allow sql queries with binding to prevent...
[openemr.git] / library / formatting.inc.php
blob03a424694a0930f5459845b99d25d2c1c1e987af
1 <?php
2 // Copyright (C) 2010 Rod Roark <rod@sunsetsystems.com>
3 //
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";
17 return $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);
29 return $date;
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) {
39 $i = 0;
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;
47 return $note;
50 function oeFormatClientID($id) {
52 // TBD
54 return $id;