-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_select.php
53 lines (48 loc) · 2.28 KB
/
main_select.php
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
<?php
echo "<div id='main_select'>\n";
$coder = mysqli_query($dbc, "SELECT * FROM clients ".($userinfo['admin']!='1'?" LEFT JOIN staff_clients ON clients.id=staff_clients.clientID WHERE staff_clients.staffID='{$userinfo['id']}'":''));
// -- CODEMENU START
if(mysqli_num_rows($coder)>0){
echo "<form method=\"GET\" action=\"$PHP_SELF\" id='search_c' style='display:inline'>\n";
echo "<select name=\"clientID\" onchange='document.forms[\"search_c\"].submit();'>\n";
echo "<option value=''>Sort by Client</option>";
while ($code = (mysqli_fetch_assoc($coder))) {
if($clientID==$code['id']) $thisClient=$code;
echo "<option value=\"" . $code['id'] . "\" ".($clientID==$code['id']?'selected="selected"':'').">" . $code['name'];
if ($code['code']) {
echo " - " . $code['code'];
}
echo "</option>\n";
}
echo "</select>\n";
echo "</form>";
}
// -- CODEMENU ENDS
if($userinfo['admin']==1){
$staffr = mysqli_query($dbc, "SELECT * FROM staff");
if(mysqli_num_rows($staffr)>0){
// -- STAFFMENU START
echo "<form method=\"GET\" action=\"$PHP_SELF\" id='search_s' style='display:inline; margin-right:20px;'>\n";
echo "<select name=\"staffID\" onchange='document.forms[\"search_s\"].submit();'>\n";
echo "<option value=''>Sort by Staff</option>";
while ($staff = (mysqli_fetch_assoc($staffr))) {
if($staffID==$staff['id']) $thisStaff=$staff;
$fullname = $staff['firstname'] . " " . $staff['lastname'];
echo "<option value=\"" . $staff['id'] . "\" ".($thisStaff['id']==$staff['id']?'selected="selected"':'').">" . $fullname;
echo "</option>\n";
}
echo "</select>\n";
// -- STAFFMENU ENDS
echo "</form>";
}
if(!empty($staffID) && !empty($thisStaff)) echo " | <a href='staff_profile.php?staffID={$staffID}' class='main_btn'>edit {$thisStaff['firstname']}</a>";
if(!empty($clientID) && !empty($thisClient)) {
echo " | <a href='client_profile.php?clientID={$clientID}' class='main_btn'>edit {$thisClient['name']}</a>";
if(mysqli_num_rows($result)>0)
echo " | <a href='pdf.php?clientID={$clientID}' class='main_btn'>create report for {$thisClient['name']}</a>";
}
// echo "<input type=\"submit\" name=\"submit\" value=\"Add\">\n";
}
echo "</form>";
echo "</div>"; // end main_select
?>