<?php 
	$this->Html->css(array('ui/jquery-ui.min'), '', array('inline'=>false));
	$this->Html->script(array('ui/jquery-ui-custom.min'),  array('inline'=>false));
?>
<h2 class="title" id="p-title"><?php echo (!empty($d1) && !empty($d2)) ? __('Summary Report from %s to %s',$d1, $d2) : __('Summary Report'); ?></h2>
<div class="form-error" style="font-size:12px; text-align: center;" id="error_mess"></div>
<div class="links">
	<ul>
		<li><?php echo $this->Html->link(__('Export'), 'javascript:void(0);', array('class' => 'button','title'=>__('Export'), 'id'=>'export_report')); ?> </li>
	</ul>
</div>
<div class="search-frm">
	<?php echo $this->Form->create('Report', array('id'=>'filter-form', 'novalidate' => true, 'url'=>array('controller'=>'overall', 'action'=>'summary_report'), 'type' => 'get', 'error'=>true, 'inputDefaults'=>array('div'=>false, 'label'=>false), 'errorMessage' => false)); ?>
	<div class="inline">
		<label><?php echo __('Target for the Month of')?>:</label>
		<?php echo $this->Form->input(null, array('name'=>'t-month', 'id'=>'month', 'options'=>getMonths(), 'empty'=>__('Select Month'), 'class'=>'field-inline', 'value' => isset($this->request->query['t-month'])?$this->request->query['t-month']:''));?>
	</div>
	<div class="inline">
		<label><?php echo __('From:')?></label>
		<?php echo $this->Form->input(null, array('name'=>'from', 'id'=>'from-date', 'type'=>'text', 'class'=>'field-inline', 'value' => !empty($d1) ? $d1 :''));?>
	</div>
	<div class="inline">
		<label><?php echo __('To:') ?></label>
		<?php echo $this->Form->input(null, array('name'=>'to', 'id'=>'to-date', 'type'=>'text', 'class'=>'field-inline', 'value' => !empty($d2) ? $d2 : ''));?>
	</div>
	<?php
	echo $this->Form->submit('Filter', array('class'=>'field-inline'));
	echo $this->Form->end(); ?> 
</div>
<section>
	<div class="clr"></div>
	<div class="row" id="summary_report_tbl" style="overflow-x: auto;">
		<?php if(!empty($reports)): ?>
		<table class="tbl-list" cellpadding="0" cellspacing="0" border="0">
			<tr>
				<th width="5%">#</th>
				<th></th>
				<?php if($locations): foreach($locations  as $url): ?>
				<th id="<?php echo $url['id']?>" ><?php echo $url['title'] ?></th>
				<?php endforeach; endif; ?>
				<th id="total"><?php echo __('Total')?></th>
			</tr>
			<?php 
			$i=0;
			foreach($reports  as $key => $report): ?>
			<tr>
				<td><?php echo ++$i ?></td>
				<td><?php echo $report; ?></td>
				<?php if($locations): foreach($locations  as $url): ?>
				<td id="<?php echo $key.'_'.$url['id']?>" align="right"></td>
				<?php endforeach; endif; ?>
				<td id ="<?php echo $key.'_total'?>" align="right"></td>
			</tr>
			<?php endforeach; ?>
		</table>
		<?php endif; ?>
	</div>
</section>
<script>
var locationsObj = jQuery.parseJSON('<?php echo json_encode($locations) ?>');
var reportsObj = jQuery.parseJSON('<?php echo json_encode(array_keys($reports)) ?>');
</script>
<?php echo $this->Html->script(array('jquery.table2excel', 'summary_report'), array('fullBase' => true)); ?>