1<?php
2require_once("classes/DBUtils.class.php");
3
4$edit_table = isset( $_POST['edit_table'] ) ? $_POST['edit_table'] : '';
5?>
6<script language="JavaScript">
7<!--
8function addEntry()
9{
10	if (document.addForm.new_desc.value == "")
11	{
12		alert("<?php echo $LangUI->_("Please enter a value for your new entry");?>");
13		document.addForm.new_desc.focus();
14	}
15	else
16		document.addForm.submit();
17}
18// -->
19</script>
20<table cellspacing="0" cellpadding="1" border="0" width="100%">
21<tr>
22	<td align="left" class="title"><?php echo $LangUI->_('Customize DropDowns');?></td>
23</tr>
24</table>
25<P>
26
27<?php
28// The listing of the users
29if ($SMObj->checkAccessLevel($SMObj->getSuperUserLevel())) {
30?>
31<form action="./index.php?m=admin&a=customize" method="POST">
32<table  cellspacing="1" cellpadding="2" border="0" class="data">
33	<tr>
34		<td><?php echo $LangUI->_('Table to Customize');?>:</td>
35		<td>
36			<?php
37			// Workaround to put the values in the dropdown
38			$arr = array(
39				$db_table_ethnicity => $LangUI->_('Ethnicity'),
40				$db_table_bases => $LangUI->_('Bases'),
41				$db_table_prep_time => $LangUI->_('Preparation Time'),
42				$db_table_courses => $LangUI->_('Courses'),
43				$db_table_difficulty => $LangUI->_('Difficulty'),
44				$db_table_locations => $LangUI->_('Store Sections'),
45				$db_table_prices => $LangUI->_('Restaurant Prices'),
46				$db_table_meals => $LangUI->_('Meals'),
47				$db_table_sources => $LangUI->_('Sources')
48			);
49			echo DBUtils::arraySelect( $arr, 'edit_table', 'size=1', $edit_table );
50			?>
51		</td>
52		<td>
53			<input type="submit" value="<?php echo $LangUI->_('Edit Table');?>" class="button">
54		</td>
55	</tr>
56</table>
57</form>
58
59<?php
60	if ($edit_table != "") {
61		$counter=0;
62		$sql = "SELECT * FROM " . $DB_LINK->addq($edit_table, get_magic_quotes_gpc()) . " ORDER BY " . $DB_LINK->addq($db_fields[$edit_table][0], get_magic_quotes_gpc());
63		$rc = $DB_LINK->Execute( $sql );
64		DBUtils::checkResult($rc, NULL, NULL, $sql);
65?>
66<form action="./index.php?m=admin&a=customize&dosql=update_customize" method="POST">
67<input type="hidden" name="mode" value="update">
68<input type="hidden" name="edit_table" value="<?php echo $edit_table;?>">
69<table cellspacing="1" cellpadding="2" border="0" class="data">
70	<th><?php echo $LangUI->_('Delete');?></th>
71	<th><?php echo $LangUI->_('Description');?></th>
72
73	<?php while (!$rc->EOF) { ?>
74	<tr>
75		<td>
76			<input type="hidden" name="entry_<?php echo $counter;?>" value="<?php echo $rc->fields[0];?>">
77			<input type="checkbox" name="delete_<?php echo $counter;?>" value="yes">
78		</td>
79		<td>
80			<input type="textbox" size="40" name="desc_<?php echo $counter . '" value="' . $rc->fields[1];?>">
81		</td>
82	</tr>
83			<?php if (count($db_fields[$edit_table]) == 3) { ?>
84	<tr>
85			<td></td>
86			<td>
87				<textarea cols="60" rows="15" name="text_<?php echo $counter;?>"><?php echo $rc->fields[2];?></textarea>
88			</td>
89	</tr>
90	<?php
91			}
92			$rc->MoveNext();
93			$counter++;
94		}
95?>
96	<tr>
97		<td colspan=3>
98			<input type="hidden" name="total_entries" value="<?php echo $counter;?>">
99			<input type="submit" value="<?php echo $LangUI->_('Update');?>" class="button">
100		</td>
101	</tr>
102</table>
103</form>
104
105<P>
106<form action="./index.php?m=admin&a=customize&dosql=update_customize" name="addForm" method="POST">
107<table cellspacing="1" cellpadding="2" border="0" class="data">
108	<tr>
109		<td>
110			<?php echo $LangUI->_('Create new entry');?>:
111		</td>
112		<td>
113			<input type="hidden" name="edit_table" value="<?php echo $edit_table;?>">
114			<input type="hidden" name="mode" value="add">
115			<input type="textbox" name="new_desc">
116		</td>
117		<td colspan=2>
118			<input type="button" value="<?php echo $LangUI->_('Add Entry');?>" onClick="Javascript:addEntry();" class="button">
119		</td>
120		</tr>
121		<?php if (count($db_fields[$edit_table]) == 3) { ?>
122		<tr>
123			<td></td>
124			<td colspan="2"><textarea cols="60" rows="15"  name="new_text"></textarea></td>
125		</tr>
126		<?php } ?>
127
128</table>
129</form>
130<P>
131<?php
132	}
133} else {
134	// They are not an admin, so give them an error message
135	echo $LangUI->_('You do not have permission to customize the database') . "<br />";
136}
137?>
138