This repository has been archived by the owner on Apr 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
updatechi.php
173 lines (163 loc) · 6.58 KB
/
updatechi.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
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
<?php
if(isset($_POST['uptl'])){
if(!$_POST['chi']){
echo '<script type = "text/javascript">alert("Chưa nhập số tiền!!!")</script>';
echo '<script type = "text/javascript">window.location.reload();</script>';
}
$chi = $_POST['chi'];
$mabp = $_POST['mabp'];
$macv = $_POST['macv'];
if($_POST['ldthuong'] == 1 && ($mabp == 0 OR $macv == 0)){
$query = "UPDATE hosonv SET chidot1 = '$chi'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 2 && ($mabp == 0 OR $macv == 0)){
$query = "UPDATE hosonv SET chidot2 = '$chi'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 3 && ($mabp == 0 OR $macv == 0)){
$query = "UPDATE hosonv SET chidot3 = '$chi'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 4 && ($mabp == 0 OR $macv == 0)){
$query = "UPDATE hosonv SET chidot4 = '$chi'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 5 && ($mabp == 0 OR $macv == 0)){
$query = "UPDATE hosonv SET chidot5 = '$chi'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 1 && $mabp != 0 && $macv == 0){
$query = "UPDATE hosonv SET chidot1 = '$chi' WHERE bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 2 && $mabp != 0 && $macv == 0){
$query = "UPDATE hosonv SET chidot2 = '$chi' WHERE bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 3 && $mabp != 0 && $macv == 0){
$query = "UPDATE hosonv SET chidot3 = '$chi' WHERE bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 4 && $mabp != 0 && $macv == 0) {
$query = "UPDATE hosonv SET chidot4 = '$chi' WHERE bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 5 && $mabp != 0 && $macv == 0) {
$query = "UPDATE hosonv SET chidot5 = '$chi' WHERE bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 1 && $macv != 0 && $mabp == 0){
$query = "UPDATE hosonv SET chidot1 = '$chi' WHERE cvID = '$macv'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 2 && $macv != 0 && $mabp == 0){
$query = "UPDATE hosonv SET chidot2 = '$chi' WHERE cvID = '$macv'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 3 && $macv != 0 && $mabp == 0){
$query = "UPDATE hosonv SET chidot3 = '$chi' WHERE cvID = '$macv'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 4 && $macv != 0 && $mabp == 0) {
$query = "UPDATE hosonv SET chidot4 = '$chi' WHERE cvID = '$macv'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 5 && $macv != 0 && $mabp == 0) {
$query = "UPDATE hosonv SET chidot5 = '$chi' WHERE cvID = '$macv'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 1 && $macv != 0 && $mabp != 0) {
$query = "UPDATE hosonv SET chidot1 = '$chi' WHERE cvID = '$macv' AND bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 2 && $macv != 0 && $mabp != 0) {
$query = "UPDATE hosonv SET chidot2 = '$chi' WHERE cvID = '$macv' AND bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 3 && $macv != 0 && $mabp != 0) {
$query = "UPDATE hosonv SET chidot3 = '$chi' WHERE cvID = '$macv' AND bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 4 && $macv != 0 && $mabp != 0) {
$query = "UPDATE hosonv SET chidot4 = '$chi' WHERE cvID = '$macv' AND bophanID = '$mabp'";
$db->querySql($query);
}
if($_POST['ldthuong'] == 5 && $macv != 0 && $mabp != 0) {
$query = "UPDATE hosonv SET chidot5 = '$chi' WHERE cvID = '$macv' AND bophanID = '$mabp'";
$db->querySql($query);
}
}
$query = "SELECT * FROM bophan";
$db->querySql($query);
$arr_bp = $db->fetchToArray();
$query = "SELECT * FROM congty";
$db->querySql($query);
$arr_cv = $db->fetchToArray();
?>
<form action = "" method = "POST">
<div class="block-border">
<div class="block-header">
<h1>Cập Nhật Chi</h1>
</div>
<div class="block-content">
<table class="table">
<tr>
<td>
<h5>Mã Bộ Phận : </h5>
</td>
<td>
<p><select style = "width:200px" name = "mabp">
<option value = "0">Tất cả các bộ phận</option>
<?php
foreach($arr_bp as $bp){
if($_POST['mabp'] == $bp['bophanID']) $selected = " selected";
else $selected = "";
echo "<option value = '".$bp['bophanID']."' ".$selected.">".$bp['tenBPVi']."</option>";
}
?>
</select> </p>
</td>
</tr>
<tr>
<td>
<h5>Mã Chức Vụ : </h5>
</td>
<td>
<p><select style = "width:200px" name = "macv">
<option value = "0">Tất cả các chức vụ</option>
<?php
foreach($arr_cv as $cv){
if($_POST['macv'] == $cv['cvID']) $selected = " selected";
else $selected = "";
echo "<option value = '".$cv['cvID']."' ".$selected.">".$cv['tenCVVi']."</option>";
}
?>
</select> </p>
</td>
</tr>
<tr>
<td><h5>Số Lần Chi: </h5></td>
<td>
<p><select name = "ldthuong">
<option value = "1">Chi lần 2</option>
<option value = "2">Chi lần 3</option>
<option value = "3">Chi lần 4</option>
<option value = "4">Chi lần 5</option>
<option value = "5">Chi lần 6</option>
</select></p>
</td>
</tr>
<tr>
<td><h5>Nhập Chi : </h5></td>
<td><p><input style = "width:150px" type = "text" name = "chi" value = "" /></p></td>
</tr>
</table>
</div>
<div class="block-actions">
<ul class="actions-left">
<li><input class="button" type = "submit" name = "uptl" value = "Cập Nhập" onclick="return confirm('Bạn chắc chắn muốn thuốc hiện???');" /></li>
</ul>
</div>
</div>
</form>