Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Quote::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(['qid' => $this->qid, 'exchid' => $this->exchid, 'companyid' => $this->companyid, 'privileged' => $this->privileged, 'ActiveFlag' => $this->ActiveFlag, 'ChangeDate' => $this->ChangeDate]);
     $query->andFilterWhere(['like', 'fullname', $this->fullname])->andFilterWhere(['like', 'shortname', $this->shortname])->andFilterWhere(['like', 'englishname', $this->englishname])->andFilterWhere(['like', 'acronym', $this->acronym]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Quote model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Quote the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Quote::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getQuotes()
 {
     return $this->hasMany(Quote::className(), ['companyid' => 'companyid']);
 }
Example #4
0
 /**
  * Loading rates from CSV file
  */
 public function actionLoad()
 {
     $model = new UploadForm();
     if (Yii::$app->request->isPost) {
         $model->csvFile = UploadedFile::getInstance($model, 'csvFile');
         if ($model->upload()) {
             try {
                 $csv = new CSV(Yii::getAlias('@uploads') . '/' . $model->csvFile->baseName . '.' . $model->csvFile->extension);
                 $models = Quote::findAll(['ActiveFlag' => 1]);
                 $filter = array();
                 foreach ($models as $model) {
                     $filter[strtoupper(trim($model->acronym))] = $model->qid;
                 }
                 $arr = $csv->getFilteredCSV($filter);
                 $this->batchInsertRows($arr);
             } catch (Exception $e) {
             }
         }
     } else {
         return $this->render('load', ['model' => $model]);
     }
 }
Example #5
0
 public static function getQuotesFullnameList()
 {
     return ArrayHelper::map(Quote::find()->orderBy('fullname ASC')->all(), 'qid', 'fullname');
 }
Example #6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getQuotes()
 {
     return $this->hasMany(Quote::className(), ['qid' => 'quoteid'])->viaTable('indiceslinks', ['indid' => 'indexid']);
 }
Example #7
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getQuote()
 {
     return $this->hasOne(Quote::className(), ['qid' => 'quoteid']);
 }