<?PHP

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">Advance Voucher</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>

								Advance Voucher

							</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 -->

<br />



						<div class="row">

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

                            

								<!-- PAGE CONTENT BEGINS -->



<script type="text/javascript" src="assets/js/jquery.js"></script>



<script type='text/javascript'>

$(document).ready(function() {



$(".year").change(function(){

var employee=$('.employee').val();

var month=$('.month').val();

var year=$('.year').val();

var dataString = 'empid='+ employee +'&month='+ month +'&year='+ year;

 //alert(dataString);

    $.ajax

({

type: "GET",

url: "getsal.php",

data: dataString,

cache: false,

success: function( html )

{

	//alert(html);

	var bal=$(html).filter('#bal').text();

	var bal1=$(html).filter('#bal1').text();

	var salary=$(html).filter('#salary').text();

	var advance=$(html).filter('#advance').text();

	

	$('.salary').val(salary);

	$('.advance').val(advance);

	$('.balance').val(bal);

	$('.bal1').val(bal1);

		

}

});

});	



});



</script>



<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#register').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:11px;color:#ff0000;" class="'+ errorcn +'">'+ msg +'</span>')

					.appendTo(parent)

					.fadeIn('fast')

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

				valid = false;

			};

		});

		

		return valid;

	});

	

});	



</script>





<?php



if($_GET['id'])

{



$id=$_GET['id'];



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

	

	{

	 $status=$_GET['s'];

		 if($status=='1')

		 {

           echo'<div class="alert alert-success alert-dismissable" style="width:80%; margin:auto;">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Values Added Successfully.</span>

                </div><br />';

		}

		elseif($status=='2')

		 {

           echo'<div class="alert alert-error alert-dismissable" style="width:80%; margin:auto;">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Values not inserted.</span>

                </div><br />';

		}

		

	}



?>



<center>

<script type="text/javascript">

// Popup window code

function newPopup(url) {

	popupWindow = window.open(

		url,'popUpWindow','height=500,width=1000,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,onscreendisplay=yes,menubar=no,location=no,directories=no,status=yes')

}

</script>

<br />

<a href="JavaScript:newPopup('printvoucher.php?id=<?php echo $id ?>');" title="Print"><i class="splashy-printer"></i></a></center><br /><br />





<?php



$sql=mysql_query("select * from advance where ID='$id'");

$sql1=mysql_fetch_array($sql);



$emp=mysql_query("select * from employee where empid='$sql1[empid]'");

$emp1=mysql_fetch_array($emp);



echo'<center><table style="margin:auto;">



<tr><td id="page"><b>Employee Name</b> </td><td style="padding:0 7px;">:</td><td id="page">'.$emp1['name'].'</td><td style="width:450px;"></td><td><b>Date</b> </td><td style="padding:0 7px;">:</td><td> '.date('d-m-Y',strtotime($sql1['date'])).'</td></tr>



<tr><td id="page"><b>Employee ID</b> </td><td style="padding:0 7px;">:</td> <td id="page">'.$sql1['empid'].'</td><td style="width:450px;"></td><td><b>Voucher No</b> </td><td style="padding:0 7px;">:</td><td> '.$id.'</td></tr>



<tr><td id="page"><b>Month</b> </td><td style="padding:0 7px;">:</td> <td id="page">'.date("F",mktime(0,0,0,$sql1['month'],10)).'</td><td style="width:450px;"></td><td><b>Year</b> </td><td style="padding:0 7px;">:</td><td> '.$sql1['year'].'</td></tr>



</table><br />';



echo"<table class='table table-striped table-bordered table-condensed' style='width:75%; margin:auto;'>

<thead><tr><th width='50%'>Description</th><th width='50%'>Amount</th></tr></thead><tbody>



<tr><td>Net Pay</td><td style='text-align:right;'>".$sql1['amount']."</td></tr>



</table><br /><br /></center>



<p style='margin-left:15%;'><b>Remarks</b> : ".$sql1['remarks']."</p><br /><br />



<center><a href='viewadvance.php'>Back</a></center>";



}



else

{



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

	{

		

	 $status=$_GET['s'];

		 if($status=='3')

		 {

           echo'<div class="alert alert-success alert-dismissable" style="width:80%; margin:auto;">

                <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>

                <span style="text-align:left;">Values Deleted Successfully.</span>

                </div><br />';

		}

		

	}



echo"<br /><a href='advance.php' style='padding-left:85px;'>Create</a>



<center><table style='width:85%;'>

<tr><td><table class='table table-striped table-bordered table-condensed' id='dynamic-table'>

<thead><tr><th width='11%'>ID</th><th width='11%'>Date</th>

<th width='20%'>Employee</th><th width='15%'>Amount</th>

<th width='15%'>Actions</th></tr></thead><tbody>";



$g=mysql_query("select * from advance Order by ID desc");

$csk=mysql_num_rows($g);



while($g1=mysql_fetch_array($g))

{        



$emp=mysql_query("select * from employee where empid='$g1[empid]'");

$num=mysql_num_rows($emp);



$emp1=mysql_fetch_array($emp);



echo"<tr><td>".$g1['ID']."</td><td>".date('d-m-Y',strtotime($g1['date']))."</td><td>".$emp1['name']."</td><td>".$g1['amount']."</td><td><a href='viewadvance.php?id=".$g1['ID']."' title='View'><i class='ace-icon fa fa-search-plus bigger-100 blue'></i></a> &nbsp; <a href='editadvance.php?id=".$g1['ID']."' title='Edit'><i class='ace-icon fa fa-pencil bigger-100 blue'></i></a> &nbsp; <a href='del.php?id=".$g1['ID']."&desc=salaryadvance' title='Delete'><i class='ace-icon fa fa-trash-o bigger-100 red'></i></a></td></tr>";

}



echo"</tbody></table></td></tr></table></center><br />";



}

?>



								<!-- PAGE CONTENT ENDS -->

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

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

					



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

				</div>

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





<?php



include 'bottom.php';

}

else

{



 header("location:login.php");

}



?>