<?php

session_start();

    require_once('../libs/Ultraviolet.php');
	
	require_once('../libs/Database.php');
	
	require_once('../libs/AdminFunctions.php');
		
	$database =& DatabaseConnect::getInstance();
	
	$database->query("SET CHARACTER SET utf8");
	
	$functions =& AdminFunctions::getInstance();


for($i = 0; $i < count($_POST); $i++):

		${key($_POST)} = $_POST[key($_POST)];

		next($_POST);	

	endfor;

$database->query("DELETE FROM task WHERE user = '".$user."' AND date = '".$date."'");

$dayarray = explode("|", $dayarray);

$clients = explode(",", $dayarray[0]);

$projects = explode(",", $dayarray[1]);

$descriptions = explode(",", $dayarray[2]);

$durations = explode(",", $dayarray[3]);

for($i = 0; $i < count($clients); $i++):

	$database->query("INSERT INTO task(project, user, description, duration, date) VALUES('$projects[$i]', '$user', '$descriptions[$i]', '$durations[$i]', '$date')");

endfor;

echo 'success';




?>
