Blame view

views/manage/import-process.php 1.84 KB
2f25da09   Yarik   first commit
1
2
3
4
5
6
7
8
9
10
11
12
  <?php
      /**
       * @var View   $this
       * @var string $method
       */
      use yii\web\View;
      
      $this->registerJs("
  var in_process=false;
          var count=1;
  
          in_process=true;
2f25da09   Yarik   first commit
13
14
15
16
17
18
          doImport();
  
          function doImport(from) {
              from = typeof(from) != 'undefined' ? from : 0;
              console.log('go', from);
              $.ajax({
25c82e9e   Administrator   full commit
19
                  url: '" . \Yii::$app->request->baseUrl . '/ecommerce/manage/' . $method . "',
2f25da09   Yarik   first commit
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
                  data: {from:from},
                  dataType: 'json',
                  success: function(data){
                      for(var key in data.items)
                      {
                          $('ul#process-result').prepend('<li>'+ data.items[key] +'</li>');
                          count++;
                      }
  
                      var per = Math.round(100*data.from/data.totalsize)+'%';
                      $('#progressbar div').css({width: per});
  
                      if(data != false && !data.end)
                      {
                          doImport(data.from);
                      }
                      else
                      {
                          $('ul#process-result').prepend('<li>Импорт цен успешно завершен!</li>');
                          progressbar.hide('fast');
                          in_process = false;
                      }
                  },
                  error: function(xhr, status, errorThrown) {
                  }
              });
          }
  ");
      //?>
  
  <div class="product-import-process-form">
      <h1>Импорт <?= $method == 'prices' ? 'цен' : 'данных' ?> товаров</h1>
      
      <?= \yii\jui\ProgressBar::widget([
          'clientOptions' => [
              'value' => 100,
              'label' => '',
          ],
          'options'       => [
              'id' => 'progressbar',
          ],
      ]); ?>
      <ul id="process-result"></ul>
  </div>