Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / add_context.php
blob1865cf5cfc594549886bf981a42e215ca87fe530
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 if(trim($_POST['contextname'])!='' && $_POST['action']=='add'){
38 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0 AND cl_list_item_long=?",array($_POST['contextname']));
39 if(!sqlNumRows($res)){
40 $id = sqlInsert("INSERT INTO customlists (cl_list_type,cl_list_item_long) VALUES(?,?)",array(2,$_POST['contextname']));
41 sqlStatement("UPDATE customlists SET cl_list_id=? WHERE cl_list_slno=?",array($id,$id));
44 elseif($_POST['action']=='delete' && $_POST['item']!=''){
45 sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_type=2 AND cl_list_slno=?",array($_POST['item']));
47 elseif($_POST['action']=='update' && $_POST['item']!=''){
48 sqlStatement("UPDATE customlists SET cl_list_item_long=? WHERE cl_deleted=0 AND cl_list_type=2 AND cl_list_slno=?",array($_POST['updatecontextname'],$_POST['item']));
51 <html>
52 <head>
53 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
54 <style>
55 .bottom{border-bottom:1px solid black;}
56 .top{border-top:1px solid black;}
57 .left{border-left:1px solid black;}
58 .right{border-right:1px solid black;}
59 .class1{background-color:#add9e9}
60 .class2{background-color:#b1c0a5}
61 </style>
62 <script type="text/javascript" src="<?php echo $GLOBALS['webroot'] ?>/library/js/jquery.1.3.2.js"></script>
63 <script type="text/javascript">
64 $(document).ready(function() {
65 $('#contextadd').hide();
66 $('#contextupdate').hide();
67 $('#addcontextbtn').click(function() {
68 $('#contextadd').show(600);
69 $('#contextlist').hide(600);
70 $('#addcontextbtn').hide(600);
71 return false;
72 });
73 $('#cancel').click(function() {
74 $('#contextadd').hide(600);
75 $('#contextlist').show(600);
76 $('#addcontextbtn').show(600);
77 return false;
78 });
79 $('#ucancel').click(function() {
80 $('#contextupdate').hide(600);
81 $('#contextlist').show(600);
82 $('#addcontextbtn').show(600);
83 return false;
84 });
85 });
86 function checkSubmit(){
87 top.restoreSession();
88 if(document.getElementById('contextname').value){
89 document.getElementById('action').value='add';
90 document.designation_managment.submit();
92 else{
93 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
96 function deleteme(id){
97 top.restoreSession();
98 msg = '';
99 CheckContextLive(id);
100 stat = document.getElementById('stat').value;
101 if(stat==1){
102 msg = "<?php echo addslashes(xl('This context contains categories, which will be deleted. Do you still want to continue?'));?>";
104 else{
105 msg = "<?php echo addslashes(xl('Do you want to delete this?'));?>";
107 if(confirm(msg)){
108 document.getElementById('action').value='delete';
109 document.getElementById('item').value=id;
110 document.designation_managment.submit();
113 function editme(id,val){
114 top.restoreSession();
115 $('#contextupdate').show(600);
116 $('#contextlist').hide(600);
117 $('#addcontextbtn').hide(600);
118 document.getElementById('item').value=id;
119 document.getElementById('updatecontextname').value=val;
121 function checkUpdate(){
122 top.restoreSession();
123 if(document.getElementById('updatecontextname').value){
124 document.getElementById('action').value='update';
125 document.designation_managment.submit();
127 else{
128 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
131 function CheckContextLive(id){
132 top.restoreSession();
133 $.ajax({
134 type: "POST",
135 url: "ajax_code.php",
136 dataType: "html",
137 data: {
138 list_id: id,
139 source: "checkcontext"
141 async: false,
142 success: function(thedata){
143 document.getElementById('stat').value=thedata;
145 error:function(){
146 alert("fail");
149 return;
151 </script>
153 </head>
154 <body class="body_top">
155 <form name="designation_managment" action="" method="post">
156 <table cellpadding='2' cellspacing='0' border="0" align="center">
158 <tr height="30">
159 <td class='title_bar' colspan="4" align="center"><u><?php echo htmlspecialchars(xl('Add Context'),ENT_QUOTES);?></u></td>
160 <td class='title_bar' align="center"><a href="#" id="addcontextbtn" class="css_button"><span><?php echo htmlspecialchars(xl('Add'),ENT_QUOTES);?></span></a></td>
161 </tr>
162 <tr id="contextlist">
163 <td colspan="4">
164 <table>
165 <tr>
166 <td align="center" class="title_bar_top top right bottom left">#</td>
167 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Context'),ENT_QUOTES);?></td>
168 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Edit'),ENT_QUOTES);?></td>
169 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Delete'),ENT_QUOTES);?></td>
170 </tr>
171 <?php
172 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
173 $i = 0;
174 while($row = sqlFetchArray($res)){
175 $i++;
176 $class = ($class=='class1') ? 'class2' : 'class1';
178 <tr class="text <?php echo $class;?>">
179 <td class="right bottom left"><?php echo htmlspecialchars($i,ENT_QUOTES);?></td>
180 <td class="right bottom"><?php echo htmlspecialchars(xl($row['cl_list_item_long']),ENT_QUOTES);?></td>
181 <td class="right bottom"><a href="#" onclick='editme("<?php echo htmlspecialchars($row['cl_list_slno'],ENT_QUOTES);?>","<?php echo htmlspecialchars($row['cl_list_item_long'],ENT_QUOTES);?>")'><img src='../../images/b_edit.png' border=0></a></td>
182 <td class="right bottom"><a href="#" onclick="deleteme(<?php echo htmlspecialchars($row['cl_list_slno'],ENT_QUOTES);?>)"><img src='../../images/deleteBtn.png' border=0></a></td>
183 </tr>
184 <?php
187 </table>
188 </td>
189 </tr>
190 <tr id="contextadd">
191 <td colspan="3"><input type="text" name="contextname" id="contextname"></td>
192 <td colspan="1"><a href="#" onclick="checkSubmit()" class="css_button"><span><?php echo htmlspecialchars(xl('Save'),ENT_QUOTES);?><a href="#" id="cancel" class="css_button"><span><?php echo htmlspecialchars(xl('Cancel'),ENT_QUOTES);?></td>
193 </tr>
194 <tr id="contextupdate">
195 <td colspan="3"><input type="text" name="updatecontextname" id="updatecontextname"></td>
196 <td colspan="1"><a href="#" onclick="checkUpdate()" class="css_button"><span><?php echo htmlspecialchars(xl('Update'),ENT_QUOTES);?><a href="#" id="ucancel" class="css_button"><span><?php echo htmlspecialchars(xl('Cancel'),ENT_QUOTES);?></td>
197 </tr>
198 <input type="hidden" name="action" id="action">
199 <input type="hidden" name="item" id="item">
200 <input type="hidden" name="stat" id="stat">
201 </table>
202 </form>
203 </body>
204 </html>