Added stripe package (#1085)
[openemr.git] / interface / therapy_groups / therapy_groups_models / users_model.php
bloba881dcfb0b21bea158f1444b58355fce9bbad299
1 <?php
2 /**
3 * interface/therapy_groups/therapy_groups_models/users_model.php contains the model for users.
5 * This model fetches the users data to be used for the therapy group from the DB.
7 * Copyright (C) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
8 * Copyright (C) 2016 Amiel Elboim <amielel@matrix.co.il>
10 * LICENSE: This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 3
13 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://opensource.org/licenses/gpl-license.php>;.
21 * @package OpenEMR
22 * @author Shachar Zilbershlag <shaharzi@matrix.co.il>
23 * @author Amiel Elboim <amielel@matrix.co.il>
24 * @link http://www.open-emr.org
27 class Users
30 const TABLE = 'users';
31 const EVENTS_TABLE = 'openemr_postcalendar_events';
33 /**
34 * Get all users' ids and full names from users table.
35 * @return array
37 public function getAllUsers()
40 $sql = 'SELECT id, fname, lname FROM ' . self::TABLE . ' WHERE active = 1';
42 $users = array();
43 $result = sqlStatement($sql);
44 while ($u = sqlFetchArray($result)) {
45 $users[] = $u;
48 return $users;
51 /**
52 * Get user name by user id from users table.
53 * @param $uid
54 * @return string
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;
66 /**
67 * Get all providers of event.
68 * @param $eid
69 * @return array
71 public function getProvidersOfEvent($eid)
74 $multiple = $this->checkIfMultiple($eid);
75 if ($multiple > 0) {
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'];
82 return $providers;
83 } else {
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'];
90 return $providers;
95 /**
96 * Checks if event has multiple providers and if so returns the key of 'multiple providers'.
97 * @param $eid
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) {
106 return false;
109 return $result['pc_multiple'];