Blame view

common/models/Cart.php 2.34 KB
f68e7edd   Mihail   add bills models,...
1
2
3
4
  <?php
  
  namespace common\models;
  
f6c3dc95   Mihail   finish with cart ...
5
  use backend\models\Importers;
f68e7edd   Mihail   add bills models,...
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
  use Yii;
  
  /**
   * This is the model class for table "{{%cart}}".
   *
   * @property string $bill_id
   * @property string $account_id
   * @property string $count
   * @property double $price
   * @property double $price_purchase
   * @property integer $status
   * @property string $article
   * @property string $brand
   * @property string $descr
   * @property string $import_id
   * @property string $timestamp
   */
  class Cart extends \backend\components\base\BaseActiveRecord
  {
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return '{{%cart}}';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['bill_id', 'account_id', 'count', 'price', 'price_purchase', 'article', 'brand', 'descr', 'import_id'], 'required'],
              [['bill_id', 'account_id', 'count', 'status', 'import_id'], 'integer'],
              [['price', 'price_purchase'], 'number'],
              [['timestamp'], 'safe'],
              [['article', 'brand'], 'string', 'max' => 100],
              [['descr'], 'string', 'max' => 254]
          ];
      }
  
f6c3dc95   Mihail   finish with cart ...
48
49
50
51
52
53
54
55
56
57
58
59
      public function getImporter ()
      {
          return Importers::findOne(['id' => $this->import_id])->name;
      }
      public function getStatus_name ()
      {
          return DicStatuses::findOne(['id' => $this->status])->name;
      }
      public function getAggregate ()
      {
          return (float)$this->price * (float)$this->count;
      }
f68e7edd   Mihail   add bills models,...
60
61
62
63
64
65
66
67
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'bill_id' => Yii::t('app', 'Bill ID'),
              'account_id' => Yii::t('app', 'Account ID'),
f6c3dc95   Mihail   finish with cart ...
68
69
              'count' => Yii::t('app', 'Кол-во'),
              'price' => Yii::t('app', 'Цена'),
f68e7edd   Mihail   add bills models,...
70
              'price_purchase' => Yii::t('app', 'Price Purchase'),
f6c3dc95   Mihail   finish with cart ...
71
72
73
74
75
              'status' => Yii::t('app', 'id status'),
              'status_name' => Yii::t('app', 'Статус'),
              'article' => Yii::t('app', 'Артикул'),
              'brand' => Yii::t('app', 'Бренд'),
              'descr' => Yii::t('app', 'Описание'),
f68e7edd   Mihail   add bills models,...
76
              'import_id' => Yii::t('app', 'Import ID'),
f6c3dc95   Mihail   finish with cart ...
77
              'importer' => Yii::t('app', 'Поставщик'),
f68e7edd   Mihail   add bills models,...
78
              'timestamp' => Yii::t('app', 'Timestamp'),
f6c3dc95   Mihail   finish with cart ...
79
              'aggregate' => Yii::t('app', 'Сумма'),
f68e7edd   Mihail   add bills models,...
80
81
82
          ];
      }
  }