<?php
	
	include("../config/mysql_connect.php");

	if(isset($_REQUEST["id"])){
		$id = $_REQUEST['id'];

		if($id == 'reset'){

			$sql = "select * from tb_number where num_clear='No' and num_payment='Yes'"; // ดัก num_payment ไว้
		 	$Query = mysqli_query($link,$sql);
		  	$num_rows = mysqli_num_rows($Query);

		  	if($num_rows){

				while($Result = mysqli_fetch_array($Query)){
				$num_id = $Result['num_id'];

				$sql_update = "update tb_number set num_clear='Yes' where num_id='$num_id'";
				$objQuery = mysqli_query($link,$sql_update);

				}

			}

			echo "<meta http-equiv=refresh content=0;url=announce.php>";

		}




	}
	elseif(isset($_REQUEST["status"])){
		$status = $_REQUEST['status'];
		$text = "";

		if($status == 'On'){
			$text = "Off";
		}else{
			$text = "On";
		}

		$sql_update = "update setting_default set def_status='$text' where def_id='1'";
		$objQuery = mysqli_query($link,$sql_update);

		if($objQuery){
			echo "<meta http-equiv=refresh content=0;url=announce.php>";
		}
		else{
			echo "<div class='alert alert-danger'>
			<button type='button' class='close' data-dismiss='alert'>&times;</button>
			<strong>Alerts!</strong> ล้มเหลว </div>";
		}
	}
	elseif(isset($_REQUEST["info"])){
		$info = $_REQUEST['info'];
		$text = "";

		if($info == 'On'){
			$text = "Off";
		}else{
			$text = "On";
		}

		$sql_update = "update setting_default set def_info='$text' where def_id='1'";
		$objQuery = mysqli_query($link,$sql_update);

		if($objQuery){
			echo "<meta http-equiv=refresh content=0;url=announce.php>";
		}
		else{
			echo "<div class='alert alert-danger'>
			<button type='button' class='close' data-dismiss='alert'>&times;</button>
			<strong>Alerts!</strong> ล้มเหลว </div>";
		}
	}

?>