<?php 
require 'lock.php'; 
$cby=$_SESSION['user_id'];
$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 Comment</h3>
                  <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index">Home</a></li>
                    <li class="breadcrumb-item active">Task Comment</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 call-chat-body">
                <div class="card">
                  <div class="card-body p-2">
                     <div class="row chat-box" style="height: auto;">
                      <!-- Chat right side start-->
                      <div class="col chat-right-aside">
                        <!-- chat start-->
                        <div class="chat">
                          <div class="chat-history chat-msg-box custom-scrollbar" style="    height: auto;">
							<ul>
							<?php
							$taskcommentqueryrun="select task_tracking.*,user_master.user_name from task_tracking 
							inner join user_master ON user_master.user_id=task_tracking.tt_userid
							where tt_taskid='$task_id' order by tt_id ASC";
							$taskcommentquery=mysqli_query($con,$taskcommentqueryrun);
							while($taskcommentdata=mysqli_fetch_assoc($taskcommentquery))
							{
							$tt_userid = $taskcommentdata['tt_userid'];
							if($tt_userid==$cby)
							{
							?>
							<li class="clearfix">
							<div class="message other-message pull-right">
							<img class="rounded-circle float-end chat-user-img img-30" src="assets/img/1.png" alt="">
							<div class="message-data">
							<span class="message-data-time"><?php echo date('d-M-Y h:i A',strtotime($taskcommentdata['tt_ctime'])) ?> : 
							<?php echo $taskcommentdata['user_name'] ?></span>
							</div>
							<?php echo htmlspecialchars($taskcommentdata['tt_remark']); ?>
							<?php
                            if($taskcommentdata['tt_file']!='')
                            {
                            ?>
                            <a href="task-image/<?php echo $taskcommentdata['tt_file'] ?>" target="_blank"><i data-feather="file-plus"></i></a>
                            <?php
                            }
                            ?>
							</div>
							</li>
							<?php
							}
							else
							{
							?>
							<li>
							<div class="message my-message">
							<img class="rounded-circle float-start chat-user-img img-30" src="assets/img/1.png" alt="">
							<div class="message-data text-end">
							<span class="message-data-time">
							<?php echo date('d-m-Y h:i A',strtotime($taskcommentdata['tt_ctime'])) ?> : 
							<?php echo $taskcommentdata['user_name'] ?>
							</span>
							</div> 
							<?php echo htmlspecialchars($taskcommentdata['tt_remark']); ?>
							<?php
                            if($taskcommentdata['tt_file']!='')
                            {
                            ?>
                            <a href="task-image/<?php echo $taskcommentdata['tt_file'] ?>" target="_blank"><i data-feather="file-plus"></i></a>
                            <?php
                            }
                            ?>
							</div>
							</li>
							<?php
							}
							}
							?>
							</ul>
							</div>  
                        </div>
                        </div>
                        </div>
                            
                    <div class="row">
                     
					  <form action="task-comment" method="post" enctype="multipart/form-data">
                              <div class="col-xl-12">
                              <input type="hidden" class="form-control" name="task_id" value="<?php echo $task_id ?>"/>
							  <textarea class="form-control" name="remarks" placeholder="Type a message......" required style="min-height: 280px;border: 2px solid #f06d0b;"></textarea>
                              </div>
                              
                              <div class="col-xl-12 mt-3">
							  <input class="form-control" type="file"  name="category_img">
                              <span class="text-danger"> Note : File type Word, Excel, Pdf, Image</span>
							  </div>
							  
							  <div class="col-xl-12 mt-3">
							  <button class="btn btn-primary" type="submit" name="taskadd">SEND</button>
							  </div>
							  </form>
                     
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid Ends-->
		  
		  
        </div>
        
		<?php include 'footer.php'; ?>
  </body>
</html>