public function actionSite() { $params = ['today' => new \DateTime(), 'metrics' => empty(YII_DEBUG), 'review' => $day_review = Yii::$app->hryvna->getAvg(), 'banks_exchanges' => $banks_days = Yii::$app->hryvna->getBankDays(null, -10), 'banks_names' => $banks_names = ArrayHelper::map(models\Bank::find()->orderBy([new \yii\db\Expression('FIELD(rate, 0), rate, id')])->all(), 'id', 'title')]; // generate days $periods = ['week' => ['delta' => 1, 'story_one' => 'останній тиждень', 'story_two' => 'десять днів'], 'month' => ['delta' => 3, 'story_one' => 'останній місяць', 'story_two' => 'тридцять днів'], 'kvartal' => ['delta' => 9, 'story_one' => 'останній квартал', 'story_two' => "дев'яносто днів"], 'halfyear' => ['delta' => 18, 'story_one' => 'останні півроку', 'story_two' => 'сто вісімдесят днів'], 'year' => ['delta' => 36, 'story_one' => 'останній рік', 'story_two' => 'триста шістдесят днів']]; $data_tank = []; foreach ($periods as $period_code => $period_info) { $data_tank[$period_code] = Storyteller::describePeriod($period_info['delta'], $period_info['story_one'], $period_info['story_two']); } $params['days'] = $data_tank; // generate exchange rates table $converter_exchanges = end($banks_days); foreach ($converter_exchanges as $bank_id => $exchange) { // change NBU to avg exchange rates if ($bank_id == 1) { $exchange['dollar_buy'] = ['value' => $day_review['dollar_buy_banks']['value']]; $exchange['dollar_sale'] = ['value' => $day_review['dollar_sale_banks']['value']]; $exchange['euro_buy'] = ['value' => $day_review['euro_buy_banks']['value']]; $exchange['euro_sale'] = ['value' => $day_review['euro_sale_banks']['value']]; $exchange['title'] = 'Середній банковий курс'; } else { $exchange['title'] = $banks_names[$bank_id]; } $converter_exchanges[$bank_id] = $exchange; } $params['converter_exchanges'] = $converter_exchanges; // render site $site = $this->view->render('@app/views/templates/site.tpl', $params); $js = $this->view->render('@app/views/templates/js.tpl', $params); // save generated files to public dir echo file_put_contents(Yii::$app->params['site']['index'], $site) . PHP_EOL; echo file_put_contents(Yii::$app->params['site']['js'], $js) . PHP_EOL; }
/** * Actual date is a last date when exchanges for all bank are ready * @return String Date string in mysql format(Y-m-d) */ public function getActualDate() { $banks_count = models\Bank::find()->count(); $table_exchanges = models\ExchangeRate::tableName(); $query = "\n SELECT grab_date as actual_date, count(*) as exchanges_count\n\n FROM `{$table_exchanges}` as exchanges\n\n GROUP BY `grab_date`\n\n HAVING exchanges_count = {$banks_count}\n ORDER BY `grab_date` DESC\n\n LIMIT 1\n "; $command = Yii::$app->db->createCommand($query); $result = $command->queryOne(); return $result['actual_date']; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bank::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['like', 'b_id', $this->b_id])->andFilterWhere(['like', 'bezeichnung', $this->bezeichnung])->andFilterWhere(['like', 'klasse', $this->klasse]); return $dataProvider; }
/** * Fungsi untuk menghapus data bank * @param [type] $id [description] * @return [type] [description] */ public function destroy($id) { $bank = Bank::find($id); if ($bank) { if ($bank->delete()) { return ['status' => 'success', 'message' => 'Data bank berhasil dihapus.']; } else { return ['status' => 'failed', 'message' => 'Data bank tidak berhasil dihapus.']; } } else { return ['status' => 'failed', 'message' => 'Data bank tidak ditemukan.']; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bank::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', 'name', $this->name])->andFilterWhere(['like', 'website', $this->website])->andFilterWhere(['like', 'xpathDollarBuy', $this->xpathDollarBuy])->andFilterWhere(['like', 'xpathDollarSell', $this->xpathDollarSell])->andFilterWhere(['like', 'xpathEuroBuy', $this->xpathEuroBuy])->andFilterWhere(['like', 'xpathEuroSell', $this->xpathEuroSell]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bank::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', 'Keterangan', $this->Keterangan])->andFilterWhere(['like', 'OptimisticLockField', $this->OptimisticLockField])->andFilterWhere(['like', 'GCRecord', $this->GCRecord])->andFilterWhere(['like', 'Lokasi', $this->Lokasi]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Bank::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['ID' => $this->ID, 'BIK' => $this->BIK]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'CorrAccount', $this->CorrAccount])->andFilterWhere(['like', 'City', $this->City]); return $dataProvider; }
public function actionStatisticList() { //$model = $this->findModel($bankId); /* $searchModel = new Statistic($bankId); $dataProvider = $searchModel->search( \Yii::$app->request->queryParams );*/ return $this->render('statistic-list', ['list' => Bank::find()->orderBy('bezeichnung')->all()]); }
?> Auswahlfragen<br/> <?php echo \app\models\Question::find()->andFilterWhere(['display' => 'multi'])->count(); ?> Mehrfachauswahlfragen<br/> <h4>Banken</h4> <?php echo \app\models\Bank::find()->count(); ?> Banken insgesamt, in<br/> <?php echo \app\models\Bank::find()->distinct('klasse')->count(); ?> verschiedenen Bankenklassen<br/> <h4>Benutzergruppen</h4> <?php echo \app\models\Group::find()->count(); ?> Benutzergruppen insgesamt<br/> <h4>Zugangscodes</h4> <?php echo \app\models\Code::find()->count(); ?>
<?php use app\assets\MultipleSelectAsset; use yii\helpers\Html; use yii\helpers\Url; use kartik\grid\GridView; use dosamigos\multiselect\MultiSelect; use yii\helpers\ArrayHelper; MultipleSelectAsset::register($this); /* @var $this yii\web\View */ /* @var $model app\models\Bank */ $this->title = 'Platzhalter'; $this->params['breadcrumbs'][] = ['label' => 'Banken', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; $data = ArrayHelper::map(\app\models\Bank::find()->orderBy('bezeichnung')->all(), 'b_id', 'bezeichnung'); ?> <div class="bank-view"> <?php if (isset($error)) { ?> <div class="alert alert-danger alert-dismissible" role="alert"> <?php echo $error; ?> </div> <?php } ?> <form action=<?php echo Url::toRoute("/bank/placeholders/set-alias"); ?>
public function actionUpdateRates() { libxml_use_internal_errors(true); $banks = Bank::find()->all(); foreach ($banks as $bank) { if (($bank->xpathDollarBuy || $bank->xpathDollarSell || $bank->xpathEuroBuy || $bank->xpathEuroSell) && $bank->website) { $cookie = $bank->cookie ? "Cookie: " . $bank->cookie . "\r\n" : ''; $opts = ['http' => ['header' => "User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36\r\n" . $cookie]]; $context = stream_context_create($opts); $html = file_get_contents('https://' . $bank->website, FALSE, $context); $dom = new DomDocument(); $dom->loadHTML($html); $xpath = new DomXPath($dom); $bank->dollarBuy = $xpath->query($bank->xpathDollarBuy)[0]->nodeValue; $bank->dollarSell = $xpath->query($bank->xpathDollarSell)[0]->nodeValue; $bank->euroBuy = $xpath->query($bank->xpathEuroBuy)[0]->nodeValue; $bank->euroSell = $xpath->query($bank->xpathEuroSell)[0]->nodeValue; $bank->relevantCity = $xpath->query($bank->xPathRelevantCity)[0]->nodeValue; $bank->save(); } } $this->redirect(['bank/index']); }
/** * List of actual banks ordered in site style * @return array */ public function actionBanklist() { return models\Bank::find()->orderBy([new \yii\db\Expression('FIELD(rate, 0), rate, id')])->all(); }