Blame view

backend/views/check_price/index.php 1.8 KB
c3d64258   Mihail   merge with server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
  <?php
  use yii\helpers\Html;
  use yii\grid\GridView;
  use yii\grid\SerialColumn;
  use yii\grid\ActionColumn;
  use yii\widgets\Pjax;
  
  
  /* @var $this yii\web\View */
  /* @var $searchModel backend\models\CatalogSearch */
  /* @var $dataProvider yii\data\ActiveDataProvider */
  
  $this->title = 'Проверка прайсов';
  $this->params['breadcrumbs'][] = $this->title;
  ?>
  <div class="catalog-index">
  
      <h1><?= Html::encode($this->title) ?></h1>
  
  
      <?= GridView::widget( ['dataProvider' => $dataProvider,
          'columns' => [['class' => SerialColumn::className()],
              [
                  'class' => ActionColumn::className(),
                  'template'=>'{view}',
                  'contentOptions' => function ($model, $key, $index, $column){
                      return ['data' => ['id' => $model->id, 'date' => $model->price_date_update]];
                  }
              ],
              [
                  'label' =>'Поставщик',
                  'value' => function ($data) {
                      return '№ ' .$data->id . ' ' . $data->name;
                  },
              ],
                             ['label' =>'Дата обновления',
                             'attribute' => 'price_date_update' ],
          ['label' => 'Кол-во дней',
              'value' => function ($data) {
                  $date1 = new DateTime("now");
                  $date2 = new DateTime( $data->price_date_update );
                  $quo_days = $date2->diff($date1)->format('%R%a');
                  // уберем первый символ - там знак "+"
                  $quo_days = substr( $quo_days, 1, strlen($quo_days) );
                  $quo_days = (int) $quo_days;
  
                  if($quo_days > 15)
                      $quo_days = '>15';
  
                  return $quo_days;
              }
          ],
          ]] );?>
  
  
  
  
  </div>