<?php $monthList = CHtml::listData(DateHelper::monthList(true), 'value', 'label'); ?>
<?php $dayList = CHtml::listData(DateHelper::dayList(true), 'value', 'label'); ?>
<?php $form=$this->beginWidget('DynamicTabularForm',array(   'id'=>'special-day-form','enableAjaxValidation'=>false,'defaultRowView'=>'_timeSlotForm'));; ?>
<div class="time-schedule-field">
  <?php echo $form->textFieldRow($model,'Descrizione',array('class'=>'span5','maxlength'=>250)); ?>
</div>
<div class="time-schedule-field start-row">
  <?php echo $form->dropDownListRow($model,'start_day', $dayList, array('class'=>'span1')); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->dropDownListRow($model,'start_month', $monthList, array('class'=>'span2')); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->dropDownListRow($model,'end_day', $dayList, array('class'=>'span1')); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->dropDownListRow($model,'end_month', $monthList, array('class'=>'span2')); ?>
</div>
<div class="time-schedule-field start-row">
  <?php echo htmlspecialchars(t('Scope').":",ENT_QUOTES,'UTF-8'); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->checkBoxRow($model,'for_run'); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->checkBoxRow($model,'for_whitelisttable'); ?>
</div>
<div class="time-schedule-field">
  <?php echo $form->checkBoxRow($model,'for_ztl'); ?>
</div>
<div class="time-schedule-field start-row">
  <div id="event-search-page">
    <?php $path = 'time-schedule'; ?>
    <label for="TimeSchedule_icon">
      <?php echo htmlspecialchars(t('Icon'),ENT_QUOTES,'UTF-8'); ?>
    </label>
    <select id="TimeSchedule_icon" name="TimeSchedule[icon]">
      <?php $images=ImageHelper::getImagesAt($path); ?>
      <?php $images[] = ''; ?>
      <?php foreach($images as $imgsrc) { ?>
        <?php $key = basename($imgsrc); ?>
        <?php $selected = $model->icon == $key; ?>
        <?php if($imgsrc == '') { ?>
          <?php if($selected) { ?>
            <option value="" selected="selected">
              <?php echo htmlspecialchars(t('None'),ENT_QUOTES,'UTF-8'); ?>
            </option>
          <?php } else { ?>
            <option value="">
              <?php echo htmlspecialchars(t('None'),ENT_QUOTES,'UTF-8'); ?>
            </option>
          <?php } ?>
        <?php } else           { ?>
          <?php $relativeUrl = $path.'/'.$key; ?>
          <?php $url = ImageHelper::getImageUrl($relativeUrl); ?>
          <?php $tag = ImageHelper::getImageTag($relativeUrl, $key, array('width'=>"20",'height'=>"20")); ?>
          <?php $dataContent = "<div class='data-content'><div class='icc'>$tag</div></div>"; ?>
          <?php if($selected) { ?>
            <option <?php echo MtHaml\Runtime::renderAttributes(array(array('value', $key), array('data-content', $dataContent), array('selected', 'selected')), 'html5', 'UTF-8'); ?>></option>
          <?php } else { ?>
            <option <?php echo MtHaml\Runtime::renderAttributes(array(array('value', $key), array('data-content', $dataContent)), 'html5', 'UTF-8'); ?>></option>
          <?php } ?>
        <?php } ?>
      <?php } ?>
    </select>
  </div>
</div>
<div class="row" style="clear: left">
  <div class="span">
    <h3>
      <?php echo htmlspecialchars(t("Time Slots"),ENT_QUOTES,'UTF-8'); ?>
    </h3>
  </div>
</div>
<?php echo $form->rowForm($timeSlots); ?>
<div class="form-actions">
  <?php $this->widget('bootstrap.widgets.TbButton', array('buttonType'=>'submit', 'type'=>'primary', 'label'=>$model->isNewRecord ? t('Create') : t('Save'), ));; ?>
  <?php $this->widget('bootstrap.widgets.TbButton', array( 'buttonType'=>'link', 'label'=> t('Cancel'), 'url' => Yii::app()->createAbsoluteUrl('timeSchedule/index')));                                                           ; ?>
</div>
<?php $this->endWidget(); ?>
