예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = SptTask::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'project_id' => $this->project_id, 'estimation' => $this->estimation, 'assignee' => $this->assignee, 'watcher' => $this->watcher, 'type' => $this->type, 'progress' => $this->progress, 'created_by' => $this->created_by, 'created_at' => $this->created_at, 'updated_by' => $this->updated_by, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTask()
 {
     return $this->hasOne(SptTask::className(), ['id' => 'task_id']);
 }
예제 #3
0
 /**
  * Finds the SptTask model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SptTask the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SptTask::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTasks()
 {
     return $this->hasMany(SptTask::className(), ['project_id' => 'id']);
 }
예제 #5
0
<?php

/**
 * Created by PhpStorm.
 * User: longnguyen
 * Date: 27/07/2016
 * Time: 17:19
 * @var ivoglent\simpletask\models\SptProject $model
 */
$provider = new \yii\data\ActiveDataProvider(['query' => \ivoglent\simpletask\models\SptTask::find()->where(['project_id' => $model->id])]);
$totals = \ivoglent\simpletask\models\SptTask::find()->where(['project_id' => $model->id])->all();
$status = \Yii::$app->params['task_status'];
$data = [];
foreach ($totals as $task) {
    if (!isset($data[$task->status])) {
        $data[$task->status] = 0;
    }
    $data[$task->status] += 1;
}
$colors = explode(",", "#7cb5ec,#434348,#90ed7d,#f7a35c,#8085e9,#f15c80,#e4d354,#2b908f,#f45b5b,#91e8e1");
$completed = isset($data[TASK_STATUS_COMPLETED]) ? $data[TASK_STATUS_COMPLETED] : 0;
$completed_percent = $totals ? (int) ($completed / count($totals) * 100) : 0;
foreach ($data as $id => &$item) {
    $item = ['y' => $totals ? (int) ($item / count($totals) * 100) : 0, 'color' => $colors[$id]];
}
?>
<h3><?php 
echo $model->name;
?>
</h3>
<div class="progress big">