index.php 2.68 KB
<?php
    
    use yii\helpers\Html;
    use yii\helpers\Url;
    use yiister\gentelella\widgets\Panel;
    
    /* @var $this yii\web\View */
    
    $this->title = Yii::t('catalog', 'Unload');
    $this->params[ 'breadcrumbs' ][] = $this->title;
?>
<div class="unload-index">
    
    <?php
        $xPanel = Panel::begin(
            [
                'header' => Html::encode($this->title),
            ]
        );
        ?>
    <div class="row">
    <?php
        echo Html::button(
            \Yii::t('catalog', 'Hotline'),
            [
                'class' => 'btn btn-success btn-lg hotline_button',
                'data'  => [
                    'url' => Url::to([ '/ajax/generate-hotline' ]),
                ],
            ]
        );
        echo Html::button(
            \Yii::t('catalog', 'Nadavi'),
            [
                'class' => 'btn btn-success btn-lg nadavi_button',
                'data'  => [
                    'url' => Url::to([ '/ajax/generate-nadavi' ]),
                ],
            ]
        );
    ?>
    </div>
  <div class="row">
  
    <a class="btn btn-primary" target="_blank" href="/hotline.xml"><?=\Yii::t('app', 'Открыть выгрузку Hotline')?></a>
  
    <a class="btn btn-primary" target="_blank" href="/nadavi.xml"><?=\Yii::t('app', 'Открыть выгрузку Nadavi')?></a>

  </div>
    <?php
        $xPanel::end();
    ?>
</div>
<?php
    $js = <<<JS
$(document)
    .on('click', '.hotline_button', function() {
        $(document.body).append('<div class="animated yt-loader"></div>');
        var url = $(this)
            .data('url');
        $.get(url, function() {
            new PNotify({
                        title: "Оповещение",
                        text: "Выгрузка обновлена",
                        type: "success",
                        styling: "bootstrap3",
                        icon: "glyphicon glyphicon-exclamation-sign"
                      });
            $('.yt-loader')
                        .remove();
        });
    });
$(document)
    .on('click', '.nadavi_button', function(e) {
        $(document.body).append('<div class="animated yt-loader"></div>');
        var url = $(this)
            .data('url');
        $.get(url, function() {
            new PNotify({
                        title: "Оповещение",
                        text: "Выгрузка обновлена",
                        type: "success",
                        styling: "bootstrap3",
                        icon: "glyphicon glyphicon-exclamation-sign"
                      });
            $('.yt-loader')
                        .remove();
        });
    });
JS;
    $this->registerJs($js);
?>