Ejemplo n.º 1
0
 public function actionIndex()
 {
     $query = Forms::find();
     $pagination = new Pagination(['defaultPageSize' => 5, 'totalCount' => $query->count()]);
     $forms = $query->orderBy(['date' => SORT_ASC])->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['forms' => $forms, 'pagination' => $pagination]);
 }
Ejemplo n.º 2
0
 public function actionData($id)
 {
     if (isset($_GET['del'])) {
         return $this->render('data', ['id' => $id, 'forms' => Forms::find()->where(['id' => $id])->one()->delete(), 'exercises' => Exercise::deleteAll(['p_id' => $id])]);
     } elseif (isset($_GET['edit']) && isset($_POST['Forms'])) {
         $f = Forms::find()->where(['id' => $id])->one();
         $f->load(Yii::$app->request->post());
         $f->save();
         echo "<script>location.href = '/';</script>";
     } elseif (isset($_GET['edit'])) {
         return $this->render('data', ['id' => $id, 'forms' => Forms::find()->where(['id' => $id])->one()]);
     }
 }
Ejemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Forms::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'datasource_id' => $this->datasource_id, 'viewer_id' => $_GET['viewer_id'], 'chage_data' => $this->chage_data, 'setOrder' => $this->setOrder]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'html_template', $this->html_template])->andFilterWhere(['like', 'sql_select', $this->sql_select])->andFilterWhere(['like', 'sql_insert', $this->sql_insert])->andFilterWhere(['like', 'sql_update', $this->sql_update])->andFilterWhere(['like', 'sql_delete', $this->sql_delete])->andFilterWhere(['like', 'icon', $this->icon]);
     return $dataProvider;
 }
Ejemplo n.º 4
0
 /**
  * Finds the Forms model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Forms the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Forms::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getForm()
 {
     return $this->hasOne(Forms::className(), ['id' => 'form_id']);
 }