4 * Holds functions for the calendar, one is for holidays
6 * @link https://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2005 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 //Require once the holidays controller for the is_holiday() function
13 require_once($GLOBALS['incdir'] . "/main/holidays/Holidays_Controller.php");
15 // Returns an array of the facility ids and names that the user is allowed to access.
16 // Access might be for inventory purposes ($inventory=true) or calendar purposes.
18 function getUserFacilities($uID, $orderby = 'id', $inventory = false)
20 $restrict = $inventory ?
$GLOBALS['gbl_fac_warehouse_restrictions'] : $GLOBALS['restrict_user_facility'];
22 // No entries in this table means the user is not restricted.
24 "SELECT count(*) AS count FROM users_facility WHERE " .
25 "tablename = 'users' AND table_id = ?",
29 if (!$restrict ||
empty($countrow['count'])) {
31 "SELECT id, name, color FROM facility " .
35 // This query gets facilities that the user is authorized to access.
37 "SELECT f.id, f.name, f.color " .
38 "FROM facility AS f " .
39 "JOIN users AS u ON u.id = ? " .
40 "WHERE f.id = u.facility_id OR f.id IN " .
41 "(SELECT DISTINCT uf.facility_id FROM users_facility AS uf WHERE uf.tablename = 'users' AND uf.table_id = u.id) " .
42 "ORDER BY f.$orderby",
47 while ($row = sqlFetchArray($rez)) {
53 // Returns an array of warehouse IDs for the given user and facility.
54 function getUserFacWH($uID, $fID)
57 "SELECT warehouse_id FROM users_facility WHERE tablename = ? " .
58 "AND table_id = ? AND facility_id = ?",
59 array('users', $uID, $fID)
62 while ($row = sqlFetchArray($res)) {
63 if ($row['warehouse_id'] === '') {
66 $returnVal[] = $row['warehouse_id'];
72 * Check if day is weekend day
76 function is_weekend_day($day)
79 if (in_array($day, $GLOBALS['weekend_days'])) {
87 * This function checks if a certain date (YYYY/MM/DD) is a marked as a holiday/closed event in the events table
91 function is_holiday($date)
93 Holidays_Controller
::is_holiday($date);