<?php
	include("my_functions.php");
	$pagetitle = "Manage targets";
	require('includes/applicationtop.php');
	require('includes/applicationmenu.php');
	
	$err= "";

    $actual_link = 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
		$parts = explode('managetasks' , $actual_link);
		
    $fromdate = false;
    $command = false;
	
	$startdatevalid = false;
	
	 
	 
?>
			<!-- Content Wrapper. Contains page content -->
			<div class="content-wrapper">
			 

				<!-- Main content -->
				<section class="content">
					<!-- Default card -->
					<div class="card card-primary">
						<?php
							if($_SESSION["connectedusergroup"] == 1 || $_SESSION["connectedusergroup"] == 3)
							{
						?>
						<div class="card-body">
							<div id="servererrormessage">
							</div>
							
							<?php
								if($err!="")
								{
							?>
							<div class="alert alert-danger alert-dismissable">
								<i class="fa fa-ban"></i>
								<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button><br>
								<?php 
									echo $err; 
								?>
							</div>
							<?php
								}
							?>
							
							<div class="card card-info">
                                <div class="card-header">
                                    <h6 class="card-title"><?= $pagetitle ?></h6>
                                </div>
                                <div class="card-body">
                            
                               
							
							 
								<?php
									if($err=="" )
									{

                                        $targets= targets();

                                     

                                        ?>
                                     <div class="col-sm-12">
									<div class="input-group-btn">
										<a href="<?php echo $base_url; ?>newtarget" class="btn btn-sm btn-primary pull-right"><i class="fa fa-plus"></i> Add new</a>
									</div>
								 
								
								<table id="example1"   class="table table-bordered table-striped">
									<thead>
										<tr>
                                            <th>Name</th>
											<th>Amount</th>
											 
											<th class="text-center">Action</th>
										</tr>
									</thead>

                                        <?php
                                        foreach($targets as $row){
                                          

                                            echo '<tr> <td>'.$row['tperiod'].' </td><td>'.$row['target'].' </td><td>'.$row['ta_id'].' </td></tr>';

                                           
                                        }
								?>
                                </table>
								   
 
								  
								   
                                     

                                </div>
                            </div>
              <!-- /.card-body -->
            </div>
									 
								
								   
								 
										 
								
								
								
								</div>
							</div>
						</div><!-- /.card-body -->
						<?php
							}
							}
							else
							{
						?>
						<div class="alert alert-danger alert-dismissable">
							<i class="fa fa-ban-circle"></i><br>
							Limited Access
						</div>
						<?php
							}
						?>
					</div><!-- /.card -->
				</section><!-- /.content -->
			</div><!-- /.content-wrapper -->
 
		</div><!-- ./wrapper -->
		
		<div class="modal" id="waitdialogmodal"  data-backdrop="static">
            <div class="modal-dialog modal-sm">
              <div class="modal-content">
                  <div class="modal-body">
					<div class="text-center">
						<img src="<?php echo $base_url . $ajax_loading_image; ?>" />
					</div>
				  </div>
              </div>
            </div>
        </div>

		 
	
	
	
	
 <?php include ('includes/general_footer.php')?>  
 
<script>
 
		$(function(){
			 
			$('#from').datepicker();
			$('#to').datepicker();
			 
			 
		});
	</script>

	 
		<script src="plugins/bert/storepos.js" type="text/javascript"></script>
		<script src="plugins/bert/store.js" type="text/javascript"></script>
	</body>
</html>