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 // +------------------------------------------------------------------------------+
30 require_once("../../interface/globals.php");
31 $list_id= $_REQUEST['list_id'] ?
$_REQUEST['list_id']: $_REQUEST['filter_context'];
33 function Delete_Rows($id){
34 sqlStatement("DELETE FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($id,$_SESSION['authId']));
36 function Insert_Rows($id,$order=""){
37 sqlStatement("REPLACE INTO template_users (tu_template_id,tu_user_id,tu_template_order) VALUES (?,?,?)",array($id,$_SESSION['authId'],$order));
40 if(isset($_REQUEST['submitform']) && $_REQUEST['submitform']=='save'){
41 $topersonalized = $_REQUEST['topersonalized'];
42 $personalized = $_REQUEST['personalized'];
43 foreach($topersonalized as $key=>$value){
44 $arr=explode("|",$value);
45 $res = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($arr[0],$_SESSION['authId']));
48 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
49 while($row=sqlFetchArray($qry)){
50 Delete_Rows($row['cl_list_slno']);
56 foreach($personalized as $key=>$value){
57 $arr=explode("|",$value);
59 $res = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($arr[0],$_SESSION['authId']));
61 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
62 while($row=sqlFetchArray($qry)){
63 $qryTU = sqlStatement("SELECT * FROM template_users WHERE tu_template_id=? AND tu_user_id=?",array($row['cl_list_slno'],$arr[1]));
64 while($rowTU=sqlFetchArray($qryTU)){
65 Insert_Rows($rowTU['tu_template_id'],$rowTU['tu_template_order']);
71 $qry = sqlStatement("SELECT * FROM customlists WHERE cl_list_id=? AND cl_deleted=0",array($arr[0]));
72 while($row=sqlFetchArray($qry)){
73 Insert_Rows($row['cl_list_slno'],$row['cl_order']);
81 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
82 <link rel
="stylesheet" type
="text/css" href
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media
="screen" />
83 <script type
="text/javascript" src
="ckeditor/ckeditor.js"></script
>
84 <script src
="ckeditor/_samples/sample.js" type
="text/javascript"></script
>
85 <link href
="ckeditor/_samples/sample.css" rel
="stylesheet" type
="text/css" />
86 <link rel
="stylesheet" href
="<?php echo $css_header;?>" type
="text/css">
87 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js?v=<?php echo $v_js_includes; ?>"></script
>
88 <script type
="text/javascript" src
="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-1-3-2/index.js"></script
>
89 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.7.1.custom.min.js"></script
>
90 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script
>
91 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script
>
92 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script
>
93 <script type
="text/javascript" src
="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script
>
94 <script type
="text/javascript">
95 $
(document
).ready(function(){
103 $
(".iframe_small").fancybox( {
104 'overlayOpacity' : 0.0,
105 'showCloseButton' : true,
109 $
(".iframe_medium").fancybox( {
110 'overlayOpacity' : 0.0,
111 'showCloseButton' : true,
115 $
(".iframe_abvmedium").fancybox( {
116 'overlayOpacity' : 0.0,
117 'showCloseButton' : true,
122 // add drag and drop functionality to fancybox
123 $
("#fancy_outer").easydrag();
126 function check_user_category(form
,selectFrom
,selectedList
){
127 top
.restoreSession();
128 var total_selected
= form
.elements
[selectedList
].length
-1;
130 for (total_selected
; total_selected
>= 0; total_selected
--)
132 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
133 { if(document
.getElementById('filter_users').value
){
136 url
: "ajax_code.php",
139 item
: form
.elements
[selectedList
].options
[total_selected
].value
,
140 list_id
: document
.getElementById('filter_users').value
,
144 success
: function(thedata
){
146 total_clients
= form
.elements
[selectFrom
].length
;
147 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
148 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
149 form
.elements
[selectedList
].options
[total_selected
] = null;
152 msg +
= form
.elements
[selectedList
].options
[total_selected
].text+
"\n";
161 total_clients
= form
.elements
[selectFrom
].length
;
162 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
163 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
164 form
.elements
[selectedList
].options
[total_selected
] = null;
168 jsub_sortNow(form
.elements
[selectFrom
]);
170 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?'));?>")){
171 remove_selected(form
,selectedList
);
176 function remove_selected(form
,selectedList
)
178 top
.restoreSession();
179 var total_selected
= form
.elements
[selectedList
].length
-1;
180 for (total_selected
; total_selected
>= 0; total_selected
--)
182 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
184 form
.elements
[selectedList
].options
[total_selected
] = null;
187 jsub_sortNow(form
.elements
[selectFrom
]);
190 function all_selected(selectedList
){
191 top
.restoreSession();
192 var total_selected
= document
.getElementById(selectedList
).length
-1;
193 for (total_selected
; total_selected
>= 0; total_selected
--)
195 document
.getElementById(selectedList
).options
[total_selected
].selected
=true;
198 function all_deselected(selectedList
){
199 top
.restoreSession();
200 var total_selected
= document
.getElementById(selectedList
).length
-1;
201 for (total_selected
; total_selected
>= 0; total_selected
--)
203 document
.getElementById(selectedList
).options
[total_selected
].selected
=false;
206 function jsub_selected(form
,selectFrom
,selectedList
)
208 top
.restoreSession();
209 var total_selected
= form
.elements
[selectedList
].length
-1;
210 for (total_selected
; total_selected
>= 0; total_selected
--)
212 if (form
.elements
[selectedList
].options
[total_selected
].selected
)
214 total_clients
= form
.elements
[selectFrom
].length
;
215 opt
= new Option(form
.elements
[selectedList
].options
[total_selected
].text
, form
.elements
[selectedList
].options
[total_selected
].value
);
216 form
.elements
[selectFrom
].options
[total_clients
] = opt
;
217 form
.elements
[selectedList
].options
[total_selected
] = null;
220 jsub_sortNow(form
.elements
[selectFrom
]);
223 function display_category_item(form
,selectedList
){
224 top
.restoreSession();
227 var total_selected
= form
.elements
[selectedList
].length
-1;
228 for (total_selected
; total_selected
>= 0; total_selected
--)
230 if(form
.elements
[selectedList
].options
[total_selected
].selected
)
232 selectedval
=form
.elements
[selectedList
].options
[total_selected
].value
;
237 document
.getElementById('itemdiv').style
.display
='none';
240 document
.getElementById('itemdiv').style
.display
='';
243 url
: "ajax_code.php",
246 list_id
: selectedval
,
250 success
: function(thedata
){
251 document
.getElementById('itemdiv').innerHTML
=thedata
;
260 function jsub_sortNow(obj
)
262 top
.restoreSession();
263 var len
= obj
.length
-1;
264 var text
= new Array();
265 var values
= new Array();
266 var sortarr
= new Array();
267 for(var i
=len
; i
>=0; i
--)
269 text
[i
] = obj
.options
[i
].text
;
270 values
[i
]=obj
.options
[i
].value
;
271 sortarr
[i
]=obj
.options
[i
].text
;
275 for(i
=0; i
<=len
; i++
)
277 for(j
=0; j
<=len
; j++
)
279 if(sortarr
[i
] == text
[j
])
284 opt
= new Option(text
[j
],values
[j
]);
285 obj
.options
[i
] = opt
;
288 function personalize_save(){
289 top
.restoreSession();
290 document
.getElementById('submitform').value
='save';
291 all_selected('topersonalized');
292 all_selected('personalized');
293 document
.myform
.submit();
297 <body
class="body_top">
298 <form name
="myform" method
="post" onsubmit
="top.restoreSession();">
300 <legend
><span
class="text"><?php
echo htmlspecialchars(xl('Filter'),ENT_QUOTES
);?
></span
></legend
>
303 <td
><?php
echo htmlspecialchars(xl('Context'),ENT_QUOTES
);?
></td
>
305 <select name
='filter_context' id
='filter_context' onchange
='javascript:document.myform.submit();'>
306 <option value
=''><?php
echo htmlspecialchars(xl('Select a Context'),ENT_QUOTES
);?
></option
>
308 $context_sql="SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0";
309 $context_res=sqlStatement($context_sql);
310 while($context_row=sqlFetchArray($context_res)){
311 echo "<option value='".htmlspecialchars($context_row['cl_list_slno'],ENT_QUOTES
)."' ";
312 echo ($_REQUEST['filter_context']==$context_row['cl_list_slno']) ?
'selected' : '' ;
313 echo ">".htmlspecialchars($context_row['cl_list_item_long'],ENT_QUOTES
)."</option>";
318 <td
><?php
echo htmlspecialchars(xl('Users'),ENT_QUOTES
);?
></td
>
320 <select name
='filter_users' id
='filter_users' onchange
='javascript:document.myform.submit();'>
321 <option value
=''><?php
echo htmlspecialchars(xl('Select a User'),ENT_QUOTES
);?
></option
>
323 $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!=?";
324 $user_res=sqlStatement($user_sql,array($_SESSION['authId']));
325 while($user_row=sqlFetchArray($user_res)){
326 echo "<option value='".htmlspecialchars($user_row['tu_user_id'],ENT_QUOTES
)."' ";
327 echo ($_REQUEST['filter_users']==$user_row['tu_user_id']) ?
'selected' : '' ;
328 echo ">".htmlspecialchars($user_row['fname']." ".$user_row['lname'],ENT_QUOTES
)."</option>";
336 <table align
="center" width
="100%">
339 <a href
=# class="css_button" onclick="top.restoreSession();personalize_save()"><span><?php echo htmlspecialchars(xl('Save'),ENT_QUOTES);?></span></a>
341 if(acl_check('nationnotes', 'nn_configure')){
343 <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
>
348 if(acl_check('nationnotes', 'nn_configure')){
350 <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
>
355 if(acl_check('nationnotes', 'nn_configure')){
357 <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
>
362 <th
><?php
echo htmlspecialchars(xl('Available categories'),ENT_QUOTES
);?
></th
>
365 $user = sqlQuery("SELECT * FROM users WHERE id=?",array($_SESSION['authId']));
367 <th
><?php
echo htmlspecialchars(xl('Categories for')." ".$user['fname']." ".$user['lname'],ENT_QUOTES
);?
></th
>
371 <select multiple name
="topersonalized[]" id
="topersonalized" size
="6" style
="width:220px" onchange
="display_category_item(document.myform,'topersonalized');">
375 $arval = array($_SESSION['authId']);
376 $arval1 = array($_REQUEST['filter_users'],$_SESSION['authId']);
377 if($_REQUEST['filter_context']){
378 $where .=" AND cl_list_id=?";
379 array_push($arval,$_REQUEST['filter_context']);
380 array_push($arval1,$_REQUEST['filter_context']);
382 $sql = "SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno
383 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
386 " ORDER BY cl_list_id,tu_user_id,cl_list_item_long";
387 $resTemplates = sqlStatement($sql,$arval);
388 if($_REQUEST['filter_users']){
389 $sql = " SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno WHERE
390 tu.tu_user_id=? AND c.cl_list_type=3 AND cl_deleted=0 AND tu.tu_template_id NOT IN
391 (SELECT tu_template_id FROM template_users AS tuser WHERE tu_user_id=?)".
393 "ORDER BY cl_list_id,tu_user_id,c.cl_list_item_long";
394 $resTemplates = sqlStatement($sql,$arval1);
396 while($rowTemplates = sqlFetchArray($resTemplates)){
398 if(!$_REQUEST['filter_context']){
399 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($rowTemplates['cl_list_id']));
400 $cntxt.=$context['cl_list_item_long']."->";
402 if(!$_REQUEST['filter_users']){
403 $context=sqlQuery("SELECT * FROM users WHERE id=?",array($rowTemplates['tu_user_id']));
404 $cntxt.=$context['username']."->";
406 echo "<option value='".htmlspecialchars($rowTemplates['cl_list_slno']."|".$rowTemplates['tu_user_id'],ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$rowTemplates['cl_list_item_long'],ENT_QUOTES
)."</option>";
408 $sqlorphan = "SELECT * FROM customlists WHERE cl_list_type=3 AND cl_deleted=0 AND cl_list_slno ".
409 " NOT IN (SELECT DISTINCT tu_template_id FROM template_users) ".
411 " ORDER BY cl_list_id,cl_list_item_long";
412 $resorphan = sqlStatement($sqlorphan);
413 while($roworphan = sqlFetchArray($resorphan)){
415 if(!$_REQUEST['filter_context']){
416 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($roworphan['cl_list_id']));
417 $cntxt.=$context['cl_list_item_long']."->";
419 echo "<option value='".htmlspecialchars($roworphan['cl_list_slno']."|",ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$roworphan['cl_list_item_long'],ENT_QUOTES
)."</option>";
425 <input type
="button" name
="remove" value
=»
; onclick
="jsub_selected(document.myform,'personalized','topersonalized')"></br
>
426 <input type
="button" name
="remove" value
=«
; onclick
="check_user_category(document.myform,'topersonalized','personalized')">
429 <select multiple name
="personalized[]" id
="personalized" size
="6" style
="width:220px">
432 if($_REQUEST['filter_context']){
433 $where .=" AND cl_list_id='".$_REQUEST['filter_context']."'";
435 $sql = "SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS c ON tu.tu_template_id=c.cl_list_slno WHERE
436 tu.tu_user_id=? AND c.cl_list_type=3 AND cl_deleted=0 ".
438 "ORDER BY c.cl_list_item_long";
439 $resTemplates = sqlStatement($sql,array($_SESSION['authId']));
440 while($rowTemplates = sqlFetchArray($resTemplates)){
442 if(!$_REQUEST['filter_context']){
443 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($rowTemplates['cl_list_id']));
444 $cntxt.=$context['cl_list_item_long']."->";
446 echo "<option value='".htmlspecialchars($rowTemplates['cl_list_slno']."|".$rowTemplates['tu_user_id'],ENT_QUOTES
)."'>".htmlspecialchars($cntxt.$rowTemplates['cl_list_item_long'],ENT_QUOTES
)."</option>";
455 <td
><input type
="hidden" name
="submitform" id
="submitform" value
=""></td
>
459 <div style
="width:100%;overflow:auto;height:150px" id
="itemdiv"></div
>