minor bug fix
[openemr.git] / library / custom_template / delete_category.php
blob64e73f656a194822d93cdda13a5397829fb4f014
1 <?php
2 // +-----------------------------------------------------------------------------+
3 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
4 //
5 //
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.
22 //
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 $res=sqlStatement("SELECT * FROM customlists as cl left outer join users as u on cl_creator=u.id WHERE cl_list_type=3 AND cl_deleted=0");
39 <html>
40 <head>
41 <title><!-- Insert your title here --></title>
42 <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.css" media="screen" />
43 <script type="text/javascript" src="ckeditor/ckeditor.js"></script>
44 <script src="ckeditor/_samples/sample.js" type="text/javascript"></script>
45 <link href="ckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
46 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
47 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/dialog.js"></script>
48 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script>
49 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui-1.7.1.custom.min.js"></script>
50 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/common.js"></script>
51 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/fancybox/jquery.fancybox-1.2.6.js"></script>
52 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery-ui.js"></script>
53 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.easydrag.handler.beta2.js"></script>
54 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/ajax_functions_writer.js"></script>
55 <script type='text/javascript'>
56 function delete_full_category(id){
57 top.restoreSession();
58 $.ajax({
59 type: "POST",
60 url: "ajax_code.php",
61 dataType: "html",
62 data: {
63 templateid: id,
64 source: "delete_full_category"
66 success: function(thedata){
67 alert("<?php echo addslashes(xl('Deleted Successfully.'));?>");
68 document.location.reload();
70 error:function(){
72 });
73 return;
75 function delete_category(id){
76 top.restoreSession();
77 if(confirm("<?php echo addslashes(xl('Do you want to delete?'));?>")){
78 $.ajax({
79 type: "POST",
80 url: "ajax_code.php",
81 dataType: "html",
82 data: {
83 templateid: id,
84 source: "delete_category"
86 success: function(thedata){
87 if(thedata){
88 alert("<?php echo addslashes('There are currently other users of the category you are trying to delete. Please contact them and ask them to delete it. Categories may not be deleted while in use. This Categories are currently used by \n');?>"+thedata);
90 else{
91 delete_full_category(id);
94 error:function(){
96 });
98 return;
101 </script>
102 </head>
103 <body class="body_top">
104 <form name="myform">
105 <table align="center">
106 <tr class="text reportTableHeadRow">
107 <th><?php echo htmlspecialchars('Sl.No',ENT_QUOTES);?></th>
108 <th><?php echo htmlspecialchars(xl('Category'),ENT_QUOTES);?></th>
109 <th><?php echo htmlspecialchars(xl('Context'),ENT_QUOTES);?></th>
110 <th><?php echo htmlspecialchars(xl('Creator'),ENT_QUOTES);?></th>
111 <th><?php echo htmlspecialchars(xl('Delete'),ENT_QUOTES);?></th>
112 </tr>
113 <?php
114 $i=0;
115 while($row=sqlFetchArray($res)){
116 $context=sqlQuery("SELECT * FROM customlists WHERE cl_list_slno=?",array($row['cl_list_id']));
117 $i++;
118 $class = ($class=='reportTableOddRow') ? 'reportTableEvenRow' : 'reportTableOddRow';
119 echo "<tr class='text ".htmlspecialchars($class,ENT_QUOTES)."'>";
120 echo "<td>".$i."</td>";
121 echo "<td>".htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES)."</td>";
122 echo "<td>".htmlspecialchars($context['cl_list_item_long'],ENT_QUOTES)."</td>";
123 echo "<td>".htmlspecialchars($row['fname']." ".$row['mname']." ".$row['lname'],ENT_QUOTES)."</td>";
124 echo "<td><a href=#>";
125 echo "<img src='../../interface/pic/Delete.gif' border=0 title='Delete This Row' onclick=delete_category('".htmlspecialchars($row['cl_list_slno'],ENT_QUOTES)."')>";
126 echo "</a></td>";
127 echo "</tr>";
129 echo "</table>";