Blame view

common/modules/product/views/manage/import-process.php 1.84 KB
d8c1a2e0   Yarik   Big commit artbox
1
  <?php
5c2eb7c8   Yarik   Big commit almost...
2
3
4
5
6
7
8
      /**
       * @var View   $this
       * @var string $method
       */
      use yii\web\View;
      
      $this->registerJs("
e8ccb1b4   Yarik   Import beta
9
  var in_process=false;
d8c1a2e0   Yarik   Big commit artbox
10
11
12
13
14
15
16
17
18
19
          var count=1;
  
          in_process=true;
  
          doImport();
  
          function doImport(from) {
              from = typeof(from) != 'undefined' ? from : 0;
              console.log('go', from);
              $.ajax({
5c2eb7c8   Yarik   Big commit almost...
20
                  url: '" . \Yii::$app->request->baseUrl . '/product/manage/' . $method . "',
d8c1a2e0   Yarik   Big commit artbox
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
                  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) {
d8c1a2e0   Yarik   Big commit artbox
45
46
47
                  }
              });
          }
e8ccb1b4   Yarik   Import beta
48
  ");
5c2eb7c8   Yarik   Big commit almost...
49
      //?>
d8c1a2e0   Yarik   Big commit artbox
50
51
  
  <div class="product-import-process-form">
5c2eb7c8   Yarik   Big commit almost...
52
53
      <h1>Импорт <?= $method == 'prices' ? 'цен' : 'данных' ?> товаров</h1>
      
d8c1a2e0   Yarik   Big commit artbox
54
55
56
      <?= \yii\jui\ProgressBar::widget([
          'clientOptions' => [
              'value' => 100,
5c2eb7c8   Yarik   Big commit almost...
57
              'label' => '',
d8c1a2e0   Yarik   Big commit artbox
58
          ],
5c2eb7c8   Yarik   Big commit almost...
59
60
          'options'       => [
              'id' => 'progressbar',
d8c1a2e0   Yarik   Big commit artbox
61
          ],
5c2eb7c8   Yarik   Big commit almost...
62
      ]); ?>
d8c1a2e0   Yarik   Big commit artbox
63
64
      <ul id="process-result"></ul>
  </div>