<!DOCTYPE html>
<html lang="en">
{{fscript
	
	"We don't really need to set the date like this here. It is more to illustrate how to pass dates to other pages of the report. Also, we can easily change the date range of the report this way."
	
	"Today's date minus 30 days"
	start := (NSDate date) mcDateByAddingDays:-30.
	end := NSDate date.
		
	globals setStartDate:start.
	globals setEndDate:end.

	lines := {
		#{'entity' -> 'Contact', 'dateAttribute' -> 'createDate', 'name' -> 'People', 'total' -> (objectContext resultCountForEntityNamed:'Contact')},
		#{'entity' -> 'Organization', 'dateAttribute' -> 'createDate', 'name' -> 'Companies', 'total' -> (objectContext resultCountForEntityNamed:'Organization')},
		#{'entity' -> 'Role', 'dateAttribute' -> 'createDate', 'name' -> 'Roles', 'total' -> (objectContext resultCountForEntityNamed:'Role')},
		#{'entity' -> 'Task', 'dateAttribute' -> 'createDate', 'name' -> 'Tasks', 'total' -> (objectContext resultCountForEntityNamed:'Task')},
		#{'entity' -> 'Timeblock', 'dateAttribute' -> 'createDate', 'name' -> 'Appointments', 'total' -> (objectContext resultCountForEntityNamed:'Timeblock')},
		#{'entity' -> 'Reminder', 'dateAttribute' -> 'createDate', 'name' -> 'Reminders', 'total' -> (objectContext resultCountForEntityNamed:'Reminder')},
		#{'entity' -> 'AlertObject', 'dateAttribute' -> 'createDate', 'name' -> 'AlertObject', 'total' -> (objectContext resultCountForEntityNamed:'AlertObject')},
		#{'entity' -> 'Note', 'dateAttribute' -> 'createDate', 'name' -> 'Notes', 'total' -> (objectContext resultCountForEntityNamed:'Note')},
		#{'entity' -> 'Email', 'dateAttribute' -> 'createDate', 'name' -> 'Emails', 'total' -> (objectContext resultCountForEntityNamed:'Email')},
		#{'entity' -> 'CustomRecord', 'dateAttribute' -> 'createDate', 'name' -> 'CustomRecord', 'total' -> (objectContext resultCountForEntityNamed:'CustomRecord')},
		#{'entity' -> 'CustomRecordSet', 'dateAttribute' -> 'createDate', 'name' -> 'Forms', 'total' -> (objectContext resultCountForEntityNamed:'CustomRecordSet')},
		#{'entity' -> 'Project', 'dateAttribute' -> 'createDate', 'name' -> 'Projects', 'total' -> (objectContext resultCountForEntityNamed:'Project')},
		#{'entity' -> 'Opportunity', 'dateAttribute' -> 'createDate', 'name' -> 'Opportunities', 'total' -> (objectContext resultCountForEntityNamed:'Opportunity')},
		#{'entity' -> 'Pipeline', 'dateAttribute' -> 'createDate', 'name' -> 'Pipelines', 'total' -> (objectContext resultCountForEntityNamed:'Pipeline')},
		#{'entity' -> 'Group', 'dateAttribute' -> 'createDate', 'name' -> 'Groups', 'total' -> (objectContext resultCountForEntityNamed:'Group')},
		#{'entity' -> 'FileAttachment', 'dateAttribute' -> 'createDate', 'name' -> 'Attachments', 'total' -> (objectContext resultCountForEntityNamed:'FileAttachment')},
		#{'entity' -> 'ProductService', 'dateAttribute' -> 'createDate', 'name' -> 'Products and Services', 'total' -> (objectContext resultCountForEntityNamed:'ProductService')},
		#{'entity' -> 'Category', 'dateAttribute' -> 'createDate', 'name' -> 'Categories', 'total' -> (objectContext resultCountForEntityNamed:'Category')},
		#{'entity' -> 'Keyword', 'dateAttribute' -> 'createDate', 'name' -> 'Keywords', 'total' -> (objectContext resultCountForEntityNamed:'Keyword')},
		#{'entity' -> 'User', 'dateAttribute' -> 'createDate', 'name' -> 'Users', 'total' -> (objectContext resultCountForEntityNamed:'User')},
		#{'entity' -> 'Resource', 'dateAttribute' -> 'createDate', 'name' -> 'Resources', 'total' -> (objectContext resultCountForEntityNamed:'Resource')}
	}.

	globals setLines:lines.
}}
<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>
	<h1>{{localize 'Object Counts'}}</h1>
	<p>{{localize 'This report displays the number of objects created for specific types. You can drill down to see a bit more for the specific type. Only the most common types are displayed here.'}}</p>
	
	<table>
		<thead>
			<tr>
				<td>{{localize 'Kind'}}</td>
				<td width="15%">Count</td>
			</tr>
		</thead>
		<tbody>
			{{foreach line lines do}}
			<tr>
				<td><a href="{{baseURL}}/detail?startDateInterval={{startDate.timeIntervalSinceReferenceDate}}&endDateInterval={{endDate.timeIntervalSinceReferenceDate}}&entity={{line.entity}}&kind={{line.name}}&days=30&dateAttribute={{line.dateAttribute}}">{{line.name}}</a></td>
				<td width="15%">{{line.total}}</td>
			</tr>
			{{endforeach do}}
		</tbody>
	</table>
	
	<div id="reportfooter">
	{{localize 'Generated by %@ on %@.', objectContext.user.contact.cachedName, date}}
	</div>
</body>
</html>