<!DOCTYPE html>
<html lang="en">
{{fscript
	
	dueDate := NSDate date.
	arrayOfOpps := {}.

	incompleteTasks := objectContext objectsForEntityNamed:'Task' qualifierLocum:'(statusCode < 7)' bindings:nil.
	
	projectsForTasks := incompleteTasks projects.

	globals setFetchedProjects:(projectsForTasks flattenArrayOfArrays) distinct.
	globals setIncompTasks:incompleteTasks.
		
}}
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="{{framework}}/default.css" type="text/css" charset="utf-8">
	<link rel="stylesheet" href="{{framework}}/screen.css" type="text/css" charset="utf-8" media="screen">
	<link rel="stylesheet" href="{{framework}}/print.css" type="text/css" charset="utf-8" media="print">
	
</head>
<body>
	<h2>{{localize 'Incomplete Tasks By Project'}}</h2>
	{{foreach project fetchedProjects do}}
	<br>
	Project:  <b>{{project.name}} </b><br>
	Status: <b>{{fscript (project statusString).}}</b>
	<br><br>
	<table>
		<thead>
				<td width="40%">{{localize 'Task Name'}}</td>
				<td width="20%">{{localize 'Due Date'}}</td>
				<td width="20%">{{localize 'Status'}}</td>
				<td width="20%">{{localize 'Owner'}}</td>
		</thead>
		{{fscript
			globals setIncompTasksForProject:nil.
			incomptasksForProject := {}.
			allTasksForProject := project tasks.
			allTasksForProject do:[:task |		
				(task statusCode < 7) ifTrue:
				[
					incomptasksForProject addObject:task.
				].

			].
			incomptasksForProject := incomptasksForProject sortedArrayUsingDescriptors:{(NSSortDescriptor sortDescriptorWithKey:'dueDate' ascending:true)}.
			globals setIncompTasksForProject:incomptasksForProject.
			
		}}
		<tbody>{{foreach task incompTasksForProject do}}
			<tr>
			<td>
				{{task.name}}</a>
			</td>
			<td>
				{{fscript (task dueDate) mcShortDate.}}
			</td>
			<td>
				{{fscript (task statusString).}}
			</td>
			<td>
				{{fscript task assignedTo contact derivedFullname.}}
			</td>
			</tr>{{endforeach do}}
		</tbody>	
	</table>
	
	<br>
	{{endforeach do}}

	<br>
	<br>
	<div id="reportfooter">
	{{localize 'Generated by %@ on %@', objectContext.user.contact.cachedName, date}}.		
	</div>

</body>
</html>