Esempio n. 1
0
 private function getRatesForPeriod($quoteid, $startdate, $enddate)
 {
     $models = Rate::find()->select(['rate.ratedate', 'rate.maximum', 'rate.minimum', 'rate.openrate', 'rate.closerate'])->join('INNER JOIN', 'quote', 'quote.qid = rate.quoteid')->where('quote.qid = :qid', [':qid' => $quoteid])->andWhere(['between', 'rate.ratedate', $startdate, $enddate])->all();
     $result = array();
     if (!empty($models)) {
         foreach ($models as $model) {
             $result[] = $model->toArray();
         }
     }
     return $result;
 }
Esempio n. 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Rate::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(['rateid' => $this->rateid, 'quoteid' => $this->quoteid, 'openrate' => $this->openrate, 'closerate' => $this->closerate, 'ratedate' => $this->ratedate, 'minimum' => $this->minimum, 'maximum' => $this->maximum, 'lastdeal' => $this->lastdeal, 'deals' => $this->deals, 'wa' => $this->wa, 'dayval' => $this->dayval, 'dayvol' => $this->dayvol, 'ActiveFlag' => $this->ActiveFlag, 'ChangeDate' => $this->ChangeDate]);
     return $dataProvider;
 }
Esempio n. 3
0
 public function actionGetLeadersAndLoosers($period)
 {
     if ($period == 'day') {
         $dates = Rate::getDatesForLiderTab('day');
     } elseif ($period == 'month') {
         $dates = Rate::getDatesForLiderTab('month');
     } elseif ($period == 'year') {
         $dates = Rate::getDatesForLiderTab('year');
     } elseif ($period == 'all') {
         $dates = Rate::getDatesForLiderTab('all');
     }
     $leaders = Rate::getLidersBetweenSelectedDates($dates[0], $dates[1]);
     $loosers = Rate::getLidersBetweenSelectedDates($dates[0], $dates[1], false);
     $return = array($leaders, $loosers);
     $response = Yii::$app->response;
     $response->format = Response::FORMAT_JSON;
     $response->data = $return;
     return $response;
 }
Esempio n. 4
0
 /**
  * Finds the Rate model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Rate the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Rate::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Esempio n. 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRates()
 {
     return $this->hasMany(Rate::className(), ['quoteid' => 'qid']);
 }