<?php
/* @var $this LocationController */
/* @var $model Location */

$this->breadcrumbs = array(
    yii::t('default', 'Reports') => array('/dashboard/Reports'),
    yii::t('default', 'Items Summary For Department'),
);
?>

<?php
$form = $this->beginWidget('ext.bootstrap.widgets.TbActiveForm', array(
    'action' => Yii::app()->createUrl($this->route),
    'method' => 'get',
	));
echo Yii::t('default', 'Location');
echo "<br />";

$state = $this->createWidget('application.extensions.jquery-cascade.jQueryCascade');
echo $state->dropDownList('Location', $model->location_filter, 
	User::model()->getLocationsInGeomarket(true), array('name'=>''), CController::createUrl('report/getDepartments'), 
	'VReportItemSummaryForDepartment_department_filter');

$location = $model->location_filter;
$departments = array();
if ($location != '')
    $departments = Department::getDepartmentsInLocation($location,true);
else
    $departments[''] = yii::t('default', 'All Departments');

echo $form->dropDownListRow($model, 'department_filter', $departments);


echo "<br />";
echo Yii::t('default', 'From Date');
echo "<br />";
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker', array(
    'model' => $model,
    'attribute' => 'from_date',
    'mode' => 'date', //use "time","date" or "datetime" (default)
    'language' => '',
    'options' => array(
	'dateFormat' => 'yy-mm-dd',
	'showAnim' => 'fold',
	'changeMonth' => true,
	'changeYear' => true,
	'yearRange' => 'c-30:c+5',
    )
));

echo "<br />";
echo Yii::t('default', 'To Date');
echo "<br />";
Yii::import('application.extensions.CJuiDateTimePicker.CJuiDateTimePicker');
$this->widget('CJuiDateTimePicker', array(
    'model' => $model,
    'attribute' => 'to_date',
    'mode' => 'date', //use "time","date" or "datetime" (default)
    'language' => '',
    'options' => array(
	'dateFormat' => 'yy-mm-dd',
	'showAnim' => 'fold',
	'changeMonth' => true,
	'changeYear' => true,
	'yearRange' => 'c-30:c+5',
    )
));
?>
<div class="actions">
<?php echo CHtml::submitButton(Yii::t('default', 'Go'), array('name' => 'go', 'class' => 'btn primary',)); ?>
    &ensp;
    <?php echo CHtml::submitButton(Yii::t('default', 'Export'), array('name' => 'export', 'class' => 'btn primary')); ?>
</div>
    <?php $this->endWidget(); ?>
<!-- search-form -->







<?php
$this->widget('ext.bootstrap.widgets.TbGridView', array(
    'id' => 'VReportItemsSummaryperDepartment-grid',
    'type' => 'striped',
    'dataProvider' => $model->search($is_empty),
    'type' => 'striped',
    'filter' => $model,
    'columns' => array(
//	'user_name',
	array(
	    'name' => 'location_code',
	    'filter' => CHtml::listData(Location::getAll(), 'id', 'code')
	),
	array(
	    'name' => 'department',
	    'filter' => CHtml::listData(Department::getAll(), 'id', 'name')
	),
	array(
	    'name' => 'item_name',
	    'filter' => Item::getNamesForDropDown()
	),
//	'date_time',
	'quantity_sum',
    ),
));
?>
