| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- <?php
- namespace app\models;
- use Yii;
- /**
- * This is the model class for table "auctions".
- *
- * @property integer $id
- * @property string $name
- * @property integer $user_id
- * @property integer $lot_id
- * @property string $date_start
- * @property string $date_stop
- * @property double $last_price
- * @property integer $last_user
- * @property string $last_date
- * @property integer $type
- * @property integer $status
- * @property Lots $lot
- */
- class Publishing extends \yii\db\ActiveRecord
- {
- /**
- * @inheritdoc
- */
- public static function tableName()
- {
- return 'auctions';
- }
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['name', 'user_id', 'lot_id', 'last_price', 'last_user','status'], 'required'],
- [['user_id', 'lot_id', 'last_user', 'type'], 'integer'],
- [['date_start', 'date_stop', 'last_date','userName', 'lotNum','lotName','statusName','endBidding','lotDesc','lotPrice','lotStep'], 'safe'],
- [['last_price'], 'number'],
- [['name'], 'string', 'max' => 30],
- [['lot_id'], 'unique']
- ];
- }
- /**
- * @inheritdoc
- */
- public function attributeLabels()
- {
- return [
- 'id' => Yii::t('app', 'Number ID'),
- 'name' => Yii::t('app', 'AukName ID'),
- 'user_id' => Yii::t('app', 'организатор'),
- 'lot_id' => Yii::t('app', 'лот'),
- 'date_start' => Yii::t('app', 'PublishDateStart ID'),
- 'date_stop' => Yii::t('app', 'дата завершения'),
- 'last_price' => Yii::t('app', 'текущая цена'),
- 'last_user' => Yii::t('app', 'ставка последнего юзера'),
- 'last_date' => Yii::t('app', 'время последней ставки'),
- 'type' => Yii::t('app', 'type'),
- 'status' => Yii::t('app', 'statusName ID'),
- 'lotName' => Yii::t('app', 'Predmet ID'),
- 'userName' => Yii::t('app', 'OrgName ID'),
- 'statusName' => Yii::t('app', 'statusName ID'),
- 'endBidding' => Yii::t('app', 'endBidding ID'),
- 'created_at' => Yii::t('app','BiddingStartDate ID'),
- 'lotDesc' => Yii::t('app', 'PublishLotDesc ID'),
- 'lotPrice' => Yii::t('app', 'StartPrice ID'),
- 'lotStep' => Yii::t('app', 'Step ID'),
- 'NDS' => Yii::t('app', 'NDS ID'),
- //'Pterm' => Yii::t('app', 'PaymentTerm ID'),
- ];
- }
- public function getLot()
- {
- return $this->hasOne(Lots::className(), ['id' => 'lot_id']);
- }
- public function getUser()
- {
- return $this->hasOne(User::className(), ['id' => 'user_id']);
- }
- public function getProfile(){
- return $this->hasOne(Profile::className(), ['user_id' => 'id'])->via('user');
- }
- public function getLotName()
- {
- if($this->lot)
- {
- return $this->lot->name;
- }
- else
- {
- return false;
- }
- }
- public function getUserName()
- {
- if($this->user)
- {
- return $this->user->at_org;
- }
- else
- {
- return false;
- }
- }
- public function getLotNum()
- {
- return $this->lot->num;
- }
- public function getLotDesc()
- {
- return $this->lot->description;
- }
- public function getLotPrice()
- {
- return $this->lot->start_price;
- }
- public function getNDS()
- {
- $nds = $this->lot->nds;
- if($nds==1)
- {
- return 'з ПДВ';///Yii::t('app', 'withNDS ID');
- }
- else
- {
- return Yii::t('app', 'withoutNDS ID');
- }
- }
- public function getLotStep()
- {
- return $this->lot->step;
- }
- public function getEndBidding()
- {
- if($this->lot)
- {
- return $this->lot->bidding_date;
- }
- else
- {
- return false;
- }
- }
- function getStatusName()
- {
- if($this->status==0)
- {
- return Yii::t('app','pMakeBidding ID');
- }
- if($this->status==1)
- {
- return Yii::t('app','pWaitAuction ID');
- }
- elseif($this->status==2)
- {
- return Yii::t('app','pMakeAuction ID');
- }
- elseif($this->status==3)
- {
- return Yii::t('app','pMakeFinal ID');
- }
- elseif($this->status==4)
- {
- return Yii::t('app','pEndTorg ID');
- }
- else
- {
- return false;
- }
- }
- public function setLotName()
- {
- // add
- }
- public function setUserName()
- {
- // add
- }
- public function setEndBidding()
- {
- // add
- }
- public function getProtocol()
- {
- $protocol = Files::find()->where(['user_id'=>'23','auction_id'=>$this->id])->one();
- if($protocol)
- {
- return $protocol;
- }
- else
- {
- return false;
- }
- }
- public function fields()
- {
- return [
- 'id',
- 'userName',
- 'lotNum',
- 'lotName',
- 'user_id',
- 'endBidding',
- 'statusName',
- ];
- }
- }
|