<?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'];
									   $newtasks = $_POST['newtasks'];
									    $note = $_POST['note'];
									    
			$query1=mysqli_query($con,"select * from users where id='$techid'")or die(mysqli_error());
		        $row1=mysqli_fetch_array($query1);
					$techname=$row1['fullname'];
					
					
					$query2=mysqli_query($con,"select * from tasks order by id DESC")or die(mysqli_error());
		        $row2=mysqli_fetch_array($query2);
					$idpolpol=$row2['id'];
					$jamesid=$idpolpol + 1;	    
									    
mysqli_query($con,"INSERT INTO tasks(taskname,reportid,userid,staffid,techid,filename,notes,technotes,techreminder,status,remarks,date)
VALUES ('$newtasks','$jamesid','$id','$id','$techid','0','$note','0','$note','0','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 ('$jamesid','$id','$id','$message','HYDRO STAFF','$date')")or die(mysqli_error($con)); 
echo "<script>alert('Hydrocheck Successfully  New Assigned Tasks');</script>";
echo "<script>document.location='newreports.php'</script>";  

									}
									?>
