more bug fixes (#1917)
[openemr.git] / interface / main / dated_reminders / dated_reminders_log.php
blob72515ab2db04473480fd102f4dc3d8fc748135b1
1 <?php
2 /**
3 * Used for adding dated reminders.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Craig Bezuidenhout <http://www.tajemo.co.za/>
8 * @author Brady Miller <brady.g.miller@gmail.com>
9 * @copyright Copyright (c) 2012 tajemo.co.za <http://www.tajemo.co.za/>
10 * @copyright Copyright (c) 2017-2018 Brady Miller <brady.g.miller@gmail.com>
14 require_once("../../globals.php");
15 require_once("$srcdir/acl.inc");
16 require_once("$srcdir/dated_reminder_functions.php");
18 use OpenEMR\Core\Header;
20 $isAdmin =acl_check('admin', 'users');
22 <?php
24 ------------------- HANDLE POST ---------------------
26 if ($_GET) {
27 if (!verifyCsrfToken($_GET["csrf_token_form"])) {
28 die(xlt('Authentication Error'));
31 if (!$isAdmin) {
32 if (empty($_GET['sentBy']) and empty($_GET['sentTo'])) {
33 $_GET['sentTo'] = array(intval($_SESSION['authId']));
37 echo ' <div class="col-xs-12">
38 <h4>'.xlt('Click and drag bottom right corner to resize this display').'</h4>
39 <table class="table table-bordered" id="logTable">
40 <thead>
41 <tr>
42 <th>'.xlt('ID').'</th>
43 <th>'.xlt('Sent Date').'</th>
44 <th>'.xlt('From').'</th>
45 <th>'.xlt('To').'</th>
46 <th>'.xlt('Patient').'</th>
47 <th>'.xlt('Message').'</th>
48 <th>'.xlt('Due Date').'</th>
49 <th>'.xlt('Processed Date').'</th>
50 <th>'.xlt('Processed By').'</th>
51 </tr>
52 </thead>
53 <tbody>';
54 $remindersArray = array();
55 $TempRemindersArray = logRemindersArray();
56 foreach ($TempRemindersArray as $RA) {
57 $remindersArray[$RA['messageID']]['messageID'] = $RA['messageID'];
58 $remindersArray[$RA['messageID']]['ToName'] = ($remindersArray[$RA['messageID']]['ToName'] ? $remindersArray[$RA['messageID']]['ToName'].', '.$RA['ToName'] : $RA['ToName']);
59 $remindersArray[$RA['messageID']]['PatientName'] = $RA['PatientName'];
60 $remindersArray[$RA['messageID']]['message'] = $RA['message'];
61 $remindersArray[$RA['messageID']]['dDate'] = $RA['dDate'];
62 $remindersArray[$RA['messageID']]['sDate'] = $RA['sDate'];
63 $remindersArray[$RA['messageID']]['pDate'] = $RA['pDate'];
64 $remindersArray[$RA['messageID']]['processedByName'] = $RA['processedByName'];
65 $remindersArray[$RA['messageID']]['fromName'] = $RA['fromName'];
68 foreach ($remindersArray as $RA) {
69 echo '<tr class="heading">
70 <td>'.text($RA['messageID']).'</td>
71 <td>'.text($RA['sDate']).'</td>
72 <td>'.text($RA['fromName']).'</td>
73 <td>'.text($RA['ToName']).'</td>
74 <td>'.text($RA['PatientName']).'</td>
75 <td>'.text($RA['message']).'</td>
76 <td>'.text($RA['dDate']).'</td>
77 <td>'.text($RA['pDate']).'</td>
78 <td>'.text($RA['processedByName']).'</td>
79 </tr>';
82 echo '</tbody></table></div>';
84 die;
87 <html>
88 <head>
89 <?php Header::setupHeader(['datetime-picker']); ?>
90 <style>
91 @media only screen and (max-width: 680px) {
92 [class*="col-"] {
93 width: 100%;
94 text-align: left!Important;
97 </style>
98 <script language="JavaScript">
99 $(document).ready(function (){
100 $("#submitForm").click(function(){
101 // top.restoreSession(); --> can't use this as it negates this ajax refresh
102 $.get("dated_reminders_log.php?"+$("#logForm").serialize(),
103 function(data) {
104 $("#resultsDiv").html(data);
105 <?php
106 if (!$isAdmin) {
107 echo '$("select option").removeAttr("selected");';
110 return false;
113 return false;
116 $('.datepicker').datetimepicker({
117 <?php $datetimepicker_timepicker = false; ?>
118 <?php $datetimepicker_showseconds = false; ?>
119 <?php $datetimepicker_formatInput = false; ?>
120 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
121 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
124 </script>
125 </head>
126 <body class="body_top">
127 <div class="container">
128 <!-- Required for the popup date selectors -->
129 <div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
130 <?php
131 $allUsers = array();
132 $uSQL = sqlStatement('SELECT id, fname, mname, lname FROM `users` WHERE `active` = 1 AND `facility_id` > 0 AND id != ?', array(intval($_SESSION['authId'])));
133 for ($i=0; $uRow=sqlFetchArray($uSQL);
134 $i++) {
135 $allUsers[] = $uRow;
138 <div class="row">
139 <div class="col-xs-12">
140 <div class="page-header">
141 <h2><?php echo xlt('Dated Message Log');?> &nbsp;<i id="show_hide" class="fa fa-eye-slash fa-2x small" title="<?php echo xla('Click to Hide Filters'); ?>"></i></h2>
142 </div>
143 </div>
144 </div>
145 <div class="row hideaway">
146 <div class="col-xs-12">
147 <form method="get" id="logForm" onsubmit="return top.restoreSession()">
148 <input type="hidden" name="csrf_token_form" value="<?php echo attr(collectCsrfToken()); ?>" />
150 <fieldset>
151 <legend><?php echo xlt('Filters') ?></legend>
152 <div class="col-xs-12">
153 <h5><?php echo xlt('Date The Message Was Sent');?></h5>
154 <div class="col-xs-6">
155 <label class="control-label" for="sd"><?php echo xlt('Start Date') ?>:</label>
156 <input id="sd" type="text" class='form-control datepicker' name="sd" value="" title='<?php echo xla('yyyy-mm-dd'); ?>'>
157 </div>
158 <div class="col-xs-6">
159 <label class="control-label" for="ed"><?php echo xlt('End Date') ?>:</label>
160 <input id="ed" type="text" class='form-control datepicker' name="ed" value="" title='<?php echo xla('yyyy-mm-dd'); ?>'>
161 </div>
162 </div>
163 <div class="col-xs-12">
164 <div class="col-xs-6">
165 <label class="control-label" for="sentBy"><?php echo xlt('Sent By, Leave Blank For All');?>:</label>
166 <select class="form-control" id="sentBy" name="sentBy[]" multiple="multiple">
167 <option value="<?php echo attr(intval($_SESSION['authId'])); ?>"><?php echo xlt('Myself') ?></option>
168 <?php
169 if ($isAdmin) {
170 foreach ($allUsers as $user) {
171 echo '<option value="'.attr($user['id']).'">'.text($user['fname'].' '.$user['mname'].' '.$user['lname']).'</option>';
175 </select>
176 </div>
177 <div class="col-xs-6">
178 <label class="control-label" for="sentBy"><?php echo xlt('Sent To, Leave Blank For All') ?>:</label>
179 <select class="form-control" id="sentTo" name="sentTo[]" multiple="multiple">
180 <option value="<?php echo attr(intval($_SESSION['authId'])); ?>"><?php echo xlt('Myself') ?></option>
181 <?php
182 if ($isAdmin) {
183 foreach ($allUsers as $user) {
184 echo '<option value="'.attr($user['id']).'">'.text($user['fname'].' '.$user['mname'].' '.$user['lname']).'</option>';
188 </select>
189 </div>
190 </div>
191 <div class="col-xs-12">
192 <div class="col-xs-12 form-group">
193 <div class="checkbox">
194 <label>
195 <input type="checkbox" name="processed" id="processed"><?php echo xlt('Processed') ?>
196 </label>
197 <label>
198 <input type="checkbox" name="pending" id="pending"><?php echo xlt('Pending') ?>
199 </label>
200 </div>
201 </div>
202 </div>
203 </fieldset>
204 <div class="form-group">
205 <div class="col-sm-12 position-override">
206 <div class="btn-group oe-opt-btn-group-pinch form-group" role="group">
207 <button type="button" value="Refresh" id="submitForm" class="btn btn-default btn-refresh" ><?php echo xlt('Refresh') ?></button>
208 </div>
209 </div>
210 </div>
211 </form>
212 </div>
213 </div>
214 <div class="row">
215 <div class="col-xs-12">
216 <div id="resultsDiv"></div>
217 </div>
218 </div>
219 </div><!--end of container div-->
220 <script>
221 $('#show_hide').click(function() {
222 var elementTitle = $('#show_hide').prop('title');
223 var hideTitle = '<?php echo xla('Click to Hide Filters'); ?>';
224 var showTitle = '<?php echo xla('Click to Show Filters'); ?>';
225 $('.hideaway').toggle('1000');
226 $(this).toggleClass('fa-eye-slash fa-eye');
227 if (elementTitle == hideTitle) {
228 elementTitle = showTitle;
229 } else if (elementTitle == showTitle) {
230 elementTitle = hideTitle;
232 $('#show_hide').prop('title', elementTitle);
234 </script>
235 </body>
236 </html>