public function actionIndex($id, $limit = 2) { $model = Todo::find()->limit($limit)->with('idcities0')->all(); if (!\Yii::$app->request->getIsAjax()) { return $this->render('index', ['model' => $model, 'limit' => $limit]); } else { return $this->renderAjax('_form', ['model' => $model, 'limit' => $limit]); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Todo::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['idtodo' => $this->idtodo, 'idcities' => $this->idcities, 'iduser' => $this->iduser, 'cdate' => $this->cdate, 'mdate' => $this->mdate]); $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'image', $this->image]); return $dataProvider; }
public function actionIndex($id) { $text = new Comments(); $model = Todo::find()->where(['idtodo' => $id])->one(); $provider = new ActiveDataProvider(['query' => Comments::find()->with('iduser0')]); function replyComments($idcomments) { $data = Comments::find()->with('iduser0')->where(['parent' => $idcomments])->all(); foreach ($data as $val) { echo "<u>" . $val['iduser0']['username'] . "</u> replied<br/>" . "<b>" . $val['description'] . "</b><br/>"; } } return $this->render('index', ['model' => $model, 'text' => $text, 'dataprovider' => $provider]); }
/** * Displays a single Functionality model. * @param integer $id * @return mixed */ public function actionView($id) { $model = $this->findModel($id); if (Yii::$app->user->can('viewProject', ['project' => $model->project], false)) { $todo = new Todo(); $todo->creator_id = Yii::$app->user->id; $todo->updater_id = Yii::$app->user->id; $todo->deleted = false; $todo->functionality_id = $id; if ($todo->load(Yii::$app->request->post()) && $todo->save(false)) { \Yii::$app->getSession()->setFlash('success', Yii::t('todo', 'Todo saved')); $todo = new Todo(); $todo->creator_id = Yii::$app->user->id; $todo->updater_id = Yii::$app->user->id; $todo->deleted = false; $todo->functionality_id = $id; } $dataProvider = new ActiveDataProvider(['query' => Todo::find()->andWhere(['or', ['functionality_id' => $id]])]); return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider, 'todo' => $todo]); } throw new NotFoundHttpException('The requested page does not exist.'); }
/** * Updates an existing File model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (!Yii::$app->user->can('editFile', ['file' => $model])) { throw new NotFoundHttpException('The requested page does not exist.'); } if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->file_id]); } else { return $this->render('update', ['model' => $model, 'projects' => Project::find()->all(), 'todos' => Todo::find()->all()]); } }
echo Html::encode($this->title); ?> </h1> <div class="block"> <p> <?php echo Html::a(Yii::t('common', 'Update'), ['update', 'id' => $model->todo_id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('common', 'Delete'), ['delete', 'id' => $model->todo_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['name', 'description', ['attribute' => 'status_id', 'label' => 'Status', 'format' => 'raw', 'value' => Todo::statusses()[$model->status_id]], ['attribute' => 'functionality_id', 'label' => 'Functionaliteit', 'format' => 'raw', 'value' => html::a($model->functionality->name, ['functionality/view', 'id' => $model->functionality_id])], ['attribute' => 'creator_id', 'label' => Yii::t('user', 'Creator'), 'format' => 'raw', 'value' => $model->creator->username], 'datetime_added:datetime', ['attribute' => 'updater_id', 'label' => Yii::t('user', 'Updater'), 'formate' => 'raw', 'value' => $model->updater->username], 'datetime_updated:datetime']]); ?> <h2>Bestanden voor deze Todo</h2> <p><?php echo Html::a(Yii::t('file', 'Create file'), ['/file/create', 'tid' => $model->todo_id], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['name', 'description', 'creator.username', 'datetime_added', ['class' => 'yii\\grid\\ActionColumn', 'controller' => '/file']]]); ?> </div> </div>
<div class="file-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'description')->textInput(); ?> <?php echo $form->field($model, 'todo_id')->dropdownList(ArrayHelper::map(Todo::find()->all(), 'todo_id', 'name')); ?> <?php echo $form->field($model, 'project_id')->dropdownList(ArrayHelper::map(Project::find()->all(), 'project_id', 'description')); ?> <?php echo $form->field($model, 'deleted')->checkBox(); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getTodo() { return $this->hasOne(Todo::className(), ['todo_id' => 'todo_id']); }
echo Yii::t('todo', 'Status ID'); ?> </th> </thead> <tbody> <tr> <td><?php echo $form->field($model, 'name')->textInput(['maxlength' => true])->label(false); ?> </td> <td><?php echo $form->field($model, 'description')->textInput()->label(false); ?> </td> <td><?php echo $form->field($model, 'status_id')->dropdownList(Todo::statusses())->label(false); ?> </td> </tr> </tbody> </table> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? Yii::t('common', 'Create') : Yii::t('common', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>
/** * @return \yii\db\ActiveQuery */ public function getTodos0() { return $this->hasMany(Todo::className(), ['updater_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getTodos() { return $this->hasMany(Todo::className(), ['idcities' => 'idcities']); }
/** * Finds the Todo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Todo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Todo::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo Html::encode($this->title); ?> </h1> <div class="block"> <p> <?php echo Html::a(Yii::t('common', 'Update'), ['update', 'id' => $model->functionality_id], ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('common', 'Delete'), ['delete', 'id' => $model->functionality_id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('common', 'Are you sure you want to delete this item?'), 'method' => 'post']]); ?> </p> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['name', 'description', 'price:currency', ['attribute' => 'project_id', 'format' => 'raw', 'value' => Html::a($model->project->description, ['project/view', 'id' => $model->project_id])], ['label' => Yii::t('user', 'Creator'), 'value' => $model->creator->username], 'datetime_added:datetime', ['label' => Yii::t('user', 'Updater'), 'value' => $model->updater->username], 'datetime_updated:datetime']]); ?> <?php echo $this->render('../todo/_form', ['model' => $todo]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'name', 'description', ['attribute' => 'status_id', 'format' => 'raw', 'value' => function ($model) { return Todo::statusses()[$model->status_id]; }], ['class' => 'yii\\grid\\ActionColumn', 'controller' => 'todo']]]); ?> </div> </div>
/** * @return \yii\db\ActiveQuery */ public function getIdtodo0() { return $this->hasOne(Todo::className(), ['idtodo' => 'idtodo']); }
/** * @return \yii\db\ActiveQuery */ public function getTodos() { return $this->hasMany(Todo::className(), ['functionality_id' => 'functionality_id']); }