2 // Copyright (C) 2007 Rod Roark <rod@sunsetsystems.com>
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");
13 'language' => xl('Language'),
14 'marital' => xl('Marital Status'),
15 'pricelevel' => xl('Price Level'),
16 'ethrace' => xl('Race/Ethnicity'),
17 'risklevel' => xl('Risk Level'),
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.");
35 // Write one option line to the form.
37 function writeOptionLine($option_id, $title, $seq, $default, $value) {
38 global $opt_line_no, $list_id;
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' />";
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' />";
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' />";
60 echo " <td align='center' class='optcell'>";
61 echo "<input type='checkbox' name='opt[$opt_line_no][default]' value='1'$checked class='optin' />";
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' />";
78 <link rel
=stylesheet href
='<?php echo $css_header ?>' type
='text/css'>
79 <title
><?php
xl('List Editor','e'); ?
></title
>
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; }
88 .optin
{ background
-color
:transparent
; }
91 <script type
="text/javascript" src
="../../library/dialog.js"></script
>
93 <script language
="JavaScript">
98 <body
<?php
echo $top_bg_line;?
>>
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 " .
114 "'" . trim($iter['id']) . "', " .
115 "'" . trim($iter['title']) . "', " .
116 "'" . trim($iter['seq']) . "', " .
117 "'" . trim($iter['default']) . "', " .
118 "'" . $value . "' " .
124 // Get the selected list's elements.
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
> 
;
134 <select name
='list_id' onchange
='form.submit()'>
136 foreach ($lists as $key => $value) {
137 echo "<option value='$key'";
138 if ($key == $list_id) echo " selected";
139 echo ">$value</option>\n";
146 <table cellpadding
='2' cellspacing
='0'>
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
>
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);
171 <input type
='submit' name
='form_save' value
='<?php xl('Save
','e
'); ?>' />