/** * [actionCreate description] * @param string module * @param integer id * @return view [description] */ public function actionCreate($module = NULL, $id = NULL) { $model = new Categories(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if (\Yii::$app->request->isAjax) { header('Content-type: application/json'); echo Json::encode(['status' => 'DONE', 'model' => $model]); exit; } else { return $this->redirect(['view', 'id' => $model->id]); } } else { if (!is_null($module) && !is_null($id)) { $model->mod_table = $module; $model->mod_id = $id; } return $this->renderAjax('@frenzelgmbh/cmcategories/widgets/views/iviews/_form', ['model' => $model]); } }
/** * renders the content for the widget */ protected function renderContent() { if (!is_null($this->module)) { $categories = Categories::getOptions($this->module); foreach ($categories as $key => $value) { echo Html::a(strtoupper(Html::encode($value)), array($this->target, 'category' => $key, 'reference' => Html::encode($value)), array('class' => $this->linkclass)) . " // \n"; } } else { echo " "; } }
public function search($params) { $query = Categories::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'mod_id' => $this->mod_id, 'system_upate' => $this->system_upate, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'mod_table', $this->mod_table])->andFilterWhere(['like', 'system_key', $this->system_key])->andFilterWhere(['like', 'system_name', $this->system_name]); return $dataProvider; }
/** * this produces an json array with the available categories for the passed * over module. */ public function actionJsoncategories() { header('Content-type: application/json'); $out = []; if (isset($_POST['depdrop_parents'])) { $parents = $_POST['depdrop_parents']; if ($parents != null) { $mod_table = $parents[0]; $out = Categories::jsCategories($mod_table); echo Json::encode(['output' => $out, 'selected' => '']); return; } } echo Json::encode(['output' => '', 'selected' => '']); exit; }