/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Auctions::find()->joinWith([ 'company0', 'auctionsCriterias', 'bidsTerms' ]); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); $dataProvider->pagination->pageSize=$this->pageSize; 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([ 'duration' => $this->duration, 'auctions.amount' => $this->amount, 'auctions.status' => $this->status, ]); $query->andFilterWhere(['like', 'auctions.name', $this->name]) ->andFilterWhere(['like', 'companies.name', $this->companyName]) ->andFilterWhere(['like', 'auctions.create_date', $this->create_date]); return $dataProvider; }
protected function dataTables(){ $allModels = (new Query())->select( '('.(new Query())->select('count(*)')->from(Auctions::tableName())->createCommand()->rawSql.') as auctions,'. '('.(new Query())->select('count(*)')->from(Dealers::tableName())->createCommand()->rawSql.') as dealers,'. '('.(new Query())->select('count(*)')->from(Companies::tableName())->createCommand()->rawSql.') as companies,'. '('.(new Query())->select('count(*)')->from(Brands::tableName())->createCommand()->rawSql.') as brands,'. '('.(new Query())->select('count(*)')->from(Categories::tableName())->createCommand()->rawSql.') as categories' )->one(); $_message = Auction::loggerMessageFormat('Admin Dashboard Created With :: ',$allModels); Auction::info($_message); return new ArrayDataProvider([ 'allModels' => $allModels, 'pagination' => false ]); }
/** * @return \yii\db\ActiveQuery */ public function getAuction0() { return $this->hasOne(Auctions::className(), ['id' => 'auction']); }
public function actionListAuctions($term){ $array = Auctions::find()->select('id,name') ->where(['like' , 'name' , $term]) ->asArray()->all(); return Json::encode($array); }
public function getCompanyDetails(){ return (new Query())->select( '('.(new Query())->select('count(*)')->from(Auctions::tableName())->where(['company' => $this->id])->createCommand()->rawSql.') as companyAuctions,'. '('.(new Query())->select('count(*)')->from(CompanyUsers::tableName())->where('company=:c and user!=:u',[':c' => $this->id , ':u' => Auction::$app->user->id])->createCommand()->rawSql.') as companyUsers,'. '('.(new Query())->select('count(*)')->from(DealerCompany::tableName())->where(['company' => $this->id])->createCommand()->rawSql.') as companyDealers' )->one(); }
/* @var $model auction\models\Lots */ /* @var $form yii\widgets\ActiveForm */ ?> <?php Pjax::begin(['id' => 'brand-form','enablePushState' => false, 'timeout' => false])?> <?php $form = ActiveForm::begin([ 'id' => 'create-brand', 'action' => Auction::createUrl('company/lots/create'), 'fieldClass' => 'auction\widgets\ActiveField', 'options' => [ 'data-pjax' => 1, ], ]); ?> <fieldset> <?= $form->field($model, 'name')->textInput() ?> <?= $form->field($model, 'auction')->dropDownList(ArrayHelper::map(Auctions::find()->all(),'id','name'),['class' => 'form-control']) ?> <?= $form->field($model, 'condition')->textInput() ?> <?= $form->field($model, 'is_quantity')->textInput() ?> <?= Html::submitButton('Create a new lot',['class' => 'btn btn-lg btn-info btn-block'])?> </fieldset> <?php ActiveForm::end(); ?> <?php Pjax::end();?>
</div> <!-- /.row --> <?php Pjax::begin(['id' => 'toggle-status', 'enablePushState' => false, 'clientOptions' => ['async' => false]]) ?> <div class="row"> <div class="col-lg-8"> <div class="chat-panel panel panel-green"> <div class="panel-heading"> <i class="fa fa-comments fa-fw"></i> Latest Company Auctions <div class="btn-group pull-right"> </div> </div> <!-- /.panel-heading --> <div class="panel-body"> <?= ListView::widget([ 'dataProvider' => Auctions::latestCompanyAuction($model->id), 'summary' => false, 'emptyText' => '<address>No Auction Found for this Company</address>', 'itemView' => '_latest_auctions' ]) ?> </div> <div class="panel-footer"> <?= Html::a(($preferenceData) ? ($preferenceData->status) ? 'Unsubscribe' : 'Subscribe' : 'Subscribe', \yii\helpers\Url::to(['toggle-status', 'id' => $model->id]) ) ?> </div> <!-- /.panel-body --> </div> <!-- /.panel .chat-panel --> </div> <!-- /.col-lg-8 -->
/** * Finds the Auctions model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Auctions the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { $model = Auctions::find()->joinWith([ 'bidsTerms', 'auctionsCriterias' ])->where([ 'auctions.id' => $id ])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * Finds the Auctions model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Auctions the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Auctions::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }