Commit 79824db5 authored by Tibor Katelbach's avatar Tibor Katelbach
Browse files

tweas

parent 27fd39b2
......@@ -54,7 +54,7 @@ pageProfil.views.answers= function(){
if(typeof contextData.links != "undefined" && typeof contextData.links.projects != "undefined")
formParentId=Object.keys(contextData.links.projects)[0];
if(typeof contextData.links != "undefined" && typeof contextData.links.answers != "undefined"){
ajaxPost('#central-container', baseUrl+"/survey/co/answer/id/"+Object.keys(contextData.links.answers)[0]+"/view/answerEdit",
ajaxPost('#central-container', baseUrl+"/survey/answer/index/id/"+Object.keys(contextData.links.answers)[0]+"/mode/r",
null,
function(){
//alert("pageProfil.params.subview : "+pageProfil.params.subview)
......@@ -118,6 +118,12 @@ pageProfil.views.dashboard= function(){
function(){},"html");
};
pageProfil.views.actionDash= function(){
ajaxPost('#central-container', baseUrl+'/costum/ctenat/dashboard/action/'+contextData.slug,
null,
function(){},"html");
};
pageProfil.views.adminCter = function(){
formParentId=contextData.id;
authorizedSubview=["candidatures", "communityCter"];
......
<?php
class DashboardAction extends CAction
{
public function run($slug=null,$tag=null)
public function run($slug=null,$tag=null,$action=null)
{
$controller = $this->getController();
$params=array("page"=>"pie");
......@@ -18,7 +18,7 @@ class DashboardAction extends CAction
if($tag && $slug){
$el = Slug::getElementBySlug($slug);
$tagsLbls = $controller->costum["lists"]["domainAction"][$tag];
$answers = PHDB::find( Form::ANSWER_COLLECTION, [ "source.key"=>"ctenat",
$answers = PHDB::find( Form::ANSWER_COLLECTION, [ "source.key"=>Ctenat::KEY,
"formId"=>$slug,
"priorisation" => ['$in'=> Ctenat::$validActionStates ] ] );
......@@ -87,7 +87,7 @@ class DashboardAction extends CAction
else if( $tag ){
//var_dump($this->getController()->costum);exit;
$tagsLbls = $controller->costum["lists"]["domainAction"][$tag];
$answers = PHDB::find( Form::ANSWER_COLLECTION, [ "source.key"=>"ctenat",
$answers = PHDB::find( Form::ANSWER_COLLECTION, [ "source.key"=>Ctenat::KEY,
"priorisation" => ['$in'=> Ctenat::$validActionStates ] ] );
$actionsIds = [];
......@@ -167,16 +167,26 @@ class DashboardAction extends CAction
];
}
//onglet en chiffre d'un CTER
else if($slug){
else if($slug || $action){
if(!empty($action))
$slug = $action;
$el = Slug::getElementBySlug($slug);
$title = "<span style='font-size:12px'>".$el["el"]["name"]."</span><br/> Tableau de bord";
//financement
$financeData = [];
$financeLbls = [];
$answers = PHDB::find( Form::ANSWER_COLLECTION, ["source.key"=>"ctenat",
"cterSlug"=>$slug,
"priorisation" => ['$in'=> Ctenat::$validActionStates ] ] );
//var_dump($action);
if(!empty($action)){
$answers = PHDB::find( Form::ANSWER_COLLECTION, ["source.key"=>Ctenat::KEY,
"answers.action.project.id"=>$el["id"],
"priorisation" => ['$in'=> Ctenat::$validActionStates ] ] );
}
else
$answers = PHDB::find( Form::ANSWER_COLLECTION, ["source.key"=>Ctenat::KEY,
"cterSlug"=>$slug,
"priorisation" => ['$in'=> Ctenat::$validActionStates ] ] );
//var_dump($answers);
$finance = Ctenat::chiffreFinancementByType($slug);
$financeData = $finance["data"];
$financeLbls = $finance["lbls"];
......@@ -220,7 +230,7 @@ class DashboardAction extends CAction
}
}
}
$actions = PHDB::find(Project::COLLECTION, array("_id" => array( '$in'=>$actionsIds ) ),
$actions = PHDB::find(Project::COLLECTION, [ "_id" => [ '$in'=>$actionsIds ] ] ,
["name","slug","description","tags","profilMediumImageUrl","links","geo","geoPosition","address"]);
foreach ($actions as $key => $value) {
......@@ -236,52 +246,52 @@ class DashboardAction extends CAction
$params = array(
"elements" => null,
"slug" => $slug,
"title" => "<span style='font-size:12px'>".$el["el"]["name"]."</span><br/> Tableau de bord",
"blocks" => array(
"barActions" => array(
"title" => $title,
"blocks" => []
);
if(empty($action))
$params['blocks']["barActions"] = [
"title" => "Actions",
"counter" => $totalCountActions,
"graph" => array (
"graph" => [
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.barActionsCTErr",
"key"=>"barActionsCTErr",
"data"=> array (
"datasets"=> array(
array(
"data"=> [
"datasets"=> [
[
"data"=> $actionData,
"backgroundColor"=> Ctenat::$COLORS,
"borderWidth"=> 1
)
),
]
],
"labels"=> $actionLbls
)
)
)
)
);
if(isset($finance["total"]))
$params["blocks"]["pieFinance"] = [
"title" => "millions €",
"counter" => $finance["total"],
"graph" => [
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany",
"key"=>"pieManyFinance",
"data"=> [
"datasets"=> [
[ "data"=> $financeData,
"backgroundColor"=> Ctenat::$COLORS ]],
"labels"=> $financeLbls
]
]
]
];
];
if(isset($finance["total"]) && empty($action))
$params["blocks"]["pieFinance"] = [
"title" => "millions €",
"counter" => $finance["total"],
"graph" => [
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany",
"key"=>"pieManyFinance",
"data"=> [
"datasets"=> [
[ "data"=> $financeData,
"backgroundColor"=> Ctenat::$COLORS ]],
"labels"=> $financeLbls
]
]
];
$states = [ Ctenat::STATUT_ACTION_VALID,
Ctenat::STATUT_ACTION_COMPLETED,
Ctenat::STATUT_ACTION_MATURATION,
Ctenat::STATUT_ACTION_CONTRACT ];
$answersList2 = PHDB::find(Form::ANSWER_COLLECTION,[
"cterSlug"=>$slug,
"priorisation" => ['$in'=>$states]],["_id", "priorisation"]);
$answersList2 = PHDB::find(Form::ANSWER_COLLECTION,
[ "cterSlug" => $slug,
"priorisation" => ['$in'=>$states]], [ "_id", "priorisation" ] );
$stateData = [0,0,0];
foreach ($answersList2 as $k => $v) {
if($v["priorisation"] == Ctenat::STATUT_ACTION_VALID)
......@@ -299,35 +309,38 @@ class DashboardAction extends CAction
// }
// }
$colors = array_splice(Ctenat::$COLORS ,0,2);
$params["blocks"]["pieStatuts"] = [
"title" => "Statuts des actions",
"counter" => null,
"graph" => [
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany",
"key"=>"pieManyState",
"data"=> [
"datasets"=> [
[ "data"=> $stateData,
"backgroundColor"=> Ctenat::$COLORS ]],
"labels"=> $states
if(empty($action)){
$params["blocks"]["pieStatuts"] = [
"title" => "Statuts des actions",
"counter" => null,
"graph" => [
"url"=>"/graph/co/dash/g/costum.views.custom.ctenat.graph.pieMany",
"key"=>"pieManyState",
"data"=> [
"datasets"=> [
[ "data"=> $stateData,
"backgroundColor"=> Ctenat::$COLORS ]],
"labels"=> $states
]
]
]
];
];
}
$indicators = [];
//[
//"title"=>"emploi",
//"obj"=>"10",
//"done"=>"12",
//]
$indicateurs = Ctenat::getIndicator();
foreach ($answers as $i => $a) {
//var_dump($a);
if( isset( $a["answers"]["murir"]["results"] ) )
{
foreach ( $a["answers"]["murir"]["results"] as $ind => $vind )
{
if(isset($indicateurs[ $vind["indicateur"] ])){
if(isset( $indicateurs[ $vind["indicateur"] ]))
{
if(!isset( $indicators[$vind["indicateur"]] ))
$indicators[$vind["indicateur"]] = ["title" => $indicateurs[ $vind["indicateur"] ] , "obj"=>0,"done"=>0];
$indicators[$vind["indicateur"]] = [ "title" => $indicateurs[ $vind["indicateur"] ] ,
"obj"=>0,
"done"=>0 ];
if(isset( $vind["reality"] ))
{
if(isset($vind["reality"]["res2019"]))
......@@ -363,8 +376,9 @@ class DashboardAction extends CAction
}
//dashboard vision globale, aggregation
else{
$answers = PHDB::find( Form::ANSWER_COLLECTION, array("source.key"=>"ctenat",
"priorisation" => ['$in'=>Ctenat::$validActionStates]) );
$answers = PHDB::find( Form::ANSWER_COLLECTION,
[ "source.key" => Ctenat::KEY,
"priorisation" => ['$in'=>Ctenat::$validActionStates] ] );
$ssBadgeFamily = [];
foreach ($controller->costum["lists"]["domainAction"] as $pb => $bChild) {
foreach ($bChild as $key => $bName) {
......
......@@ -5,6 +5,7 @@
"host":"cte.ecologique-solidaire.gouv.fr",
"sourceKey" : true,
"forms" : true,
"formId" : "ctenatForm",
"filters" : {
"sourceKey" : true
},
......@@ -342,6 +343,22 @@
"class":"hidden-xs",
"view" : "newspaper"
},
"dashboard" : {
"label" : "En chiffres",
"icon" : "tachometer",
"view" : "dashboard",
"class":"hidden-xs",
"urlExtra" : "/url/costum.views.custom.ctenat.dashboard",
"restricted":{
"types" : [
"projects"
],
"category":["ficheAction"],
"members":true
},
"view" : "actionDash"
},
"answer":{
"label" : "Candidature",
"icon" : "list-alt",
......
......@@ -5,9 +5,12 @@ class Ctenat {
const CONTROLLER = "costum";
const MODULE = "costum";
const KEY = "ctenat";
const CATEGORY_CTER = "cteR";
const CATEGORY_FICHEACTION = "ficheAction";
const PARENT_FORM = "ctenatForm";
const STATUT_CTER_LAUREAT = "Territoire lauréat";
const STATUT_CTER_SIGNE = "CTE Signé";
const STATUT_CTER_CANDIDAT = "Territoire Candidat";
......@@ -22,7 +25,7 @@ class Ctenat {
const STATUT_ACTION_REFUSE = "Action refusée";
const STATUT_ACTION_CANDIDAT = "Action Candidate";
const PARENT_FORM = "ctenatForm";
public static $validCter = [ self::STATUT_CTER_LAUREAT,
self::STATUT_CTER_SIGNE];
......
......@@ -91,7 +91,7 @@
<?php
foreach ($d["indicator"] as $ix => $ind) {
?>
<div class=" col-md-<?php echo $blocksize?> text-center padding-10" >
<div class=" col-md-4 col-xs-12 text-center padding-10" >
<div class="<?php echo $borderClass; ?>">
<h4 style="color:#18a47d"><?php echo $ind["title"];?></h4>
......@@ -133,6 +133,7 @@
<script type="text/javascript">
//alert("/modules/costum/views/custom/ctenat/dashboard.php")
//prepare global graph variable needed to build generic graphs
<?php
foreach ($blocks as $id => $d) {
if( isset($d["graph"]) ) {
......@@ -191,8 +192,8 @@ if(isset($elements)){
$colorCt++;
}
function getBadgeFamily($tag, $badgeColor){
foreach ($this->costum["lists"]["domainAction"] as $key => $childBadges) {
function getBadgeFamily($tag, $badgeColor,$domainAction ){
foreach ( $domainAction as $key => $childBadges) {
foreach ($childBadges as $ic => $cb) {
if($tag == $cb)
return array(
......@@ -237,7 +238,7 @@ if(isset($elements)){
echo "<a href='#@".$p["slug"]."' class='lbh-preview-element text-dark' data-id='".$id."' data-type='projects'> ".$p["name"]." </a>";
if(isset($p["tags"])){
foreach ( $p["tags"] as $i => $t ) {
$badgeParent = (getBadgeFamily($t, $badgeColor)) ? getBadgeFamily($t, $badgeColor) : array("parent"=>"","color"=>"#ccc");
$badgeParent = (getBadgeFamily($t, $badgeColor,$this->costum["lists"]["domainAction"])) ? getBadgeFamily($t, $badgeColor,$this->costum["lists"]["domainAction"]) : array("parent"=>"","color"=>"#ccc");
if( !empty($badgeParent["parent"] ))
echo "<br/><a href='javascript:;' data-badge='".$p["domaineAction"]["family"]."' ".$slugData." class='btn btn-xs openDashModal' style='background-color:".$badgeColor[$p["domaineAction"]["family"]]."'>#".$t."</a>";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment