4 * interface/therapy_groups/therapy_groups_models/users_model.php contains the model for users.
6 * This model fetches the users data to be used for the therapy group from the DB.
8 * Copyright (C) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
9 * Copyright (C) 2016 Amiel Elboim <amielel@matrix.co.il>
11 * LICENSE: This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 3
14 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
23 * @author Shachar Zilbershlag <shaharzi@matrix.co.il>
24 * @author Amiel Elboim <amielel@matrix.co.il>
25 * @link http://www.open-emr.org
30 const TABLE
= 'users';
31 const EVENTS_TABLE
= 'openemr_postcalendar_events';
34 * Get all users' ids and full names from users table.
37 public function getAllUsers()
40 $sql = 'SELECT id, fname, lname FROM ' . self
::TABLE
. ' WHERE active = 1';
43 $result = sqlStatement($sql);
44 while ($u = sqlFetchArray($result)) {
52 * Get user name by user id from users table.
56 public function getUserNameById($uid)
58 $sql = 'SELECT fname, lname FROM ' . self
::TABLE
. ' WHERE id = ?';
60 $user_name = sqlQuery($sql, array($uid));
61 $user_full_name = $user_name['fname'] . " " . $user_name['lname'];
63 return $user_full_name;
67 * Get all providers of event.
71 public function getProvidersOfEvent($eid)
74 $multiple = $this->checkIfMultiple($eid);
76 $sql = "SELECT pc_aid From " . self
::EVENTS_TABLE
. " WHERE pc_multiple = ?";
77 $result = sqlStatement($sql, array($multiple));
78 while ($p = sqlFetchArray($result)) {
79 $providers[] = $p['pc_aid'];
84 $sql = "SELECT pc_aid From " . self
::EVENTS_TABLE
. " WHERE pc_eid = ?";
85 $result = sqlStatement($sql, array($eid));
86 while ($p = sqlFetchArray($result)) {
87 $providers[] = $p['pc_aid'];
96 * Checks if event has multiple providers and if so returns the key of 'multiple providers'.
98 * @return bool|ADORecordSet_mysqli
100 private function checkIfMultiple($eid)
103 $sql = "SELECT pc_multiple FROM " . self
::EVENTS_TABLE
. " WHERE pc_eid = ?";
104 $result = sqlQuery($sql, array($eid));
105 if ($result['pc_multiple'] == 0) {
109 return $result['pc_multiple'];