Highway to PSR2
[openemr.git] / interface / super / rules / controllers / alerts / controller.php
blob4129b7ddfb3f4cd45eb6733cab82faecf71e952c
1 <?php
2 // Copyright (C) 2011 Ensoftek, Inc
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.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // A copy of the GNU General Public License is included along with this program:
15 // openemr/interface/login/GnuGPL.html
16 // For more information write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 class Controller_alerts extends BaseController
22 function _action_listactmgr()
24 $c = new CdrAlertManager();
25 // Instantiating object if does not exist to avoid
26 // "creating default object from empty value" warning.
27 if (!isset($this->viewBean)) {
28 $this->viewBean = new stdClass();
31 $this->viewBean->rules = $c->populate();
32 $this->set_view("list_actmgr.php");
36 function _action_submitactmgr()
40 $ids = $_POST["id"];
41 $actives = $_POST["active"];
42 $passives = $_POST["passive"];
43 $reminders = $_POST["reminder"];
44 $access_controls = $_POST["access_control"];
47 // The array of check-boxes we get from the POST are only those of the checked ones with value 'on'.
48 // So, we have to manually create the entitre arrays with right values.
49 $actives_final = array();
50 $passives_final = array();
51 $reminders_final = array();
54 $numrows = count($ids);
55 for ($i = 0; $i < $numrows; ++$i) {
56 if ($actives[$i] == "on") {
57 $actives_final[] = "1";
58 } else {
59 $actives_final[] = "0";
63 if ($passives[$i] == "on") {
64 $passives_final[] = "1";
65 } else {
66 $passives_final[] = "0";
70 if ($reminders[$i] == "on") {
71 $reminders_final[] = "1";
72 } else {
73 $reminders_final[] = "0";
78 // Reflect the changes to the database.
79 $c = new CdrAlertManager();
80 $c->update($ids, $actives_final, $passives_final, $reminders_final, $access_controls);
81 // Instantiating object if does not exist to avoid
82 // "creating default object from empty value" warning.
83 if (!isset($this->viewBean)) {
84 $this->viewBean = new stdClass();
87 $this->forward("listactmgr");