<?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">Employee Designation</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>

								Employee Designation

							</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($_POST['submit']))



{



$id=$_POST['id'];



$designation=$_POST['designation'];



$department=$_POST['department'];







$up=mysql_query("update employee_designation set department='$department',designation='$designation' where ID='$id'");







if($up)



{



header("location:viewdesignation.php?s=1");



}







}      







elseif($_GET['id'])



{



$id=$_GET['id'];







$c=mysql_query("select * from employee_designation where ID='$id'");

$c1=mysql_fetch_array($c);







echo"<center><form action='viewdesignation.php?id=".$id."' method='post' id='course'>



<input type='hidden' name='id' value='".$id."'>



<table style='line-height:35px;'>



<tr><td>Designation <span class='red'>*</span> </td><td style='padding:0 3px;'>:</td><td> <input type='text' name='designation' value='".$c1['designation']."' style='width:220px;' id='required' title='*' autocomplete='off' /> </td></tr>



<tr><td>Department <span class='red'>*</span> </td><td style='padding:0 3px;'>:</td><td> <select name='department' id='required' title='*' style='width:220px;'><option value=''></option>";



$depar=mysql_query("select * from department order by ID asc");

while($depar1=mysql_fetch_array($depar))

{



$dept="<option value='".$depar1['ID']."'>".$depar1['department']."</option>";

$dept=str_replace("<option value='".$c1['department']."'","<option value='".$c1['department']."' selected",$dept);

echo $dept;

	

}



echo"</select> </td></tr>



</table><br><br>



<button type='submit' class='btn btn-sm btn-primary' name='submit' value='submit'>Edit</button>



</form></center>";



}



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>

						Designation Created Successfully.

				  </div>';				  

		 }

		 if($status=='7')

		 {

			 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>

						Designation Deleted Successfully.

				  </div>';				  

		 }

	}

	

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

                                        

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

                                        <a href="designation.php"><button class="btn btn-minier btn-info">+ Add Designation</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='30%'>Designation</th><th width='30%'>Department</th><th width='10%' style='text-align:center;'>Actions</th></thead>

<tbody>";



$select="select * from employee_designation order by ID ASC";

$select1=mysql_query($select);

$sno=0;

while($value=mysql_fetch_array($select1))

{

$sno=$sno+1;



$dept=mysql_query("select * from department where ID='$value[department]'");

$dept1=mysql_fetch_array($dept);



echo'<tr><td>'.$sno.'</td><td>'.$value['designation'].'</td><td>'.$dept1['department'].'</td><td>';



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

													   {

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

													   

															<a href="viewdesignation.php?id='.$value['ID'].'" title="Edit">

																<i class="ace-icon fa fa-pencil bigger-100 green"></i></a> &nbsp; 

																

															<a href="del.php?id='.$value['ID'].'&desc=designation" 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();

?>