<commit_before><?php
require_once('tiki-setup.php');
TikiLib::lib("trkqry");

$projectList = TrackerQueryLib::tracker("Project list")->byName()->query();
$timeSheet = TrackerQueryLib::tracker("Time sheet")->byName()->query();

if(isset($projectList)) {
	if (isset($_REQUEST['save'])) {	
		TikiLib::lib("trk")->replaceItemFromRequestValuesByName("Time sheet", array(
			"Summary",
            "Associated project",
            "Description",
            "Amount of time spent",
            "Done by"
		), $_REQUEST); 
		die;
	}

	$timeSheetProfileLoaded = true;
	$smarty->assign("timeSheetProfileLoaded", $timeSheetProfileLoaded);
	$smarty->assign("projectList", $projectList);
	$smarty->assign("timeSheet", $timeSheet);
}

TikiLib::lib("sheet")->setup_jquery_sheet();

$headerlib = TikiLib::lib("header");

$headerlib->add_cssfile("lib/jquery/jtrack/css/jtrack.css");
$headerlib->add_jsfile("lib/jquery/jtrack/js/domcached-0.1-jquery.js");
$headerlib->add_jsfile("lib/jquery/jtrack/js/jtrack.js");


$headerlib->add_jq_onready("
	jTask.init();
	var remainingWidth = $('#timeSheetUnsaved').width() - $('#jtrack-holder').width();
	
	$.timesheetSpreadsheet = function() {
		var table = $('<table title=/>').attr('title', tr('Local Cache (Not Committed)'));
		table.append('<tr><td>Summary</td><td>Estimate</td><td>Time Spent</td></tr>');
		
		var rowI = 1;
		for (var namespace in $.DOMCached.getStorage()) {
			var row = $('<tr />').appendTo(table);
			
			row.append('<td>' + namespace + '</td>');
			row.append('<td>' + $.DOMCached.get('estimate', namespace) + '</td>');
			row.append('<td formula=\'ROUND(' + ($.DOMCached.get('timer', namespace) / 60) + ', 2)\' />');
			rowI++;
		}
		var row = $('<tr />').appendTo(table);
		row.append('<td>Totals</td>');
		row.append('<td formula=\'ROUND(SUM(B2:B' + rowI + '), 2)\'/>');
		row.append('<td formula=\'=ROUND(SUM(C2:C' + rowI + '), 2)\' />');
		
		$('#timesheetSpreadsheet').siblings().remove();
		$('#timesheetSpreadsheet').parent().width(remainingWidth);
		<commit_msg>[ENH] Made default list only show the tracker items that are associated with your user [ENH] Made the username save under "Done by" field.<commit_after><?php
require_once('tiki-setup.php');
global $user;
TikiLib::lib("trkqry");

$projectList = TrackerQueryLib::tracker("Project list")->byName()->query();

if (isset($_REQUEST['all'])) { //all views all sheet items
	$timeSheet = TrackerQueryLib::tracker("Time sheet")->byName()->query();
} else {//views only your items
	$timeSheet = TrackerQueryLib::tracker("Time sheet")->byName()->search(array($user))->fields(array("Done by"))->query();
}

if(isset($projectList)) {
	if (isset($_REQUEST['save'])) {	
		$_REQUEST['Done_by'] = $user;
		TikiLib::lib("trk")->replaceItemFromRequestValuesByName("Time sheet", array(
			"Summary",
            "Associated project",
            "Description",
            "Amount of time spent",
            "Done by"
		), $_REQUEST); 
		die;
	}

	$timeSheetProfileLoaded = true;
	$smarty->assign("timeSheetProfileLoaded", $timeSheetProfileLoaded);
	$smarty->assign("projectList", $projectList);
	$smarty->assign("timeSheet", $timeSheet);
}

TikiLib::lib("sheet")->setup_jquery_sheet();

$headerlib = TikiLib::lib("header");
$headerlib->add_cssfile("lib/jquery/jtrack/css/jtrack.css");
$headerlib->add_jsfile("lib/jquery/jtrack/js/domcached-0.1-jquery.js");
$headerlib->add_jsfile("lib/jquery/jtrack/js/jtrack.js");
$headerlib->add_jq_onready("
	jTask.init();
	var remainingWidth = $('#timeSheetUnsaved').width() - $('#jtrack-holder').width();
	
	$.timesheetSpreadsheet = function() {
		var table = $('<table title=/>').attr('title', tr('Local Cache (Not Committed)'));
		table.append('<tr><td>Summary</td><td>Estimate</td><td>Time Spent</td></tr>');
		
		var rowI = 1;
		for (var namespace in $.DOMCached.getStorage()) {
			var row = $('<tr />').appendTo(table);
			
			row.append('<td>' + namespace + '</td>');
			row.append('<td>' + $.DOMCached.get('estimate', namespace) + '</td>');
			row.append('<td formula=\'ROUND(' + ($.DOMCached.get('timer', namespace) / 60) + ', 2)\' />');
			rowI++;
		}
		var row = $('<tr />').appendTo(table);
		row.append('<td>Totals</td>');
		row.append('<td formula=\'ROUND(SUM(B2:B' + rowI + '), 2)\'/>');
		row.append('<td formula=\'=ROUND(SUM(C2:C' + rowI + '), 2)\' />');
		
		$('#timesheetSpreadsheet').siblings().remove();
		$('#timesheetSpreadsheet').parent().width(remainingWidth);
		
{'fraction_non_alphanumeric': 0.23215898825654924, 'fraction_numerical': 0.004516711833785004, 'mean_word_length': 4.96900269541779, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 73, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4637361', 'n_tokens_mistral': 1624, 'n_tokens_neox': 1524, 'n_words': 243}