<?php 
session_start();
include("connect/config.php");
include("validate-scripts.php");
include("checksession.php");
include("branch.php");
include("RemoveSpecialChar.php");
?>

<!--A Design by W3layouts
Author: W3layout
Author URL: http://w3layouts.com
License: Creative Commons Attribution 3.0 Unported
License URL: http://creativecommons.org/licenses/by/3.0/
-->
<!DOCTYPE html>
<head>
<title>Followup Task :: <?=$CompnayTitle_Name;?></title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="keywords" content="" />
<script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<!-- bootstrap-css -->
<link rel="stylesheet" href="css/bootstrap.min.css" >
<!-- //bootstrap-css -->
<!-- Custom CSS -->
<link href="css/style.css" rel='stylesheet' type='text/css' />
<link href="css/style-responsive.css" rel="stylesheet"/>
<!-- font CSS -->
<link href='//fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900,900italic' rel='stylesheet' type='text/css'>
<!-- font-awesome icons -->
<link rel="stylesheet" href="css/font.css" type="text/css"/>
<link href="css/font-awesome.css" rel="stylesheet"> 
<link rel="stylesheet" href="css/morris.css" type="text/css"/>
<!-- calendar -->
<link rel="stylesheet" href="css/monthly.css">
<link rel="stylesheet" href="sweet/sweet-alert.css">
<!-- //calendar -->
<!-- //font-awesome icons -->
<script src="js/jquery2.0.3.min.js"></script>
<script src="js/raphael-min.js"></script>
<script src="js/morris.js"></script>
</head>
<body>
<section id="container">
<!--header start-->
<?php include("header.php");?>
<!--header end-->
<!--sidebar start-->
<?php include("menu.php");?>
<!--sidebar end-->

<?php
// Check for error message in session
if (isset($_SESSION['sucMessage'])) {
$sucMessage = $_SESSION['sucMessage'];
?>
                      <script src="sweet/sweet-alert.js"></script>
                      <script>
                        Swal.fire({
                          icon: 'success',
                          title: 'Success',
                          text: '<?php echo $sucMessage; ?>',
                          confirmButtonText: 'OK'
                        });
					</script>
<?php  unset($_SESSION['sucMessage']); } ?>

<!--main content start-->
<section id="main-content">
	<section class="wrapper">
		
		<?php include("market.php");?>
		
		<div class="row">
			<div class="panel-body">
				<div class="col-md-12 w3ls-graph">
					<!--agileinfo-grap-->
						<div class="agileinfo-grap">
							<div class="agileits-box">
								<header class="agileits-box-header clearfix">
									<div class="row w3-res-tb">
      <div class="col-sm-5 m-b-xs">
        <h4 style="color:blue;margin-bottom:25px;">Followup Task</h4>                
      </div>
      <div class="col-sm-4">
      </div>
      <div class="col-sm-3">
        <div class="input-group">
<?php if($Log_UserType=="1"){?>           
		   <!----<a href="#myModal" data-toggle="modal" class="btn btn-success">
                                    &#43; Create New Task
                                </a>---->
<?php }?>
        </div>
      </div>
    </div>
	
	
	<?php include("model_form.php");?>
						
						
						<?php 
						//UPDATE TASK STATUS - USERS LOGIN
if(isset($_REQUEST['UpdateTaskEXE']))
{
	$updateid=$_REQUEST['updateid'];
	$task_status=$_REQUEST['task_status'];
	
	$followup_remarks=$_REQUEST['followup_remarks'];
	$followup_remarks = RemoveSpecialChar($followup_remarks);
	
	$updateTask="UPDATE task_mng SET status='$task_status' WHERE id='$updateid'";
	mysqli_query($db_conn,$updateTask);
	
	
	//TASK COMPLETED ONLY
	if($task_status=="completed")
	{
	date_default_timezone_set("Asia/Kolkata");
	$completeDate=date("Y-m-d");
		
	$updateTask="UPDATE task_mng SET completed_date='$completeDate',completed_by='$followup_remarks' WHERE id='$updateid'";
	mysqli_query($db_conn,$updateTask);
	}
	//----------------------
	
	$_SESSION['sucMessage']="One Task Completed Successfully";
	echo "<script>window.location='completed';</script>";
}
?>
										
										
										
										<div class="table-responsive">
      <table class="table table-striped b-t b-light">
        <thead>
          <tr>
            <?php if($Log_UserType=="1"){?><th>Branch</th><?php }?>
			<th>Date</th>
            <th>Task</th>
			<th>Remarks</th>
			<?php 
			//showed users only
			if($Log_UserType=="18"){
			?>
			<th></th>
			<?php }?>
			
			
			
          </tr>
        </thead>
        <tbody>
<?php 
if($Log_UserType=="1"){
$Select_followup_taskSHOW="select * from task_mng where status='followup' order by id desc LIMIT 0,100";
}else{
$Select_followup_taskSHOW="select * from task_mng where status='followup' and branchid='$Log_UserBranchID' order by id desc  LIMIT 0,100";	
}
$fetch_followup_taskSHOW=mysqli_query($db_conn,$Select_followup_taskSHOW);

while($result_pending_task=mysqli_fetch_array($fetch_followup_taskSHOW))
{
	$task_branchID=$result_pending_task['branchid'];
	
	//GET BRANCH NAME
$Select_task_branch="select name from admin_branch where id='$task_branchID'";
$fetch_task_branch=mysqli_query($db_conn,$Select_task_branch);
$result_task_branch=mysqli_fetch_array($fetch_task_branch);

$task_branch_name=$result_task_branch['name'];
$task_rowid=$result_pending_task['id'];
?>
          <tr>
            
			<?php 
			//showed admin only
			if($Log_UserType=="1"){?>
			<td><?=$task_branch_name;?></td>
			<?php }?>
			
            <td><?=date("d/m/Y",strtotime($result_pending_task['start_date']));?></td>
			<td><?=$result_pending_task['task'];?></td>
			
			<td>
			<?php if($result_pending_task['followup_remarks']!=NULL){?>
			<?=$result_pending_task['followup_remarks'];?>
			<?php }else{ echo "---";}?>
			</td>
			
			<?php 
			//showed users only
			if($Log_UserType=="18"){
			?>
			<td>
			<a href="#myModal<?=$task_rowid;?>" data-toggle="modal" class="btn btn-success">
                                    &#43; Update
                                </a>
								</td>
								  <!------model form open----->
	<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal<?=$task_rowid;?>" class="modal fade">
                            <div class="modal-dialog">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                                        <h4 class="modal-title">Update Task</h4>
                                    </div>
                                    <div class="modal-body">
									
<form role="form" method="post" enctype="multipart/form-data" action="<?php echo $_SERVER['PHP_SELF'];?>">
<input type="hidden" name="updateid" value="<?=$task_rowid?>">
					<div class="form-group">
                                                <label>Status</label>
                                                <select class="form-control" required="" name="task_status">
												<option value="" hidden="">Select</option>
												<option value="completed">completed</option>
												</select>
                                            </div>
                                            <div class="form-group">
                                                <label>Remarks (optional)</label>
                                                <textarea class="form-control" rows="5" onkeypress="restrictSpecialChars(event)" name="followup_remarks"></textarea>
                                            </div>
                                            
                                   <button type="submit" name="UpdateTaskEXE" class="btn btn-success">Submit</button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
						<!------model form close----->
			<?php }?>
								
								
          </tr>
		  
		  
		
						
						
<?php }?>
        </tbody>
      </table>
    </div>
	
								</header>
								
							</div>
						</div>
	<!--//agileinfo-grap-->

				</div>
			</div>
		</div>
		
</section>
 <!-- footer -->
		  <?php include("footer.php");?>
  <!-- / footer -->
</section>
<!--main content end-->
</section>
<script src="js/bootstrap.js"></script>
<script src="js/jquery.dcjqaccordion.2.7.js"></script>
<script src="js/scripts.js"></script>
<script src="js/jquery.slimscroll.js"></script>
<script src="js/jquery.nicescroll.js"></script>
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="js/flot-chart/excanvas.min.js"></script><![endif]-->
<script src="js/jquery.scrollTo.js"></script>
<!-- morris JavaScript -->	
<script>
	$(document).ready(function() {
		//BOX BUTTON SHOW AND CLOSE
	   jQuery('.small-graph-box').hover(function() {
		  jQuery(this).find('.box-button').fadeIn('fast');
	   }, function() {
		  jQuery(this).find('.box-button').fadeOut('fast');
	   });
	   jQuery('.small-graph-box .box-close').click(function() {
		  jQuery(this).closest('.small-graph-box').fadeOut(200);
		  return false;
	   });
	   
	    //CHARTS
	    function gd(year, day, month) {
			return new Date(year, month - 1, day).getTime();
		}
		
		graphArea2 = Morris.Area({
			element: 'hero-area',
			padding: 10,
        behaveLikeLine: true,
        gridEnabled: false,
        gridLineColor: '#dddddd',
        axes: true,
        resize: true,
        smooth:true,
        pointSize: 0,
        lineWidth: 0,
        fillOpacity:0.85,
			data: [
				{period: '2015 Q1', iphone: 2668, ipad: null, itouch: 2649},
				{period: '2015 Q2', iphone: 15780, ipad: 13799, itouch: 12051},
				{period: '2015 Q3', iphone: 12920, ipad: 10975, itouch: 9910},
				{period: '2015 Q4', iphone: 8770, ipad: 6600, itouch: 6695},
				{period: '2016 Q1', iphone: 10820, ipad: 10924, itouch: 12300},
				{period: '2016 Q2', iphone: 9680, ipad: 9010, itouch: 7891},
				{period: '2016 Q3', iphone: 4830, ipad: 3805, itouch: 1598},
				{period: '2016 Q4', iphone: 15083, ipad: 8977, itouch: 5185},
				{period: '2017 Q1', iphone: 10697, ipad: 4470, itouch: 2038},
			
			],
			lineColors:['#eb6f6f','#926383','#eb6f6f'],
			xkey: 'period',
            redraw: true,
            ykeys: ['iphone', 'ipad', 'itouch'],
            labels: ['All Visitors', 'Returning Visitors', 'Unique Visitors'],
			pointSize: 2,
			hideHover: 'auto',
			resize: true
		});
		
	   
	});
	</script>
<!-- calendar -->
	<script type="text/javascript" src="js/monthly.js"></script>
	<script type="text/javascript">
		$(window).load( function() {

			$('#mycalendar').monthly({
				mode: 'event',
				
			});

			$('#mycalendar2').monthly({
				mode: 'picker',
				target: '#mytarget',
				setWidth: '250px',
				startHidden: true,
				showTrigger: '#mytarget',
				stylePast: true,
				disablePast: true
			});

		switch(window.location.protocol) {
		case 'http:':
		case 'https:':
		// running on a server, should be good.
		break;
		case 'file:':
		alert('Just a heads-up, events will not work when run locally.');
		}

		});
	</script>
	<!-- //calendar -->
</body>
</html>
