<? ob_start(); ?>
<?php
  //login_success.php  
 session_start();

	error_reporting( ~E_NOTICE ); // avoid notice
	
	require_once 'dbconfig.php';
	
	if(isset($_POST['btnsave']))
	{
		$fullname = $_POST['name_i'];// Full Name
		$address = $_POST['address_i'];// user address
		$acref = $_POST['acref_i'];// user account number
		$actype = $_POST['actype_i'];// account type
		$currencytype = $_POST['currencytype_i'];// user currency
		$username = $_POST['user_name'];// user name
		$password = $_POST['password_i'];// user password
		$opendate = $_POST['opendate_i'];// user open date
		$balance = $_POST['balance_i'];// user account balance
		$deposit = $_POST['deposit_i'];// deposit
		$aclimit = $_POST['aclimit_i'];// user account limit
		$loan = $_POST['loan_i'];// loan
		$spent = $_POST['spent_i'];// expenses
		$recenttransfer = $_POST['recenttransfer_i'];// rececnt transfer
		$pending = $_POST['pending_i'];// pending
		
		
		
		$imgFile = $_FILES['user_image']['name'];
		$tmp_dir = $_FILES['user_image']['tmp_name'];
		$imgSize = $_FILES['user_image']['size'];
		
		
		if(empty($username)){
			$errMSG = "Please Enter User Name.";
		}
		else if(empty($password)){
			$errMSG = "Please Enter Password.";
		}
		
		else if(empty($imgFile)){
			$errMSG = "Please Select Image File.";
		}
		else
		{
			$upload_dir = 'user_images/'; // upload directory
	
			$imgExt = strtolower(pathinfo($imgFile,PATHINFO_EXTENSION)); // get image extension
		
			// valid image extensions
			$valid_extensions = array('jpeg', 'jpg', 'png', 'gif'); // valid extensions
		
			// rename uploading image
			$userpic = rand(1000,1000000).".".$imgExt;
				
			// allow valid image file formats
			if(in_array($imgExt, $valid_extensions)){			
				// Check file size '5MB'
				if($imgSize < 5000000)				{
					move_uploaded_file($tmp_dir,$upload_dir.$userpic);
				}
				else{
					$errMSG = "Sorry, your file is too large.";
				}
			}
			else{
				$errMSG = "Sorry, only JPG, JPEG, PNG & GIF files are allowed.";		
			}
		}
		
		
		// if no error occured, continue ....
 

		
		if(!isset($errMSG))
		{
			
			$stmt = $DB_con->prepare('INSERT INTO tbl_users(fullname,address,acref,username,password,balance,currencytype,actype,opendate,deposit,aclimit,loan,spent,recenttransfer,pending,userPic) VALUES(:uname, :uadd, :uacr, :unam, :upas, :ubal, :ucur, :uact, :uope, :udep, :uacl, :uloa, :uspe, :urec, :upen, :upic)');
			$stmt->bindParam(':uname',$fullname);
			$stmt->bindParam(':uadd',$address);
			$stmt->bindParam(':uacr',$acref);
			$stmt->bindParam(':unam',$username);
			$stmt->bindParam(':upas',$password);
			$stmt->bindParam(':ubal',$balance);
			$stmt->bindParam(':ucur',$currencytype);
			$stmt->bindParam(':uact',$actype);
			$stmt->bindParam(':uope',$opendate);
			$stmt->bindParam(':udep',$deposit);
			$stmt->bindParam(':uacl',$aclimit);
			$stmt->bindParam(':uloa',$loan);
			$stmt->bindParam(':uspe',$spent);
			$stmt->bindParam(':urec',$recenttransfer);
			$stmt->bindParam(':upen',$pending);
			$stmt->bindParam(':upic',$userpic);
			
			  // check first if record exists
			  if($stmt->execute())
			{
        if(!isset($successMSG)) {
       
 
          // check first if record exists	
		  
			
			
                 
				$successMSG = "New Account Created succesfully...";
				header("refresh:5;dashboard.php"); // redirects image view page after 5 seconds.
			}
			else
			{
				$errMSG = "error while inserting....";
			}
		}
	}
	}
		
?>









<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Upload, Insert, Update, Delete Clients</title>

<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

</head>
<body>

<div class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container">
 
        <div class="navbar-header">
           <div class="navbar-brand">ADMIN PANEL</div> 
        </div>
 
    </div>
</div>

<div class="container">
	 <?php  
  
 if(isset($_SESSION["username"]))  
 {  
      echo '<h3>Login Success, Welcome - '.$_SESSION["username"].'</h3>';    
 }  
 else  
 {  
      header("location:view.php");  
 }  
 ?>

	<div class="page-header">
    	<h1 class="h2">Create New Account. <a class="btn btn-default" href="view.php"> <span class="glyphicon glyphicon-eye-open"></span> &nbsp; view all </a> &nbsp; <a class="btn btn-default" href="logout.php"> <span class="glyphicon glyphicon-eye-open"></span> &nbsp; Sign Out </a></h1>
    </div>
    

	<?php
	if(isset($errMSG)){
			?>
            <div class="alert alert-danger">
            	<span class="glyphicon glyphicon-info-sign"></span> <strong><?php echo $errMSG; ?></strong>
            </div>
            <?php
	}
	else if(isset($successMSG)){
		?>
        <div class="alert alert-success">
              <strong><span class="glyphicon glyphicon-info-sign"></span> <?php echo $successMSG; ?></strong>
        </div>
        <?php
	}
	?>   

<form method="post" enctype="multipart/form-data" class="form-horizontal"/>
	    
	<table class="table table-bordered table-responsive">
	<tr>
                 <td width="100%" bgcolor="#eef1fb" colspan="2" height="20">
					<font face="Trebuchet MS" size="3" color="#000000"><strong>Account Details</strong></font></td>
               </tr>
    <tr>
    	<td><label class="control-label">Full Name.</label></td>
        <td><input class="form-control" type="text" name="name_i" placeholder="Enter Full name" value="<?php echo $fullname; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Address.</label></td>
        <td><input class="form-control" type="text" name="address_i" placeholder="Address" value="<?php echo $address; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Account Number.</label></td>
        <td><input class="form-control" type="text" name="acref_i" placeholder="Account Number" value="<?php echo $acref; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">User Name</label></td>
        <td><input class="form-control" type="text" name="user_name" placeholder="UserName" value="<?php echo $username; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Password</label></td>
        <td><input class="form-control" type="text" name="password_i" placeholder="Password" value="<?php echo $password; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Amount.</label></td>
        <td><input class="form-control" type="text" name="balance_i" placeholder="Amount Balance" value="<?php echo $balance; ?>" /></td>
    </tr>
    <tr>
    	<td><label class="control-label">Currency Type.</label></td>
        <td><select class="form-control" type="text" name="currencytype_i" placeholder="Currency Type	" value="<?php echo $currencytype; ?>" />
        <option selected="" value="Select">Select</option>
            
			<option value="USD">$</option>
	<option value="EUR">Euro</option>
	<option value="GBP">United Kingdom Pounds</option>
	<option value="DZD">Algeria Dinars</option>
	<option value="ARP">Argentina Pesos</option>
	<option value="AUD">Australia Dollars</option>
	<option value="ATS">Austria Schillings</option>
	<option value="BSD">Bahamas Dollars</option>
	<option value="BBD">Barbados Dollars</option>
	<option value="BEF">Belgium Francs</option>
	<option value="BMD">Bermuda Dollars</option>
	<option value="BRR">Brazil Real</option>
	<option value="BGL">Bulgaria Lev</option>
	<option value="CAD">Canada Dollars</option>
	<option value="CLP">Chile Pesos</option>
	<option value="CNY">China Yuan Renmimbi</option>
	<option value="CYP">Cyprus Pounds</option>
	<option value="CSK">Czech Republic Koruna</option>
	<option value="DKK">Denmark Kroner</option>
	<option value="NLG">Dutch Guilders</option>
	<option value="XCD">Eastern Caribbean Dollars</option>
	<option value="EGP">Egypt Pounds</option>
	<option value="FJD">Fiji Dollars</option>
	<option value="FIM">Finland Markka</option>
	<option value="FRF">France Francs</option>
	<option value="DEM">Germany Deutsche Marks</option>
	<option value="XAU">Gold Ounces</option>
	<option value="GRD">Greece Drachmas</option>
	<option value="HKD">Hong Kong Dollars</option>
	<option value="HUF">Hungary Forint</option>
	<option value="ISK">Iceland Krona</option>
	<option value="INR">India Rupees</option>
	<option value="IDR">Indonesia Rupiah</option>
	<option value="IEP">Ireland Punt</option>
	<option value="ILS">Israel New Shekels</option>
	<option value="ITL">Italy Lira</option>
	<option value="JMD">Jamaica Dollars</option>
	<option value="JPY">Japan Yen</option>
	<option value="JOD">Jordan Dinar</option>
	<option value="KRW">Korea (South) Won</option>
	<option value="LBP">Lebanon Pounds</option>
	<option value="LUF">Luxembourg Francs</option>
	<option value="MYR">Malaysia Ringgit</option>
	<option value="MXP">Mexico Pesos</option>
	<option value="NLG">Netherlands Guilders</option>
	<option value="NZD">New Zealand Dollars</option>
	<option value="NOK">Norway Kroner</option>
	<option value="PKR">Pakistan Rupees</option>
	<option value="XPD">Palladium Ounces</option>
	<option value="PHP">Philippines Pesos</option>
	<option value="XPT">Platinum Ounces</option>
	<option value="PLZ">Poland Zloty</option>
	<option value="PTE">Portugal Escudo</option>
	<option value="ROL">Romania Leu</option>
	<option value="RUR">Russia Rubles</option>
	<option value="SAR">Saudi Arabia Riyal</option>
	<option value="XAG">Silver Ounces</option>
	<option value="SGD">Singapore Dollars</option>
	<option value="SKK">Slovakia Koruna</option>
	<option value="ZAR">South Africa Rand</option>
	<option value="KRW">South Korea Won</option>
	<option value="ESP">Spain Pesetas</option>
	<option value="XDR">Special Drawing Right (IMF)</option>
	<option value="SDD">Sudan Dinar</option>
	<option value="SEK">Sweden Krona</option>
	<option value="CHF">Switzerland Francs</option>
	<option value="TWD">Taiwan Dollars</option>
	<option value="THB">Thailand Baht</option>
	<option value="TTD">Trinidad and Tobago Dollars</option>
	<option value="TRL">Turkey Lira</option>
	<option value="VEB">Venezuela Bolivar</option>
	<option value="ZMK">Zambia Kwacha</option>
	<option value="EUR">Euro</option>
	<option value="XCD">Eastern Caribbean Dollars</option>
	<option value="XDR">Special Drawing Right (IMF)</option>
	<option value="XAG">Silver Ounces</option>
	<option value="XAU">Gold Ounces</option>
	<option value="XPD">Palladium Ounces</option>
	<option value="XPT">Platinum Ounces</option>
			
			</select></td>
    </tr>
      <tr>
    	<td><label class="control-label">Account Type.</label></td>
        <td><select class="form-control" type="text" name="actype_i" placeholder="Account Type" value="<?php echo $actype; ?>" />
         <option selected="">Select</option>
          <option value="saving">Savings</option>
          <option value="Domiciliary">Domiciliary</option>
          <option value="Online">Online</option>
          <option value="Joint Account">Joint Account</option>
          <option value="current">Current</option>
          <option value="fixed">Fixed Deposit</option>
        </select></td>
    </tr>
      
     <tr>
    	<td><label class="control-label">Opening Date.</label></td>
        <td><input class="form-control" type="text" name="opendate_i" placeholder="Account Opening Date" value="<?php echo $opendate; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Depositor Name.</label></td>
        <td><input class="form-control" type="text" name="deposit_i" placeholder="Depositor Name" value="<?php echo $deposit; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Account Limit.</label></td>
        <td><input class="form-control" type="text" name="aclimit_i" placeholder="Account Limit" value="<?php echo $aclimit; ?>" /></td>
    </tr>
     <tr>
    	<td><label class="control-label">Pending Loan Amount.</label></td>
        <td><input class="form-control" type="text" name="loan_i" placeholder="Pending Loan Amount" value="<?php echo $loan; ?>" /></td>
    </tr>    
         <tr>
    	<td><label class="control-label">Expenses.</label></td>
        <td><input class="form-control" type="text" name="spent_i" placeholder="Expenses" value="<?php echo $spent; ?>" /></td>
    </tr>
         <tr>
    	<td><label class="control-label">Recent Transfer.</label></td>
        <td><input class="form-control" type="text" name="recenttransfer_i" placeholder="Recent Transfer" value="<?php echo $recenttransfer; ?>" /></td>
    </tr>
         <tr>
    	<td><label class="control-label">Pending Amount.</label></td>
        <td><input class="form-control" type="text" name="pending_i" placeholder="Pending Amount" value="<?php echo $pending; ?>" /></td>
    </tr>
   
    <tr>
                 <td width="100%" bgcolor="#eef1fb" colspan="2" height="20">
					<font face="Trebuchet MS" size="3" color="#000000"><strong>Client Pictures</strong></font></td>
               </tr>
    <tr>
    	<td><label class="control-label">Profile Img.</label></td>
        <td><input class="input-group" type="file" name="user_image" accept="image/*" /></td>
    </tr>
    	
    <tr>
        <td colspan="2"><button type="submit" name="btnsave" class="btn btn-default">
        <span class="glyphicon glyphicon-save"></span> &nbsp; save
        </button>
        </td>
    </tr>
    
    </table>
    
</form>



<div class="alert alert-info">
    
</div>

    

</div>



	


<!-- Latest compiled and minified JavaScript -->
<script src="bootstrap/js/bootstrap.min.js"></script>




</body>
</html>
<? ob_flush(); ?>