another minor fix to groups code
[openemr.git] / interface / therapy_groups / therapy_groups_views / groupDetailsGeneralData.php
blobe30b93ddfe20d0401915559159d4fa50511a74d8
1 <?php
2 /**
3 * interface/therapy_groups/therapy_groups_views/groupDetailsGeneralData.php contains group details view .
5 * This is the therapy group 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 require 'header.php'; ?>
28 <main id="group-details">
29 <div class="container-group">
30 <span class="hidden title"><?php echo text($groupData['group_name']);?></span>
31 <div class="row">
32 <div id="main-component" class="col-md-8 col-sm-12">
33 <div class="row">
34 <div class="col-md-8 col-sm-12">
35 <ul class="tabNav">
36 <li class="current"><a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupDetails&group_id=' . attr($groupData['group_id']); ?>"><?php echo xlt('General data');?></a></li>
37 <li><a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupParticipants&group_id=' . attr($groupData['group_id']); ?>"><?php echo xlt('Participants ');?></a></li>
38 </ul>
39 </div>
40 <div class="col-md-4 col-sm-4">
41 <button onclick="newGroup()"><?php echo xlt('Add encounter'); ?></button>
43 <?php if($readonly == ''): ?>
44 <button class="float-right" onclick="location.href='<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupDetails&group_id=' . attr($groupData['group_id']); ?>'"><?php echo xlt('Cancel');?></button>
45 <button id="saveUpdates" class="float-right"><?php echo xlt('Save');?></button>
46 <?php else: ?>
47 <button class="float-right" onclick="location.href='<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupDetails&editGroup=1&group_id=' . attr($groupData['group_id']); ?>'"><?php echo xlt('Update');?></button>
48 <?php endif; ?>
49 </div>
50 </div>
51 <div class="row">
52 <div class="col-md-12">
53 <div id="component-border">
54 <form method="post" id='editGroup' name="editGroup">
55 <input type="hidden" name="group_id" value="<?php echo isset($groupData['group_id']) ? attr($groupData['group_id']) : '';?>">
56 <div class="row group-row">
57 <div class="col-md-6 col-sm-7">
58 <div class="row">
59 <div class="col-md-4 col-sm-5">
60 <span class="bold"><?php echo xlt("Group's name") ?>:</span>
61 </div>
62 <div class="col-md-8 col-sm-7">
63 <input type="text" name="group_name" class="full-width" value="<?php echo attr($groupData['group_name']);?>" <?php echo $readonly; ?>>
64 </div>
65 </div>
66 </div>
67 <div class="col-md-2 col-sm-3">
68 <span class="bold"><?php echo xlt('Group number') ?>:</span>
69 <span ><?php echo text($groupData['group_id'])?></span>
70 </div>
71 <div class="col-md-4">
72 <div class="row">
73 <div class="col-md-6 col-sm-6 attach-input">
74 <span class="bold"><?php echo xlt('Status'); ?>:</span>
75 </div>
76 <div class="col-md-6 col-sm-6">
77 <select name="group_status" class="full-width" value="<?php echo attr($groupData['group_status']);?>" <?php echo $readonly; ?>>
78 <?php foreach($statuses as $key => $status): ?>
79 <option value="<?php echo attr($key);?>" <?php echo $key == $groupData['group_status'] ? 'selected' : ''; ?>><?php echo xlt($status); ?></option>
80 <?php endforeach; ?>
81 </select>
82 </div>
83 </div>
84 </div>
85 </div>
86 <div class="row group-row">
87 <div class="col-md-6">
88 <span class="bold"><?php echo xlt('Type of group'); ?>:</span>
89 <label class="radio-inline radio-pos">
90 <input type="radio" value="1" name="group_type" <?php echo is_null($groupData['group_type']) || $groupData['group_type'] == '1' ? 'checked' : '';?> <?php echo $readonly; ?>><?php echo xlt('Closed'); ?>
91 </label>
92 <label class="radio-inline radio-pos">
93 <input type="radio" value="2" name="group_type" <?php echo $groupData['group_type'] == '2' ? 'checked' : '';?> <?php echo $readonly; ?>><?php echo xlt('Open'); ?>
94 </label>
95 <label class="radio-inline radio-pos">
96 <input type="radio" value="3" name="group_type" <?php echo $groupData['group_type'] == '3' ? 'checked' : '';?> <?php echo $readonly; ?>><?php echo xlt('Train'); ?>
97 </label>
98 </div>
99 <div class="col-md-6">
100 <span class="bold"><?php echo xlt('Obligatory participation'); ?>:</span>
101 <label class="radio-inline radio-pos">
102 <input type="radio" value="1" name="group_participation" <?php echo is_null($groupData['group_participation']) || $groupData['group_participation'] == '1' ? 'checked' : '';?> <?php echo $readonly; ?>><?php echo xlt('Mandatory'); ?>
103 </label>
104 <label class="radio-inline radio-pos">
105 <input type="radio" value="2" name="group_participation" <?php echo $groupData['group_participation'] == '2' ? 'checked' : '';?> <?php echo $readonly; ?>><?php echo xlt('Optional'); ?>
106 </label>
107 </div>
108 </div>
109 <div class="row group-row">
110 <div class="col-md-6 col-sm-6">
111 <div class="row">
112 <div class="col-md-5 col-sm-6">
113 <span class="bold"><?php echo xlt('Starting date'); ?>:</span>
114 </div>
115 <div class="col-md-offset1 col-md-6 col-sm-6">
116 <input type="text" name="group_start_date" class="full-width datepicker" value="<?php echo attr($groupData['group_start_date']);?>" <?php echo $readonly; ?>>
117 </div>
118 </div>
119 </div>
120 <div class="col-md-6 col-sm-6">
121 <div class="row">
122 <div class="col-md-5 col-sm-6">
123 <span class="bold"><?php echo xlt('Ending date'); ?>:</span>
124 </div>
125 <div class="col-md-6 col-sm-6">
126 <input type="text" name="group_end_date" class="full-width datepicker" value="<?php echo $groupData['group_end_date'] == '0000-00-00' ? '' : attr($groupData['group_end_date']) ;?>" <?php echo $readonly; ?>>
127 </div>
128 </div>
129 </div>
130 </div>
131 <div class="row group-row">
132 <div class="col-md-6">
133 <div class="row">
134 <div class="col-md-4 col-sm-5">
135 <span class="bold"><?php echo xlt('Main counselors'); ?>:</span>
136 </div>
137 <div class="col-md-8 col-sm-7">
138 <select name="counselors[]" multiple class="full-width" <?php echo $readonly; ?>>
139 <?php foreach($users as $user): ?>
140 <option value="<?php echo attr($user['id']);?>" <?php echo !is_null($groupData['counselors']) && in_array($user['id'], $groupData['counselors']) ? 'selected' : '';?>><?php echo text($user['fname'] . ' ' . $user['lname']);?></option>
141 <?php endforeach; ?>
142 </select>
143 </div>
144 </div>
145 </div>
146 <div class="col-md-6">
147 <div class="row">
148 <div class="col-md-3 col-sm-5">
149 <span class="bold"><?php echo xlt('Notes'); ?>:</span>
150 </div>
151 <div class="col-md-9 col-sm-7">
152 <textarea name="group_notes" class="full-width" style="height: 70px" <?php echo $readonly; ?>><?php echo text($groupData['group_notes']);?></textarea>
153 </div>
154 </div>
155 </div>
156 </div>
157 <div class="row group-row">
158 <div class="col-md-8">
159 <div class="row">
160 <div class="col-md-4 col-sm-5">
161 <span class="bold"><?php echo xlt('Guest counselors'); ?>:</span>
162 </div>
163 <div class="col-md-8 col-sm-7">
164 <input type="text" name="group_guest_counselors" class="full-width" value="<?php echo attr($groupData['group_guest_counselors']);?>" <?php echo $readonly; ?>>
165 </div>
166 </div>
167 </div>
168 </div>
169 <div class="row group-row">
170 <div class="col-md-9 col-sm 12">
171 <?php if($savingStatus == 'exist'): ?>
172 <div id="exist-group"><h4 class="group-error-msg"><?php echo text($message) ?></h4><button id="cancel-save"><?php echo xlt('cancel') ?></button><button type="submit" value="save_anyway" name="save"><?php echo xlt('Creating anyway') ?></button></div>
173 <?php endif ?>
174 <?php if($savingStatus == 'success'): ?>
175 <h4 class="group-success-msg"><?php echo text($message) ?></h4>
176 <?php endif ?>
177 <?php if($savingStatus == 'failed'): ?>
178 <h4 class="group-serror-msg"><?php echo text($message) ?></h4>
179 <?php endif ?>
180 </div>
181 </div>
182 </form>
183 </div>
184 </div>
185 </div>
186 </div>
187 <div id="appointment-component" class="col-md-2 col-sm-12">
188 <?php require 'appointmentComponent.php';?>
189 </div>
190 </div>
191 </div>
192 </main>
193 <script>
194 $(document).ready(function(){
195 $('.datepicker').datetimepicker({
196 <?php $datetimepicker_timepicker = false; ?>
197 <?php $datetimepicker_formatInput = false; ?>
198 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
199 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
202 $('#cancel-save').on('click', function(e){
203 e.preventDefault();
204 $('#exist-group').hide();
207 $('#saveUpdates').on('click', function () {
208 $('#editGroup').append('<input type="hidden" name="save">').submit();
211 function refreshme() {
212 top.restoreSession();
213 location.reload();
216 function newGroup(){
217 <?php if ($GLOBALS['new_tabs_layout']) : ?>
218 top.restoreSession();
219 parent.left_nav.loadFrame('gcv4','enc','forms/newGroupEncounter/new.php?autoloaded=1&calenc=')
220 <?php else : ?>
221 top.restoreSession();
222 top.frames['RBot'].location = '<?php echo $GLOBALS['web_root'] . "/interface/" ?>' + 'forms/newGroupEncounter/new.php?autoloaded=1&calenc=';
223 <?php endif; ?>
226 parent.left_nav.setTherapyGroup(<?php echo attr($groupData['group_id'])?>,'<?php echo attr($groupData['group_name'])?>');
227 <?php if (!$GLOBALS['new_tabs_layout']) : ?>
228 top.restoreSession();
229 parent.left_nav.loadFrame('enc2', 'RBot', '/patient_file/history/encounters.php');
230 $(parent.Title.document.getElementById('clear_active')).hide();
231 <?php endif;?>
232 /* show the encounters menu in the title menu (code like interface/forms/newGroupEncounter/save.php) */
233 <?php
234 $result4 = sqlStatement("SELECT fe.encounter,fe.date,openemr_postcalendar_categories.pc_catname FROM form_groups_encounter AS fe ".
235 " left join openemr_postcalendar_categories on fe.pc_catid=openemr_postcalendar_categories.pc_catid WHERE fe.group_id = ? order by fe.date desc", array( $groupData['group_id']));
238 EncounterDateArray=new Array;
239 CalendarCategoryArray=new Array;
240 EncounterIdArray=new Array;
241 Count=0;
242 <?php
243 if(sqlNumRows($result4)>0)
244 while($rowresult4 = sqlFetchArray($result4))
247 EncounterIdArray[Count]='<?php echo attr($rowresult4['encounter']); ?>';
248 EncounterDateArray[Count]='<?php echo attr(oeFormatShortDate(date("Y-m-d", strtotime($rowresult4['date'])))); ?>';
249 CalendarCategoryArray[Count]='<?php echo attr(xl_appt_category($rowresult4['pc_catname'])); ?>';
250 Count++;
251 <?php
254 top.window.parent.left_nav.setPatientEncounter(EncounterIdArray,EncounterDateArray,CalendarCategoryArray);
255 </script>
256 <?php $use_validate_js = 1;?>
257 <?php validateUsingPageRules($_SERVER['PHP_SELF'] . '?method=groupDetails');?>
258 <?php require 'footer.php'; ?>