<?php
	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();
	require_once ('spreadsheet/vendor/autoload.php');

	for($i = 0; $i < count($_GET); $i++):
		${key($_GET)} = $_GET[key($_GET)];
		next($_GET);
	endfor;

	$database->setQuery("SELECT name FROM client WHERE id = '$client'");
	$clientname = $database->loadResult();
	$convertm = explode('-', $month);
	$monthheader = $convertm[1].'.'.$convertm[0];
	switch($convertm[1]){
		case('12'):$mesec = 'Decembar ';break;
		case('1'):$mesec = 'Januar ';break;
		case('2'):$mesec = 'Februar ';break;
		case('3'):$mesec = 'Mart ';break;
		case('4'):$mesec = 'April ';break;
		case('5'):$mesec = 'Maj ';break;
		case('6'):$mesec = 'Jun ';break;
		case('7'):$mesec = 'Jul ';break;
		case('8'):$mesec = 'Avgust ';break;
		case('9'):$mesec = 'Septembar ';break;
		case('10'):$mesec = 'Oktobar ';break;
		case('11'):$mesec = 'Novembar ';break;
		}

	$fd =  $convertm[0].'-'.$convertm[1];
	$database->setBareQuery("SELECT DISTINCT(user) FROM task WHERE project IN (SELECT id FROM project WHERE parent = '$client') AND  SUBSTRING_INDEX( DATE,  '-', 2 ) =  '$fd' ORDER BY user");
	$users = $database->loadResultArray(0);
	$endcell = count($users);
	$endcell = $endcell + 67;
	$endcell = chr($endcell).'1';
	$reportdate = $mesec.$convertm[0];
	$database->setBareQuery("SELECT DISTINCT(t1.name), t1.id, t1.project_num, t1.project_year FROM project t1, task t2 WHERE SUBSTRING_INDEX(t2.date, '-', 2) = '".$fd."' AND t1.parent = '".$client."' AND t1.id = t2.project ORDER BY t1.project_year, t1.project_num");
	$projects = $database->loadResultArray(0);
	$pid = $database->loadResultArray(1);
	$projectnum = $database->loadResultArray(2);
	$project_year = $database->loadResultArray(3);
	$projectcount = count($projects);

 ?>
