<?php 
require 'lock.php'; 

$task_id = decryptId($_GET['task_id']);
if($task_id)
{
$taskgetquery=mysqli_query($con,"select task_master.*,user_master.user_name from task_master 
						inner join user_master ON user_master.user_id=task_master.task_userid
						where task_id='$task_id'");
$taskgetdata=mysqli_fetch_assoc($taskgetquery);
}
else
{
echo '<script> window.location="task-list"; </script>';
}
?>

<!DOCTYPE html>
<html lang="en">
<?php require 'head.php'; ?>
<body>
    <!-- Loader starts-->
    <div class="loader-wrapper">
      <div class="theme-loader">    
        <div class="loader-p"></div>
      </div>
    </div>
    <!-- Loader ends-->
    <!-- page-wrapper Start-->
    <div class="page-wrapper" id="pageWrapper">
      <?php include 'top.php'; ?>
      <!-- Page Header Ends                              -->
      <!-- Page Body Start-->
      <div class="page-body-wrapper horizontal-menu">
        <?php include 'header.php'; ?>
        <!-- Page Sidebar Ends-->
        <div class="page-body">
          <div class="container-fluid">
            <div class="page-header">
              <div class="row">
                <div class="col-6">
                  <h3>Task Edit</h3>
                  <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index">Home</a></li>
                    <li class="breadcrumb-item active">Task Edit</li>
                  </ol>
                </div>
                <div class="col-6">
                    <a href="index" class="btn btn-secondary me-3">Back</a> 
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid starts-->
           <div class="container-fluid">
            <div class="row">
              <div class="col-sm-12">
                <div class="card">
                  <div class="card-body">
				    <form action="task-add-db.php" method="post"  enctype="multipart/form-data">
	                <input type="hidden" class="form-control" name="task_id" value="<?php echo $task_id ?>"/>
	                <input type="hidden" class="form-control" name="category_img_old" value="<?php echo $taskgetdata['task_file'] ?>"/>
                    <div class="form theme-form">
                      <div class="row">
                        <div class="col">
                          <div class="mb-3">
                            <label>Task Name <sup class="text-danger">*</sup></label>
                            <input class="form-control" type="text" placeholder="Task Name *" name="task_title" value="<?php echo $taskgetdata['task_title'] ?>" required>
                          </div>
                        </div>
                      </div>
                      
                      <div class="row">
                       <div class="col-sm-4">
                          <div class="mb-3">
                            <label>Task Assign User <sup class="text-danger">*</sup></label>
                            <select class="form-select"  name="task_userid" required>
							<option value="<?php echo $taskgetdata['task_userid'] ?>"><?php echo $taskgetdata['user_name'] ?></option>
							<?php
							$customerqry=mysqli_query($con,"select * from user_master where user_status='Enable' order by user_id DESC");
							while($customerdata=mysqli_fetch_assoc($customerqry))
							{
							?>
							<option value="<?php echo $customerdata['user_id']; ?>"><?php echo $customerdata['user_name']; ?></option>
							<?php
							}
							?>
                            </select>
                          </div>
                        </div>
                        <div class="col-sm-4">
                          <div class="mb-3">
                            <label>Task Priority <sup class="text-danger">*</sup></label>
                            <select class="form-select"  name="task_priority" required>
                              <option value="<?php echo $taskgetdata['task_priority'] ?>"><?php echo $taskgetdata['task_priority'] ?></option>
                              <option value="Low">Low</option>
                              <option value="Medium">Medium</option>
                              <option value="High">High</option>
                              <option value="Urgent">Urgent</option>
                            </select>
                          </div>
                        </div>
						
						<div class="col-sm-4">
                          <div class="mb-3">
                            <label>Task Type <sup class="text-danger">*</sup></label>
                            <select class="form-select"  name="task_type" required>
                              <option value="<?php echo $taskgetdata['task_type'] ?>"><?php echo $taskgetdata['task_type'] ?></option>
                              <option value="Work">Work</option>
                              <option value="Personal">Personal</option>
                              <option value="Social">Social</option>
                            </select>
                          </div>
                        </div>
						
						<div class="col-sm-4">
                          <div class="mb-3">
                            <label>Task Deadline - Date</label>
                            <input class="datepicker-here form-control" type="date" value="<?php echo $taskgetdata['task_enddate'] ?>" name="task_enddate" >
                          </div>
                        </div>
                        
                        <div class="col-sm-4">
                          <div class="mb-3">
                            <label>Task Deadline  - Time </label>
                            <input class="datepicker-here form-control" type="time" value="<?php echo $taskgetdata['task_endtime'] ?>" name="task_endtime" >
                          </div>
                        </div>
						
                      </div>
                     
                      <div class="row">
                        <div class="col">
                          <div class="mb-3">
                            <label>Task Details <sup class="text-danger">*</sup></label>
                            <textarea class="form-control" rows="3"  name="task_detail" required><?php echo $taskgetdata['task_detail'] ?></textarea>
                          </div>
                        </div>
                      </div>
                      <div class="row">
                        <div class="col">
                          <div class="mb-3">
                            <label>Task Upload File </label>
                            <input class="form-control" type="file"  name="category_img">
                            <span class="text-danger"> Note : File type Word, Excel, Pdf, Image</span>
                          </div>
                        </div>
                      </div>
                      <div class="row">
                        <div class="col">
                          <div class="text-end">
						  <button class="btn btn-secondary me-3" name="taskadd" type="submit"> Update </button>
                        </div>
                      </div>
                    </div>
                  </div>
				  </form>	
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid Ends-->
        </div>
        
		<?php include 'footer.php'; ?>
  </body>
</html>