<?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 View</h3>
                  <ol class="breadcrumb">
                    <li class="breadcrumb-item"><a href="index">Home</a></li>
                    <li class="breadcrumb-item active">Task View</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-0">
                    <div class="row chat-box">
                      <!-- Chat right side start-->
                      <div class="col chat-right-aside">
                        <!-- chat start-->
                        <div class="chat">
                          <!-- chat-header start-->
                          <div class="media chat-header clearfix"><img class="rounded-circle" src="assets/img/1.png" alt="">
                            <div class="media-body">
                              <div class="about">
                                <div class="name"><?php echo $taskgetdata['task_title'] ?>  
								<span class="font-primary f-12"><?php echo $taskgetdata['task_status'] ?></span></div>
                                <div class="status digits"><?php echo $taskgetdata['user_name'] ?></div>
                              </div>
                            </div>
                            <ul class="list-inline float-start float-sm-end chat-menu-icons">
                              <li class="list-inline-item">
							  <a href="task-edit?task_id=<?php echo $_GET['task_id'] ?>"><i data-feather="edit"></i></a>
							  </li>
                              <li class="list-inline-item">
							  <a href="task-status?task_id=<?php echo $_GET['task_id'] ?>"><i data-feather="settings"></i></a>
							  </li>
                            </ul>
                          </div>
                          <!-- chat-header end-->
							<div class="chat-history chat-msg-box custom-scrollbar">
							<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>
							<!-- end chat-history-->
						    <div class="chat-message clearfix">
                            <div class="row">
							  <form action="task-comment" method="post">
                              <div class="col-xl-12 d-flex">
                                <div class="input-group text-box">
								<input type="hidden" class="form-control" name="task_id" value="<?php echo $task_id ?>"/>
								<input class="form-control input-txt-bx" type="text" name="remarks" placeholder="Type a message......" required >
								<button class="btn btn-primary input-group-text" type="submit" name="taskadd">SEND</button>
                                </div>
                              </div>
							  </form>
                            </div>
                          </div>
                          <!-- end chat-message-->
                        </div>
                      </div>
                     
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <!-- Container-fluid Ends-->
		  
		  
        </div>
        
		<?php include 'footer.php'; ?>
  </body>
</html>