2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
18 // A copy of the GNU General Public License is included along with this program:
19 // openemr/interface/login/GnuGPL.html
20 // For more information write to the Free Software
21 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Jacob T Paul <jacob@zhservices.com>
26 // +------------------------------------------------------------------------------+
28 //SANITIZE ALL ESCAPES
29 $sanitize_all_escapes=true;
32 //STOP FAKE REGISTER GLOBALS
33 $fake_register_globals=false;
36 require_once("../../interface/globals.php");
37 $list_id= $_REQUEST['list_id'] ?
$_REQUEST['list_id']: $_REQUEST['filter_context'];
39 function Delete_Rows($id){
40 sqlStatement("DELETE FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($id,$_SESSION['authId']));
42 function Insert_Rows($id,$order=""){
43 sqlStatement("REPLACE INTO template_users (tu_template_id,tu_user_id,tu_template_order) VALUES (?,?,?)",array($id,$_SESSION['authId'],$order));
46 if(isset($_REQUEST['submitform']) && $_REQUEST['submitform']=='save'){
47 $topersonalized = $_REQUEST['topersonalized'];
48 $personalized = $_REQUEST['personalized'];
49 foreach($topersonalized as $key=>$value){
50 $arr=explode("|",$value);
51 $res = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($arr[0],$_SESSION['authId']));
54 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
55 while($row=sqlFetchArray($qry)){
56 Delete_Rows($row['cl_list_slno']);
62 foreach($personalized as $key=>$value){
63 $arr=explode("|",$value);
65 $res = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($arr[0],$_SESSION['authId']));
67 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
68 while($row=sqlFetchArray($qry)){
69 $qryTU = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($row['cl_list_slno'],$arr[1]));
70 while($rowTU=sqlFetchArray($qryTU)){
71 Insert_Rows($rowTU['tu_template_id'],$rowTU['tu_template_order']);
77 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
78 while($row=sqlFetchArray($qry)){
79 Insert_Rows($row['cl_list_slno'],$row['cl_order']);
87 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
88 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
89 <script type
="text/javascript" src
="ckeditor/ckeditor.js"></script
>
90 <script src
="ckeditor/_samples/sample.js" type
="text/javascript"></script
>
91 <link href
="ckeditor/_samples/sample.css" rel
="stylesheet" type
="text/css" />
92 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
93 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script
>
94 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script
>
95 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.7.1.custom.min.js"></script
>
96 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script
>
97 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
98 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script
>
99 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script
>
100 <script type
="text/javascript">
101 $
(document
).ready(function(){
109 $
(".iframe_small").fancybox( {
110 'overlayOpacity' : 0.0,
111 'showCloseButton' : true,
115 $
(".iframe_medium").fancybox( {
116 'overlayOpacity' : 0.0,
117 'showCloseButton' : true,
121 $
(".iframe_abvmedium").fancybox( {
122 'overlayOpacity' : 0.0,
123 'showCloseButton' : true,
128 // add drag and drop functionality to fancybox
129 $
("#fancy_outer").easydrag();
132 function check_user_category(form
,selectFrom
,selectedList
){
133 top
.restoreSession();
134 var total_selected
= form
.elements
[selectedList
].length
-1;
136 for (total_selected
; total_selected
>= 0; total_selected
--)
138 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
139 { if(document
.getElementById('filter_users').value
){
142 url
: "ajax_code.php",
145 item
: form
.elements
[selectedList
].options
[total_selected
].value
,
146 list_id
: document
.getElementById('filter_users').value
,
150 success
: function(thedata
){
152 total_clients
= form
.elements
[selectFrom
].length
;
153 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
154 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
155 form
.elements
[selectedList
].options
[total_selected
] = null;
158 msg +
= form
.elements
[selectedList
].options
[total_selected
].text+
"\n";
167 total_clients
= form
.elements
[selectFrom
].length
;
168 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
169 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
170 form
.elements
[selectedList
].options
[total_selected
] = null;
174 jsub_sortNow(form
.elements
[selectFrom
]);
176 if(confirm("<?php echo addslashes(xl('The following categories will be removed from your category List'));?> \n" +msg +
"\n <?php echo addslashes(xl('Do you want to continue?'));?>")){
177 remove_selected(form
,selectedList
);
182 function remove_selected(form
,selectedList
)
184 top
.restoreSession();
185 var total_selected
= form
.elements
[selectedList
].length
-1;
186 for (total_selected
; total_selected
>= 0; total_selected
--)
188 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
190 form
.elements
[selectedList
].options
[total_selected
] = null;
193 jsub_sortNow(form
.elements
[selectFrom
]);
196 function all_selected(selectedList
){
197 top
.restoreSession();
198 var total_selected
= document
.getElementById(selectedList
).length
-1;
199 for (total_selected
; total_selected
>= 0; total_selected
--)
201 document
.getElementById(selectedList
).options
[total_selected
].selected
=true;
204 function all_deselected(selectedList
){
205 top
.restoreSession();
206 var total_selected
= document
.getElementById(selectedList
).length
-1;
207 for (total_selected
; total_selected
>= 0; total_selected
--)
209 document
.getElementById(selectedList
).options
[total_selected
].selected
=false;
212 function jsub_selected(form
,selectFrom
,selectedList
)
214 top
.restoreSession();
215 var total_selected
= form
.elements
[selectedList
].length
-1;
216 for (total_selected
; total_selected
>= 0; total_selected
--)
218 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
220 total_clients
= form
.elements
[selectFrom
].length
;
221 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
222 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
223 form
.elements
[selectedList
].options
[total_selected
] = null;
226 jsub_sortNow(form
.elements
[selectFrom
]);
229 function display_category_item(form
,selectedList
){
230 top
.restoreSession();
233 var total_selected
= form
.elements
[selectedList
].length
-1;
234 for (total_selected
; total_selected
>= 0; total_selected
--)
236 if(form
.elements
[selectedList
].options
[total_selected
].selected
)
238 selectedval
=form
.elements
[selectedList
].options
[total_selected
].value
;
243 document
.getElementById('itemdiv').style
.display
='none';
246 document
.getElementById('itemdiv').style
.display
='';
249 url
: "ajax_code.php",
252 list_id
: selectedval
,
256 success
: function(thedata
){
257 document
.getElementById('itemdiv').innerHTML
=thedata
;
266 function jsub_sortNow(obj
)
268 top
.restoreSession();
269 var len
= obj
.length
-1;
270 var text
= new Array();
271 var values
= new Array();
272 var sortarr
= new Array();
273 for(var i
=len
; i
>=0; i
--)
275 text
[i
] = obj
.options
[i
].text
;
276 values
[i
]=obj
.options
[i
].value
;
277 sortarr
[i
]=obj
.options
[i
].text
;
281 for(i
=0; i
<=len
; i++
)
283 for(j
=0; j
<=len
; j++
)
285 if(sortarr
[i
] == text
[j
])
290 opt
= new Option(text
[j
],values
[j
]);
291 obj
.options
[i
] = opt
;
294 function personalize_save(){
295 top
.restoreSession();
296 document
.getElementById('submitform').value
='save';
297 all_selected('topersonalized');
298 all_selected('personalized');
299 document
.myform
.submit();
303 <body
class="body_top">
304 <form name
="myform" method
="post" onsubmit
="top.restoreSession();">
306 <legend
><span
class="text"><?php
echo htmlspecialchars(xl('Filter'),ENT_QUOTES
);?
></span
></legend
>
309 <td
><?php
echo htmlspecialchars(xl('Context'),ENT_QUOTES
);?
></td
>
311 <select name
='filter_context' id
='filter_context' onchange
='javascript:document.myform.submit();'>
312 <option value
=''><?php
echo htmlspecialchars(xl('Select a Context'),ENT_QUOTES
);?
></option
>
314 $context_sql="SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0";
315 $context_res=sqlStatement($context_sql);
316 while($context_row=sqlFetchArray($context_res)){
317 echo "<option value='".htmlspecialchars($context_row['cl_list_slno'],ENT_QUOTES
)."' ";
318 echo ($_REQUEST['filter_context']==$context_row['cl_list_slno']) ?
'selected' : '' ;
319 echo ">".htmlspecialchars($context_row['cl_list_item_long'],ENT_QUOTES
)."</option>";
324 <td
><?php
echo htmlspecialchars(xl('Users'),ENT_QUOTES
);?
></td
>
326 <select name
='filter_users' id
='filter_users' onchange
='javascript:document.myform.submit();'>
327 <option value
=''><?php
echo htmlspecialchars(xl('Select a User'),ENT_QUOTES
);?
></option
>
329 $user_sql="SELECT DISTINCT(tu.tu_user_id),u.fname,u.lname FROM template_users AS tu LEFT OUTER JOIN users AS u ON tu.tu_user_id=u.id WHERE tu.tu_user_id!=?";
330 $user_res=sqlStatement($user_sql,array($_SESSION['authId']));
331 while($user_row=sqlFetchArray($user_res)){
332 echo "<option value='".htmlspecialchars($user_row['tu_user_id'],ENT_QUOTES
)."' ";
333 echo ($_REQUEST['filter_users']==$user_row['tu_user_id']) ?
'selected' : '' ;
334 echo ">".htmlspecialchars($user_row['fname']." ".$user_row['lname'],ENT_QUOTES
)."</option>";
342 <table align
="center" width
="100%">
345 <a href
=# class="css_button" onclick="top.restoreSession();personalize_save()"><span><?php echo htmlspecialchars(xl('Save'),ENT_QUOTES);?></span></a>
347 if(acl_check('nationnotes', 'nn_configure')){
349 <a href
="delete_category.php" id
="share_link" class="iframe_medium css_button" onclick
="top.restoreSession();"><span
><?php
echo htmlspecialchars(xl('Delete Category'),ENT_QUOTES
);?
></span
></a
>
354 if(acl_check('nationnotes', 'nn_configure')){
356 <a href
="add_template.php?list_id=<?php echo $_REQUEST['list_id'];?>" onclick
="top.restoreSession();" class="iframe_small css_button" title
="<?php echo htmlspecialchars(xl('Add Category'),ENT_QUOTES);?>"><span
><?php
echo htmlspecialchars(xl('Add Category'),ENT_QUOTES
);?
></span
></a
>
361 if(acl_check('nationnotes', 'nn_configure')){
363 <a href
="add_context.php" class="iframe_medium css_button" onclick
="top.restoreSession();" title
="<?php echo htmlspecialchars(xl('Add Context'),ENT_QUOTES);?>"><span
><?php
echo htmlspecialchars(xl('Add Context'),ENT_QUOTES
);?
></span
></a
>
368 <th
><?php
echo htmlspecialchars(xl('Available categories'),ENT_QUOTES
);?
></th
>
371 $user = sqlQuery("SELECT * FROM users WHERE id=?",array($_SESSION['authId']));
373 <th
><?php
echo htmlspecialchars(xl('Categories for')." ".$user['fname']." ".$user['lname'],ENT_QUOTES
);?
></th
>
377 <select multiple name
="topersonalized[]" id
="topersonalized" size
="6" style
="width:220px" onchange
="display_category_item(document.myform,'topersonalized');">
381 $arval = array($_SESSION['authId']);
382 $arval1 = array($_REQUEST['filter_users'],$_SESSION['authId']);
383 if($_REQUEST['filter_context']){
384 $where .=" AND cl_list_id=?";
385 array_push($arval,$_REQUEST['filter_context']);
386 array_push($arval1,$_REQUEST['filter_context']);
388 $sql = "SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno
389 WHERE cl_list_type=3 AND cl_deleted=0 AND tu.tu_template_id NOT IN (SELECT tu_template_id FROM template_users AS tuser WHERE
392 " ORDER BY cl_list_id,tu_user_id,cl_list_item_long";
393 $resTemplates = sqlStatement($sql,$arval);
394 if($_REQUEST['filter_users']){
395 $sql = " SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno WHERE
396 tu.tu_user_id=? AND c.cl_list_type=3 AND cl_deleted=0 AND tu.tu_template_id NOT IN
397 (SELECT tu_template_id FROM template_users AS tuser WHERE tu_user_id=?)".
399 "ORDER BY cl_list_id,tu_user_id,c.cl_list_item_long";
400 $resTemplates = sqlStatement($sql,$arval1);
402 while($rowTemplates = sqlFetchArray($resTemplates)){
404 if(!$_REQUEST['filter_context']){
405 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($rowTemplates['cl_list_id']));
406 $cntxt.=$context['cl_list_item_long']."->";
408 if(!$_REQUEST['filter_users']){
409 $context=sqlQuery("SELECT * FROM users WHERE id=?",array($rowTemplates['tu_user_id']));
410 $cntxt.=$context['username']."->";
412 echo "<option value='".htmlspecialchars($rowTemplates['cl_list_slno']."|".$rowTemplates['tu_user_id'],ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$rowTemplates['cl_list_item_long'],ENT_QUOTES
)."</option>";
414 $sqlorphan = "SELECT * FROM customlists WHERE cl_list_type=3 AND cl_deleted=0 AND cl_list_slno ".
415 " NOT IN (SELECT DISTINCT tu_template_id FROM template_users) ".
417 " ORDER BY cl_list_id,cl_list_item_long";
418 $resorphan = sqlStatement($sqlorphan);
419 while($roworphan = sqlFetchArray($resorphan)){
421 if(!$_REQUEST['filter_context']){
422 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($roworphan['cl_list_id']));
423 $cntxt.=$context['cl_list_item_long']."->";
425 echo "<option value='".htmlspecialchars($roworphan['cl_list_slno']."|",ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$roworphan['cl_list_item_long'],ENT_QUOTES
)."</option>";
431 <input type
="button" name
="remove" value
=»
; onclick
="jsub_selected(document.myform,'personalized','topersonalized')"></br
>
432 <input type
="button" name
="remove" value
=«
; onclick
="check_user_category(document.myform,'topersonalized','personalized')">
435 <select multiple name
="personalized[]" id
="personalized" size
="6" style
="width:220px">
438 if($_REQUEST['filter_context']){
439 $where .=" AND cl_list_id='".$_REQUEST['filter_context']."'";
441 $sql = "SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno WHERE
442 tu.tu_user_id=? AND c.cl_list_type=3 AND cl_deleted=0 ".
444 "ORDER BY c.cl_list_item_long";
445 $resTemplates = sqlStatement($sql,array($_SESSION['authId']));
446 while($rowTemplates = sqlFetchArray($resTemplates)){
448 if(!$_REQUEST['filter_context']){
449 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($rowTemplates['cl_list_id']));
450 $cntxt.=$context['cl_list_item_long']."->";
452 echo "<option value='".htmlspecialchars($rowTemplates['cl_list_slno']."|".$rowTemplates['tu_user_id'],ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$rowTemplates['cl_list_item_long'],ENT_QUOTES
)."</option>";
461 <td
><input type
="hidden" name
="submitform" id
="submitform" value
=""></td
>
465 <div style
="width:100%;overflow:auto;height:150px" id
="itemdiv"></div
>