<?php
$cs = Yii::app()->getClientScript();
?><?php
$form = $this->beginWidget('CActiveForm', array(
    'id' => 'invreport_upload-form',
    'enableAjaxValidation' => false,
    'enableClientValidation' => false,
));
?>
<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->inv_year == '') {
                    $year = date('Y');
                } else {
                    $year = $model->inv_year;
                }
                $option = array($year => array('selected' => 'selected'));
                echo $form->dropDownList($model, 'inv_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, 'inv_month', Order::getmonths(), array('data-label' => 'Month <span style="color:red">*</span>','empty'=>'-Select-')); ?>
            </li>
            <li  class="col-sm-4">
                <?php
                echo CHtml::label('BASE INVENTORY LIST', '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/inventoryreport')),
                        'multiple' => false, 
                        'allowedExtensions' => $allowedExtensions,
                        'sizeLimit' => 25 * 1024 * 1024, 
                        'onStart' => "js:function(){}", 
                        'class' => 'pull-right', 
                        'onComplete' => "js:function(id, fileName, responseJSON){ 
                           // alert(fileName);
                        $('.icon_images2').html('<input type=\"hidden\" value=\"'+responseJSON.filename+'\" name=\"InventoryReportBaseinventoryUpload[bi_file]\">');                                                                    "
                        . "}",)));
                ?>        
                <div class="icon_images2">
                </div>
            </li>
        </ul>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" id="invreport_upload_close" data-dismiss="modal">Close</button>
    <?php
    $url = Yii::app()->createUrl('inventoryreport/SaveBaseInventoryUpload');
    echo CHtml::ajaxSubmitButton('Save', $url, array(
        'dataType' => 'json',
        'type' => 'post',
        'success' => 'function(data) {
            $("#loader").hide();
            if(data.status=="success"){  
                t8.success("Inventory Report Saved Successfully!");
                $("#invreport_upload_close").click();
                reloadTable("#tbl_invreport_basetnventory_details");
            } else { 
                $("#invreport_upload-form .invreport_upload-save-btn").prop("disabled", false);                      
                $("#invreport_upload-form .invreport_upload-save-btn").addClass("btn-theme").removeClass("btn_loading"); 
                $.each(data, function(key, val) {
                    t8.error(""+val+""); 
                }); 
            } 
        }',
        'beforeSend' => 'function(){ 
            $("#loader").show();
            $(".toast8-error").hide();
            $("#invreport_upload-form .invreport_upload-save-btn").prop("disabled", true);                      
            $("#invreport_upload-form .invreport_upload-save-btn").addClass("btn_loading").removeClass("btn-theme"); 
        }'
    ), array('id' => 'mybtn' . rand(), 'class' => 'invreport_upload-save-btn btn btn-theme'));
    ?>
</div>
<?php $this->endWidget(); ?>
