incorporated centralized translations into DataTable js (#574)
[openemr.git] / interface / therapy_groups / therapy_groups_views / listGroups.php
blobabd988f4742b031b8e724546c2a54e38dde10491
1 <?php
2 /**
3 * interface/therapy_groups/therapy_groups_views/listGroups.php contains the group list view .
5 * In this view all therapy groups are listed with their details and links to their details screen.
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 <span class="hidden title"><?php echo xlt('Therapy Group Finder');?></span>
29 <div id="therapy_groups_list_container" class="container">
31 <!--------- ERRORS ----------->
32 <?php if($deletion_try == 1 && $deletion_response['success'] == 0) :?>
33 <div class="row">
34 <div class="col-md-6 col-md-offset-3">
35 <div class="alert alert-danger text-center">
36 <p class="failed_message"><?php echo xlt($deletion_response['message']);?></p>
37 </div>
38 </div>
39 </div>
40 <?php endif ?>
42 <!---------- FILTERS SECTION ------------->
43 <button id="clear_filters" class="btn"><?php echo xlt("Clear Filters")?></button>
44 </br></br></br>
45 <div id="filters">
46 <div class="row">
47 <div class=" form-group col-md-2">
48 <label class="" for="group_name_filter"><?php echo xlt('Group Name');?>:</label>
49 <input type="text" class="form-control" id="group_name_filter" placeholder="" >
50 </div>
51 <div class=" form-group col-md-2">
52 <label class="" for="group_id_filter"><?php echo xlt('Group Id');?>:</label>
53 <input type="number" class="form-control" id="group_id_filter" placeholder="" >
54 </div>
55 <div class=" form-group col-md-2">
56 <label class="" for="group_type_filter"><?php echo xlt('Group Type');?>:</label>
57 <select type="text" class="form-control" id="group_type_filter" placeholder="" >
58 <option value=""><?php echo xlt('choose');?></option>
59 <?php foreach ($group_types as $type):?>
60 <option value="<?php echo attr($type);?>"><?php echo text($type) ;?></option>
61 <?php endforeach; ?>
62 </select>
63 </div>
64 <div class=" form-group col-md-2">
65 <label class="" for="group_status_filter"><?php echo xlt('Status');?>:</label>
66 <select type="text" class="form-control" id="group_status_filter" placeholder="" >
67 <option value="<?php echo attr($statuses[10]); ?>"><?php echo xlt($statuses[10]);?></option>
68 <?php foreach ($statuses as $status):?>
69 <?php if($status != $statuses[10]): ?>
70 <option value="<?php echo attr($status);?>"><?php echo xlt($status) ;?></option>
71 <?php endif; ?>
72 <?php endforeach; ?>
73 <option value="all"><?php echo xlt("all");?></option>
74 </select>
75 </div>
76 <div class=" form-group col-md-2">
77 <label class="" for="counselors_filter"><?php echo xlt('Main Counselors');?>:</label>
78 <select type="text" class="form-control" id="counselors_filter" placeholder="" >
79 <option value=""><?php echo xlt('choose');?></option>
80 <?php foreach ($counselors as $counselor):?>
81 <option value="<?php echo attr($counselor);?>"><?php echo text($counselor) ;?></option>
82 <?php endforeach; ?>
83 </select>
84 </div>
85 </div>
86 <div class="row">
87 <div class=" form-group col-md-2">
88 <label class="" for="group_from_start_date_filter"><?php echo xlt('Starting Date From');?>:</label>
89 <input type="text" class="form-control datepicker" id="group_from_start_date_filter" placeholder="" >
90 </div>
91 <div class=" form-group col-md-2">
92 <label class="" for="group_to_start_date_filter"><?php echo xlt('Starting Date To');?>:</label>
93 <input type="text" class="form-control datepicker" id="group_to_start_date_filter" placeholder="" >
94 </div>
95 <div class=" form-group col-md-2">
96 <label class="" for="group_from_end_date_filter"><?php echo xlt('End Date From');?>:</label>
97 <input type="text" class="form-control datepicker" id="group_from_end_date_filter" placeholder="" >
98 </div>
99 <div class=" form-group col-md-2">
100 <label class="" for="group_to_end_date_filter"><?php echo xlt('End Date To');?>:</label>
101 <input type="text" class="form-control datepicker" id="group_to_end_date_filter" placeholder="" >
102 </div>
104 </div>
105 </div>
106 <!---------- END OF FILTERS SECTION ------------->
108 </br></br>
110 <!---------- TABLE SECTION -------------->
111 <div class="row">
112 <table id="therapy_groups_list" class="dataTable display">
113 <thead>
114 <tr>
115 <th><?php echo xlt('Group Name'); ?></th>
116 <th><?php echo xlt('Group Id'); ?></th>
117 <th><?php echo xlt('Group Type'); ?></th>
118 <th><?php echo xlt('Status'); ?></th>
119 <th><?php echo xlt('Start Date'); ?></th>
120 <th><?php echo xlt('End Date'); ?></th>
121 <th><?php echo xlt('Main Counselors'); ?></th>
122 <th><?php echo xlt('Comment'); ?></th>
123 <th><?php echo xlt('Delete'); ?></th>
124 </tr>
125 </thead>
126 <tbody>
127 <?php foreach ($therapyGroups as $group) : ?>
128 <tr>
129 <td><a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=groupDetails&group_id=' . attr($group['group_id']); ?>"><?php echo text($group['group_name']);?></a></td>
130 <td><?php echo text($group['group_id']);?></td>
131 <td><?php echo xlt($group_types[$group['group_type']]);?></td>
132 <td><?php echo xlt($statuses[$group['group_status']]);?></td>
133 <td><?php echo text(oeFormatShortDate($group['group_start_date']));?></td>
134 <td><?php echo ($group['group_end_date'] == '0000-00-00' OR $group['group_end_date'] == '00-00-0000' OR empty($group['group_end_date'])) ? '' : text(oeFormatShortDate($group['group_end_date'])); ?></td>
135 <td>
136 <?php foreach ($group['counselors'] as $counselor){
137 echo text($counselor) . " </br> ";
138 } ;?>
139 </td>
140 <td><?php echo text($group['group_notes']);?></td>
141 <td class="delete_btn">
142 <?php
143 //Enable deletion only for groups that weren't yet deleted.
144 if($group['group_status'] == 10): ?>
145 <a href="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=listGroups&deleteGroup=1&group_id=' . attr($group['group_id']); ?>"><button>X</button></a></td>
146 <?php endif; ?>
148 </td>
149 </tr>
150 <?php endforeach; ?>
151 </tbody>
152 </table>
153 </div>
154 <!---------- END OF TABLE SECTION -------------->
156 </div>
158 <script>
161 /* ========= Initialise Data Table & Filters ========= */
162 $(document).ready(function() {
164 // var lang = '<?php //echo $lang ?>//';//get language support for filters
166 /* Initialise Date Picker */
167 $('.datepicker').datetimepicker({
168 <?php $datetimepicker_timepicker = false; ?>
169 <?php $datetimepicker_showseconds = false; ?>
170 <?php $datetimepicker_formatInput = true; ?>
171 <?php require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?>
172 <?php // can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
175 /* Initialise Datatable */
176 var table = $('#therapy_groups_list').DataTable({
177 initComplete: function () {
178 $('#therapy_groups_list_filter').hide(); //hide searchbar
180 <?php // Bring in the translations ?>
181 <?php $translationsDatatablesOverride = array('lengthMenu'=>(xla('Display').' _MENU_ '.xla('records per page')),
182 'zeroRecords'=>(xla('Nothing found - sorry')),
183 'info'=>(xla('Showing page') .' _PAGE_ '. xla('of') . ' _PAGES_'),
184 'infoEmpty'=>(xla('No records available')),
185 'infoFiltered'=>('('.xla('filtered from').' _MAX_ '.xla('total records').')'),
186 'infoPostFix'=>(''),
187 'url'=>('')); ?>
188 <?php require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?>
191 /* Order by Start Date column (descending) */
192 table.order( [ 4, 'desc' ] ).draw();
194 /* Hide/Show filters */
195 $("#show_filters").click(function () {
196 $('#filters').show();
197 $("#hide_filters").show();
198 $("#show_filters").hide();
201 $("#hide_filters").click(function () {
202 $('#filters').hide();
203 $("#hide_filters").hide();
204 $("#show_filters").show();
207 /* ------------ Toggle filter functions on keyup/change ----------- */
210 * Note: where there is an explicit extension made for the filter, just table.draw() was used.
211 * Otherwise 'table.columns( ).search( this.value ).draw();' was used.
215 /* ---- Datetimepickers ---- */
216 $('#group_from_start_date_filter').change( function() {
217 table.draw();
218 } );
219 $('#group_to_start_date_filter').change( function() {
220 table.draw();
221 } );
223 $('#group_from_end_date_filter').change( function() {
224 table.draw();
225 } );
226 $('#group_to_end_date_filter').change( function() {
227 table.draw();
228 } );
230 /* --- Text inputs --- */
231 $('#group_name_filter').keyup( function() {
232 table.draw();
233 } );
234 $('#group_id_filter').keyup( function() {
235 table.draw();
236 } );
238 /* ---- Select Boxes ---- */
239 $('#group_type_filter').change(function () {
240 table.columns( 2 ).search( this.value ).draw();
241 } );
243 $('#group_status_filter').change( function() {
244 table.draw();
245 } );
247 $('#counselors_filter').change( function() {
248 table.columns( 6 ).search( this.value ).draw();
249 } );
251 /* ----------------- End of filter toggles -------------------- */
254 /* --------- Reset Filters ------ */
255 $('#clear_filters').click(function(){
256 top.restoreSession();
257 location.reload();
261 /* Bring in the DateToYYYYMMDD_js function */
262 <?php require($GLOBALS['srcdir'] . '/formatting_DateToYYYYMMDD_js.js.php'); ?>
264 /* ========= End Of Data Table & Filters Initialisation ========= */
266 /* ======= DATATABLE FILTER EXTENSIONS ======== */
268 /* Extension for distribution date */
269 $.fn.dataTableExt.afnFiltering.push(
270 function( oSettings, aData, iDataIndex ) {
272 if(document.getElementById('group_from_start_date_filter').value === ""){
273 var iFini = document.getElementById('group_from_start_date_filter').value;
275 else{
276 var iFini = new Date(DateToYYYYMMDD_js(document.getElementById('group_from_start_date_filter').value));
279 if(document.getElementById('group_to_start_date_filter').value === ""){
280 var iFfin = document.getElementById('group_to_start_date_filter').value;
282 else{
283 var iFfin = new Date(DateToYYYYMMDD_js(document.getElementById('group_to_start_date_filter').value));
286 var iStartDateCol = 4;
287 var iEndDateCol = 4;
289 var datofini = new Date(DateToYYYYMMDD_js(aData[iStartDateCol]));
290 var datoffin = new Date(DateToYYYYMMDD_js(aData[iEndDateCol]));
293 if ( iFini === "" && iFfin === "" )
295 return true;
297 else if ( iFini <= datofini && iFfin === "")
299 return true;
301 else if ( iFfin >= datoffin && iFini === "")
303 return true;
305 else if (iFini <= datofini && iFfin >= datoffin)
307 return true;
309 return false;
313 /* Extension for Irregular approval date */
314 $.fn.dataTableExt.afnFiltering.push(
315 function( oSettings, aData, iDataIndex ) {
317 if(document.getElementById('group_from_end_date_filter').value === ""){
318 var iFini = document.getElementById('group_from_end_date_filter').value;
320 else{
321 var iFini = new Date(DateToYYYYMMDD_js(document.getElementById('group_from_end_date_filter').value));
324 if(document.getElementById('group_to_end_date_filter').value === ""){
325 var iFfin = document.getElementById('group_to_end_date_filter').value;
327 else{
328 var iFfin = new Date(DateToYYYYMMDD_js(document.getElementById('group_to_end_date_filter').value));
331 var iStartDateCol = 5;
332 var iEndDateCol = 5;
336 var datofini = new Date(DateToYYYYMMDD_js(aData[iStartDateCol]));
337 var datoffin = new Date(DateToYYYYMMDD_js(aData[iEndDateCol]));
340 if ( iFini === "" && iFfin === "" )
342 return true;
344 else if ( iFini <= datofini && iFfin === "")
346 return true;
348 else if ( iFfin >= datoffin && iFini === "")
350 return true;
352 else if (iFini <= datofini && iFfin >= datoffin)
354 return true;
356 return false;
360 /* Extension for group name */
361 $.fn.dataTableExt.afnFiltering.push(
362 function( oSettings, aData, iDataIndex ) {
363 var iColumn = 0;
364 var iVal = document.getElementById('group_name_filter').value;
365 var iVersion = aData[iColumn] == "-" ? 0 : aData[iColumn];
367 if(iVal === "" || iVal == 0){
368 return true;
370 else if(iVersion.indexOf(iVal) != -1){
371 return true;
373 return false;
377 /* Extension for group id */
378 $.fn.dataTableExt.afnFiltering.push(
379 function( oSettings, aData, iDataIndex ) {
380 var iColumn = 1;
381 var iVal = document.getElementById('group_id_filter').value;
382 var iVersion = aData[iColumn] == "-" ? 0 : aData[iColumn];
384 if(iVal === "" || iVal == 0){
385 return true;
387 else if(iVersion.indexOf(iVal) != -1){
388 return true;
390 return false;
394 /* Extension for group status */
395 $.fn.dataTableExt.afnFiltering.push(
396 function( settings, data, dataIndex ) {
397 var status_selected = $("#group_status_filter").val()||'';
398 var status = data[3] || '';
399 if(status_selected=='' || status_selected == 'all'){
400 return true;
402 if(status==status_selected)
403 return true;
404 return false;
409 /* ========= END OF EXTENSIONS ============= */
412 </script>
414 <?php require 'footer.php'; ?>