<?php session_start();
if(empty($_SESSION['id'])):
header('Location:../index.php');
endif;

include('../dist/dbcon.php');

	
	if(isset($_POST['submit'])) { 
	date_default_timezone_set("Asia/Manila"); 
	$date = date("Y-m-d");
									$id = $_SESSION['id'];
									  $techid = $_POST['techid'];
									   $taskid = $_POST['taskid'];
									    $note = $_POST['note'];
									    
				$query=mysqli_query($con,"select * from userreports where id='$taskid'")or die(mysqli_error());
		        $row=mysqli_fetch_array($query);
					$taskname=$row['reportname'];
					$notes=$row['note'];
					$userid=$row['userid'];
			$query1=mysqli_query($con,"select * from users where id='$techid'")or die(mysqli_error());
		        $row1=mysqli_fetch_array($query1);
					$techname=$row1['fullname'];
										    
									    
mysqli_query($con,"INSERT INTO tasks(taskname,reportid,userid,staffid,techid,filename,notes,technotes,techreminder,status,remarks,date)
VALUES ('$taskname','$taskid','$userid','$id','$techid','','$notes','','$note','','pending','$date')")or die(mysqli_error($con)); 
$message="Your Queries is now in line to fix assigned to technician: $techname ";

mysqli_query($con,"INSERT INTO convo(reportid,userid,replayid,message,remarks,date)
VALUES ('$taskid','$userid','$id','$message','HYDRO STAFF','$date')")or die(mysqli_error($con)); 
echo "<script>alert('Hydrocheck Successfully Assigned Tasks');</script>";
									 		echo "<script>document.location='assign.php'</script>";  
									}
									?>
