<?php
session_start();
ob_start();
require "../model/configuration.php";
if(isset($_POST['staff_add']))
{
	$name = $_POST['name'];
	$email = $_POST['mail'];
	$phone = $_POST['phone'];
	$dob = date("Y-m-d", strtotime($_POST['dob']));//date('Y-m-d', strtotime(str_replace('/', '-', mysql_real_escape_string($_POST['dob']))));
	$address = $_POST['address'];
	$dep = $_POST['dep'];
	$role = $_POST['role'];
	$log = $_POST['log'];
	$place = $_POST['place'];
	$zipcode = $_POST['zipcode'];
	$usrname = $email;//strtoupper(substr($name, 0, 3).substr($phone, 0, 3).substr($dob, 0, 4));
	
$query = $db->execute("INSERT INTO staff(user_name,role_id,staff_name,stfaddress,dob,depid,logaccess,email,place,zipcode,phone) VALUES('$usrname','$role','$name','$address','$dob','$dep','$log','$email','$place','$zipcode','$phone')");



$querya = "SELECT * FROM staff where user_name='$usrname'";
$resulta = $db->execute($querya);
$rowa = $resulta->fetch_assoc();
$idstf=$rowa['staff_id'];
$querys = "INSERT INTO users(user_name,password,name,staff_id,loginpermission) VALUES('$usrname','$phone','$name','$idstf','$log')";
$db->execute($querys);


}
header("location:../Pages/staff_add.php");
?>