<?PHP

ob_start();

session_start();

include 'connect.php';

if(isset($_SESSION['adminemail']))

{

$user=$_SESSION['adminemail'];



$gtp=mysql_query("select * from admin where username='$user'");

$gtp1=mysql_fetch_array($gtp);



include 'top.php';

?>







			<div class="main-content">

				<div class="main-content-inner">

					<div class="breadcrumbs ace-save-state" id="breadcrumbs">

						<ul class="breadcrumb">

							<li>

								<i class="ace-icon fa fa-home home-icon"></i>

								<a href="#">Home</a>

							</li>

							<li class="active">Department</li>

						</ul><!-- /.breadcrumb -->

					</div>



					<div class="page-content">

			



						<div class="page-header">

                        

<?php



$aca=mysql_query("select * from financial where user='$user' order by ID desc");

$aca1=mysql_fetch_array($aca);



$financial=$aca1['financial'];



?>                        

                        

							<table style="width:100%;">

                        

                        <tr><td style="width:50%;">

                        

							<h1>

								Team Allocation

							</h1>

                            

                            </td>

                            

                            <td style="width:50%; text-align:right; padding-right:15px; font-size:15px;">

                            

                            <i class="fa fa-calendar"></i>&nbsp; <?php echo $financial; ?>

                            

                            </td></tr></table>

                            

						</div><!-- /.page-header -->



						<div class="row">

							<div class="col-xs-12">

                            

								<!-- PAGE CONTENT BEGINS -->



<script src="assets/js/jquery-2.1.4.min.js"></script>

<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#course').submit(function(){

		

		var valid = true;

		var errormsg = 'This field is required!';

		var errorcn = 'error';

		

		$('.' + errorcn, this).remove();			

		

		$('#required', this).each(function(){

			var parent = $(this).parent();

			if( $(this).val() == '' ){

				var msg = $(this).attr('title');

				msg = (msg != '') ? msg : errormsg;

				$('<span style="font-size:13px;color:#FF0000; padding-left:3px;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

					.click(function(){ $(this).remove(); });

				valid = false;

			};

		});

		

		return valid;

		

		$('button:submit').prop('disabled', true);

		

	});

	

});	



</script>					

										

                                        

<?php  







if(isset($_GET['id']))



{



$id=$_GET['id'];





$up=mysql_query("delete from team_allocation where team_leader='$id'");







if($up)



{



header("location:viewteam.php?s=3");



}







}



else



	{

	

if (isset($_GET['s'])) 	

	{

	 $status=$_GET['s'];

		

		 if($status=='1')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values Edited Successfully.

				  </div>';				  

		 }

		 if($status=='2')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Team Created Successfully.

				  </div>';				  

		 }

		 if($status=='3')

		 {

			 echo'<div class="alert alert-block alert-success">

									<button type="button" class="close" data-dismiss="alert">

										<i class="ace-icon fa fa-times"></i>

									</button>

						Values Deleted Successfully.

				  </div>';				  

		 }

	}

	

	echo'<table style="width:99%; margin:11px auto 10px auto;">

                                        

                                        <tr><td style="width:20%;">

                                        <a href="team.php"><button class="btn btn-minier btn-info">+ Create Team</button></a>

                                        </td>

                                        

                                        <td style="width:50%;"></td>

                                        

                                        <td style="width:30%;">

                                        

                                        </td>

                                        

                                        </tr>

                                        

                                        </table>';

									

echo'<table id="dynamic-table" class="table table-striped table-bordered table-hover">';



echo"<thead><th height='25' width='5%'>S.No</th><th width='35%'>Team Leader</th><th>Executives</th><th width='10%' style='text-align:center;'>Actions</th></thead>

<tbody>";



$select="select * from team_allocation group by team_leader order by team_leader asc";

$select1=mysql_query($select);

$sno=0;

while($value=mysql_fetch_array($select1))

{

$sno=$sno+1;



$empl=mysql_query("select * from employee where ID='$value[team_leader]'");

$empl1=mysql_fetch_array($empl);



echo'<tr><td>'.$sno.'</td><td>'.$empl1['name'].'</td>



<td style="padding:0px;"><table style="width:100%; border-collapse:collapse; border-color:#DDDDDD;">';



$sno=0;

$sl=mysql_query("select * from team_allocation where team_leader='$value[team_leader]'");

$nmr=mysql_num_rows($sl);

while($sl1=mysql_fetch_array($sl))

{

$sno=$sno+1;



$exc=mysql_query("select * from employee where ID='$sl1[executive]'");

$exc1=mysql_fetch_array($exc);



if($sno==$nmr)

{

echo"<tr><td style='padding:2px 0 2px 7px;'>".$exc1['name']."</td></tr>";

}

else

{

echo"<tr><td style='border-bottom:1px solid #DDDDDD; padding:2px 0 2px 7px;'>".$exc1['name']."</td></tr>";

}



}



echo'</table></td>



<td>';



													   if($gtp1['type']!='staff')

													   {

													   echo'<div class="hidden-sm hidden-xs btn-group">

													   

															<a href="viewteam.php?id='.$value['team_leader'].'&desc=del" title="Delete">

																<i class="ace-icon fa fa-trash-o bigger-110 dark grey"></i></a>

															

														</div>';

													   }



echo'</td></tr>';

}



echo"</tbody></table>";



}



?>









										<!-- PAGE CONTENT ENDS -->

									</div><!-- /.col -->

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

							</div><!-- /.page-content -->

						</div>

					</div><!-- /.main-content -->





<?php

include 'bottom.php';

}

else

{



 header("location:login.php");

}

ob_flush();

?>