<?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">Imprest</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>

								Imprest

							</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 src="assets/js/jquery.js"></script>



<script>





  $(".bank").live('change',function()



		  {



		  var bank=$(this).val();



		  var dataString = 'bank='+ bank;



		  //alert(dataString);



		  $.ajax



		  ({



		  type: "GET",



		  url: "getacc.php",



		  data: dataString,



		  cache: false,



		  success: function(resp)



		  {



		  $('.account').html($('#account',resp).html());



		  }



		  });



		  });



		  



$(".customer").live('change',function()



		  {



		  var customer=$(this).val();



		  



		  var customer=customer.replace('&', '%26');



		  



		  var dataString = 'customer='+ customer;



		  //alert(dataString);



		  $.ajax



		  ({



		  type: "GET",



		  url: "getbal.php",



		  data: dataString,



		  cache: false,



		  success: function(html)



		  {



		  //alert(html);



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



	



			$('.bal').html(bal);



		  }



		  });



		  });





</script>





<script>

	

jQuery(function($){

		   

	// simple jQuery validation script

	$('#work').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']))















{















$date=$_POST['date'];







$factory=$_POST['factory'];





$description=$_POST['description'];





$amount=$_POST['amount'];











if($factory)















{















$date=date('Y-m-d',strtotime($date));







$insert="INSERT into imprest(date,factory,description,amount) values('$date','$factory','$description','$amount')";















mysql_query($insert) or die(mysql_error());















}























if($insert){







header("location:imprest.php?s=1" . urlencode($Message));











}















else{















echo "<script type='text/javascript'>alert('Field Missing.');</script><META HTTP-EQUIV = 'Refresh' Content = '1; URL =imprest.php'>";















}















}















else







{







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







	{







	 $status=$_GET['s'];







		 if($status=='1')







		 {







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







				<a class="close" data-dismiss="alert">x</a>







					Values Added Successfully !







			  </div>';







		}







	}





echo '<form action="imprest.php" method="post" id="work">





<br />















<center><table width="70%" id="page" style="line-height:35px;">















<tr><td id="page">Date <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input type="text" name="date" autocomplete="off" class="datepicker" id="required" title="*" autocomplete="off" /></td></tr>







<tr><td id="page">Factory <span class="red">*</span></td><td width="2%">:</td> <td id="page"><select name="factory" id="required" title="*" style="width:220px;">



<option value="">Select Factory</option>';











$cus=mysql_query("select * from factory order by factory asc");







while($cus1=mysql_fetch_array($cus))







{







echo"<option value='".$cus1['ID']."'>".$cus1['factory']."</option>";







}















echo'</select></td></tr>









<tr><td id="page">Description <span class="red">*</span></td><td width="2%">:</td> <td id="page"><textarea name="description" style="width:220px; height:70px;" id="required" title="*"></textarea></td></tr>















<tr><td id="page" style="width:180px;">Amount <span class="red">*</span></td><td width="2%">:</td> <td id="page"><input size="25" type="text" name="amount" autocomplete="off" id="required" title="*" autocomplete="off" /></td></tr>





</table>





<center><button class="btn btn-sm btn-primary" type="submit" name="submit" value="Add">Save</button></center>









</form>';















}







	







?>                                

                               

							<br>

<br>

	



								<!-- 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();

?>