<?php
/* @var $this BannerController */
/* @var $model Banner */
/* @var $form CActiveForm */
?>

<div id="communicationsbox" style="height:525px; background-color:#f7eee1;">
<?php
    foreach(Yii::app()->user->getFlashes() as $key => $message) {
        echo '<div class="flash-' . $key . '">' . $message . "</div>\n";
    }
?>

  <div id="form_wrapper">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'download-centre-form',
	'enableAjaxValidation'=>false,
        'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
        ),
)); ?>

	

	<?php echo $form->errorSummary($model); ?>

	<div id="row">
  <fieldset id="current">
    <legend><strong>Download center</strong></legend>
    <br />
    <table width="800" border="0" cellspacing="0" cellpadding="5">
      
      <tr>
        <td><?php echo $form->labelEx($model,'user_group_id'); ?></td>
        <td>
		
<?php echo $form->dropDownList($model,'user_group_id',UserGroup::userGroupFrontEnd()); ?>		<?php echo $form->error($model,'user_group_id'); ?>
	</td>
      </tr>
      <?php if(!$model->isNewRecord): ?>
      <tr>
        <td>
		<?php echo $form->labelEx($model,'file_title'); ?>
            </td>
        <td>
		<?php echo $form->textArea($model,'file_title',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'file_title'); ?>
	</td>
      </tr>
      <tr>
        <td>
		<?php echo $form->labelEx($model,'file_type'); ?>
            </td>
        <td>
		<?php echo $form->textField($model,'file_type',array('size'=>60,'maxlength'=>255)); ?>
		<?php echo $form->error($model,'file_type'); ?>
	</td>
      </tr>
      <tr>
        <td>
		
            </td>
        <td>
            <?php
            switch($model->file_type)
            {
                case 'PDF':
                    $icon_image =   'pdf.png';
                    break;
                case 'PPT':
                     $icon_image =   'ppt.png';
                    break;
                case 'PPTX':
                    $icon_image =   'pptx.png';
                    break;
                case 'ZIP':
                    $icon_image =   'zip.png';
                    break;
                case 'DOC':
                    $icon_image =   'doc.png';
                    break;
                default:
                    $icon_image =   'unknown.png';
                    break;
            }
            ?>
		<a target="_blank" href="<?php echo Yii::app()->getBaseUrl(true); ?>/media/downloadcenter/<?php echo $model->file; ?>"><img src="<?php echo Yii::app()->baseUrl;?>/images/<?php echo $icon_image; ?>"/></a>
	</td>
      </tr>
      <tr>
        <td><?php echo $form->labelEx($model,'file'); ?></td>
        <td>&nbsp;&nbsp;
            <?php echo $form->fileField($model,'file'); ?>
             <?php echo $form->hiddenField($model,'file'); ?>
            <?php echo $form->error($model,'file'); ?>
	</td>
      </tr>
      <?php else: ?>
      <tr>
        <td><?php echo $form->labelEx($model,'Add multiple files'); ?></td>
        <td>&nbsp;&nbsp;
            <?php $this->widget('CMultiFileUpload',array(
'model'=>$model,
     'attribute'=>'file',
                'name'=>'files',
'accept'=>'pdf|jpg|png|zip|rar|doc|ppt|pptx|docx',
'max'=>10,
'remove'=>Yii::t('ui','Remove'),
'denied'=>'type is not allowed', //message that is displayed when a file type is not allowed
'duplicate'=>'file appears twice', //message that is displayed when a file appears twice
'htmlOptions'=>array('size'=>25),
)); ?>
		<?php echo $form->error($model,'file'); ?>
	</td>
      </tr>
      <?php endif; ?>
      <tr>
          <td>
		
	</td>
        <td>
		<?php echo CHtml::submitButton($model->isNewRecord ? 'Submit' : 'Save'); ?>
	</td>
      </tr>
      </table>
  </fieldset>
</div>

<?php $this->endWidget(); ?>

</div><!-- form -->
</div>