/** * Finds user by [[username]] * * @return UserAccounts|null */ public function getUser() { if ($this->_user === false) { $this->_user = UserAccounts::findByUsername($this->username); } return $this->_user; }
/** * Lists all Products models. * @return mixed */ public function actionUser() { $transactions = []; $user_account = null; $pagination = null; $date_posted = ''; $g_total_quantity = $g_total_amount = $g_total_amount_paid = 0; $user_id = Yii::$app->request->post('player_select'); if (Yii::$app->request->post('date_range')) { $date_posted = Yii::$app->request->post('date_range'); } elseif (Yii::$app->request->getQueryParam('page')) { $date_posted = Yii::$app->session['date_posted']; $user_id = Yii::$app->session['user_id']; } if ($date_posted != '') { Yii::$app->session['date_posted'] = $date_posted; Yii::$app->session['user_id'] = $user_id; $date_range = explode(' to ', $date_posted); $start_date = $date_range[0]; $end_date = $date_range[1]; $query = Transactions::find()->where(['BETWEEN', 'transaction_date', Yii::$app->formatter->asDate($start_date, 'php:Y-m-d') . ' 00:00:00', Yii::$app->formatter->asDate($end_date, 'php:Y-m-d') . ' 23:59:59'])->orderBy(['transaction_date' => SORT_DESC]); if ($user_id > 0) { $query->andWhere(['user_id' => $user_id]); } $pagination = new Pagination(['totalCount' => $query->count(), 'pageSize' => 10]); $g_total_quantity = $query->sum('total_quantity'); $g_total_amount = $query->sum('total_amount'); $g_total_amount_paid = $query->sum('amount_paid'); $transactions = $query->offset($pagination->offset)->limit($pagination->limit)->all(); $user_account = UserAccounts::findOne($user_id); } return $this->render('users', ['transactions' => $transactions, 'user_account' => $user_account, 'g_total_quantity' => $g_total_quantity, 'g_total_amount' => $g_total_amount, 'g_total_amount_paid' => $g_total_amount_paid, 'pagination' => $pagination]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = UserAccounts::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, 'date_created' => $this->date_created, 'last_login' => $this->last_login, 'category_id' => $this->category_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'password', $this->password]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getUsuarioCreacion() { return $this->hasOne(UserAccounts::className(), ['id' => 'usuario_creacion']); }
<div class=""> <div class="input-group drp-container"> <?php echo DateRangePicker::widget(['name' => 'date_range', 'value' => isset($posted_data['date_range']) ? $posted_data['date_range'] : Yii::$app->formatter->asDate('now', 'php:d-M-y') . ' to ' . Yii::$app->formatter->asDate('now', 'php:d-M-y'), 'convertFormat' => true, 'options' => ['id' => 'date_range'], 'pluginOptions' => ['format' => 'd-M-y', 'separator' => ' to ']]); ?> </div> </div> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label for="player_select" class="control-label">Select Cashier</label> <div class=""> <?php echo Html::dropDownList('player_select', isset($posted_data['player_select']) ? $posted_data['player_select'] : null, ['0' => 'All'] + ArrayHelper::map(UserAccounts::find()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'player_select']); ?> </div> </div> </div> <div class="clearfix"></div> <div class="col-sm-6"> <div class="form-group"> <label for="category_select" class="control-label">Select Category</label> <div class=""> <?php echo Html::dropDownList('category_select', isset($posted_data['category_select']) ? $posted_data['category_select'] : null, ['0' => 'All'] + ArrayHelper::map(ProductCategories::find()->all(), 'id', 'name'), ['class' => 'form-control', 'id' => 'category_select']); ?> </div> </div> </div>
<div class=""> <div class="input-group drp-container"> <?php echo DateRangePicker::widget(['name' => 'date_range', 'value' => Yii::$app->request->post('date_range') ? Yii::$app->request->post('date_range') : Yii::$app->formatter->asDate('now', 'php:d-M-y') . ' to ' . Yii::$app->formatter->asDate('now', 'php:d-M-y'), 'convertFormat' => true, 'pluginOptions' => ['format' => 'd-M-y', 'separator' => ' to ']]); ?> </div> </div> </div> </div> <div class="col-sm-6"> <div class="form-group"> <label for="inputEmail3" class="control-label">Select User</label> <div class=""> <?php echo Html::dropDownList('player_select', null, [0 => 'All'] + ArrayHelper::map(UserAccounts::find()->all(), 'id', 'name'), ['class' => 'form-control']); ?> </div> </div> </div> <div class="clearfix"></div> <div class="col-sm-12"> <?php echo Html::submitButton('Generate Reports', ['class' => 'btn btn-success ']); ?> </div> <div class="clearfix"></div> </div> </div>
/** * Finds the UserAccounts model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return UserAccounts the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = UserAccounts::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function getUserAccount() { return $this->hasOne(UserAccounts::className(), ['id' => 'user_id']); }