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
188
189
190
191
192
|
<?php if (!Util::isAdmin()) { header("Location: ../index.php" ); exit; }
$sql = "SELECT * FROM sys_login ORDER BY username"; $parameters = array(0); if (!($sth = $dbh->prepare($sql))) { throw new Exception("sql prepare statement failure: $sql"); } $sth->setFetchMode(PDO::FETCH_ASSOC); if (!$sth->execute($parameters)) { throw new Exception("sql execute statement failure: $sql"); } $staffs = $sth->fetchAll();
?>
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head>
<?php require(__DIR__ . '/../../inc/_head_meta.php'); ?>
<?php require(__DIR__ . '/../../inc/_head_css.php'); ?>
<style type="text/css"> body { padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */ padding-bottom: 40px; } </style>
<?php require(__DIR__ . '/../../inc/_head_script.php'); ?> <script type="text/javascript"> $(function() { $('.select2').select2(); }); </script> </head> <body>
<?php require( __DIR__ . '/../../inc/_navbar.php'); ?>
<div class="container">
<?php if (isset($message) && !empty($message)): ?> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">×</button> <h5 class="alert-heading">Note:</h5> <p><?=$message?></p> </div> <?php endif; ?>
<h2><?=empty($staff['id']) ? 'Add' : 'Modify'?> Staff</h2>
<form id="form" class="form-horizontal" method="post"> <?php $attribute = 'id'; ?> <input type="hidden" name="<?=$attribute?>" value="<?=h($staff[$attribute])?>" />
<div class="control-group"> <?php $attribute = 'role'; $label = 'Role'; ?> <label class="control-label"><?=$label?></label> <div class="controls"> <?php foreach ($roleOptions as $value => $label): ?> <label class="radio"> <input type="radio" name="<?=$attribute?>"<?=$staff[$attribute] == $value ? ' checked="checked"' : ''?> placeholder="<?=$label?>" value="<?=$value?>" class="required" /> <?=h($label)?> </label> <?php endforeach; ?> </div> </div> <div class="control-group"> <?php $attribute = 'username'; $label = 'User name'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="required" value="<?=h($staff[$attribute])?>" placeholder="<?=$label?>" /> </div> </div> <div class="control-group"> <?php $attribute = 'loginname'; $label = 'Login name'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="required" value="<?=h($staff[$attribute])?>" placeholder="<?=$label?>" /> </div> </div> <div class="control-group"> <?php $attribute = 'loginpw'; $label = 'Login password'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="password" id="<?=$attribute?>" name="<?=$attribute?>" class="<?=empty($staff['id']) ? 'required' : ''?>" value="" placeholder="<?=$label?>" /> </div> </div> <div class="control-group"> <?php $attribute = 'loginpw2'; $label = 'Re-enter password'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="password" id="<?=$attribute?>" name="<?=$attribute?>" value="" placeholder="<?=$label?>" /> </div> </div>
<div class="control-group"> <?php $attribute = 'email'; $label = 'Email'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="required email" value="<?=h($staff[$attribute])?>" placeholder="<?=$label?>" /> </div> </div>
<div class="control-group"> <?php $attribute = 'staff_tel_no'; $label = 'Staff Tel'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="text" id="<?=$attribute?>" name="<?=$attribute?>" class="required" value="<?=h($staff[$attribute])?>" placeholder="<?=$label?>" /> </div> </div>
<div class="control-group"> <?php $attribute = 'is_sales'; $label = 'Is Sales?'; ?> <label class="control-label" for="<?=$attribute?>"><?=$label?></label> <div class="controls"> <input type="checkbox" id="<?=$attribute?>" name="<?=$attribute?>" value="1" <?=$staff[$attribute] == 1 ? "checked" : ""; ?>/> </div> </div>
<?php if(Util::isAdmin()){ ?> <div class="control-group"> <?php $attribute = 'parentid'; $label = 'Staff Under'; ?> <label class="control-label" for="<?= $attribute ?>"><?= $label ?></label>
<div class="controls"> <select id="<?= $attribute ?>" name="<?= $attribute ?>" placeholder="Select a <?= $label ?>"class="select2" <?= Util::isAdmin() ? '' : ' disabled="disabled"' ?>> <option value=""></option> <?php foreach ($staffs as $_staff): if($_staff["role"] != 3){ ?> <option value="<?= h($_staff['id']) ?>"<?= $_staff['id'] == $staff[$attribute] ? ' selected="selected"' : '' ?>><?= $_staff['actived'] == 1 ? '' : '[Disabled] ' ?><?= h($_staff['username']) ?></option> <?php } endforeach; ?> </select> </div> </div> <?php } ?>
<?php if(!empty($staff['id'])){ ?> <div class="control-group"> <?php $attribute = 'actived'; $label = 'Status'; ?> <label class="control-label"><?=$label?></label> <div class="controls"> <label class="radio"> <input type="radio" name="<?=$attribute?>"<?=$staff[$attribute] == 1 ? ' checked="checked"' : ''?> placeholder="<?=$label?>" value="1" class="required" /> Enable<br> <input type="radio" name="<?=$attribute?>"<?=$staff[$attribute] == 0 ? ' checked="checked"' : ''?> placeholder="<?=$label?>" value="0" class="required" /> Disable </label>
</div> </div> <?php } ?>
<div class="control-group"> <div class="controls"> <button type="submit" class="btn btn-primary">Save</button> </div> </div>
</form>
<script type="text/javascript"> $(function() { $('.select2').select2(); $('#form').validate({ rules: { 'loginpw': { minlength: 4 }, 'loginpw2': { equalTo: '#loginpw' } } }); }); </script>
<?php require( __DIR__ . '/../../inc/_footer.php'); ?>
</div> <!-- /container --> </body> </html>
|