add product sale changes

This commit is contained in:
2015-10-01 09:37:34 +02:00
parent 7128cd438d
commit e3d6c0b902
34 changed files with 1801 additions and 1 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "currency".
*
* @property integer $id_currency
* @property string $currency
* @property string $name
* @property integer $rate
* @property string $created_at
* @property string $updated_at
*/
class Currency extends \common\models\BaseFitnessActiveRecord
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'currency';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['currency', 'name'], 'required'],
[['rate'], 'integer'],
[['currency'], 'string', 'max' => 10],
[['name'], 'string', 'max' => 32]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_currency' => Yii::t('common/currency', 'Id Currency'),
'currency' => Yii::t('common/currency', 'Currency'),
'name' => Yii::t('common/currency', 'Name'),
'rate' => Yii::t('common/currency', 'Rate'),
'created_at' => Yii::t('common/currency', 'Created At'),
'updated_at' => Yii::t('common/currency', 'Updated At'),
];
}
}

View File

@@ -0,0 +1,75 @@
<?php
namespace common\models;
use Yii;
/**
* This is the model class for table "transfer".
*
* @property integer $id_transfer
* @property integer $id_discount
* @property integer $id_currency
* @property integer $id_object
* @property integer $status
* @property integer $type
* @property integer $item_price
* @property integer $count
* @property integer $money
* @property integer $money_currency
* @property integer $rate
* @property integer $id_user
* @property string $comment
* @property string $created_at
* @property string $updated_at
*/
class Transfer extends \yii\db\ActiveRecord
{
const TYPE_PRODUCT = 10;
const TYPE_TICKET = 20;
/**
* @inheritdoc
*/
public static function tableName()
{
return 'transfer';
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['created_at', 'updated_at'], 'safe'],
[['comment'], 'string', 'max' => 255]
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'id_transfer' => Yii::t('common/transfer', 'Id Transfer'),
'id_discount' => Yii::t('common/transfer', 'Id Discount'),
'id_currency' => Yii::t('common/transfer', 'Id Currency'),
'id_object' => Yii::t('common/transfer', 'Id Object'),
'status' => Yii::t('common/transfer', 'Status'),
'type' => Yii::t('common/transfer', 'Type'),
'item_price' => Yii::t('common/transfer', 'Item Price'),
'count' => Yii::t('common/transfer', 'Count'),
'money' => Yii::t('common/transfer', 'Money'),
'money_currency' => Yii::t('common/transfer', 'Money Currency'),
'rate' => Yii::t('common/transfer', 'Rate'),
'id_user' => Yii::t('common/transfer', 'Id User'),
'comment' => Yii::t('common/transfer', 'Comment'),
'created_at' => Yii::t('common/transfer', 'Created At'),
'updated_at' => Yii::t('common/transfer', 'Updated At'),
];
}
}

View File

@@ -0,0 +1,79 @@
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\Transfer;
/**
* TransferSearch represents the model behind the search form about `common\models\Transfer`.
*/
class TransferSearch extends Transfer
{
/**
* @inheritdoc
*/
public function rules()
{
return [
[['id_transfer', 'id_discount', 'id_currency', 'id_object', 'status', 'type', 'item_price', 'count', 'money', 'money_currency', 'rate', 'id_user'], 'integer'],
[['comment', 'created_at', 'updated_at'], 'safe'],
];
}
/**
* @inheritdoc
*/
public function scenarios()
{
// bypass scenarios() implementation in the parent class
return Model::scenarios();
}
/**
* Creates data provider instance with search query applied
*
* @param array $params
*
* @return ActiveDataProvider
*/
public function search($params)
{
$query = Transfer::find();
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$this->load($params);
if (!$this->validate()) {
// uncomment the following line if you do not want to return any records when validation fails
// $query->where('0=1');
return $dataProvider;
}
$query->andFilterWhere([
'id_transfer' => $this->id_transfer,
'id_discount' => $this->id_discount,
'id_currency' => $this->id_currency,
'id_object' => $this->id_object,
'status' => $this->status,
'type' => $this->type,
'item_price' => $this->item_price,
'count' => $this->count,
'money' => $this->money,
'money_currency' => $this->money_currency,
'rate' => $this->rate,
'id_user' => $this->id_user,
'created_at' => $this->created_at,
'updated_at' => $this->updated_at,
]);
$query->andFilterWhere(['like', 'comment', $this->comment]);
return $dataProvider;
}
}