<title>Leader Panel - <?php echo Config::$factions[Config::getData('users','Leader',$_SESSION['user'])]; ?> - <?php echo Config::$_SITE_NAME; ?></title>
<?php
if(!defined('panel'))
	die('Nope.');
if(!isset($_SESSION['user'])) echo '<script> location.replace("'.Config::$_PAGE_URL.'login"); </script>';
if(!Config::getData('users','Leader',$_SESSION['user'])) echo '<script> location.replace("'.Config::$_PAGE_URL.'"); </script>';
?>
</div>
	<div class="main-content">
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
			try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
		</script>

		<ul class="breadcrumb">
			<li>
				<i class="ace-icon fa fa-home home-icon"></i>
				<a href="<?php echo Config::$_PAGE_URL; ?>">Home</a>
			</li>
			<li class="active">Leader Panel - <?php echo Config::$factions[Config::getData('users','Leader',$_SESSION['user'])]; ?></li>
		</ul><!-- /.breadcrumb -->

	<div class="nav-search" id="nav-search">
			<form method="POST" action="<?php echo Config::$_PAGE_URL; ?>search">
				<span class="input-icon">
					<input type="text" placeholder="Search ..." name="sname" id="username" type="submit" class="nav-search-input" autocomplete="on"> 
					<i class="ace-icon fa fa-search nav-search-icon"></i>
				</span>
			</form>
		</div> <!-- /.nav-search -->
	</div>	


<div class="page-content"><div class="row-fluid"><div class="span12">
<?php
if(isset(Config::$_url[1]) =="intrebari") { ?>
<h3>Modifica intrebari aplicatii</h3>

<?php
if(isset($_POST['submit']))
{
	if($_POST['q_1'] == "") { $q1 = ""; } else $q1 = htmlspecialchars($_POST['q_1']);
	if($_POST['q_2'] == "") { $q2 = ""; } else $q2 = htmlspecialchars($_POST['q_2']);
	if($_POST['q_3'] == "") { $q3 = ""; } else $q3 = htmlspecialchars($_POST['q_3']);
	if($_POST['q_4'] == "") { $q4 = ""; } else $q4 = htmlspecialchars($_POST['q_4']);
	if($_POST['q_5'] == "") { $q5 = ""; } else $q5 = htmlspecialchars($_POST['q_5']);
	if($_POST['q_6'] == "") { $q6 = ""; } else $q6 = htmlspecialchars($_POST['q_6']);
	if($_POST['q_7'] == "") { $q7 = ""; } else $q7 = htmlspecialchars($_POST['q_7']);
	if($_POST['q_8'] == "") { $q8 = ""; } else $q8 = htmlspecialchars($_POST['q_8']);
	if($_POST['q_9'] == "") { $q9 = ""; } else $q9 = htmlspecialchars($_POST['q_9']);
	if($_POST['q_10'] == "") { $q10 = ""; } else $q10 = htmlspecialchars($_POST['q_10']);
	if($_POST['q_11'] == "") { $q11 = ""; } else $q11 = htmlspecialchars($_POST['q_11']);
	if($_POST['q_12'] == "") { $q12 = ""; } else $q12 = htmlspecialchars($_POST['q_12']);
	if($_POST['q_13'] == "") { $q13 = ""; } else $q13 = htmlspecialchars($_POST['q_13']);
	if($_POST['q_14'] == "") { $q14 = ""; } else $q14 = htmlspecialchars($_POST['q_14']);
	if($_POST['q_15'] == "") { $q15 = ""; } else $q15 = htmlspecialchars($_POST['q_15']);
	
	$q = Config::$g_con->prepare('UPDATE `factions` SET 
		`q1` = ?, `q2` = ?, `q3` = ?, `q4` = ?, `q5` = ?, `q6` = ?, `q7` = ?, `q8` = ?, `q9` = ?, `q10` = ?, `q11` = ?, `q12` = ?, `q13` = ?, `q14` = ?, `q15` = ?
		WHERE `ID` = ?');
	$q->execute(array($q1,$q2,$q3,$q4,$q5,$q6,$q7,$q8,$q9,$q10,$q11,$q12,$q13,$q14,$q15,Config::getData('users','Leader',$_SESSION['user'])));
	echo '<script> location.replace("'.Config::$_PAGE_URL.'leader"); </script>';		
}
 
	$q = Config::$g_con->prepare('SELECT * FROM `factions` WHERE `ID` = ?');
	$q->execute(array(Config::getData('users','Leader',$_SESSION['user'])));
	while($dnn = $q->fetch(PDO::FETCH_OBJ)) { ?>
	
<form name="login_form"  id="login_form" action="" method="post">
		Intrebarea 1:<br>
		<textarea name='q_1' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 2:<br>
		<textarea name='q_2' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>
		
		Intrebarea 3:<br>
		<textarea name='q_3' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 4:<br>
		<textarea name='q_4' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 5:<br>
		<textarea name='q_5' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea6:<br>
		<textarea name='q_6' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 7:<br>
		<textarea name='q_7' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 8:<br>
		<textarea name='q_8' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 9:<br>
		<textarea name='q_9' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 10:<br>
		<textarea name='q_10' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 11:<br>
		<textarea name='q_11' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 12:<br>
		<textarea name='q_12' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 13:<br>
		<textarea name='q_13' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 14:<br>
		<textarea name='q_14' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>

		Intrebarea 15:<br>
		<textarea name='q_15' class="span6" placeholder="Intrebare noua" rows="2"></textarea>
		<br><br><br>
	<?php } ?>
<br />
<input type="submit" name="submit" value="Modifica intrebari" class="btn btn-info btn-small"/>
</form>	
	
<?php } else { ?>
<?php 
	$q = Config::$g_con->prepare('SELECT * FROM `factions` WHERE `ID` = ?');
	$q->execute(array(Config::getData('users','Leader',$_SESSION['user'])));
        	if($q->rowCount()) 
			while($dnn = $q->fetch(PDO::FETCH_OBJ)) {
if (isset($_POST['inchide']))
{
	$id = Config::getData('users','Leader',$_SESSION['user']);
		$q = Config::$g_con->prepare('UPDATE `factions` SET `Application` = 0 WHERE `id` = ?');
		$q->execute(array($id));
	echo '<div class="alert alert-danger">Ai &#206;NCHIS aplica&#355;iile cu succes!
	<button type="button" class="close" data-dismiss="alert">
    <i class="icon-remove"></i>
    </button></div>';
	echo '<meta http-equiv="refresh" content="3;URL=\''.Config::$_PAGE_URL.'leader\'/>';
}
if (isset($_POST['reseteaza']))
{
	$id = Config::getData('users','Leader',$_SESSION['user']);
		$q = Config::$g_con->prepare('UPDATE `users` SET `Commands` = 0, `Lconf` = 0, `Frisks` = 0, `Matsdep` = 0, `Drugsdep` = 0, `Lives` = 0, `Tickets` = 0 WHERE `Member` = ?');
		$q->execute(array($id));
}
if (isset($_POST['deschide']))
{
	$id = Config::getData('users','Leader',$_SESSION['user']);
		$q = Config::$g_con->prepare('UPDATE `factions` SET `Application` = 1 WHERE `id` = ?');
		$q->execute(array($id));
	echo '<div class="alert alert-success">Ai DESCHIS aplica&#355;iile cu succes!
	<button type="button" class="close" data-dismiss="alert">
    <i class="icon-remove"></i>
    </button></div>';
	echo '<meta http-equiv="refresh" content="3;URL=\''.Config::$_PAGE_URL.'leader\'/>';
} ?>
<div class="col-xs-12">
	<h3>Setari factiune</h3>
		<div class="space-12"></div>
<style>
.btn-link{
  border:none;
  outline:none;
  background:none;
  cursor:pointer;
  color:#0000EE;
  padding:0;
  text-decoration:underline;
  font-family:inherit;
  font-size:inherit;
}
button {text-decoration: none}
</style>		
<form method="post">
<?php if($dnn->Application == "1") { ?>
	<li><button type="submit" name="inchide" style="text-decoration: none;color:#dd5a43" class="btn-link">Inchide aplicatii</button></li>
<?php } ?>
 
<?php if($dnn->Application == "0") { ?>
	<li><button type="submit" name="deschide" style="text-decoration: none;color:#dd5a43" class="btn-link">Deschide aplicatii</button></li>
<?php } ?>
<li><button type="submit" name="reseteaza" style="text-decoration: none;color:#dd5a43" class="btn-link">Accepta rapoartele de activitate</button></li>
</form>
<?php } ?>
		<li><a href="<?php echo Config::$_PAGE_URL ?>leader/intrebari">Seteaza intrebari aplicatii </a></li>
		<hr />
<?php
	$q = Config::$g_con->prepare('SELECT * FROM `aplications` WHERE `factionid` = ? AND `status` = 0');
	$q->execute(array(Config::getData('users','Leader',$_SESSION['user'])));
	$q2 = Config::$g_con->prepare('SELECT * FROM `complaints` WHERE `factionid` = ? AND `status` = 0');
	$q2->execute(array(Config::getData('users','Leader',$_SESSION['user'])));	
?>	
		Faction complaints: <a href="<?php echo Config::$_PAGE_URL ?>fcomplaints/<?php echo Config::getData('users','Leader',$_SESSION['user']) ?>"><?php echo $q2->rowCount() ?> complaints pending</a><br />
		Faction applications: <a href="<?php echo Config::$_PAGE_URL ?>applications/<?php echo Config::getData('users','Leader',$_SESSION['user']) ?>"><?php echo $q->rowCount() ?> applications pending</a>
<?php } ?>
