<?php
require 'dao/LogBook.php';
//Requires PHP 5
date_default_timezone_set("Europe/London");
define('UPLOAD_DIR', '../logBook/');
if (isset($_POST['imgBase64'])) {
	$img = $_POST['imgBase64'];
	$token = $_POST['token'];
	$img = str_replace('data:image/png;base64,', '', $img);
	$img = str_replace(' ', '+', $img);
	$data = base64_decode($img);
	$d = strtotime("10:30pm April 15 2014");
	$date_create = date("Y-m-d h;i;sa"); 
     
	$file = UPLOAD_DIR . $token . ' ' . $date_create . '.png';
	$success = file_put_contents($file, $data);
	//print $success ? $file : 'Unable to save the file.';
	// if ($success) {
		$staff_name = $logbook->get_staff_details($token);
		
		if ($staff_name) {
		$data = array("staff_id"=>$token,
					  "date_time"=>$date_create);
		$sign = $logbook->signin($data);
			echo $staff_name[0]['first_name'].' '.$staff_name[0]['last_name'];
		}else{
			echo 2;
		}
		
	// }else{
	// 	echo 3;
	// }
}else{
	
}

$staff_log = $logbook->get_all_staff_log();
?>