<?php include('code.php'); ?>
<?php 
	session_start(); 
	include('../conn/connect.php');
	$sql_place = "SELECT * FROM place,worker WHERE place.workerID = worker.IDworker and place.ID_place = '".$_POST['placeID']."' and  keycode_text = '".$_POST['confirm_number']."' ";
	$query_place = mysqli_query($conn,$sql_place);
	$result_place=mysqli_fetch_array($query_place);
	//-----------------------request-------------------------------------
	$sql_request = "SELECT * FROM request WHERE placeID = '".$_POST['placeID']."' and (status = '1' or status = '2' or status = '3') ";
	$query_request = mysqli_query($conn,$sql_request);
	$result_request_num = 0;
	while ($result_request=mysqli_fetch_array($query_request)) {
		$result_request_array[$result_request_num] = $result_request['request_typeID'];
	 	$result_request_num++;
	}
	//-----------------------request-------------------------------------
	//-----------------------request_type-------------------------------------
	$request_type_array_text = '';
	$request_type_array = explode(",", $result_place['request_typeID']);
	for($i_array=0;$i_array<count($request_type_array);$i_array++){
		$request_type_array_text = $request_type_array_text." request_typeID = '".$request_type_array[$i_array]."' ";
		if($i_array+1 < count($request_type_array)){
			$request_type_array_text = $request_type_array_text."or";
		}
	}
	$sql_request_type = "SELECT * FROM request_type WHERE ".$request_type_array_text;
	$query_request_type = mysqli_query($conn,$sql_request_type);
	$result_request_type_array = 0; 
	//-----------------------request_type-------------------------------------
	if (mysqli_num_rows($query_place) > 0) { //ตรวจสอบข้อมูลมีหรือไม่
?>
			<div class="rate">
				<center>
					<h3>
						กรุณาให้คะแนนความพึงพอใจ
					</h3>
					<div id="rate">
						<div class="vote" onclick="javascript:vote(1);">
							<img src="<?=$IP_SERVER?>img/vote5.png"><br />
							<font color="#2b4d7d">แย่มาก</font>
						</div>
						<div class="vote" onclick="javascript:vote(2);">
							<img src="<?=$IP_SERVER?>img/vote4.png"><br />
							<font color="#2b4d7d">แย่</font>
						</div>
						<div class="vote" onclick="javascript:vote(3);">
							<img src="<?=$IP_SERVER?>img/vote3.png"><br />
							<font color="#2b4d7d">พอใช้</font>
						</div>
						<div class="vote" onclick="javascript:vote(4);">
							<img src="<?=$IP_SERVER?>img/vote2.png"><br />
							<font color="#2b4d7d">ดี</font>
						</div>
						<div class="vote" onclick="javascript:vote(5);">
							<img src="<?=$IP_SERVER?>img/vote1.png"><br />
							<font color="#2b4d7d">ดีมาก</font>
						</div>
					</div>
					
				</center>
			</div>	
			<br />
			<div class="inform">	
				<center>
					<h3>
						แจ้งปัญหา
					</h3>
					
						<div class="vote_data_div" id="vote_data_div">
<?php
							while ($result_request_type=mysqli_fetch_array($query_request_type)) {
									$result_request_type_array++;
?>
									<div class="vote_data" onclick="javascript:btn(<?=$result_request_type_array?>,<?=$result_request_type['request_typeID']?>,'<?=$result_request_type['request_type']?>','no');">
										<img src="<?=$result_request_type['url_img']?>">
										<div class="font_txt"><font><?=$result_request_type['request_type']?></font></div>
									</div>
<?php
							}

?>
						</div>
						<div class="vote_data_div_confirm" id="vote_data_div_confirm" style="display: none;">
							<br /><img src="<?=$IP_SERVER?>img/save.png" width="50"><br />
							ระบบทำการบันทึกข้อมูลแล้ว<br />
							หากต้องการแจ้งปัญหารายการอื่นเพิ่มเติม คลิ๊กปุ่มด้านล่าง<br />
							<button class="send_data" style="font-size: 16px;" onclick="javascript:vote_data_div_show();">แจ้งปัญหาอื่น</button><br /><br />
						</div>
						
				</center> 
			</div>	
			<br />	
			<div class="CONTACT">	
				<h3>
					<center>แจ้งปัญหาเพิ่มเติม / แนะนำ / ติชม</center> 
				</h3>
				<div class="CONTACT_from" id="CONTACT_from">
					<textarea placeholder="พิมพ์ข้อความที่นี่" id="CONTACT_from_txt"></textarea>
					<br />
					<center>
						<div id="image_file" style="display : none; width: 100%;">
							<div class="btn-file">
							    <div class="btn-file-button"><span>รูปภาพ</span></div>
							    <div class="btn-file-name" id="btn-file-name"></div>
							    <div class="btn-file-close" onclick="javascript:close_load_image();"><span>X</span></div>
							</div>
							<br />
						</div>
						<table border="0" width="90%" cellpadding="0" cellspacing="0">
							<tr>
								<td align="left" width="100">
									<div class="load_image" id="load_image" style="display : block;" onclick="javascript:load_image();" >
										<center>
											<img src="<?=$IP_SERVER?>img/Upload.png"><span>เพิ่มรูปภาพ</span>
											<input name="image_file" id="imageInput" type="file" onchange="javascript:ChangeText(this, 'btn-file-name');" accept=".jpg, .jpeg" />
										</center>
									</div>
									
								</td>
								<td align="center">
									<button class="send_data" style="color: #ffffff;font-size: 20px;" onclick="javascript:upload_send_data();">ส่งความคิดเห็น</button>
								</td>
							</tr>
						</table>
					</center>
					<br />
				</div>
			</div>
			<div id="confirm_number_text" style="display: none;"><?=$_POST['confirm_number']?></div>
<?php
 	}else{
?>
	<div class="CONTACT">	
		<h3>
			<center>ยืนยันสถานที่ห้องน้ำ</center> 
		</h3>
		<div class="CONTACT_from">	
			<br />
			<center>
				ใส่หมายเลขใต้ QR-Code
				<br />
				<font color="#FF0000">รหัสไม่ถูกต้องกรุณาใส่ตัวเลขใหม่</font>
				<br /><br />
				<input type="number" id="confirm_number" name="confirm_number" max="4" style="width: 100px; height: 30px;" >
				<br /><br />
				<button class="send_data" style="color: #ffffff;font-size: 20px;" onclick="javascript:confirm_number();">ยืนยัน</button>
			</center>
			<br />
		</div>	
	</div>

<?php
 	}
?>
