Completed
Push — master ( 096fcc...a76185 )
by Hugo
04:48
created

ProjetsController::readAction()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 26
Code Lines 16

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 26
rs 8.8571
cc 2
eloc 16
nc 2
nop 1
1
<?php
2
3
class ProjetsController extends \ControllerBase{
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
5
    protected $model;
6
    protected $title;
7
    protected $controller;
8
9
    public function initialize(){
10
        $this->model = "Projet";
11
        $this->title = "Projets";
12
        $this->controller = "Projets";
13
    }
14
15
    public function readAction($id = null){
16
        $projet = Projet::findFirst($id);
17
        $usecases = Usecase::find("idProjet = $id");
18
19
        //Calcul le taux de finition du projet en fonction du nombre d'usecases total et du % fini sur chaque usecases.
20
        $countUsecases = count($usecases);
21
        $totalAvancementFini = $countUsecases*100;
22
        $totalAvancementReel = 0;
23
24
        foreach($usecases as $u){
25
            $totalAvancementReel = $totalAvancementReel + $u->getAvancement();
26
        }
27
        $avancementReel = ($totalAvancementReel / $totalAvancementFini)*100;
28
        $avancementReel = number_format($avancementReel,1);
29
30
        $this->view->setVar("projet",$projet);
31
        $this->view->setVar("usecases",$usecases);
32
        $this->view->setVar("avancement",$avancementReel);
33
34
        //Création de la progressbar
35
        $progress= $this->jquery->bootstrap()->htmlProgressbar("progress","info",$avancementReel);
36
        $progress->showcaption(true);
37
        echo $this->jquery->compile($this->view);
38
39
40
    }
41
}
42