<?php

	require_once('../libs/Ultraviolet.php');

	require_once('../libs/Database.php');

	require_once('../libs/AdminFunctions.php');
	
	require_once('../libs/SimpleImage.php');
	
	require_once('../libs/FileUpload.php');

	

	$database =& DatabaseConnect::getInstance();

	$functions =& AdminFunctions::getInstance();

	$database->query("SET CHARACTER SET utf8");



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

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

		next($_POST);	

	endfor;
	
	
	
	$projectname = str_replace("'", "`", $projectname);
	
	$database->setBareQuery("SELECT id FROM project WHERE name = '$projectname' AND parent ='$parent'");

	$id = $database->loadResultArray(0);
		
	if(count($id) == 0):
	
	if($parent != 'default'):

	if($projectname != ''):

		if($database->query("INSERT INTO project(name, parent) VALUES('$projectname', '$parent')")):

			echo "success";

		else:

			echo mysql_errno()." ".mysql_error();

		endif;
		
	else:
	
		echo 'Morate uneti ime projekta!';
		
	endif;
	
	else:
	
		echo 'Morate izabrati klijenta!';
		
	endif;
	
	else:
		
		echo 'Projekat je već dodeljen tom klijentu';
		
	endif;

?>