Blame view

common/modules/product/views/manage/import-process.php 1.73 KB
4ca21c3e   Alexey Boroda   first commit
1
2
3
4
  <?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
987739f1   Alexey Boroda   -Simple spoiler
5
      $method =  Yii::$app->request->baseUrl .'/product/manage/'. $method;
4ca21c3e   Alexey Boroda   first commit
6
  $this->registerJs("
4ca21c3e   Alexey Boroda   first commit
7
8
9
10
11
12
13
14
15
16
17
          var in_process=false;
          var count=1;
  
          in_process=true;
  
          doImport();
  
          function doImport(from) {
              from = typeof(from) != 'undefined' ? from : 0;
              console.log('go', from);
              $.ajax({
987739f1   Alexey Boroda   -Simple spoiler
18
                  url: '$method',
4ca21c3e   Alexey Boroda   first commit
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
                  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;
                      }
                  },
987739f1   Alexey Boroda   -Simple spoiler
42
            
4ca21c3e   Alexey Boroda   first commit
43
44
              });
          }
987739f1   Alexey Boroda   -Simple spoiler
45
46
  ");
  ?>
4ca21c3e   Alexey Boroda   first commit
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
  
  <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>