3 // +-----------------------------------------------------------------------------+
4 // Copyright (C) 2011 Z&H Consultancy Services Private Limited <sam@zhservices.com>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
19 // A copy of the GNU General Public License is included along with this program:
20 // openemr/interface/login/GnuGPL.html
21 // For more information write to the Free Software
22 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 // Author: Eldho Chacko <eldho@zhservices.com>
25 // Jacob T Paul <jacob@zhservices.com>
27 // +------------------------------------------------------------------------------+
31 require_once("../../interface/globals.php");
33 use OpenEMR\Core\Header
;
35 if (trim($_POST['contextname']) != '' && $_POST['action'] == 'add') {
36 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0 AND cl_list_item_long=?", array($_POST['contextname']));
37 if (!sqlNumRows($res)) {
38 $id = sqlInsert("INSERT INTO customlists (cl_list_type,cl_list_item_long) VALUES(?,?)", array(2,$_POST['contextname']));
39 sqlStatement("UPDATE customlists SET cl_list_id=? WHERE cl_list_slno=?", array($id,$id));
41 } elseif ($_POST['action'] == 'delete' && $_POST['item'] != '') {
42 sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_type=2 AND cl_list_slno=?", array($_POST['item']));
43 } elseif ($_POST['action'] == 'update' && $_POST['item'] != '') {
44 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']));
49 <?php Header
::setupHeader('opener'); ?
>
52 border
-bottom
: 1px solid
var(--black
);
55 border
-top
: 1px solid
var(--black
);
58 border
-left
: 1px solid
var(--black
);
61 border
-right
:1px solid
var(--black
);
64 background
-color
: #add9e9;
67 background
-color
: #b1c0a5;
72 $
('#contextadd').hide();
73 $
('#contextupdate').hide();
74 $
('#addcontextbtn').click(function() {
75 $
('#contextadd').show(600);
76 $
('#contextlist').hide(600);
77 $
('#addcontextbtn').hide(600);
80 $
('#cancel').click(function() {
81 $
('#contextadd').hide(600);
82 $
('#contextlist').show(600);
83 $
('#addcontextbtn').show(600);
86 $
('#ucancel').click(function() {
87 $
('#contextupdate').hide(600);
88 $
('#contextlist').show(600);
89 $
('#addcontextbtn').show(600);
93 function checkSubmit(){
95 if(document
.getElementById('contextname').value
){
96 document
.getElementById('action').value
='add';
97 document
.designation_managment
.submit();
100 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
103 function deleteme(id
){
104 top
.restoreSession();
106 CheckContextLive(id
);
107 stat
= document
.getElementById('stat').value
;
109 msg
= "<?php echo addslashes(xl('This context contains categories, which will be deleted. Do you still want to continue?'));?>";
112 msg
= "<?php echo addslashes(xl('Do you want to delete this?'));?>";
115 document
.getElementById('action').value
='delete';
116 document
.getElementById('item').value
=id
;
117 document
.designation_managment
.submit();
120 function editme(id
,val
){
121 top
.restoreSession();
122 $
('#contextupdate').show(600);
123 $
('#contextlist').hide(600);
124 $
('#addcontextbtn').hide(600);
125 document
.getElementById('item').value
=id
;
126 document
.getElementById('updatecontextname').value
=val
;
128 function checkUpdate(){
129 top
.restoreSession();
130 if(document
.getElementById('updatecontextname').value
){
131 document
.getElementById('action').value
='update';
132 document
.designation_managment
.submit();
135 alert("<?php echo addslashes(xl('Context name can\'t be empty'));?>");
138 function CheckContextLive(id
){
139 top
.restoreSession();
142 url
: "ajax_code.php",
146 source
: "checkcontext"
149 success
: function(thedata
){
150 document
.getElementById('stat').value
=thedata
;
161 <body
class="body_top">
162 <form name
="designation_managment" action
="" method
="post">
163 <table cellpadding
='2' cellspacing
='0' border
="0" align
="center">
166 <td
class='title_bar' colspan
="4" align
="center"><u
><?php
echo htmlspecialchars(xl('Add Context'), ENT_QUOTES
);?
></u
></td
>
167 <td
class='title_bar' align
="center"><a href
="#" id
="addcontextbtn" class="btn btn-primary"><span
><?php
echo htmlspecialchars(xl('Add'), ENT_QUOTES
);?
></span
></a
></td
>
169 <tr id
="contextlist">
173 <td align
="center" class="title_bar_top top right bottom left">#</td>
174 <td align
="center" class="title_bar_top top right bottom"><?php
echo htmlspecialchars(xl('Context'), ENT_QUOTES
);?
></td
>
175 <td align
="center" class="title_bar_top top right bottom"><?php
echo htmlspecialchars(xl('Edit'), ENT_QUOTES
);?
></td
>
176 <td align
="center" class="title_bar_top top right bottom"><?php
echo htmlspecialchars(xl('Delete'), ENT_QUOTES
);?
></td
>
179 $res = sqlStatement("SELECT * FROM customlists WHERE cl_list_type=2 AND cl_deleted=0");
181 while ($row = sqlFetchArray($res)) {
183 $class = ($class == 'class1') ?
'class2' : 'class1';
185 <tr
class="text <?php echo $class;?>">
186 <td
class="right bottom left"><?php
echo htmlspecialchars($i, ENT_QUOTES
);?
></td
>
187 <td
class="right bottom"><?php
echo htmlspecialchars(xl($row['cl_list_item_long']), ENT_QUOTES
);?
></td
>
188 <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
='<?php echo $GLOBALS['images_static_relative
']; ?>/b_edit.png' border
=0></a
></td
>
189 <td
class="right bottom"><a href
="#" onclick
="deleteme(<?php echo htmlspecialchars($row['cl_list_slno'], ENT_QUOTES);?>)"><img src
='<?php echo $GLOBALS['images_static_relative
']; ?>/deleteBtn.png' border
=0></a
></td
>
198 <td colspan
="3"><input type
="text" name
="contextname" id
="contextname"></td
>
199 <td colspan
="1"><a href
="#" onclick
="checkSubmit()" class="btn btn-primary"><span
><?php
echo htmlspecialchars(xl('Save'), ENT_QUOTES
);?
><a href
="#" id
="cancel" class="btn btn-secondary"><span
><?php
echo htmlspecialchars(xl('Cancel'), ENT_QUOTES
);?
></span
></a
></span
></a
></td
>
201 <tr id
="contextupdate">
202 <td colspan
="3"><input type
="text" name
="updatecontextname" id
="updatecontextname"></td
>
203 <td colspan
="1"><a href
="#" onclick
="checkUpdate()" class="btn btn-primary"><span
><?php
echo htmlspecialchars(xl('Update'), ENT_QUOTES
);?
><a href
="#" id
="ucancel" class="btn btn-secondary"><span
><?php
echo htmlspecialchars(xl('Cancel'), ENT_QUOTES
);?
></span
></a
></span
></a
></td
>
205 <input type
="hidden" name
="action" id
="action">
206 <input type
="hidden" name
="item" id
="item">
207 <input type
="hidden" name
="stat" id
="stat">