<?php
$cs = Yii::app()->getClientScript();

$form = $this->beginWidget('CActiveForm', array(
    'id' => 'upload-static-data-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
));
?>
<section class="panel">
    <header class="panel-heading clearfix panel-theame">
        <i class="fa fa-tasks"></i> Upload Static Other Data
    </header>
   
    <div class="tab-content">
        <div class="tab-pane active">
            <ul class="clearfix form-ul material">
               <?php echo $form->hiddenField($model, 'id'); ?>
            <li class="col-sm-4">
                <?php
                if ($model->year == '') {
                    $year = date('Y');
                } else {
                    $year = $model->year;
                }
                $option = array($year => array('selected' => 'selected'));
                ?>  

                <?php echo $form->dropDownList($model, 'year', Order::getyear(), array('data-label' => 'Year <span style="color:red">*</span>', 'empty' => '-Select-', 'options' => $option)); ?>
            </li>
            <li class="col-sm-4">
                <?php echo $form->dropDownList($model, 'month', Order::getmonths(), array('data-label' => 'Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>
           
            <li  class="col-sm-4">
                <?php
                echo CHtml::label('Document', 'Document');
                $allowedExtensions = array("csv");
                $this->widget('ext.EAjaxUpload.EAjaxUpload', array('id' => rand(),
                    'config' => array('action' => Yii::app()->createUrl(Yii::app()->controller->id . '/UploadDocuments', array('folder' => 'upload/uploadstaticother')),
                        'multiple' => false, 
                        'allowedExtensions' => $allowedExtensions,
                        'sizeLimit' => 4 * 1024 * 1024, 
                        'onStart' => "js:function(){}", 
                        'class' => 'pull-right', 
                        'onComplete' => "js:function(id, fileName, responseJSON){ 
                           // alert(fileName);
                        $('.icon_images').html('<input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"InventoryUploads[file_name]\">');                                                                    "
                        . "}",)));
                ?>        
                <div class="icon_images">
                
                </div>
            </li>
            </ul>
        </div>
    </div>
<div class="modal-footer">
   <button type="button" class="btn btn-default" id="order_upload_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('uploadstaticdata/SaveStaticOther');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
            $("#loader").hide();
                if(data.status=="success"){ 
                 $("#order_upload_close").click();
                    t8.success("Settings  Saved Successfully!");
                    
                } else { 
                    $("#upload-static-data-form .upload-static-data-save-btn").prop("disabled", false);                      
                    $("#upload-static-data-form .upload-static-data-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                    $.each(data, function(key, val) {
                        t8.error(""+val+""); 
                    }); 
                } 
        }',
        'beforeSend' => 'function(){ 
            $("#loader").show();
            $(".toast8-error").hide();
            $("#upload-static-data-form .upload-static-data-save-btn").prop("disabled", true);                      
            $("#upload-static-data-form .upload-static-data-save-btn").addClass("btn_loading").removeClass("btn-theme"); 

        }'
    ), array('id' => 'mybtn' . rand(), 'class' => 'upload-static-data-save-btn btn btn-theme'));
    ?>
</div>
</section>
<?php $this->endWidget(); ?>