<?php
/* @var $this categorytypeController */
/* @var $model MascategoryType */
/* @var $form CActiveForm */
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'category-storage-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
        ));
?>
<div class="tab-content">
    <div class="tab-pane active">

        <ul class="clearfix form-ul material">

               <li class="col-sm-4">
                <?php
                echo $form->hiddenField($model, 'id'); 
               echo $form->dropDownList(
    $model,
    'category_id',
    MasDocumentCategory::getCategory(),
    array('prompt' => 'Select Category','data-label' => 'Category','data-search' => true)
);
?>
            </li> 


       <li class="col-sm-4">
    <?php
    echo $form->dropDownList(
        $model,
        'document_year',
        DocumentStorage::getYearList(),
        array(
            'prompt' => 'Select Year',
            'data-label' => 'Year',
            'data-search' => true
        )
    );
    ?>
</li>
      

             <li class="col-sm-4">
    <?php
    echo $form->dropDownList(
        $model,
        'document_month',
        DocumentStorage::getMonthList(),
        array(
            'prompt' => 'Select Month',
            'data-label' => 'Document Month',
            'data-search' => true
        )
    );
    ?>
</li>
<li class="col-sm-6">
    <?php echo $form->textArea($model, 'remarks',array('data-label'=>'Remarks <span style="color:red">*</span>','data-validation'=>'required')); ?>
</li>


<li class="col-sm-4">
    <?php echo $form->hiddenField($model, 'upload_document_name'); ?>

    <?php
    echo CHtml::label('Document', 'Document');
    $allowedExtensions = array(
    'pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'csv', 
   
);


   $this->widget('ext.EAjaxUpload.EAjaxUpload', array(
    'id' => rand(),
    'config' => array(
        'action' => Yii::app()->createUrl(Yii::app()->controller->id . '/UploadDocument', array('folder' => 'upload/document-storage/')),
        'multiple' => false,
        'allowedExtensions' => $allowedExtensions,
        'sizeLimit' => 20 * 1024 * 1024, // 20 MB
        'onStart' => "js:function(){}",
        'class' => 'pull-right',
        'onComplete' => "js:function(id, fileName, responseJSON){ 
            $('.icon_images').html('<input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"DocumentStorage[upload_document_name]\">'); 
        }",
    )
));

    ?>

   <div class="icon_images">
        <?php if (!empty($model->upload_document_name)): ?>
            <input type="hidden" name="DocumentStorage[upload_document_name]" value="<?php echo CHtml::encode($model->upload_document_name); ?>">
            <div class="uploaded-file">
                <?php echo CHtml::encode($model->upload_document_name); ?>
            </div>
        <?php endif; ?>
    </div>
</li>


		
        </ul>
    </div>

</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" id="categorytype_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('documentstorage/Save');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
                                $("#loader").hide();
                                    if(data.status=="success"){  
                                        t8.success("Saved Successfully!");
                                        $("#categorytype_close").click();
                                        reloadTable("#tbl_documentstorage_details");
                                    } else { 
                                        $("#category-storage-form .categorytype-save-btn").prop("disabled", false);                      
                                        $("#category-storage-form .categorytype-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                                        $.each(data, function(key, val) {
                                            t8.error(""+val+""); 
                                        }); 
                                    } 
                            }',
        'beforeSend' => 'function(){ 
                               $("#loader").show();
                               $(".toast8-error").hide();
                               $("#category-storage-form .categorytype-save-btn").prop("disabled", true);                      
                               $("#category-storage-form .categorytype-save-btn").addClass("btn_loading").removeClass("btn-theme"); 
                                
                            }'
            ), array('id' => 'mybtn' . rand(), 'class' => 'categorytype-save-btn btn btn-theme'));
    ?>
</div>

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

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