4 * interface/main/calendar/find_group_popup.php
7 * @link http://www.open-emr.org
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @author Shachar Zilbershlag <shaharzi@matrix.co.il>
10 * @author Amiel Elboim <amielel@matrix.co.il>
11 * @author Brady Miller <brady.g.miller@gmail.com>
12 * @copyright Copyright (c) 2005-2007 Rod Roark <rod@sunsetsystems.com>
13 * @copyright Copyright (c) 2016 Shachar Zilbershlag <shaharzi@matrix.co.il>
14 * @copyright Copyright (c) 2016 Amiel Elboim <amielel@matrix.co.il>
15 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
16 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
19 require_once('../../globals.php');
20 require_once("$srcdir/group.inc.php");
21 require_once("../../therapy_groups/therapy_groups_controllers/therapy_groups_controller.php");
23 use OpenEMR\Common\Csrf\CsrfUtils
;
24 use OpenEMR\Core\Header
;
27 if (!CsrfUtils
::verifyCsrfToken($_POST["csrf_token_form"])) {
28 CsrfUtils
::csrfNotVerified();
33 $group_types = TherapyGroupsController
::prepareGroupTypesList();
34 // If we are searching, search.
36 if ($_POST['searchby'] && $_POST['searchparm']) {
37 $searchby = $_POST['searchby'];
38 $searchparm = trim($_POST['searchparm']);
40 if ($searchby == "Name") {
41 $result = getGroupData("$searchparm", "*", 'group_name');
42 } elseif ($searchby == "ID") {
43 $result = getGroupData("$searchparm", "*", 'group_id');
49 <title
><?php
echo xlt('Group Finder'); ?
></title
>
50 <?php Header
::setupHeader('opener'); ?
>
62 background
-color
: #ddddff;
67 #searchResultsHeader {
69 background
-color
: lightgrey
;
72 #searchResultsHeader table {
73 width
: 96%
; /* not 100% because the 'searchResults' table has a scrollbar */
74 border
-collapse
: collapse
;
77 #searchResultsHeader th {
91 /* search results column widths */
108 #searchResults table {
110 border
-collapse
: collapse
;
111 background
-color
: white
;
121 border
-bottom
: 1px solid
#eee;
132 /* for search results or 'searching' notification */
136 padding
: 1px
1px
10px
1px
;
143 background
-color
: #ccc;
147 background
-color
: #fc0;
151 background
-color
: #9f6;
159 /* highlight for the mouse-over */
161 background
-color
: #336699;
168 function selgid(gid
, name
, end_date
) {
169 if (opener
.closed ||
!opener
.setgroup
)
170 alert(<?php
echo xlj('The destination form was closed; I cannot act on your selection.'); ?
>);
172 opener
.setgroup(gid
, name
, end_date
);
181 <body
class="body_top">
183 <div id
="searchCriteria">
184 <form method
='post' name
='theform' id
="theform" action
='find_group_popup.php'>
185 <input type
="hidden" name
="csrf_token_form" value
="<?php echo attr(CsrfUtils::collectCsrfToken()); ?>" />
186 <?php
echo xlt('Search by') . ':'; ?
>
187 <select name
='searchby'>
188 <option value
="Name"><?php
echo xlt('Name'); ?
></option
>
189 <option value
="ID"<?php
echo ($searchby == 'ID') ?
' selected' : ''; ?
>><?php
echo xlt('ID'); ?
></option
>
191 <?php
echo xlt('for') . ':'; ?
>
192 <input type
='text' id
='searchparm' name
='searchparm' size
='12' value
='<?php echo attr($_POST['searchparm
']); ?>'>  
;
193 <input type
='submit' id
="submitbtn" value
='<?php echo xla('Search
'); ?>'>
194 <div id
="searchspinner"><img src
="<?php echo $GLOBALS['webroot'] ?>/interface/pic/ajax-loader.gif"></div
>
199 <?php
if (!isset($_POST['searchparm'])) : ?
>
200 <div id
="searchstatus"><?php
echo xlt('Enter your search criteria above'); ?
></div
>
201 <?php
elseif (count($result) == 0) : ?
>
202 <div id
="searchstatus" class="noResults"><?php
echo xlt('No records found. Please expand your search criteria.'); ?
>
205 <?php
elseif (count($result) >= 100) : ?
>
206 <div id
="searchstatus" class="tooManyResults"><?php
echo xlt('More than 100 records found. Please narrow your search criteria.'); ?
></div
>
207 <?php
elseif (count($result) < 100) : ?
>
208 <div id
="searchstatus" class="howManyResults"><?php
echo text(count($result)); ?
> <?php
echo xlt('records found.'); ?
></div
>
211 <?php
if (isset($result)) : ?
>
212 <div id
="searchResultsHeader">
215 <th
class="srName"><?php
echo xlt('Name'); ?
></th
>
216 <th
class="srGID"><?php
echo xlt('ID'); ?
></th
> <!-- (CHEMED
) Search by phone number
-->
217 <th
class="srType"><?php
echo xlt('Type'); ?
></th
>
218 <th
class="srStartDate"><?php
echo xlt('Start Date'); ?
></th
>
223 <div id
="searchResults">
224 <table id
="results_table">
226 foreach ($result as $iter) {
227 $itergid = $iter['group_id'];
228 $itername = $iter['group_name'];
229 $itertype = $group_types[$iter['group_type']];
230 $iter_start_date = $iter['group_start_date'];
231 $iter_end_date = $iter['group_end_date'];
233 $trClass = "oneresult";
235 echo " <tr class='" . attr($trClass) . "' id='" .
236 attr($itergid . "~" . $itername . "~" . $itertype . "~" . $iter_start_date . "~" . $iter_end_date) . "'>";
237 echo " <td class='srName'>" . text($itername) . "</td>\n";
238 echo " <td class='srGID'>" . text($itergid) . "</td>\n";
239 echo " <td class='srType'>" . text($itertype) . "</td>\n";
240 echo " <td class='srStartDate'>" . text($iter_start_date) . "</td>\n";
250 // jQuery stuff to make the page a little easier to use
253 $
("#searchparm").trigger("focus");
254 $
(".oneresult").on("mouseover", function() { $
(this
).toggleClass("highlight"); });
255 $
(".oneresult").on("mouseout", function() { $
(this
).toggleClass("highlight"); });
256 $
(".oneresult").on("click", function() { SelectGroup(this
); });
258 $
("#theform").on("submit" , function() { SubmitForm(this
); });
262 // show the 'searching...' status and submit the form
263 var SubmitForm
= function(eObj
) {
264 $
("#submitbtn").css("disabled", "true");
265 $
("#searchspinner").css("visibility", "visible");
270 // parts[] ==> 0=GID, 1=Group Name 4=Group End Date
271 var SelectGroup
= function (eObj
) {
273 var parts
= objID
.split("~");
274 return selgid(parts
[0], parts
[1], parts
[4]);