Cart.php
2.34 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace common\models;
use backend\models\Importers;
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]
];
}
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;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'bill_id' => Yii::t('app', 'Bill ID'),
'account_id' => Yii::t('app', 'Account ID'),
'count' => Yii::t('app', 'Кол-во'),
'price' => Yii::t('app', 'Цена'),
'price_purchase' => Yii::t('app', 'Price Purchase'),
'status' => Yii::t('app', 'id status'),
'status_name' => Yii::t('app', 'Статус'),
'article' => Yii::t('app', 'Артикул'),
'brand' => Yii::t('app', 'Бренд'),
'descr' => Yii::t('app', 'Описание'),
'import_id' => Yii::t('app', 'Import ID'),
'importer' => Yii::t('app', 'Поставщик'),
'timestamp' => Yii::t('app', 'Timestamp'),
'aggregate' => Yii::t('app', 'Сумма'),
];
}
}