Beispiel #1
0
 public function actionCreate($id)
 {
     $project = $this->loadModel('app\\models\\Project', $id);
     $this->view->params['appSettings'] = ['app_name' => $project->title];
     if (!\Yii::$app->user->can('viewProject', ['project' => $project]) || \Yii::$app->user->isGuest) {
         throw new ForbiddenHttpException('Access denied');
     }
     $model = new Milestone();
     $model->project_id = $project->id;
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         \Yii::$app->session->setFlash('success', \Yii::t('app', 'New milestone successfully created.'));
         $this->redirect(['/milestone/index', 'id' => $project->id]);
     }
     return $this->render('create', ['model' => $model, 'project' => $project]);
 }
Beispiel #2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Milestone::find();
     $query->andFilterWhere(['project_id' => $this->project_id]);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['user_id' => $this->user_id]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['like', 'title', $this->title]);
     return $dataProvider;
 }
 public function search($params)
 {
     $query = Milestone::find();
     $query->joinWith(["project"]);
     if (Yii::$app->user->identity->isViewingProject) {
         $query->where(["fkIDWithProjectID" => Yii::$app->user->identity->fkIDWithProjectID]);
     }
     $activeDataProvider = new ActiveDataProvider(["query" => $query, "pagination" => ["pageSize" => 20]]);
     $activeDataProvider->sort->attributes["projectName"] = ["asc" => ["project.name" => SORT_ASC], "desc" => ["project.name" => SORT_DESC]];
     $activeDataProvider->sort->attributes["countInCompletedTasks"] = ["asc" => [$this->countInCompletedTasksSQL => SORT_ASC], "desc" => [$this->countInCompletedTasksSQL => SORT_DESC]];
     $activeDataProvider->sort->attributes["countCompletedTasks"] = ["asc" => [$this->countCompletedTasksSQL => SORT_ASC], "desc" => [$this->countCompletedTasksSQL => SORT_DESC]];
     if (!$this->load($params) || !$this->validate()) {
         return $activeDataProvider;
     }
     $query->andFilterWhere(["like", "milestone.id", $this->id])->andFilterWhere(["like", "milestone.name", $this->name])->andFilterWhere(["like", "project.name", $this->projectName])->andFilterWhere(["like", $this->countInCompletedTasksSQL, $this->countInCompletedTasks])->andFilterWhere(["like", $this->countCompletedTasksSQL, $this->countCompletedTasks])->andFilterWhere(["like", "milestone.dueDate", !empty($this->dueDate) ? Yii::$app->formatter->asDate($this->dueDate, "Y-MM-dd") : null])->andFilterWhere(["like", "milestone.completed", $this->completed]);
     return $activeDataProvider;
 }
Beispiel #4
0
 public function getMilestones()
 {
     return $this->hasMany(Milestone::className(), ['project_id' => 'id'])->orderBy('id DESC');
 }
Beispiel #5
0
 public function getMilestone()
 {
     return $this->hasOne(Milestone::className(), ['id' => 'milestone_id']);
 }
Beispiel #6
0
 public function getMilestone()
 {
     return $this->hasOne(Milestone::className(), ["id" => "fkIDWithMilestoneID"]);
 }
Beispiel #7
0
<?php

use kartik\widgets\DatePicker;
use yii\helpers\ArrayHelper;
use app\models\Milestone;
use app\models\User;
?>

<?php 
echo $form->field($task, "name");
?>

<?php 
if (Yii::$app->user->identity->isViewingProject) {
    echo $form->field($task, "fkIDWithMilestoneID")->dropDownList(ArrayHelper::map(Milestone::find()->joinWith(["project"])->where(["project.id" => $task->milestone->fkIDWithProjectID])->all(), "id", "name"), ["prompt" => "None"]);
} else {
    echo $form->field($task, "fkIDWithMilestoneID")->dropDownList(ArrayHelper::map(Milestone::find()->all(), "id", "name"), ["prompt" => "None"]);
}
?>

<?php 
echo $form->field($task, "fkIDWithUserID")->dropDownList(ArrayHelper::map(User::find()->all(), "id", "fullName"), ["prompt" => "None"]);
echo $form->field($task, "information")->textarea();
echo $form->field($task, "dueDate")->widget(DatePicker::className(), ["pluginOptions" => ["todayHighlight" => true]]);
echo $form->field($task, "completed")->checkbox();
Beispiel #8
0
 public function getCompletedMilestones()
 {
     return $this->hasMany(Milestone::className(), ["fkIDWithProjectID" => "id"])->where(["completed" => 1]);
 }
 public function actionDelete($id)
 {
     Milestone::findOne($id)->deleteRecursive();
     Yii::$app->getSession()->setFlash("success", 'The record was deleted.');
     return $this->redirect(["milestone/"]);
 }