-
Notifications
You must be signed in to change notification settings - Fork 0
/
vote.php
181 lines (168 loc) · 11.4 KB
/
vote.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
174
175
176
177
178
179
180
181
<?php
session_start();
include('./connect/connect.php');
include('./function.php');
if (!$_SESSION['s_username']) {
header('location:index.php');
} else {
$check5 = "SELECT * FROM student WHERE s_id = " . $_SESSION['s_id'];
$m5 = mysqli_query($conn, $check5);
if (mysqli_num_rows($m5) == 1) {
$num = mysqli_fetch_array($m5);
$s_pass = $num['s_pass'];
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<?php include('./component/link.php') ?>
</head>
<body>
<?php include('./component/sidebar.php') ?>
<div class="page">
<div class="page__wrapper">
<?php include('./component/header.php') ?>
<div style="margin: 80px 60px 60px 60px">
<h1 style="font-weight:700;color:white" align="left">ระบบเลือกตั้งประธานคณะสี</h1>
<p style="color: white;">โรงเรียนยุพราชวิทยาลัย จังหวัดเชียงใหม่</p>
<div class="row">
<div class="col-xl-3 col-md-4">
<div class="box" style="padding-top:20px">
<div class="container">
<h5 align="center" style="color:#d91b5c">ข้อมูลผู้มีสิทธิ์เลือกตั้ง</h5>
<hr>
<p>
<i class="fas fa-user" style="color:#d91b5c"></i> ชื่อ : <?php echo $_SESSION['s_title'] . $_SESSION['s_name'] . " " . $_SESSION['s_surname'] ?>
</p>
<p>
<i class="fas fa-chart-line" style="color:#d91b5c"></i> ชั้นมัธยมศึกษาปีที่ <?php echo $_SESSION['s_level'] . "/" . $_SESSION['s_room'] ?>
</p>
<p>
<i class="fas fa-poll" style="color:#d91b5c"></i> คณะสี : <?php colorstatus() ?>
</p>
<?php
if ($s_pass < 1) {
?>
<div class="d-grid gap-2 mt-3">
<a class="btn btn-danger " style="pointer-events: none;">ยังไม่ได้ลงคะแนน</a>
</div>
<?php
} else {
?>
<div class="d-grid gap-2 mt-3">
<a class="btn btn-success " style="pointer-events: none;">ลงคะแนนเรียบร้อยแล้ว</a>
</div>
<?php } ?>
</div>
</div>
</div>
<div class="col-xl-9 col-md-8">
<?php
if ($s_pass > 0) {
?>
<?php }else{ ?>
<div class="box">
<div style="background:<?php color() ?>;border-radius:20px 20px 0px 0px">
<h5 class="p-3" style="color: white" align="center">การแถลงนโยบายคณะสี<?php colorstatus(); ?></h5>
</div>
<div class="container">
<div class="ratio ratio-16x9">
<?php video(); ?>
</div>
</div>
</div>
<?php } ?>
<div class="box">
<div style="background:<?php color() ?>;border-radius:20px 20px 0px 0px">
<h5 class="p-3" style="color:white" align="center">
<?php
if ($s_pass > 0) {
?>
หมายเลขที่คุณลงคะแนน
<?php } else { ?>
รายละเอียดผู้สมัคร คณะสี<?php colorstatus(); ?>
<?php } ?>
</h5>
</div>
<div class="container">
<?php
if ($s_pass > 0) {
$sql1 = "SELECT * FROM student WHERE s_id = " . $_SESSION['s_id'];
$query1 = mysqli_query($conn, $sql1);
$student = mysqli_fetch_array($query1);
?>
<div class="row">
<div class="col-xl-4 "></div>
<div class="col-xl-4 ">
<img src="./img/<?php echo $_SESSION['s_color'] . "-" . $student['s_select'] ?>.png" class="img-fluid candidate_img" style="border-radius: 20px" alt="">
<div class="d-grid gap-2 mt-2">
<a style="font-family: 'Kanit';pointer-events: none;" class="btn btn-<?php colorbtn() ?>">คุณได้ลงคะแนนเสียงเบอร์นี้</a>
</div>
</div>
<div class="col-xl-4 "></div>
</div>
<?php } else { ?>
<div class="row">
<?php
$sql = "SELECT * FROM candidate WHERE c_color = " . $_SESSION['s_color'];
$query = mysqli_query($conn, $sql);
while ($row = mysqli_fetch_array($query)) {
?>
<div class="col-xl-4 col-md-4 col-sm-4 col-xs-6 mb-3">
<img src="./img/<?php echo $_SESSION['s_color'] . "-" . $row['c_number'] ?>.png" class="img-fluid candidate_img" style="border-radius: 20px;" alt="">
<div class="d-grid gap-2 mt-2">
<a style="font-family: 'Kanit';" class="btn btn-<?php colorbtn() ?>" data-bs-toggle="modal" data-bs-target="#vote<?php echo $row['c_id'] ?>">ลงคะแนน</a>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="vote<?php echo $row['c_id'] ?>" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">ยืนยันการลงคะแนน</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
คุณต้องการลงคะแนนให้<strong> เบอร์ <?php echo $row['c_number'] . " " . $row['c_title'] . " " . $row['c_name'] . " " . $row['c_surname'] ?></strong> ใช่หรือไม่
</div>
<div class="modal-footer">
<form action="./process/submit.php" method="post">
<input type="text" name="c_id" value="<?php echo $row['c_id'] ?>" hidden>
<input type="text" name="c_number" value="<?php echo $row['c_number'] ?>" hidden>
<button style="font-family: 'Kanit';" type="button" class="btn btn-secondary" data-bs-dismiss="modal">ยกเลิก</button>
<input style="font-family: 'Kanit';" type="submit" name="submit" class="btn btn-<?php colorbtn() ?>" value="ตกลง">
</form>
</div>
</div>
</div>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
<?php include('./component/linkjs.php') ?>
<?php
if (isset($_SESSION['success'])) {
?>
<script>
Swal.fire({
title: 'เสร็จสิ้น!',
text: 'คุณลงคะแนนเสียงเรียบร้อยแล้ว',
icon: 'success',
confirmButtonText: 'ตกลง',
confirmButtonColor: '#198754'
})
</script>
<?php }
unset($_SESSION['success']);
?>
</body>
</html>
<?php } ?>