LBF custom template (nation notes) fancybox replace.
[openemr.git] / library / custom_template / add_context.php
blobe4e289dcedd536d621b3852c186f1e9c8bbd2d1a
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.
23 // Author: Eldho Chacko <eldho@zhservices.com>
24 // Jacob T Paul <jacob@zhservices.com>
26 // +------------------------------------------------------------------------------+
30 require_once("../../interface/globals.php");
31 if (trim($_POST['contextname'])!='' && $_POST['action']=='add') {
32 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0 AND cl_list_item_long=?", array($_POST['contextname']));
33 if (!sqlNumRows($res)) {
34 $id = sqlInsert("INSERT INTO customlists (cl_list_type,cl_list_item_long) VALUES(?,?)", array(2,$_POST['contextname']));
35 sqlStatement("UPDATE customlists SET cl_list_id=? WHERE cl_list_slno=?", array($id,$id));
37 } elseif ($_POST['action']=='delete' && $_POST['item']!='') {
38 sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_type=2 AND cl_list_slno=?", array($_POST['item']));
39 } elseif ($_POST['action']=='update' && $_POST['item']!='') {
40 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']));
43 <html>
44 <head>
45 <link rel="stylesheet" href="<?php echo $css_header;?>" type="text/css">
46 <style>
47 .bottom{border-bottom:1px solid black;}
48 .top{border-top:1px solid black;}
49 .left{border-left:1px solid black;}
50 .right{border-right:1px solid black;}
51 .class1{background-color:#add9e9}
52 .class2{background-color:#b1c0a5}
53 </style>
54 <script type="text/javascript" src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
55 <script type="text/javascript" src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery-min-3-1-1/index.js"></script>
56 <script type="text/javascript">
57 $(document).ready(function() {
58 $('#contextadd').hide();
59 $('#contextupdate').hide();
60 $('#addcontextbtn').click(function() {
61 $('#contextadd').show(600);
62 $('#contextlist').hide(600);
63 $('#addcontextbtn').hide(600);
64 return false;
65 });
66 $('#cancel').click(function() {
67 $('#contextadd').hide(600);
68 $('#contextlist').show(600);
69 $('#addcontextbtn').show(600);
70 return false;
71 });
72 $('#ucancel').click(function() {
73 $('#contextupdate').hide(600);
74 $('#contextlist').show(600);
75 $('#addcontextbtn').show(600);
76 return false;
77 });
78 });
79 function checkSubmit(){
80 top.restoreSession();
81 if(document.getElementById('contextname').value){
82 document.getElementById('action').value='add';
83 document.designation_managment.submit();
85 else{
86 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
89 function deleteme(id){
90 top.restoreSession();
91 msg = '';
92 CheckContextLive(id);
93 stat = document.getElementById('stat').value;
94 if(stat==1){
95 msg = "<?php echo addslashes(xl('This context contains categories, which will be deleted. Do you still want to continue?'));?>";
97 else{
98 msg = "<?php echo addslashes(xl('Do you want to delete this?'));?>";
100 if(confirm(msg)){
101 document.getElementById('action').value='delete';
102 document.getElementById('item').value=id;
103 document.designation_managment.submit();
106 function editme(id,val){
107 top.restoreSession();
108 $('#contextupdate').show(600);
109 $('#contextlist').hide(600);
110 $('#addcontextbtn').hide(600);
111 document.getElementById('item').value=id;
112 document.getElementById('updatecontextname').value=val;
114 function checkUpdate(){
115 top.restoreSession();
116 if(document.getElementById('updatecontextname').value){
117 document.getElementById('action').value='update';
118 document.designation_managment.submit();
120 else{
121 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
124 function CheckContextLive(id){
125 top.restoreSession();
126 $.ajax({
127 type: "POST",
128 url: "ajax_code.php",
129 dataType: "html",
130 data: {
131 list_id: id,
132 source: "checkcontext"
134 async: false,
135 success: function(thedata){
136 document.getElementById('stat').value=thedata;
138 error:function(){
139 alert("fail");
142 return;
144 </script>
146 </head>
147 <body class="body_top">
148 <form name="designation_managment" action="" method="post">
149 <table cellpadding='2' cellspacing='0' border="0" align="center">
151 <tr height="30">
152 <td class='title_bar' colspan="4" align="center"><u><?php echo htmlspecialchars(xl('Add Context'), ENT_QUOTES);?></u></td>
153 <td class='title_bar' align="center"><a href="#" id="addcontextbtn" class="css_button"><span><?php echo htmlspecialchars(xl('Add'), ENT_QUOTES);?></span></a></td>
154 </tr>
155 <tr id="contextlist">
156 <td colspan="4">
157 <table>
158 <tr>
159 <td align="center" class="title_bar_top top right bottom left">#</td>
160 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Context'), ENT_QUOTES);?></td>
161 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Edit'), ENT_QUOTES);?></td>
162 <td align="center" class="title_bar_top top right bottom"><?php echo htmlspecialchars(xl('Delete'), ENT_QUOTES);?></td>
163 </tr>
164 <?php
165 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
166 $i = 0;
167 while ($row = sqlFetchArray($res)) {
168 $i++;
169 $class = ($class=='class1') ? 'class2' : 'class1';
171 <tr class="text <?php echo $class;?>">
172 <td class="right bottom left"><?php echo htmlspecialchars($i, ENT_QUOTES);?></td>
173 <td class="right bottom"><?php echo htmlspecialchars(xl($row['cl_list_item_long']), ENT_QUOTES);?></td>
174 <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>
175 <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>
176 </tr>
177 <?php
180 </table>
181 </td>
182 </tr>
183 <tr id="contextadd">
184 <td colspan="3"><input type="text" name="contextname" id="contextname"></td>
185 <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>
186 </tr>
187 <tr id="contextupdate">
188 <td colspan="3"><input type="text" name="updatecontextname" id="updatecontextname"></td>
189 <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>
190 </tr>
191 <input type="hidden" name="action" id="action">
192 <input type="hidden" name="item" id="item">
193 <input type="hidden" name="stat" id="stat">
194 </table>
195 </form>
196 </body>
197 </html>