{$idEntity = ''}
{$dashboard = $widget['methods']->getDashboard()}
{if $dashboard->getOption('idCorporate')}
	{$idEntity = $dashboard->getOption('idCorporate')}
{elseif $dashboard->getOption('idCustomer')}
	{$idEntity = $dashboard->getOption('idCustomer')}
{/if}

{$calendar=$widget['data']['calendar']}
{$structure=$calendar->getStructure()}

<table class="widgetCalendar">
	<thead>
		<tr class="header">
			<td class="label" colspan="7">
				<div class="navigator controls">
					<table class="w100p">
						<tr>
							<td class="nav left"
								onClick="window.dashboardController.dashboard.request(MVC.appUrl(MVC.CURRENT_MODULE, 'editDashboardElement', { 'idEntity' : '{$idEntity}' } ), {
									operation: 'methodCall',
									method: 'prevMonth',
									src: '{$widget['id']}'
								});"
							>
								<span class="arrow-left">&#9664;</span>

							</td>
							<td class="nav right"
								onClick="window.dashboardController.dashboard.request(MVC.appUrl(MVC.CURRENT_MODULE, 'editDashboardElement', { 'idEntity' : '{$idEntity}' } ), {
									operation: 'methodCall',
									method: 'nextMonth',
									src: '{$widget['id']}'
								});"
							>
								<span class="arrow-right">&#9654;</span>
							</td>
						</tr>
					</table>
				</div>

				<div class="navigator today">
					<table class="w100p">
						<tr>
							<td class="nav today"
								onClick="window.dashboardController.dashboard.request(MVC.appUrl(MVC.CURRENT_MODULE, 'editDashboardElement', { 'idEntity' : '{$idEntity}' } ), {
									operation: 'methodCall',
									method: 'resetMonth',
									src: '{$widget['id']}'
								});"
							>
								<span class="arrow-reload">&#8617;</span>
							</td>
						</tr>
					</table>
				</div>

				<div class="label">
					<span class="month">{$_LANG['date']['month']['short'][$calendar->getInterval()->month]}</span> <span class="year">{$calendar->getInterval()->year}</span>
				</div>
			</td>
		</tr>

		<tr class="week">
			<td class="day">{$_LANG['date']['day']['short'][1]}</td>
			<td class="day">{$_LANG['date']['day']['short'][2]}</td>
			<td class="day">{$_LANG['date']['day']['short'][3]}</td>
			<td class="day">{$_LANG['date']['day']['short'][4]}</td>
			<td class="day">{$_LANG['date']['day']['short'][5]}</td>
			<td class="day inWeekend">{$_LANG['date']['day']['short'][6]}</td>
			<td class="day inWeekend">{$_LANG['date']['day']['short'][0]}</td>
		</tr>
	</thead>

	<tbody class="structure">
		{foreach $structure as $weekDays}
			<tr class="week">
				{foreach $weekDays as $day}
					<td class="
						day
						{if $day->attributes['inInterval']}inInterval{else}noInterval{/if}
						{if $day->attributes['inWeekend']}inWeekend{/if}
						{if $day->events || $day->tasks}hasEvent{/if}
						{if $day->date == $smarty.const.TODAY_ISO}today{/if}"

						{if $day->tasks}
							onClick="
								if($('widgetCalendar_{$day->ymd}').visible()){
									$(this).up('table').select('.dayTasks').each(function (d){
										d.hide();
									});
									$(this).up('table').down('.dummy_default').show();
								}else{
									$(this).up('table').select('.dayTasks').each(function (d){
										d.hide();
									});
									$(this).up('table').down('.dummy_default').hide();
									$('widgetCalendar_{$day->ymd}').show();
								}
								"
						{/if}
					>
						<div class="day">{$day->monthDay}</div>
					</td>
				{/foreach}
			</tr>
		{/foreach}
	</tbody>

	<tbody class="list">
		<tr class="dummy_default">
			<td colspan="7">
				<div>
					<br/><br/>
				</div>
			</td>
		</tr>

		{foreach $structure as $weekDays}
			{foreach $weekDays as $day}
				{if $day->tasks}
					<tr class="dayTasks" id="widgetCalendar_{$day->ymd}" style="display: none;">
						<td colspan="7">
							<div class="date">{$day->date|dateTimeFormat}</div>
							{foreach $day->tasks as $task}
								<div class="day">
									<ul>
										<li>
											<span class="description">{$task['description']}</span>
											<a href="#;" class="icon-infoOrange"
												onclick="RemoteLoad.load(this, MVC.appUrl('RemoteData/InfoBox', 'task', { 'id': '{$task['id']}' }), null); RemoteLoad.attach(this);"
											></a>

										</li>
									</ul>
								</div>
							{/foreach}
						</td>
					</tr>
				{/if}
			{/foreach}
		{/foreach}
	</tbody>
</table>