<div style="float:left;">
	<form id="setFilterForm" method="post" action="<?=$this->baseUrl?>/calendar.raw/process-set-filter">
	<div style="margin-left:10px;width:350px;">
	<div class="formRow">
	<dt><label for="calendar-provider-id"><?=__("Provider")?></label></dt>
	<select id="calendar-provider-id"  name="calendar[providerId]" style="width:325px;">
		<option value=""></option>
        <?foreach(Provider::getArray() as $personId => $name):?>
                <option value="<?=$personId?>" <?if (isset($this->data['providerId']) && $personId == $this->data['providerId']):?>selected="selected"<?endif;?>><?=$name?></option>
        <?endforeach;?>
        </select>
	</div>
<br />
	<div class="formRow" style="padding-top:4px;">
        <dt><label for="calendar-room-id"><?=__("Room")?></label></dt>
	<select id="calendar-room-id"  name="calendar[roomId]" style="width:325px;">
		<option value=""></option>
	<?foreach(Room::getRoomArray() as $roomId => $name):?>
		<option value="<?=$roomId?>" <?if (isset($this->data['roomId']) && $roomId == $this->data['roomId']):?>selected="selected"<?endif;?>><?=$name?></option>
	<?endforeach;?>
	</select>
	</div>
<br />
	<div class="formRow" style="padding-top:4px;">
        <dt><label for="calendar-date-filter"><?=__("Date")?></label></dt>
	<?if(!isset($this->data['dateFilter'])):
		$dateFilterValue = date('Y-m-d',strtotime('today'));
	else:
		$dateFilterValue = date('Y-m-d',strtotime($this->data['dateFilter']));
	endif;?>
	<?=$this->formDateText('calendar[dateFilter]',$dateFilterValue,array('id'=>'calendar-date-filter'))?>
	</div>
<br style="clear:both;" />
	<div class="formRow" style="padding-top:4px;">
		<input type="hidden" name="calendar[showCancelledAppointments]" id="calendar-showCancelledAppointments" value="0" />
		<input type="checkbox" name="calendar[showCancelledAppointments]" id="calendar-showCancelledAppointments" value="1" <?=(isset($this->data['showCancelledAppointments']) && $this->data['showCancelledAppointments'])?'checked="checked"':''?> /> <?=__('Show Cancelled Appointments')?>
	</div>

<br style="clear:left"/>
<div style="text-align:right;margin-top:10px;">
	<input type="hidden" id="calendar-filter-state-id" name="calendar[filterStateId]" value="<?=isset($this->data['filterStateId'])?$this->data['filterStateId']:0?>" />
	<input type="hidden" id="calendar-column-id" name="calendar[columnId]" value="<?=$this->columnId?>" />
	<input type="button" value="<?=__("Cancel")?>" onClick="closeFilterWindow('<?=$this->columnId?>')" />
	<input type="button" value="<?=__("Select")?>" onClick="calendarSetFilter()" />
</div>
</form>
</div>
<script>
function calendarSetFilter() {
	var dateFilter = boxCalendarDateFilter.getValue();
	if (!dateFilter) {
		alert("<?=__('Invalid date.')?>");
		return;
	}
	dojo.xhrPost({
		url: "<?=$this->baseUrl?>/calendar.raw/process-set-filter",
		form: "setFilterForm",
		handleAs: "json",
		load: function (data) {
			window.applyNewFilter("<?=$this->columnId?>",data.id);
		},
		error: function (err) {
			console.error ("Error: ", err);
		}
	});
}
</script>
