Add Portal Two Features
[openemr.git] / library / custom_template / add_custombutton.php
blob7ad6531876ccdc7f02fc4c5d2927b2253ca4512c
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 // +------------------------------------------------------------------------------+
29 require_once("../../interface/globals.php");
30 if ((isset($_POST['form_save']) && $_POST['form_save'] == 'Save') || (isset($_POST['form_delete']) && $_POST['form_delete'] == 'Delete')) {
31 $count = $_POST['count'];
32 $k = 1;
33 $sta = $_POST['start'];
34 $end = $st + $count;
35 for ($cnt = $sta; $cnt <= $end; $cnt++) {
36 if ($_POST['hidid' . $cnt]) {
37 if (trim(formData('inshort' . $cnt)) == '' && trim(formdata('designation' . $cnt)) == '') {
38 sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_slno=?", array($_POST['hidid' . $cnt]));
39 sqlStatement("DELETE FROM template_users WHERE tu_template_id=? AND tu_user_id=?", array($_POST['hidid' . $cnt], $_SESSION['authId']));
40 } else {
41 $sql = "UPDATE customlists SET cl_list_item_short=?,cl_list_item_long=?,cl_order=? WHERE cl_list_slno=?";
42 sqlStatement($sql, array($_POST['inshort' . $cnt], $_POST['designation' . $cnt], $_POST['level' . $cnt], $_POST['hidid' . $cnt]));
44 } else {
45 if (trim(formData('inshort' . $cnt)) != '' || trim(formdata('designation' . $cnt)) != '') {
46 $rowID = sqlQuery("SELECT MAX(cl_list_item_id)+1 as maxID FROM customlists WHERE cl_list_type=6");
47 $itemID = $rowID['maxID'] ? $rowID['maxID'] : 1;
48 $sql = "INSERT INTO customlists (cl_list_item_id,cl_list_type,cl_list_item_short,cl_list_item_long,cl_order) VALUES(?,?,?,?,?)";
49 $newid = sqlInsert($sql, array($itemID, 6, $_POST['inshort' . $cnt], $_POST['designation' . $cnt], $_POST['level' . $cnt]));
50 sqlStatement("INSERT INTO template_users (tu_user_id,tu_template_id) VALUES (?,?)", array($_SESSION['authId'], $newid));
53 if ($_POST['form_delete'] == 'Delete') {
54 if ($_POST['chk' . $cnt]) {
55 sqlStatement("UPDATE customlists SET cl_deleted=1 WHERE cl_list_slno=?", array($_POST['chk' . $cnt]));
56 sqlStatement("DELETE FROM template_users WHERE tu_template_id=? AND tu_user_id=?", array($_POST['chk' . $cnt], $_SESSION['authId']));
60 unset($_POST['form_save']);
61 unset($_POST['form_delete']);
64 <html>
65 <head>
66 <link rel="stylesheet" href="<?php echo $css_header; ?>" type="text/css">
67 <script type="text/javascript"
68 src="<?php echo $webroot ?>/interface/main/tabs/js/include_opener.js?v=<?php echo $v_js_includes; ?>"></script>
69 <script type="text/javascript"
70 src="<?php echo $GLOBALS['assets_static_relative']; ?>/jquery/dist/jquery.min.js"></script>
71 <style>
72 .bottom {
73 border-bottom: 1px solid black;
76 .top {
77 border-top: 1px solid black;
80 .left {
81 border-left: 1px solid black;
84 .right {
85 border-right: 1px solid black;
88 .class1 {
89 background-color: #7dc1db
92 .class2 {
93 background-color: #ef2983
95 </style>
96 </head>
97 <body class="body_top">
98 <form name="designation_managment" action="" method="post" onsubmit="top.restoreSession();">
99 <table cellpadding='2' cellspacing='0' border="0" align="center">
101 <tr height="30">
102 <td class='title_bar' colspan="4" align="center">
103 <u><?php echo htmlspecialchars(xl('Add Custom Button'), ENT_QUOTES); ?></u></td>
104 </tr>
106 <tr>
107 <td align="center" class="title_bar_top ">#</td>
108 <td align="center" class="title_bar_top "><?php echo htmlspecialchars(xl('Value'), ENT_QUOTES); ?></td>
109 <td align="center"
110 class="title_bar_top "><?php echo htmlspecialchars(xl('Display Name'), ENT_QUOTES); ?></td>
111 <td align="center" class="title_bar_top "><?php echo htmlspecialchars(xl('Order'), ENT_QUOTES); ?></td>
112 <td align="center" class="title_bar_top ">&nbsp;</td>
113 </tr>
114 <?php
115 $i = 1;
116 $res = sqlStatement("SELECT * FROM template_users AS tu LEFT OUTER JOIN customlists AS cl ON cl.cl_list_slno=tu.tu_template_id
117 WHERE tu.tu_user_id=? AND cl.cl_list_type=6 AND cl.cl_deleted=0 ORDER BY cl.cl_order", array($_SESSION['authId']));
118 $sl = 1;
119 $start = 1;
120 while ($row = sqlFetchArray($res)) {
121 if ($sl == 1) {
122 $start = $row['cl_list_slno'];
124 $i = $row['cl_list_slno'];
125 $class = 'class1';
127 <tr class='<?php echo htmlspecialchars($class, ENT_QUOTES); ?>'><input type='hidden'
128 name='<?php echo htmlspecialchars("hidid" . $i, ENT_QUOTES); ?>'
129 value='<?php echo htmlspecialchars($row['cl_list_slno'], ENT_QUOTES); ?>'>
130 <td align='center'><input type='text' name="<?php echo htmlspecialchars("sl" . $i, ENT_QUOTES); ?>"
131 value="<?php echo htmlspecialchars($sl, ENT_QUOTES); ?>" readonly=""
132 style="width:25px; background-color:#C9C9C9"/></td>
133 <td align='center'><input type='text' name="<?php echo htmlspecialchars("inshort" . $i, ENT_QUOTES); ?>"
134 size="10"
135 value="<?php echo htmlspecialchars($row['cl_list_item_short'], ENT_QUOTES); ?>"/>
136 </td>
137 <td align='center'><input type='text'
138 name="<?php echo htmlspecialchars("designation" . $i, ENT_QUOTES); ?>"
139 value="<?php echo htmlspecialchars($row['cl_list_item_long'], ENT_QUOTES); ?>"/>
140 </td>
141 <td align='center'><input type='text' name='<?php echo htmlspecialchars("level" . $i, ENT_QUOTES); ?>'
142 value="<?php echo htmlspecialchars($row['cl_order'], ENT_QUOTES); ?>" size=1>
143 </td>
144 <td align='center'><input type='checkbox' name='<?php echo htmlspecialchars("chk" . $i, ENT_QUOTES); ?>'
145 value='<?php echo htmlspecialchars($row['cl_list_slno'], ENT_QUOTES); ?>'>
146 </td>
147 </tr>
148 <?php
149 $i++;
150 $sl++;
153 <tr>
154 <td align='center'><input type='text' name="<?php echo htmlspecialchars('sl' . $i, ENT_QUOTES); ?>"
155 value="<?php echo htmlspecialchars($sl, ENT_QUOTES); ?>" readonly=""
156 style="width:25px; background-color:#C9C9C9"/></td>
157 <td align='center'><input type='text' name="<?php echo htmlspecialchars('inshort' . $i, ENT_QUOTES); ?>"
158 size="10" value=""/></td>
159 <td align='center'><input type='text' name="<?php echo htmlspecialchars('designation' . $i, ENT_QUOTES); ?>"
160 value=""/></td>
161 <td align='center'><input type='text' name='<?php echo htmlspecialchars("level" . $i, ENT_QUOTES); ?>'
162 size=1></td>
163 </tr>
164 <tr>
165 <td align='center'><input type='text' name="<?php echo htmlspecialchars('sl' . $i + 1, ENT_QUOTES); ?>"
166 value="<?php echo htmlspecialchars($sl + 1, ENT_QUOTES); ?>" readonly=""
167 style="width:25px; background-color:#C9C9C9"/></td>
168 <td align='center'><input type='text' name="<?php echo htmlspecialchars('inshort' . $i + 1, ENT_QUOTES); ?>"
169 size="10" value=""/></td>
170 <td align='center'><input type='text'
171 name="<?php echo htmlspecialchars('designation' . $i + 1, ENT_QUOTES); ?>"
172 value=""/></td>
173 <td align='center'><input type='text' name="<?php echo htmlspecialchars('level' . $i + 1, ENT_QUOTES); ?>"
174 size=1></td>
175 </tr>
176 <tr>
177 <td align='center'><input type='text' name="<?php echo htmlspecialchars('sl' . $i + 2, ENT_QUOTES); ?>"
178 value="<?php echo htmlspecialchars($sl + 2, ENT_QUOTES); ?>" readonly=""
179 style="width:25px; background-color:#C9C9C9"/></td>
180 <td align='center'><input type='text' name="<?php echo htmlspecialchars('inshort' . $i + 2, ENT_QUOTES); ?>"
181 size="10" value=""/></td>
182 <td align='center'><input type='text'
183 name="<?php echo htmlspecialchars('designation' . $i + 2, ENT_QUOTES); ?>"
184 value=""/></td>
185 <td align='center'><input type='text' name="<?php echo htmlspecialchars('level' . $i + 2, ENT_QUOTES); ?>"
186 size=1></td>
187 </tr>
188 <input type="hidden" name="count" value="<?php echo htmlspecialchars($i + 2, ENT_QUOTES); ?>">
189 <tr class="text">
190 <td colspan="5" align="center">
191 <input type='submit' name='form_save' id='form_save'
192 value="<?php echo htmlspecialchars(xl('Save'), ENT_QUOTES); ?>"/>
193 <input type='submit' name='form_delete' id='form_delete'
194 value="<?php echo htmlspecialchars(xl('Delete'), ENT_QUOTES); ?>"
195 title='<?php echo htmlspecialchars(xl('Select corresponding checkboxes to delete'), ENT_QUOTES); ?>'/>
196 </td>
197 </tr>
198 </table>
199 </form>
200 </body>
201 </html>