public function actionDelete($id) { $model = Section::find()->with('nextSection')->with('prevSection')->where(['id' => $id])->one(); if ($model->markDeleted() === false && !$model->hasErrors()) { throw new ServerErrorHttpException('Failed to update the object for unknown reason.'); } return $model; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Section::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', 'sectionNum', $this->sectionNum])->andFilterWhere(['like', 'sectionCode', $this->sectionCode])->andFilterWhere(['like', 'sectionName', $this->sectionName])->andFilterWhere(['like', 'sectionDesc', $this->sectionDesc]); return $dataProvider; }
/** * Load all sections with the same ancestor. * @param integer $id Article ID, also the ancestor fields. * @param type $status Constraint on the fields of status. False while no * constraint. * @return boolean */ public function loadArticle($id, $status = [Section::STATUS_DRAFT, Section::STATUS_PUBLISH]) { $condition = []; $condition['ancestor'] = $id; if ($status !== false) { $condition['status'] = $status; } $this->_sectionTree = Section::find()->where($condition)->indexBy('id')->all(); if (empty($this->_sectionTree)) { return false; } $this->populate($this->_sectionTree[$id]); return true; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Section::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, 'parent' => $this->parent, 'next' => $this->next, 'prev' => $this->prev, 'toc_mode' => $this->toc_mode, 'status' => $this->status, 'comment_mode' => $this->comment_mode, 'comment_num' => $this->comment_num, 'ver' => $this->ver, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
public function parseRequest($manager, $request) { /* @var Section $section */ $pathInfo = $request->getPathInfo(); if (($pos = strpos($pathInfo, '-')) === false && is_numeric($pathInfo)) { $section = Section::find()->where('id = :id', array(':id' => $pathInfo))->andWhere('slug = "" OR slug IS NULL')->one(); } elseif ($pos !== false && is_numeric($id = substr($pathInfo, 0, $pos))) { $section = Section::findOne(['id' => $id, 'slug' => substr($pathInfo, $pos + 1)]); } if (isset($section)) { return ['section/view', ['id' => $section->id, 'slug' => $section->slug]]; } return false; }
public function actionCreate($id = null) { if ($id === null) { $post = new Post(); } else { if (($post = Post::findOne(['id' => $id, 'author_id' => Yii::$app->getUser()->getId()])) === null) { throw new HttpException(404, 'Cannot find the requested post.'); } } if (Yii::$app->getRequest()->getIsAjax() && $post->load(Yii::$app->getRequest()->post())) { Yii::$app->getResponse()->format = Response::FORMAT_JSON; return ActiveForm::validate($post); } if ($post->load(Yii::$app->getRequest()->post()) && $post->save()) { return $this->redirect(Post::findOne($id)->getUrl()); } $rootSections = Section::find()->roots()->orderBy('title')->all(); $mainSections = $post->rootSectionId === null ? [] : Section::find()->where(['section_id' => $post->rootSectionId])->orderBy('title')->all(); return $this->render('create', ['post' => $post, 'rootSections' => $rootSections, 'mainSections' => $mainSections]); }
public function actionIndex() { $article = Article::find()->orderBy(['date_time' => SORT_DESC])->one(); if ($article->articlePhotos[0]->photo_path == '') { if (Yii::$app->language == 'ru') { $articleimage = Yii::getAlias('@resource/img/news_ru.jpg'); } else { $articleimage = Yii::getAlias('@resource/img/news_en.jpg'); } } else { $articleimage = $article->articlePhotos[0]->photo_path; } $event = Event::find()->orderBy(['start_timedate' => SORT_ASC])->limit(3)->all(); $section = Section::find()->limit(8)->all(); $innovation_text_on_main_page = Setting::find()->where(['key' => 'innovation_text_on_main_page'])->one(); $cooperation_with_aic = Setting::find()->where(['key' => 'cooperation_with_aic'])->one(); $fill_in_the_blank = Setting::find()->where(['key' => 'fill_in_the_blank'])->one(); $find_out_how_we_can_help_you = Setting::find()->where(['key' => 'find_out_how_we_can_help_you'])->one(); $information_for_Students = Setting::find()->where(['key' => 'information_for_Students'])->one(); $for_scientists_and_enterpreneurs = Setting::find()->where(['key' => 'for_scientists_and_enterpreneurs'])->one(); return $this->render('index', ['article' => $article, 'articleimage' => $articleimage, 'event' => $event, 'section' => $section, 'innovation_text_on_main_page' => $innovation_text_on_main_page->settingLan->index, 'cooperation_with_aic' => $cooperation_with_aic->settingLan->index, 'fill_in_the_blank' => $fill_in_the_blank->settingLan->index, 'find_out_how_we_can_help_you' => $find_out_how_we_can_help_you->settingLan->index, 'information_for_Students' => $information_for_Students->settingLan->index, 'for_scientists_and_enterpreneurs' => $for_scientists_and_enterpreneurs->settingLan->index]); }
/* @var $model common\models\Pendingdoc */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="pendingdoc-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'pendingDocFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'pendingDocSection')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> <?php echo $form->field($model, 'pendingDocName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'pendingDocTimeRelease')->textInput(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
</div> <div class="col-md-12"> <?php echo $form->field($mip, 'phone')->textInput(['maxlength' => true, 'class' => 'ntSaveForms form-control']); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'email')->textInput(['maxlength' => true, 'class' => 'ntSaveForms form-control']); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'section_id')->dropDownList(ArrayHelper::map(Section::find()->all(), 'id', 'sectionRus.section_name')); ?> </div> <div class="col-md-12"> <?php echo '<label>Начало</label>'; echo DateTimePicker::widget(['model' => $mip, 'attribute' => 'created_date', 'language' => 'ru', 'name' => 'datetime_1', 'options' => ['placeholder' => 'Select operating time ...'], 'convertFormat' => true, 'pluginOptions' => ['format' => 'yyyy-MM-dd H:mm:ss', 'startDate' => '01-Mar-2015 12:00 AM', 'todayHighlight' => true, 'todayBtn' => true, 'autoclose' => true]]); ?> </div> <div class="col-md-12"> <?php echo $form->field($mip, 'user_id')->dropDownList(ArrayHelper::map(User::find()->all(), 'id', 'username')); ?> </div> <div class="col-md-12"> <?php
/** * Lists all Section models. * @return mixed */ public function actionIndex() { return $this->render('index', ['model' => Section::find()->all()]); }
public function actionChildren($id) { $sections = Section::find()->where(['section_id' => $id])->orderBy('title')->all(); Yii::$app->getResponse()->format = Response::FORMAT_JSON; return ArrayHelper::map($sections, 'id', 'title'); }
?> --> <!--<?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> --> <?php //$form->field($model, 'position_id') echo $form->field($model, 'position_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Position::find()->all(), 'id', 'positionName'), 'options' => ['placeholder' => 'Select a position'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php //$form->field($model, 'section_id') echo $form->field($model, 'section_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), 'options' => ['placeholder' => 'Select a section'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'userFName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userMName')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'userLName')->textInput(['maxlength' => true]); ?> <?php
public function actionRelease($id) { $model = $this->findModel($id); $workflowid = ArrayHelper::getValue(Docworkflow::find()->where(['document_id' => $id])->orderBy(['id' => SORT_DESC])->one(), 'id'); //print_r($workflowid . ' level0 ' . $model->user_id); if ($model->load(Yii::$app->request->post())) { //$userid1 = ArrayHelper::getValue(User::find()->where(['username' => Yii::$app->user->identity->username])->one(), 'id'); $sectionid = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'section_id'); $userFName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userFName'); $userLName = ArrayHelper::getValue(User::find()->where(['id' => $model->user_id])->one(), 'userLName'); $section = ArrayHelper::getValue(Section::find()->where(['id' => $sectionid])->one(), 'sectionName'); $documentname = ArrayHelper::getValue(Document::find()->where(['id' => $id])->one(), 'documentName'); $pendingdoc = new Pendingdoc(); $pendingdoc->pendingDocFName = $userLName . ', ' . $userFName; $pendingdoc->pendingDocSection = $section; $pendingdoc->pendingDocName = $documentname; if ($workflowid == null) { if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } else { $workflow1 = new Docworkflow(); $workflow1 = $this->findModelWorkflow($workflowid); //$workflow1->id = $workflowid; $workflow1->timeRelease = date('Y-m-d H:i:s'); //$workflow1->totalTimeSpent = date('Y-m-d H:i:s'); $workflow1->user_release = $model->user_id; print_r('level1'); if ($workflow1->save()) { print_r('level2'); if ($pendingdoc->save()) { print_r('level3'); return $this->redirect(['index']); //return $this->redirect('index.php?r=pendingdoc'); } } } } else { return $this->renderAjax('release', ['model' => $model]); } }
public function actionView($id) { $mip = mip::find()->where(['id' => $id])->one(); return $this->render('view', ['mip' => $mip, 'sections' => $sections = Section::find()->all()]); }