<?php
$csrfToken = Yii::app()->request->csrfToken;
?>

<div class="span4">
    <div class="">
        <?php $this->widget('BSideMenu', array('items' => $this->sideMenu));?>
    </div>
</div>
<div class="span12">
    <style>

        .bar {
            height: 18px;
            background: green;
        }
        button{
            display: block;
        }
    </style>
    <h1>Загрузка данных для СТО</h1>
    <input id="fileupload" type="file" name="files" data-url="/admin/stoFilter/parser" multiple>


    <div id="progress">
        <div class="bar" style="width: 0%;"></div>
    </div>

    <?php
    $cs = Yii::app()->getClientScript();
    $cs->registerScriptFile(Yii::app()->baseUrl . '/bower_components/blueimp-file-upload/js/vendor/jquery.ui.widget.js');
    $cs->registerScriptFile(Yii::app()->baseUrl . '/bower_components/blueimp-file-upload/js/jquery.iframe-transport.js');
    $cs->registerScriptFile(Yii::app()->baseUrl . '/bower_components/blueimp-file-upload/js/jquery.fileupload.js');

    ?>
    <script>
        $(function () {
            var $input = $('#progress');
            $('#fileupload').fileupload({
                dataType: 'json',
                add: function (e, data) {
                    data.context = $('<button/>').text('Upload')
                        .appendTo($input)
                        .click(function () {
                            data.context = $('<p/>').text('Uploading...').replaceAll($(this));
                            data.submit();
                        });
                },
                done: function (e, data) {
                    console.log(data.result);
                    data.context.text('Upload finished.');
                }
            });
        });
    </script>
</div>


