Exemplo n.º 1
0
 public function actionDashboard()
 {
     $projectGraphs = NULL;
     $availableGraph = NULL;
     $unavailableGraph = NULL;
     $finalListGraph = NULL;
     $requestsGraph = NULL;
     // Get Messages
     $messages = \app\models\Message::find()->andWhere('status != 3')->andWhere('status != 1')->limit(15)->orderBy('time DESC')->all();
     // Get Project Data
     $projectDataProvider = new ActiveDataProvider(['query' => \app\models\Project::find()->orderBy('date DESC')->limit(5), 'pagination' => ['pageSize' => 5]]);
     // Get Talent Data
     $personDataProvider = new ActiveDataProvider(['query' => \app\models\Person::find()->orderBy('date_updated DESC')->limit(5), 'pagination' => ['pageSize' => 5]]);
     // Get data for graphs
     $projects = \app\models\Project::find()->limit(5)->all();
     foreach ($projects as $project) {
         $projectGraphs[] = $project->title;
         $finalListGraph[] = \app\models\Project::countList($project->id, 2);
         $availableGraph[] = \app\models\Project::countList($project->id, 1, 3);
         $unavailableGraph[] = \app\models\Project::countList($project->id, 1, 4);
         $requestsGraph[] = \app\models\Project::countList($project->id, 1, 2);
     }
     Yii::$app->view->title = 'Dashboard';
     return $this->render('dashboard', ['messages' => $messages, 'projectDataProvider' => $projectDataProvider, 'personDataProvider' => $personDataProvider, 'projectGraphs' => $projectGraphs, 'availableGraph' => $availableGraph, 'unavailableGraph' => $unavailableGraph, 'finalListGraph' => $finalListGraph, 'requestsGraph' => $requestsGraph]);
 }