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>;.
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
$view = acl_check("groups", "gadd", false, 'view');?
>
31 <?php
require 'header.php'; ?
>
32 <?php
if ($view ||
$edit) :?
>
34 <span
class="hidden title"><?php
echo xlt('Therapy Group Finder');?
></span
>
35 <div id
="therapy_groups_list_container" class="container">
37 <!--------- ERRORS
----------->
38 <?php
if ($deletion_try == 1 && $deletion_response['success'] == 0) :?
>
40 <div
class="col-md-6 col-md-offset-3">
41 <div
class="alert alert-danger text-center">
42 <p
class="failed_message"><?php
echo xlt($deletion_response['message']);?
></p
>
48 <!---------- FILTERS SECTION
------------->
50 <button id
="clear_filters" class="btn"><?php
echo xlt("Clear Filters")?
></button
>
56 <div
class=" form-group col-md-2">
58 <label
class="" for="group_name_filter"><?php
echo xlt('Group Name');?
>:</label
>
59 <input type
="text" class="form-control" id
="group_name_filter" placeholder
="" >
61 <div
class=" form-group col-md-2">
62 <label
class="" for="group_id_filter"><?php
echo xlt('Group Id');?
>:</label
>
63 <input type
="number" class="form-control" id
="group_id_filter" placeholder
="" >
65 <div
class=" form-group col-md-2">
66 <label
class="" for="group_type_filter"><?php
echo xlt('Group Type');?
>:</label
>
67 <select type
="text" class="form-control" id
="group_type_filter" placeholder
="" >
68 <option value
=""><?php
echo xlt('choose');?
></option
>
69 <?php
foreach ($group_types as $type) :?
>
70 <option value
="<?php echo attr($type);?>"><?php
echo text($type) ;?
></option
>
74 <div
class=" form-group col-md-2">
75 <label
class="" for="group_status_filter"><?php
echo xlt('Status');?
>:</label
>
76 <select type
="text" class="form-control" id
="group_status_filter" placeholder
="" >
77 <option value
="<?php echo attr($statuses[10]); ?>"><?php
echo xlt($statuses[10]);?
></option
>
78 <?php
foreach ($statuses as $status) :?
>
79 <?php
if ($status != $statuses[10]) : ?
>
80 <option value
="<?php echo attr($status);?>"><?php
echo xlt($status) ;?
></option
>
83 <option value
="all"><?php
echo xlt("all");?
></option
>
86 <div
class=" form-group col-md-2">
87 <label
class="" for="counselors_filter"><?php
echo xlt('Main Counselors');?
>:</label
>
88 <select type
="text" class="form-control" id
="counselors_filter" placeholder
="" >
89 <option value
=""><?php
echo xlt('choose');?
></option
>
90 <?php
foreach ($counselors as $counselor) :?
>
91 <option value
="<?php echo attr($counselor);?>"><?php
echo text($counselor) ;?
></option
>
97 <div
class=" form-group col-md-2">
98 <label
class="" for="group_from_start_date_filter"><?php
echo xlt('Starting Date From');?
>:</label
>
99 <input type
="text" class="form-control datepicker" id
="group_from_start_date_filter" placeholder
="" >
101 <div
class=" form-group col-md-2">
102 <label
class="" for="group_to_start_date_filter"><?php
echo xlt('Starting Date To');?
>:</label
>
103 <input type
="text" class="form-control datepicker" id
="group_to_start_date_filter" placeholder
="" >
105 <div
class=" form-group col-md-2">
106 <label
class="" for="group_from_end_date_filter"><?php
echo xlt('End Date From');?
>:</label
>
107 <input type
="text" class="form-control datepicker" id
="group_from_end_date_filter" placeholder
="" >
109 <div
class=" form-group col-md-2">
110 <label
class="" for="group_to_end_date_filter"><?php
echo xlt('End Date To');?
>:</label
>
111 <input type
="text" class="form-control datepicker" id
="group_to_end_date_filter" placeholder
="" >
116 <!---------- END OF FILTERS SECTION
------------->
120 <!---------- TABLE SECTION
-------------->
122 <table id
="therapy_groups_list" class="dataTable display">
125 <th
><?php
echo xlt('Group Name'); ?
></th
>
126 <th
><?php
echo xlt('Group Id'); ?
></th
>
127 <th
><?php
echo xlt('Group Type'); ?
></th
>
128 <th
><?php
echo xlt('Status'); ?
></th
>
129 <th
><?php
echo xlt('Start Date'); ?
></th
>
130 <th
><?php
echo xlt('End Date'); ?
></th
>
131 <th
><?php
echo xlt('Main Counselors'); ?
></th
>
132 <th
><?php
echo xlt('Comment'); ?
></th
>
133 <th
><?php
echo xlt('Delete'); ?
></th
>
137 <?php
foreach ($therapyGroups as $group) : ?
>
139 <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
>
140 <td
><?php
echo text($group['group_id']);?
></td
>
141 <td
><?php
echo xlt($group_types[$group['group_type']]);?
></td
>
142 <td
><?php
echo xlt($statuses[$group['group_status']]);?
></td
>
143 <td
><?php
echo text(oeFormatShortDate($group['group_start_date']));?
></td
>
144 <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
>
146 <?php
foreach ($group['counselors'] as $counselor) {
147 echo text($counselor) . " </br> ";
150 <td
><?php
echo text($group['group_notes']);?
></td
>
151 <td
class="delete_btn">
153 //Enable deletion only for groups that weren't yet deleted.
154 if ($group['group_status'] == 10) { ?
>
155 <a href
="<?php echo $GLOBALS['rootdir'] . '/therapy_groups/index.php?method=listGroups&deleteGroup=1&group_id=' . attr($group['group_id']); ?>"><?php
157 <button
>X
</button
><?php
168 <!---------- END OF TABLE SECTION
-------------->
175 /* ========= Initialise Data Table & Filters ========= */
176 $
(document
).ready(function() {
178 // var lang = '<?php //echo $lang ?>//';//get language support for filters
180 /* Initialise Date Picker */
181 $
('.datepicker').datetimepicker({
182 <?php
$datetimepicker_timepicker = false; ?
>
183 <?php
$datetimepicker_showseconds = false; ?
>
184 <?php
$datetimepicker_formatInput = true; ?
>
185 <?php
require($GLOBALS['srcdir'] . '/js/xl/jquery-datetimepicker-2-5-4.js.php'); ?
>
186 <?php
// can add any additional javascript settings to datetimepicker here; need to prepend first setting with a comma ?>
189 /* Initialise Datatable */
190 var table
= $
('#therapy_groups_list').DataTable({
191 initComplete
: function () {
192 $
('#therapy_groups_list_filter').hide(); //hide searchbar
194 <?php
// Bring in the translations ?>
195 <?php
$translationsDatatablesOverride = array('lengthMenu'=>(xla('Display').' _MENU_ '.xla('records per page')),
196 'zeroRecords'=>(xla('Nothing found - sorry')),
197 'info'=>(xla('Showing page') .' _PAGE_ '. xla('of') . ' _PAGES_'),
198 'infoEmpty'=>(xla('No records available')),
199 'infoFiltered'=>('('.xla('filtered from').' _MAX_ '.xla('total records').')'),
202 <?php
require($GLOBALS['srcdir'] . '/js/xl/datatables-net.js.php'); ?
>
205 /* Order by Start Date column (descending) */
206 table
.order( [ 4, 'desc' ] ).draw();
208 /* Hide/Show filters */
209 $
("#show_filters").click(function () {
210 $
('#filters').show();
211 $
("#hide_filters").show();
212 $
("#show_filters").hide();
215 $
("#hide_filters").click(function () {
216 $
('#filters').hide();
217 $
("#hide_filters").hide();
218 $
("#show_filters").show();
221 /* ------------ Toggle filter functions on keyup/change ----------- */
224 * Note: where there is an explicit extension made for the filter, just table.draw() was used.
225 * Otherwise 'table.columns( ).search( this.value ).draw();' was used.
229 /* ---- Datetimepickers ---- */
230 $
('#group_from_start_date_filter').change( function() {
233 $
('#group_to_start_date_filter').change( function() {
237 $
('#group_from_end_date_filter').change( function() {
240 $
('#group_to_end_date_filter').change( function() {
244 /* --- Text inputs --- */
245 $
('#group_name_filter').keyup( function() {
248 $
('#group_id_filter').keyup( function() {
252 /* ---- Select Boxes ---- */
253 $
('#group_type_filter').change(function () {
254 table
.columns( 2 ).search( this
.value
).draw();
257 $
('#group_status_filter').change( function() {
261 $
('#counselors_filter').change( function() {
262 table
.columns( 6 ).search( this
.value
).draw();
265 /* ----------------- End of filter toggles -------------------- */
268 /* --------- Reset Filters ------ */
269 $
('#clear_filters').click(function(){
270 top
.restoreSession();
275 /* Bring in the DateToYYYYMMDD_js function */
276 <?php
require($GLOBALS['srcdir'] . '/formatting_DateToYYYYMMDD_js.js.php'); ?
>
278 /* ========= End Of Data Table & Filters Initialisation ========= */
280 /* ======= DATATABLE FILTER EXTENSIONS ======== */
282 /* Extension for distribution date */
283 $
.fn
.dataTableExt
.afnFiltering
.push(
284 function( oSettings
, aData
, iDataIndex
) {
286 if(document
.getElementById('group_from_start_date_filter').value
=== ""){
287 var iFini
= document
.getElementById('group_from_start_date_filter').value
;
290 var iFini
= new Date(DateToYYYYMMDD_js(document
.getElementById('group_from_start_date_filter').value
));
293 if(document
.getElementById('group_to_start_date_filter').value
=== ""){
294 var iFfin
= document
.getElementById('group_to_start_date_filter').value
;
297 var iFfin
= new Date(DateToYYYYMMDD_js(document
.getElementById('group_to_start_date_filter').value
));
300 var iStartDateCol
= 4;
303 var datofini
= new Date(DateToYYYYMMDD_js(aData
[iStartDateCol
]));
304 var datoffin
= new Date(DateToYYYYMMDD_js(aData
[iEndDateCol
]));
307 if ( iFini
=== "" && iFfin
=== "" )
311 else if ( iFini
<= datofini
&& iFfin
=== "")
315 else if ( iFfin
>= datoffin
&& iFini
=== "")
319 else if (iFini
<= datofini
&& iFfin
>= datoffin
)
327 /* Extension for Irregular approval date */
328 $
.fn
.dataTableExt
.afnFiltering
.push(
329 function( oSettings
, aData
, iDataIndex
) {
331 if(document
.getElementById('group_from_end_date_filter').value
=== ""){
332 var iFini
= document
.getElementById('group_from_end_date_filter').value
;
335 var iFini
= new Date(DateToYYYYMMDD_js(document
.getElementById('group_from_end_date_filter').value
));
338 if(document
.getElementById('group_to_end_date_filter').value
=== ""){
339 var iFfin
= document
.getElementById('group_to_end_date_filter').value
;
342 var iFfin
= new Date(DateToYYYYMMDD_js(document
.getElementById('group_to_end_date_filter').value
));
345 var iStartDateCol
= 5;
350 var datofini
= new Date(DateToYYYYMMDD_js(aData
[iStartDateCol
]));
351 var datoffin
= new Date(DateToYYYYMMDD_js(aData
[iEndDateCol
]));
354 if ( iFini
=== "" && iFfin
=== "" )
358 else if ( iFini
<= datofini
&& iFfin
=== "")
362 else if ( iFfin
>= datoffin
&& iFini
=== "")
366 else if (iFini
<= datofini
&& iFfin
>= datoffin
)
374 /* Extension for group name */
375 $
.fn
.dataTableExt
.afnFiltering
.push(
376 function( oSettings
, aData
, iDataIndex
) {
378 var iVal
= document
.getElementById('group_name_filter').value
;
379 var iVersion
= aData
[iColumn
] == "-" ?
0 : aData
[iColumn
];
381 if(iVal
=== "" || iVal
== 0){
384 else if(iVersion
.indexOf(iVal
) != -1){
391 /* Extension for group id */
392 $
.fn
.dataTableExt
.afnFiltering
.push(
393 function( oSettings
, aData
, iDataIndex
) {
395 var iVal
= document
.getElementById('group_id_filter').value
;
396 var iVersion
= aData
[iColumn
] == "-" ?
0 : aData
[iColumn
];
398 if(iVal
=== "" || iVal
== 0){
401 else if(iVersion
.indexOf(iVal
) != -1){
408 /* Extension for group status */
409 $
.fn
.dataTableExt
.afnFiltering
.push(
410 function( settings
, data
, dataIndex
) {
411 var status_selected
= $
("#group_status_filter").val()||
'';
412 var status
= data
[3] ||
'';
413 if(status_selected
=='' || status_selected
== 'all'){
416 if(status
==status_selected
)
423 /* ========= END OF EXTENSIONS ============= */
428 <?php
require 'footer.php'; ?
>
431 <div
class="container">
433 <div
class="row alert alert-info">
434 <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
>