public function actionIndex() { /** * fetch a count of customers */ $custCount = Customers::find()->count(); /** * fetch the orders for today */ $orders = Orderstatuses::find()->where('StatusOrder = 1')->count(); /** * fetch the visitor count from the ebsite */ $vistors = 0; /** * fetch the profit year to date */ $profitytd = Orderdetails::find()->all(); /** * fetch todays profit */ $todayprofit = Orders::find()->with(['orderdetails', 'orderStatus'])->where('OrderStatusId = 1')->all(); /** * fetch the count of active campaigns */ $campaigncount = Campaigns::find()->where('EndedOn = NULL')->count(); /** * count of queued emails */ $countQueued = Queuedemails::find()->where('SentOn <> NULL')->count(); return $this->render('index', ['custCount' => $custCount, 'orders' => $orders, 'profitytd' => $profitytd, 'todayprofit' => $todayprofit, 'campaigncount' => $campaigncount, 'countQueued' => $countQueued]); }
public function actionCheckout() { $uid = Yii::$app->user->id; $query = Customers::find()->with('user')->where('UserId = ' . $uid)->all(); if (!empty($query)) { $message = 'Is a customer'; } else { $message = 'Not a customer'; } return $this->render('checkout', ['message' => $message, 'cust' => $query]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customers::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['CustomerId' => $this->CustomerId, 'UserId' => $this->UserId, 'IsMallingActive' => $this->IsMallingActive, 'VirtualMoney' => $this->VirtualMoney, 'RefererCustomerId' => $this->RefererCustomerId, 'LastInvoiceAddressId' => $this->LastInvoiceAddressId, 'LastShippingAddressId' => $this->LastShippingAddressId, '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', 'AffiliateSlug', $this->AffiliateSlug])->andFilterWhere(['like', 'LastCreditCardName', $this->LastCreditCardName])->andFilterWhere(['like', 'Comment', $this->Comment]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Customers::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' => $this->id]); $query->andFilterWhere(['like', 'customer_name', $this->customer_name])->andFilterWhere(['like', 'zip_code', $this->zip_code])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'provice', $this->provice]); return $dataProvider; }
<?php use yii\helpers\Html; use yii\bootstrap\ActiveForm; use yii\helpers\ArrayHelper; use common\models\Customers; $dataCustomer = ArrayHelper::map(Customers::find()->asArray()->all(), 'CustomerId', 'Name'); /* @var $this yii\web\View */ /* @var $model common\models\Affiliates */ /* @var $form yii\bootstrap\ActiveForm */ ?> <div class="affiliates-form"> <?php $form = ActiveForm::begin(['layout' => 'horizontal']); ?> <?php echo $form->field($model, 'CustomerId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->dropDownList($dataCustomer, ['prompt' => 'Choose a Customer']); ?> <?php echo $form->field($model, 'ReferedCustomerId', ['horizontalCssClasses' => ['wrapper' => 'col-sm-4']])->dropDownList($dataCustomer, ['prompt' => 'Choose a Customer']); ?> <?php // echo $form->field($model, 'ActivatedOn')->textInput() ?> <?php
/** * Finds the Customers model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Customers the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Customers::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getCustomer() { return $this->hasOne(Customers::className(), ['CustomerId' => 'CustomerId']); }