-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhienthi.php
112 lines (94 loc) · 3.92 KB
/
hienthi.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
<?php
include 'connect.php';
$sql="SELECT * FROM gv ";
if(isset($_POST['slnghi'])){
$magv=$_POST['slnghi'];
$sqlnghi = "SELECT macongviec FROM ctcongviec WHERE magv='$magv'";
$result = $conn->query($sqlnghi);
$_SESSION['magv']=$_POST['slnghi'];
$luungaynghi=array();
if($result->num_rows > 0)
{
while($row=$result->fetch_assoc()){
if($row['macongviec']=='P1')
array_push($luungaynghi, 'P1');
if($row['macongviec'] =='P2')
array_push($luungaynghi,'P2');
if($row['macongviec'] == 'P3')
array_push($luungaynghi, 'P3');
if($row['macongviec'] =='P4')
array_push($luungaynghi,'P4');
if($row['macongviec'] =='P5')
array_push($luungaynghi, 'P5');
}
}
$tongngaynghi=0;
$tongluungaynghi= count($luungaynghi);
for($y=0;$y<$tongluungaynghi;$y++){
$songayngi = explode('P', $luungaynghi[$y]);
$tongngaynghi += (int)$songayngi[1];
}
$tongngaynghi=$tongngaynghi*50;
$gio=$phut=0;
if($tongngaynghi!=0){
$gio=(int)$tongngaynghi/60;
$phut=(int)$tongngaynghi%60;
}
echo " Tổng số ngày nghỉ " .(int)$gio ." giờ " .$phut . " phút ";
}
$result=$conn->query($sql);
echo "<form action='thongke.php' method='post'>";
echo "<select name='slnghi'>";
if($result->num_rows >0)
{
while ($row=$result->fetch_assoc()) {
if(isset($_SESSION['magv']))
{
if($_SESSION['magv']==$row['magv'])
echo "<option value='".$row['magv']."' selected >".$row['tengv']." </option>";
else
echo "<option value='".$row['magv']."'>".$row['tengv']." </option>";
}
else if(!isset($_SESSION['magv']))
echo "<option value='".$row['magv']."'>".$row['tengv']." </option>";
}
}
echo "</select>";
echo "<input class='btn btn-primary' type='submit' value='Thống Kê'>";
echo "</form>";
/*$mangviecsang = array();
$mangviecchieu = array();
for($ngay = 0; $ngay < date('t'); $ngay++)
{
array_push($mangviecsang, '');
array_push($mangviecchieu, '');
}
$magv=$row['magv'];
$sql= "SELECT macongviec,ngaythuchien,buoi,ghichu FROM ctcongviec WHERE magv='$magv'";
$result=$conn->query($sql);
if($result->num_rows > 0 ){
while($row=$result->fetch_assoc()){
$buoi = $row['buoi'];
$ngay = $row['ngaythuchien'];
$mangngay = explode("-", $ngay);
if($buoi == "sang")
{
$mangviecsang[$mangngay[2] - 1] = $row['macongviec'];
}
else
{
$mangviecchieu[$mangngay[2] - 1] = $row['macongviec'];
}
}
}
$soluongmang= count($mangviecsang);
$luungaynghi=array();
for($j=0;$j<$soluongmang;$j++)
{
if($mangviecsang[$j]=='P1'){
array_push($luungaynghi, 'P1');
echo "321321";
}
}*/
//if($mangviecsang == "P1,P2,P3,P4,P5")
?>