/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Giftcards::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['GiftCardId' => $this->GiftCardId, 'GiftCardTypeId' => $this->GiftCardTypeId, 'SenderCustomerId' => $this->SenderCustomerId, 'RecipientCustomerId' => $this->RecipientCustomerId, 'StartedOn' => $this->StartedOn, 'EndedOn' => $this->EndedOn, 'IsActive' => $this->IsActive, 'IsNotified' => $this->IsNotified, 'IsLimited' => $this->IsLimited, 'MinimumBasketAmount' => $this->MinimumBasketAmount, 'MinimumBasketItemCount' => $this->MinimumBasketItemCount, 'created_by' => $this->created_by, 'LastUpdatedBy' => $this->LastUpdatedBy, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Description', $this->Description])->andFilterWhere(['like', 'GiftCardCode', $this->GiftCardCode])->andFilterWhere(['like', 'SenderName', $this->SenderName])->andFilterWhere(['like', 'SenderPhone', $this->SenderPhone])->andFilterWhere(['like', 'SenderEmail', $this->SenderEmail])->andFilterWhere(['like', 'SenderMessage', $this->SenderMessage])->andFilterWhere(['like', 'RecipientName', $this->RecipientName])->andFilterWhere(['like', 'RecipientPhone', $this->RecipientPhone])->andFilterWhere(['like', 'RecipientEmail', $this->RecipientEmail])->andFilterWhere(['like', 'Comment', $this->Comment]); return $dataProvider; }
/** * Finds the Giftcards model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Giftcards the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Giftcards::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Customers; use common\models\Orders; use common\models\Giftcards; /* @var $this yii\web\View */ /* @var $model common\models\Giftcardhistories */ /* @var $form yii\widgets\ActiveForm */ $dataCustomers = ArrayHelper::map(Customers::find()->asArray()->all(), 'CustomerId', 'UserId'); $dataOrders = ArrayHelper::map(Orders::find()->asArray()->all(), 'OrderID', 'Name'); $dataGiftCards = ArrayHelper::map(Giftcards::find()->asArray()->all(), 'GiftCardId', 'Name'); ?> <div class="giftcardhistories-form"> <?php $form = ActiveForm::begin(['layout' => 'horizontal']); ?> <?php echo $form->field($model, 'GiftCardID', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->dropDownList($dataGiftCards, ['prompt' => 'Choose']); ?> <?php echo $form->field($model, 'CustomerID', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->dropDownList($dataCustomers, ['prompt' => 'Choose']); ?> <?php