<?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">Customer</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>
								Customer				
							</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.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());

		  }

		  });

});


$(".category").live('change',function() {

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

		  var dataString = 'category='+ category;

		  //alert(dataString);

		  $.ajax

		  ({

		  type: "GET",

		  url: "getsubcategory.php",

		  data: dataString,

		  cache: false,

		  success: function(resp)

		  {
		  
		  $('.subcategory').html($('#subcategory',resp).html());
		  
		  }

		  });

});
		  
</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;
	});
	
});	

</script>                                
								
                                
                                
<?php        

if (isset($_POST['submit'])) { 

$customer=$_POST['customer'];

$name = $_POST['name'];

$address = $_POST['address'];

$phone = $_POST['phone'];


$ins=mysql_query("insert into customer_referances(name,address,phone,referredby) values('$name','$address','$phone','$customer')");

if($ins)
{
	header("location:viewcustomerhistory.php?customer=".$customer."&s=1");
}
else
{
	header("location:viewcustomerhistory.php?customer=".$customer."&s=2");
}


}

else 
{
$id=$_GET['id'];

$cusn=mysql_query("select * from customer where ID='$id'");
$cusn1=mysql_fetch_array($cusn);
 
?>

<form id="course" action="referance.php" method="post">

<table width="70%" style="margin:auto; line-height:35px;">

<tr><td>Customer</td><td>:</td><td><input type="hidden" name="customer" value="<?php echo $id; ?>" /> <?php echo $cusn1['name']; ?></td></tr>

<tr><td width="32%">Referance Name <span class="red">*</span></td><td width="11">:</td><td><input type="text" name="name" id="required" title="*" /></td></tr>

<tr><td>Address <span class="red">*</span></td><td>:</td><td><textarea name="address" id="required" title="*" style="width:220px; height:75px;"></textarea></td></tr>

<tr><td>Contact </td><td>:</td><td><input autocomplete="off" type="text" name="contact" /></td></tr>

<tr><td colspan="3" style="text-align:center; padding-top:7px;"><button type="submit" name="submit" class="btn btn-sm btn-primary">Submit</button></td></tr>

</table>

</form>

<?php

}
	
?>
                                                                
        
								

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