remove blank class
[openemr.git] / interface / therapy_groups / therapy_groups_views / groupDetailsParticipants.php
blob4ddf9b1cd97e45ce232d997f0854b877f5d3b900
1 <?php
2 /**
3 * interface/therapy_groups/therapy_groups_views/groupDetailsParticipants.php contains group participants details view .
5 * This is the therapy group's participants detail screen for the chosen group.
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 <?php $edit = acl_check("groups","gadd",false, 'write');?>
28 <?php $edit_encounter = acl_check("groups","glog",false, 'write');?>
29 <?php $view = acl_check("groups","gadd",false, 'view');?>
31 <?php require 'header.php'; ?>
32 <?php if($view || $edit) :?>
33 <main id="group-details">
34 <div class="container-group">
35 <span class="hidden title"><?php echo text($groupName);?></span>
36 <div class="row">
37 <div id="main-component" class="col-md-8 col-sm-12">
38 <div class="row">
39 <div class="col-md-8 col-sm-12">
40 <ul class="tabNav">
41 <li><a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupDetails&group_id=' . attr($groupId); ?>"><?php echo xlt('General data');?></a></li>
42 <li class="current"><a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupParticipants&group_id=' . attr($groupId); ?>"><?php echo xlt('Participants ');?></a></li>
43 </ul>
44 </div>
45 <div class="col-md-4 col-sm-4">
46 <?php if($edit) :?>
47 <?php if($edit_encounter):?>
48 <button onclick="newGroup()"><?php echo xlt('Add encounter'); ?></button>
49 <?php endif;?>
50 <?php if($readonly == ''): ?>
51 <button class="float-right" onclick="location.href='<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupParticipants&group_id=' . attr($groupId); ?>'"><?php echo xlt('Cancel');?></button>
52 <button id="saveForm" class="float-right"><?php echo xlt('Save');?></button>
53 <?php else: ?>
54 <button class="float-right" onclick="location.href='<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupParticipants&editParticipants=1&group_id=' . attr($groupId); ?>'"><?php echo xlt('Update');?></button>
55 <?php endif; ?>
56 <?php endif; ?>
57 </div>
58 </div>
59 <div class="row">
60 <div class="col-md-12">
61 <div id="component-border">
62 <div class="row">
63 <form id="add-participant-form" name="add-participant-form" class="<?php echo isset($addStatus) ? 'showAddForm' : '' ?>" action="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=addParticipant&group_id=' . attr($groupId)?>" method="post">
64 <input type="hidden" id="pid" name="pid" value="<?php echo !is_null($participant_data) ? attr($participant_data['pid']): ''?>">
65 <div class="col-md-12">
66 <div class="row">
67 <div class="col-md-offset-1 col-md-5">
68 <div class="row">
69 <div class="col-md-4">
70 <span class="bold"><?php echo xlt("Participant's name"); ?>:</span>
71 </div>
72 <div class="col-md-8">
73 <input type="text" id="participant_name" name="participant_name" class="full-width" value="<?php echo !is_null($participant_data) ? attr($participant_data['participant_name']): ''?>" readonly>
74 </div>
75 </div>
76 </div>
77 <div class="col-md-5">
78 <div class="row">
79 <div class="col-md-4">
80 <span class="bold"><?php echo xlt('Date of registration'); ?>:</span>
81 </div>
82 <div class="col-md-8">
83 <input type="text" id="group_patient_start" name="group_patient_start" class="full-width datepicker" value="<?php echo !is_null($participant_data) ? attr(oeFormatShortDate($participant_data['group_patient_start'])): oeFormatShortDate(date('Y-m-d'));?>">
84 </div>
85 </div>
86 </div>
87 </div>
88 <div class="row">
89 <div class="col-md-offset-1 col-md-2">
90 <span class="bold"><?php echo xlt('Comment'); ?>:</span>
91 </div>
92 <div class="col-md-8">
93 <input type="text" id="group_patient_comment" name="group_patient_comment" value="<?php echo !is_null($participant_data) ? attr($participant_data['group_patient_comment']): ''?>" class="full-width">
94 </div>
95 </div>
96 <div class="row">
97 <div class="col-md-offset-4 col-md-4 text-center">
98 <?php if($edit) :?>
99 <input type="submit" name="save_new" value="<?php echo xla('Adding a participant'); ?>">
100 <input id="cancelAddParticipant" type="button" value="<?php echo xla('Cancel'); ?>">
101 <?php endif;?>
102 </div>
103 </div>
104 <?php if(isset($message)): ?>
105 <div class="row">
106 <div class="col-md-offset-2 col-md-8">
107 <p class="<?php echo $addStatus == 'failed' ? 'groups-error-msg' : 'groups-success-msg' ?>"><?php echo text($message)?></p>
108 </div>
109 </div>
110 <?php endif; ?>
111 <div class="row">
112 <div class="col-md-12">
113 <hr/>
114 </div>
115 </div>
116 </div>
117 </form>
118 </div>
119 <div class="row">
120 <div class="col-md-12">
121 <form id="updateParticipants" method="post">
122 <input type="hidden" name="group_id" value="<?php echo attr($groupId); ?>" />
123 <?php if($edit) :?>
124 <button id="addParticipant"><?php echo xlt('Add'); ?></button>
125 <?php endif;?>
126 <table id="participants_table" class="dataTable display">
127 <thead>
128 <tr>
129 <th><?php echo xlt("Participant's name"); ?></th>
130 <th><?php echo xlt("Patient's number"); ?></th>
131 <th><?php echo xlt('Status in the group'); ?></th>
132 <th><?php echo xlt('Date of registration'); ?></th>
133 <th><?php echo xlt('Date of exit'); ?></th>
134 <th><?php echo xlt('Comment'); ?></th>
135 <?php if($readonly == ''): ?>
136 <th><?php echo xlt('Delete'); ?></th>
137 <?php endif; ?>
138 </tr>
139 </thead>
140 <tbody>
141 <?php foreach ($participants as $i => $participant) : ?>
142 <tr>
143 <td>
144 <input type="hidden" name="pid[]" value="<?php echo htmlspecialchars($participant['pid'],ENT_QUOTES); ?>" />
145 <span><?php echo text($participant['lname']) .', ' . text($participant['fname']); ?></span>
146 </td>
147 <td><span><?php echo text($participant['pid']); ?></span></td>
148 <td>
149 <select name="group_patient_status[]" <?php echo $readonly; ?>>
150 <?php foreach ($statuses as $key => $status): ?>
151 <option value="<?php echo attr($key);?>" <?php if($key == $participant['group_patient_status']) echo 'selected'; ?> > <?php echo text($status); ?> </option>
152 <?php endforeach; ?>
153 </select>
154 </td>
155 <td><input type="text" name="group_patient_start[]" id="start-date<?php echo $i+1?>" class="datepicker" value="<?php echo attr(oeFormatShortDate($participant['group_patient_start']));?>" <?php echo $readonly; ?>></td>
156 <td><input type="text" name="group_patient_end[]" id="end-date<?php echo $i+1?>" class="datepicker" value="<?php echo $participant['group_patient_end'] == '0000-00-00' ? '' : attr(oeFormatShortDate($participant['group_patient_end'])) ;?>" <?php echo $readonly; ?>></td>
157 <td><input type="text" name="group_patient_comment[]" class="full-width" value="<?php echo attr($participant['group_patient_comment']);?>" <?php echo $readonly; ?> /></td>
158 <?php if($readonly == ''): ?>
159 <td class="delete_btn">
160 <a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupParticipants&group_id='. attr($groupId) .'&deleteParticipant=1&pid=' . attr($participant['pid']); ?>"><span>X</span></a>
161 </td>
162 <?php endif; ?>
163 </tr>
164 <?php endforeach; ?>
165 </tbody>
166 </table>
167 </form>
168 </div>
169 </div>
170 </div>
171 </div>
172 </div>
173 </div>
174 <div id="appointment-component" class="col-md-4 col-sm-12">
175 <?php require 'appointmentComponent.php';?>
176 </div>
177 </div>
178 </div>
179 </main>
180 <script>
181 $(document).ready(function(){
182 $('.datepicker').datetimepicker({
183 <?php $datetimepicker_timepicker = false; ?>
184 <?php $datetimepicker_showseconds = false; ?>
185 <?php $datetimepicker_formatInput = true; ?>
186 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
187 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
190 var table = $('#participants_table').DataTable({
191 "columnDefs": [
192 { "width": "35%", "targets": 5 }
194 "pageLength":6,
195 "order": [[ 0, "asc" ],[ 2, "desc" ]],
196 "searching": false,
197 <?php // Bring in the translations ?>
198 <?php $translationsDatatablesOverride = array('lengthMenu'=>(xla('Display').' _MENU_ '.xla('records per page')),
199 'zeroRecords'=>(xla('Nothing found - sorry')),
200 'info'=>(xla('Showing page') .' _PAGE_ '. xla('of') . ' _PAGES_'),
201 'infoEmpty'=>(xla('No records available')),
202 'infoFiltered'=>('('.xla('filtered from').' _MAX_ '.xla('total records').')'),
203 'infoPostFix'=>(''),
204 'url'=>('')); ?>
205 <?php require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?>
207 var countRows =table.rows().count();
208 console.log(countRows);
210 // validation on submit -
211 // 1. start date not empty
212 // 2. end date not smaller than start date
213 $('#updateParticipants').on('submit', function(e){
215 for(var i = 1; i <= countRows; i++ ){
217 if($('#start-date'+i).val() == ''){
219 $('#start-date'+i).addClass('error-border').after('<p class="error-message" id="error-start-date' + i + '" ><?php echo xlt('is not valid');?></p>');
220 $('#start-date'+i).on('focus', function(){
221 $(this).removeClass('error-border');
222 $('#error-start-date' + i).hide();
224 return e.preventDefault();
226 if(typeof $('#end-date'+i).val() == 'string'){
227 if(moment($('#end-date'+i).val()).isBefore($('#start-date'+i).val())){
228 $('#end-date'+i).addClass('error-border').after('<p class="error-message" id="error-end-date' + i + '" ><?php echo xlt('End date must be equal or bigger than start date');?></p>');
229 $('#end-date'+i).on('focus', function(){
230 $(this).removeClass('error-border');
231 $('#error-end-date' + i).hide();
233 return e.preventDefault();
239 $('#saveForm').on('click', function () {
240 top.restoreSession();
241 $('#updateParticipants').append('<input type="hidden" name="save">').submit();
244 $('#addParticipant').on('click', function(e){
245 e.preventDefault();
246 if(!$('#add-participant-form').hasClass('showAddForm')){
247 $('#add-participant-form').addClass('showAddForm');
248 } else {
249 $('#add-participant-form').removeClass('showAddForm');
252 $('#cancelAddParticipant').on('click', function(e){
253 e.preventDefault();
254 $('#add-participant-form').removeClass('showAddForm');
255 $('#participant_name').val('');
256 $('#group_patient_comment').val('');
257 $('#group_patient_start').val('<?php echo date('Y-m-d');?>');
260 $('#participant_name').on('click', function(){
261 top.restoreSession();
262 var url = '<?php echo $GLOBALS['webroot']?>/interface/main/calendar/find_patient_popup.php';
263 dlgopen(url, '_blank', 500, 400);
268 function setpatient(pid, lname, fname, dob){
270 $('#pid').val(pid);
271 $('#participant_name').val(fname + " " + lname);
274 function refreshme() {
275 top.restoreSession();
276 location.href = "<?php echo $GLOBALS['webroot'] . '/interface/therapy_groups/index.php?method=groupParticipants&group_id='. attr($groupId) ?>";
279 function newGroup(){
280 <?php if ($GLOBALS['new_tabs_layout']) : ?>
281 top.restoreSession();
282 parent.left_nav.loadFrame('gcv4','enc','forms/newGroupEncounter/new.php?autoloaded=1&calenc=')
283 <?php else : ?>
284 top.restoreSession();
285 top.frames['RBot'].location = '<?php echo $GLOBALS['web_root'] . "/interface/" ?>' + 'forms/newGroupEncounter/new.php?autoloaded=1&calenc=';
286 <?php endif; ?>
288 // parent.left_nav.setTherapyGroup(<?php echo attr($group_id);?>,'<?php echo 'test'?>');
289 /* show the encounters menu in the title menu (code like interface/forms/newGroupEncounter/save.php) */
290 <?php
291 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_groups_encounter AS fe ".
292 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.group_id = ? order by fe.date desc", array($groupId));
295 EncounterDateArray=new Array;
296 CalendarCategoryArray=new Array;
297 EncounterIdArray=new Array;
298 Count=0;
299 <?php
300 if(sqlNumRows($result4)>0)
301 while($rowresult4 = sqlFetchArray($result4))
304 EncounterIdArray[Count]='<?php echo attr($rowresult4['encounter']); ?>';
305 EncounterDateArray[Count]='<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?>';
306 CalendarCategoryArray[Count]='<?php echo attr(xl_appt_category($rowresult4['pc_catname'])); ?>';
307 Count++;
308 <?php
311 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
313 </script>
314 <?php $use_validate_js = 1;?>
315 <?php validateUsingPageRules($_SERVER['PHP_SELF'] . '?method=groupParticipants');?>
316 <script src="<?php echo $GLOBALS['webroot']?>/library/dialog.js"></script>
317 <?php require 'footer.php'; ?>
319 <?php else :?>
321 <div class="container">
323 <div class="row alert alert-info">
324 <h1 class="col-md-12"><i class="col-md-3 glyphicon glyphicon-alert"></i><span class="col-md-6"><?php echo xlt("access not allowed");?></span></h1>
325 </div>
326 </div>
330 <?php endif;?>