support for multiple price levels, tax rates, related codes, non-prescription products
[openemr.git] / interface / super / edit_list.php
blobffedd2c97735ba368ed8e8231d98dd38ada536b0
1 <?php
2 // Copyright (C) 2007 Rod Roark <rod@sunsetsystems.com>
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License
6 // as published by the Free Software Foundation; either version 2
7 // of the License, or (at your option) any later version.
9 require_once("../globals.php");
10 require_once("$srcdir/acl.inc");
12 $lists = array(
13 'language' => xl('Language'),
14 'marital' => xl('Marital Status'),
15 'pricelevel' => xl('Price Level'),
16 'ethrace' => xl('Race/Ethnicity'),
17 'risklevel' => xl('Risk Level'),
18 'sex' => xl('Sex'),
19 'taxrate' => xl('Tax Rate'),
20 'titles' => xl('Titles'),
21 'yesno' => xl('Yes/No'),
22 'boolean' => xl('Boolean'),
23 'userlist1' => xl('User Defined List 1'),
24 'userlist2' => xl('User Defined List 2'),
27 $list_id = empty($_REQUEST['list_id']) ? 'language' : $_REQUEST['list_id'];
29 // Check authorization.
30 $thisauth = acl_check('admin', 'super');
31 if (!$thisauth) die("Not authorized.");
33 $opt_line_no = 0;
35 // Write one option line to the form.
37 function writeOptionLine($option_id, $title, $seq, $default, $value) {
38 global $opt_line_no, $list_id;
39 ++$opt_line_no;
40 $bgcolor = "#" . (($opt_line_no & 1) ? "ddddff" : "ffdddd");
41 $checked = $default ? " checked" : "";
43 echo " <tr bgcolor='$bgcolor'>\n";
45 echo " <td align='center' class='optcell'>";
46 echo "<input type='text' name='opt[$opt_line_no][id]' value='" .
47 htmlspecialchars($option_id, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
48 echo "</td>\n";
50 echo " <td align='center' class='optcell'>";
51 echo "<input type='text' name='opt[$opt_line_no][title]' value='" .
52 htmlspecialchars($title, ENT_QUOTES) . "' size='20' maxlength='63' class='optin' />";
53 echo "</td>\n";
55 echo " <td align='center' class='optcell'>";
56 echo "<input type='text' name='opt[$opt_line_no][seq]' value='" .
57 htmlspecialchars($seq, ENT_QUOTES) . "' size='4' maxlength='10' class='optin' />";
58 echo "</td>\n";
60 echo " <td align='center' class='optcell'>";
61 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1'$checked class='optin' />";
62 echo "</td>\n";
64 if ($list_id == 'taxrate') {
65 echo " <td align='center' class='optcell'>";
66 echo "<input type='text' name='opt[$opt_line_no][value]' value='" .
67 htmlspecialchars($value, ENT_QUOTES) . "' size='8' maxlength='15' class='optin' />";
68 echo "</td>\n";
71 echo " </tr>\n";
74 <html>
76 <head>
78 <link rel=stylesheet href='<?php echo $css_header ?>' type='text/css'>
79 <title><?php xl('List Editor','e'); ?></title>
81 <style>
82 tr.head { font-size:10pt; background-color:#cccccc; text-align:center; }
83 tr.detail { font-size:10pt; }
84 td { font-size:10pt; }
85 input { font-size:10pt; }
86 a, a:visited, a:hover { color:#0000cc; }
87 .optcell { }
88 .optin { background-color:transparent; }
89 </style>
91 <script type="text/javascript" src="../../library/dialog.js"></script>
93 <script language="JavaScript">
94 </script>
96 </head>
98 <body <?php echo $top_bg_line;?>>
100 <?php
101 // If we are saving, then save.
103 if ($_POST['form_save'] && $list_id) {
104 $opt = $_POST['opt'];
105 sqlStatement("DELETE FROM list_options WHERE list_id = '$list_id'");
106 for ($lino = 1; isset($opt["$lino"]['id']); ++$lino) {
107 $iter = $opt["$lino"];
108 $value = empty($iter['value']) ? 0 : (trim($iter['value']) + 0);
109 if (strlen(trim($iter['id'])) > 0) {
110 sqlInsert("INSERT INTO list_options ( " .
111 "list_id, option_id, title, seq, is_default, option_value " .
112 ") VALUES ( " .
113 "'$list_id', " .
114 "'" . trim($iter['id']) . "', " .
115 "'" . trim($iter['title']) . "', " .
116 "'" . trim($iter['seq']) . "', " .
117 "'" . trim($iter['default']) . "', " .
118 "'" . $value . "' " .
119 ")");
124 // Get the selected list's elements.
125 if ($list_id) {
126 $res = sqlStatement("SELECT * FROM list_options WHERE " .
127 "list_id = '$list_id' ORDER BY seq");
131 <form method='post' name='theform' action='edit_list.php'>
133 <p><b>Edit list:</b>&nbsp;
134 <select name ='list_id' onchange='form.submit()'>
135 <?php
136 foreach ($lists as $key => $value) {
137 echo "<option value='$key'";
138 if ($key == $list_id) echo " selected";
139 echo ">$value</option>\n";
142 </select></p>
144 <center>
146 <table cellpadding='2' cellspacing='0'>
147 <tr class='head'>
148 <td title='Click to edit'><b><?php xl('ID','e'); ?></b></td>
149 <td><b><?php xl('Title','e'); ?></b></td>
150 <td><b><?php xl('Order','e'); ?></b></td>
151 <td><b><?php xl('Default','e'); ?></b></td>
152 <?php if ($list_id == 'taxrate') { ?>
153 <td><b><?php xl('Rate','e'); ?></b></td>
154 <?php } ?>
155 </tr>
157 <?php
158 while ($row = sqlFetchArray($res)) {
159 writeOptionLine($row['option_id'], $row['title'], $row['seq'],
160 $row['is_default'], $row['option_value']);
163 for ($i = 0; $i < 3; ++$i) {
164 writeOptionLine('', '', '', '', 0);
168 </table>
171 <input type='submit' name='form_save' value='<?php xl('Save','e'); ?>' />
172 </p>
173 </center>
175 </form>
176 </body>
177 </html>