<?php include 'header.php'; ?>

<?php include 'sidebar.php'; ?>

<div id="page-wrapper">

    <div class="container-fluid">

		<br/>

         <div class="row">

             <div class="col-lg-12">
				<div class="panel panel-default dash">
					<div class="panel panel-primary">
						<div class="panel-heading">
							<h2 class="sub-header">
								<i class="fa fa-info-circle" aria-hidden="true"></i> Special Target Achievers
							</h2>
						</div>
						<!-- /.panel-heading -->
						<div class="panel-body">
							<div class="table-responsive">
							
								<div class="col-md-12">

									<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post" enctype="multipart/form-data" class="form-horizontal" name="newachievers">
										<fieldset>
											<?php $csrf->echoInputField(); ?>


											<div class="form-group">
												<label class="col-md-2 control-label" for="sub_title"> Name </label>
												<div class="col-md-6">
													<input id="name" name="name" type="text" class="form-control input-md" required>
												</div>
											</div>
	  																				 
											<div class="form-group">
												<label class="col-md-2 control-label" for="sub_title">Target</label>
												<div class="col-md-6">
													<input id="rank" name="rank" type="text" class="form-control input-md" required>
												</div>
											</div> 		
	  																				 
											<div class="form-group">
												<label class="col-md-2 control-label" for="sub_title">Leader</label>
												<div class="col-md-6">
													<input id="date" name="date" type="text" class="form-control input-md" required>
												</div>
											</div> 		

											<!-- Button -->
											<div class="form-group">
												<label class="col-md-10 control-label" for="singlebutton"></label>
												<div class="col-md-2">
													<input type="submit" name="newachievers" class="btn btn-primary" value="<?php echo lang('SAVE');?>" />
												</div>
											</div>									   

										</fieldset>
									</form>
									<?php		

										if (!empty($_POST['newachievers']))
										 {
											global $conection;

											$name = $_POST['name']; 
											$rank = $_POST['rank']; 
											$date = $_POST['date'];  

											$sql = mysqli_query($conection,"INSERT INTO achievers VALUES ('','".$name."', '".$rank."', '".$date."')");

													// Se os dados forem inseridos com sucesso			
													if (!$sql) {
													echo ("Can't insert into database: " . mysqli_error());
													return false;
													} else {
													echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('ADDED')."', 'success');</script>";
													echo '<meta http-equiv="refresh" content="1; achievers.php">'; 
													die();
													}		
													return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												} 
										}
											
										?>

								</div>    
							</div>
						</div>
					</div>
				</div>
			</div>
        </div>
        <!-- /.row -->

    <?php include 'copyright.php'; ?>
    
    </div>
    <!-- /.container-fluid -->

</div>
<!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<?php include 'footer.php'; ?>