1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
<?php require_once("check_login.php");
if (!empty($_GET['pid'])) { $pid = (int)$_GET['pid']; } else { $pid = 0; }
if (!empty($_GET['level_num'])) { $level_num = (int)$_GET['level_num']; } else { $level_num = 1; }
$sql = "SELECT * FROM menu WHERE parent_id = ? AND deleted = ? ORDER BY sort ASC "; $parameters = array((int)$pid, "0"); $row_array = bind_pdo($sql, $parameters, "selectall");
?> <!DOCTYPE html> <html> <head> <?php require_once('html_head.php'); ?>
<script type="text/javascript"> function DeleteRow(parent_id, id, sort) { if (confirm("Are you sure to delete this record?")) { window.location.href = 'menu_delete.php?parent_id=' + parent_id + '&id=' + id + '&sort=' + sort; } } </script> </head>
<body> <table width="1000" height="600" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="200" align="left" valign="top"> <table width="200" border="0" cellpadding="0" cellspacing="0"> <tr> <td height="70" align="left" valign="middle"> </td> </tr> <tr> <td width="200" align="left" valign="top"><!-- Main Menu --> <?php require("menu.php"); ?><!-- End Main Menu --></td> </tr> </table> </td> <td width="800" align="left" valign="top"> <table width="800" border="0" cellpadding="0" cellspacing="0"> <tr> <td> <table width="800" border="0" cellspacing="0" cellpadding="0"> <tr> <td height="70" class="pagetitletxt"> </td> <?php if (($pid) > 0) { echo '<td width="100" align="center" class="icontxt"><a href="menu_addform.php?pid=' . $pid . '&level_num='.($level_num+1).'"><img src="images/iconNew.png" alt="Add" width="32" height="32" border="0" /><br /> Add </a></td>'; } ?> </tr>
</table> </td> </tr> <tr> <td class="pagetitletxt"> <b><img src="images/iconList.jpg" width="48" height="48" align="absmiddle"/>Menu </b></td> </tr> <tr> <td height="25" align="left" valign="middle" class="msg"><?php if (!empty($_GET["msg"])) echo $msg; ?></td> </tr> <tr> <td height="35" align="left" valign="middle" class="content"><?php echo "<b><a href='menu_index.php?pid=0' />You are here: All Menu</a>" . getLevel($pid) . "</b>"; ?></td> </tr> <tr> <td align="left" valign="middle"> <form name="form1" method="post" action="menu_sort_update.php"> <table width="800" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="10" class="listtitletxt"></td> <td width="30" class="listtitletxt">Sort</td> <td width="600" class="listtitletxt">Page</td> <td width="20" class="listtitletxt"></td> <td width="20" class="listtitletxt"></td> </tr> <?php foreach ($row_array as $row) {
print "<tr>"; print "<td class='listtxt' style='padding-left:5'> </td>"; print "<td class='listtxt' style='padding-left:5'><input class='sortinput' type='text' name='idarraynumber[]' value='" . $row{'sort'} . "' size='2' /> <input type='hidden' name='idarray[]' value='" . $row{'id'} . "'><input type='hidden' name='pid' value='" . $row{'parent_id'} . "'></td>";
if (!empty($row{'name_en'})) { $name = $row{'name_en'}; } else if (!empty($row{'name_tc'})) { $name = $row{'name_tc'}; } else { }
if ($row{'level_num'} <= 2 && ($row{"id"} == 1 || $row{"id"} == 2 || $row{"id"} == 4 || $row["id"] > 9)) { $this_category = "<a href='menu_index.php?pid=" . $row{'id'} . "&level_num=".$row["level_num"]."'>" . $name . "</a>";
} else { $this_category = $name; }
print "<td class='listtxt' style='padding-left:5'>" . $this_category . "</td>";
//Status /*print "<td class='listtxt' align='center'>"; if ($row{'status'} == '1') // Enable { print "<a href='menu_status.php?id=" . $row{'id'} . "&parent_id=" . $row{'parent_id'} . "'>"; print "<img src='images/tick.png' title='Enable' alt='Enable' border='0' hspace='2'></a>"; } else // Disable { print "<a href='menu_status.php?id=" . $row{'id'} . "&parent_id=" . $row{'parent_id'} . "'>"; print "<img src='images/cross.png' title='Disable' alt='Disable' border='0' hspace='2'></a>"; } print "</td>";*/
// Modify print "<td class='listtxt' align='center'><a href='#' onClick=\"window.location='menu_modifyform.php?id=" . $row{'id'} . "&pid=" . $row["parent_id"] . "'\"><img src='images/btnModify.png' title='Modify' alt='Modify' hspace='2' border='0'></a></td>";
// Delete //check for parent_id 2 training service, if any course still link to this menu $sql = "select * from course_category where menu_id = ? and status = ? and deleted = ?"; $parameters = array($row["id"], 1, 0); $result = bind_pdo($sql, $parameters, "selectone");
if ($pid > 0 && empty($result)) { print "<td class='listtxt' align='center'><a href='#' onClick=\"DeleteRow(" . $row{'parent_id'} . ", " . $row{'id'} . ", " . $row{'sort'} . ")\"><img src='images/btnDelete.png' title='Delete' alt='Delete' hspace='2' border='0'></a></td>"; } else { print "<td class='listtxt' align='center'></td>"; }
print "</tr>"; } ?> </table> <input type="submit" value="Update Sort"></form> </td> </tr> </table> </td> </tr> </table> </body> </html> <?php // echo path function getLevel($p) { global $dbh; $n = ""; $sql1 = "select * from menu where id = ? and deleted = ?"; $parameters = array((int)$p, "0"); $result1 = bind_pdo($sql1, $parameters, "selectall");
foreach ($result1 as $row1) { if (!empty($row1{'name_en'})) { $name = $row1{'name_en'}; } else if (!empty($row1{'name_tc'})) { $name = $row1{'name_tc'}; } else {
}
if ($row1{"parent_id"} <> 0) { $n .= getLevel($row1{'parent_id'}) . " > <a href='menu_index.php?pid=" . $row1{'id'} . "'>" . $name . "</a>"; } else { $n = " > <a href='menu_index.php?pid=" . $row1{'id'} . "'>" . $name . "</a>"; } } return $n; }
|