Commit 5fbcb659 authored by tonyemma's avatar tonyemma

Merge branch 'qa' of https://gitlab.adullact.net/pixelhumain/co2 into qa

parents a889df40 ad02407f
......@@ -540,14 +540,14 @@ var coInterface = {
if($("#headerBand").length > 0){
if($(this).scrollTop() > $("#headerBand").outerHeight() && infScroll){
coInterface.menu.initTopPostion=0;
coInterface.setDomHtmlPosition();
$("#affix-sub-menu, #mainNav, #menuApp, #filters-nav").removeClass("position-absolute");
$(".main-container.vertical .headerSearchContainer").addClass("affix");
coInterface.setDomHtmlPosition();
infScroll=false;
}else if($(this).scrollTop()<=$("#headerBand").outerHeight() && !infScroll){
coInterface.menu.initTopPostion=$("#headerBand").outerHeight();
coInterface.setDomHtmlPosition();
$("#affix-sub-menu, #mainNav, #filters-nav, #menuApp").addClass("position-absolute");
coInterface.setDomHtmlPosition();
infScroll=true;
}
......@@ -587,11 +587,14 @@ var coInterface = {
}, 400);
},
setDomHtmlPosition: function(){
mylog.log("coInterface.setDomHtmlPosition", coInterface.menu.initTopPostion);
$("#mainNav").css("top",coInterface.menu.initTopPostion);
//heightNav=$("#mainNav").outerHeight();
heightTopMenu=$("#mainNav").outerHeight()+coInterface.menu.initTopPostion;
mylog.log("coInterface.setDomHtmlPosition", heightTopMenu, $("#mainNav").outerHeight());
$("#menuApp, #affix-sub-menu").css("top",heightTopMenu);
$("#notificationPanelSearch.vertical.arrow_box, #floopDrawerDirectory, #modal-preview-coop, .main-container .dropdown-main-menu, #mainNav .dropdown-result-global-search, .main-container.vertical .portfolio-modal.modal, .portfolio-modal.modal.vertical").css("top",heightTopMenu);
$("#notificationPanelSearch.horizontal.arrow_box, #notificationPanelSearch.vertical.arrow_box, #floopDrawerDirectory, #modal-preview-coop, .main-container .dropdown-main-menu, #mainNav .dropdown-result-global-search, .main-container.vertical .portfolio-modal.modal, .portfolio-modal.modal.vertical").css("top",heightTopMenu);
$(".dropdownApps-menuTop .dropdown-menu, #affix-sub-menu .dropdown-result-global-search").css("top", (heightTopMenu+$("#text-search-menu").height()));
coInterface.setTopPosition(false);
/*if(heightNav > 70){
......@@ -600,6 +603,7 @@ var coInterface = {
} */
},
setTopPosition: function(bool){
mylog.log("coInterface.setTopPosition", bool);
headerScaling=bool;
heightPos=$("#mainNav").outerHeight();
if(coInterface.menu.initTopPostion!=0)
......@@ -618,6 +622,7 @@ var coInterface = {
heightPos=heightPos+$("#filters-nav").outerHeight();
$("#mapContent").css("top",heightPos);
if($(".main-container.vertical .headerSearchContainer").hasClass("affix")){
mylog.log("coInterface.setTopPosition headerSearchContainer heightPos", heightPos);
$(".main-container.vertical .headerSearchContainer").css("top",heightPos);
heightPos=heightPos+$(".main-container.vertical .headerSearchContainer").outerHeight();
}else{
......
......@@ -1935,24 +1935,6 @@ var directory = {
str += "</div>";
if("undefined" != typeof params.organizerObj && params.organizerObj != null){
str += "<div class='col-md-8 col-sm-8 col-xs-12 entityOrganizer margin-top-10'>";
if("undefined" != typeof params.organizerObj.profilThumbImageUrl &&
params.organizerObj.profilThumbImageUrl != ""){
str += "<img class='pull-left img-responsive' src='"+baseUrl+params.organizerObj.profilThumbImageUrl+"' height='50'/>";
}
console.log("typeDYN",params.organizerObj.type, params.organizerObj);
elem = dyFInputs.get(params.organizerObj.type);
str += "<h5 class='no-margin padding-top-5'><small>"+tradDynForm.organizedby+"</small></h5>";
str += "<a href='#page.type."+elem.col+".id."+params.organizerObj["_id"]["$id"]+"' class='lbh' > <small class='entityOrganizerName'>"+params.organizerObj.name+"</small></a>";
str += "</div>";
}
str += "<div class='col-md-8 col-sm-8 col-xs-12 entityRight padding-top-10 margin-top-10 pull-right' style='border-top: 1px solid rgba(0,0,0,0.2);'>";
var thisLocality = "";
......@@ -1978,7 +1960,22 @@ var directory = {
params.name +
"</a>";
if("undefined" != typeof params.organizer && params.organizer != null){
countOrganizer=Object.keys(params.organizer).length;
str += "<div class='col-xs-12 margin-top-10 no-padding'>";
str+="<span class='bold'>"+tradDynForm.organizedby+" : </span>";
$.each(params.organizer, function(e,v){
imgIcon = (typeof v.profilThumbImageUrl != "undefined" && v.profilThumbImageUrl!="" ) ? baseUrl+"/"+v.profilThumbImageUrl: assetPath + "/images/thumb/default_"+v.type+".png";
str+='<a href="#page.type.'+v.type+'.id.'+e+'" class="lbh-preview-element tooltips" ';
if(countOrganizer>1) str+= 'data-toggle="tooltip" data-placement="top" title="'+v.name+'"';
str+=">"+
'<img src="'+imgIcon+'" class="img-circle margin-right-10" width="35" height="35"/>';
if(countOrganizer==1) str+=v.name;
str+="</a>";
});
str+="</div>";
}
str += "<div class='entityDescription margin-bottom-10'>" +
params.description +
"</div>";
......@@ -3045,8 +3042,9 @@ var directory = {
.done(function (data) {
if ( data && data.result ) {
toastr.info("élément effacé");
if( $("#"+type+id).length > 0)
$("#"+type+id).remove();
if( $(".contain_"+type+"_"+id).length > 0 )
else if( $(".contain_"+type+"_"+id).length > 0 )
$(".contain_"+type+"_"+id).remove();
else
urlCtrl.loadByHash( location.hash );
......@@ -3723,6 +3721,7 @@ var directory = {
}*/
html+="</div>";
mylog.log("directory.getAdminToolBar html end", html);
return html;
},
getTypeObj: function(e){
......
......@@ -79,11 +79,15 @@ function autoCompleteSearchGS(search, indexMin, indexMax, input, callB){
data.countType = [ "citoyens", "organizations", "projects", "events" ];
data.searchType = [ "citoyens", "organizations", "projects", "events" ];
}
if(typeof costum != "undefined" && notNull(costum) && typeof costum.filters != "undefined" && typeof costum.filters.searchTypeGS != "undefined"
&& (!notNull(input) || $.inArray(input, ["#filter-scopes-menu", "#scopes-news-form"]) < 0)){
if(typeof costum != "undefined" && notNull(costum) && typeof costum.filters != "undefined" && (!notNull(input) || $.inArray(input, ["#filter-scopes-menu", "#scopes-news-form"]) < 0)){
if(typeof costum.filters.searchTypeGS != "undefined"){
data.countType = costum.filters.searchTypeGS;
data.searchType = costum.filters.searchTypeGS;
}
if(typeof costum.filters.sourceKey != "undefined"){
data.sourceKey=[costum.slug];
}
}
var domTarget = (notNull(input)) ? input+" .dropdown-result-global-search" : ".dropdown-result-global-search";
var dropDownVisibleDom=(notNull(input)) ? input+" .dropdown-result-global-search" : ".dropdown-result-global-search";
if($(domTarget+" .content-result").length > 0)
......
......@@ -450,7 +450,7 @@ function bindButtonMenu(){
function getLabelTitleDir(dataName, dataIcon, countData, n){
mylog.log("getLabelTitleDir", dataName, dataIcon, countData, n, trad);
var elementName = "<span class='Montserrat' id='name-lbl-title'>"+$("#nameHeader .name-header").html()+"</span>";
var elementName = "<span class='Montserrat' id='name-lbl-title'>"+contextData.name+"</span>";
var s = (n>1) ? "s" : "";
......@@ -696,7 +696,7 @@ function displayInTheContainer(data, dataName, dataIcon, contextType, edit){
communityStr +='</div>';
}*/
mylog.log("communityStr", n, communityStr);
mylog.log("displayInTheContainer communityStr", n, communityStr);
if(n>0){
var thisTitle = getLabelTitleDir(dataName, dataIcon, parseInt(n), n);
......@@ -756,6 +756,7 @@ function displayInTheContainer(data, dataName, dataIcon, contextType, edit){
});
}
toogleNotif(false);
mylog.log("displayInTheContainer html",html);
$("#central-container").html(html);
//if(dataName != "collections" && directory.viewMode=="block")
// setTimeout(function(){ directory.checkImage(data);}, 300);
......@@ -788,7 +789,7 @@ function displayInTheContainer(data, dataName, dataIcon, contextType, edit){
});
});
}
mylog.log("displayInTheContainer here");
mylog.log("dataToMap", dataToMap);
$("#btn-show-links-onmap").off().click(function(){
//Sig.showMapElements(Sig.map, dataToMap, "", thisTitle);
......@@ -804,6 +805,7 @@ function displayInTheContainer(data, dataName, dataIcon, contextType, edit){
var html = communityStr+"<div class='col-md-12 col-sm-12 col-xs-12 labelTitleDir margin-bottom-15'>"+
getLabelTitleDir(dataName, dataIcon, parseInt(n), n)+
"</div>";
mylog.log("displayInTheContainer html2", html);
$("#central-container").html(html + "<span class='col-md-12 alert bold bg-white'>"+
"<i class='fa fa-ban'></i> "+trad.nodata+
"</span>");
......@@ -816,7 +818,9 @@ function displayInTheContainer(data, dataName, dataIcon, contextType, edit){
$(".load-coummunity").removeClass("active");
$(this).addClass("active");
pageProfil.params.dir = $(this).data("type-dir");
location.hash=hashUrlPage+".view.directory.dir."+pageProfil.params.dir;
//history.pushState remplace le location.hash car il recharge la page .
//location.hash=hashUrlPage+".view.directory.dir."+pageProfil.params.dir;
history.pushState(null, null, hashUrlPage+".view.directory.dir."+pageProfil.params.dir);
pageProfil.views.directory();
});
}
......
......@@ -7,8 +7,10 @@
"tool" : { "label": "Tool","key":"tool","icon":"wrench"},
"machine" : { "label": "Machine","key":"machine","icon":"cogs"},
"article" : { "label": "Article","key":"article","icon":"newspaper-o"},
"forum" : { "label": "Forum","key":"forum","icon":"comment"},
"cms" : { "label": "CMS","key":"cms","icon":"edit"},
"doc" : { "label": "Documentation","key":"doc","icon":"book"},
"faq" : { "label": "FAQ","key":"faq","icon":"info"},
"software" : { "label": "Software","key":"software","icon":"code"},
"rh" : { "label": "Human ressource","key":"rh","icon":"users"},
"financialRessource" : { "label": "Financial ressource","key":"RessourceFinanciere","icon":"money"},
......
......@@ -11,7 +11,32 @@ class DatamigrationController extends CommunecterController {
protected function beforeAction($action) {
return parent::beforeAction($action);
}
public function actionNASourceAllElts(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$colElts = array(Person::COLLECTION, Organization::COLLECTION, Poi::COLLECTION);
$res = array();
foreach ($colElts as $keyCol => $col) {
$elts=PHDB::find($col, array("source" => array('$exists' => 0)), array("name"));
$res[$col] = 0;
foreach ($elts as $id => $elt) {
$source = array(
'insertOrign' => "import",
'date'=> new MongoDate(time()),
"key" => "notragora",
"keys" => array("notragora") );
PHDB::update($col,
array("_id" => $elt["_id"]),
array('$set' => array("source" => $source))
);
$res[$col]++;
}
}
Rest::json($res); exit;
}
}
public function actionKnowsToFollows(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$persons=PHDB::find(Person::COLLECTION);
......@@ -65,21 +90,10 @@ class DatamigrationController extends CommunecterController {
}
public function actionActionWithnoAnswer(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
echo "scenario<br/>".
"clicker c'est parti génère l'answers <br/>".
"mais le links ne se fait pas plus<br/>".
"todo :<br/>".
"[ ] refaire marcher les links comme avant l'utilisation de Ctenat::surveyAfterSave<br/>".
"[ ] générer les answers pour les 25 projets orphelins <br/>".
" >>> [ ] on a pas de lien entre le projet et orga <br/>".
" >>> [ ] retrouver à quel CTER appartient de creator de l'action <br/>".
" >>> [ ] on a le creator du project qui est le meme que celui de l'orga <br/>".
" >>> [X] au save de orga et project on a bien les links dans les params de la request<br/>".
" >>> [ ] retrouver le code dans element::Save <br/>";
$projects=PHDB::find(Project::COLLECTION, array("source.key"=>"ctenat", "category"=>"ficheAction"), array("links", "name","creator"));
$answers = PHDB::find(Form::ANSWER_COLLECTION, array("source.key"=>"ctenat","answers"=>['$exists'=>0]));
echo "<b style='color:red'>Empty Answers count : ".count($answers)."</b><br/><br/>";
//if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
$projects=PHDB::find(Project::COLLECTION, array("source.key"=>"ctenat", "category"=>"ficheAction"), array("links", "name","creator","slug"));
$creators=[];
$projectNoAnswers = [];
$countAnswer=count($projects);
......@@ -88,65 +102,20 @@ class DatamigrationController extends CommunecterController {
if(!isset($p["links"]) || !isset($p["links"]["answers"]))
{
$i++;
echo "action : ".$p["name"]."<br/>";
echo "-------------------------------------------------<br/>";
echo "-------------------------------------------------<br/>";
echo "-----------------------".$i."--------------------------<br/>";
echo "Action : <a target='_blank' href='https://cte.ecologique-solidaire.gouv.fr/#@".$p["slug"]."'>".$p["name"]." : @".$p["slug"]."</a><br/>";
echo "-------------------------<br/>";
//who is the user
$person=PHDB::findOne(Person::COLLECTION, array("_id"=>new MongoId($p["creator"])), array("links", "name", "email"));
echo "<b>creator : ". $person["name"]." : ".$person["email"]." has ".count($person["links"])." links</b> <br/>";
if(!in_array($p["creator"], $creators)){
$creators[] = $p["creator"];
//echo implode(",", array_keys( $person["links"]));
foreach ($person["links"] as $what => $list) {
echo "<br/>".count($list)." ".$what."<br/>";
foreach ($list as $id => $val) {
if($what == "projects")
{
$el =PHDB::findOne(Project::COLLECTION, array( "_id"=>new MongoId($id)), array("links", "name"));
if(!in_array($id, $projectNoAnswers) && !isset($el["links"]) || !isset($el["links"]["answers"])){
$projectNoAnswers[] = $id;
echo "<b style='color:red'>proj: ".$id." : ".$el["name"]."</b><br/>";
if(!isset($el["category"]))
echo "<b>pas de category</b><br/>";
if(isset($el["links"])){
foreach ($el["links"] as $ow => $olist) {
echo "p>".count($olist)." ".$ow."<br/>";
}
}
}
} else if($what == "memberOf")
{
$el =PHDB::findOne(Organization::COLLECTION, array( "_id"=>new MongoId($id)), array("links", "name"));
if(!isset($el["links"]) || !isset($el["links"]["answers"])){
echo "<b>orga: ".$id." : ".$el["name"]."</b><br/>";
if(isset($el["links"])){
foreach ($el["links"] as $ow => $olist) {
echo "o>".count($olist)." ".$ow."<br/>";
//if($ow == "projects")
}
}
}
}
}
}
} else echo "<span style='color:red'>deja vu</span><br/>";
//find orga created by this user
$orgas =PHDB::find(Organization::COLLECTION, array( "creator"=> $p["creator"] ), array("links", "name"));
echo "orga créer : ".count($orgas);
// foreach($projects as $key => $o){
// echo "orga : ".$o["name"]."<br/>";
// }
echo "<br/><br/>-------------------------<br/>";
}
echo "<b>creator : ". $person["name"]." : ".$person["email"]."</b> <br/>";
echo "-------------------------<br/>";
}
echo "creators : ".count($creators)."<br/>";
echo count($projectNoAnswers)." n'ont pas de candidatures sur ".$countAnswer." ficheActions";
}
echo $i." n'ont pas de candidatures sur ".$countAnswer." ficheActions";
//}
}
public function actionRemoveLinkCterWithCter(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
......@@ -182,38 +151,134 @@ class DatamigrationController extends CommunecterController {
echo "<br/>-------------------------------------------------------------------------------------------<br/>";
}
}
public function actionUpdateAnswersActionCandidateMissing(){
public function actionUpdateAnswersIndicateurs(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
$answers=PHDB::find(Form::ANSWER_COLLECTION, array("source.key"=>"ctenat", "priorisation" => array('$exists' => 0)));
$answers=PHDB::find(Form::ANSWER_COLLECTION, array("source.key"=>"ctenat", "answers" => array('$exists' => 1)));
$iTer=0;
$iFa=0;
foreach($answers as $k => $v){
if(!empty($v["answers"]) &&
!empty($v["formId"])&&
!empty($v["answers"][$v["formId"]]) &&
!empty($v["answers"][$v["formId"]]["answers"]) &&
!empty($v["answers"][$v["formId"]]["answers"]["murir"])&&
!empty($v["answers"][$v["formId"]]["answers"]["murir"]["results"])){
$indList = $v["answers"][$v["formId"]]["answers"]["murir"]["results"] ;
$newsInd = array();
foreach ($indList as $keyI => $valI) {
if( is_array($valI["indicateur"]) ){
foreach ($valI["indicateur"] as $keyInd => $valInd ) {
$n = array();
$n["indicateur"] = $valInd;
if($keyInd == 0 && !empty($valI["objectif"]))
$n["objectif"] = $valI["objectif"];
if($keyInd == 0 && !empty($valI["reality"]))
$n["reality"] = $valI["reality"];
$newsInd[] = $n;
}
} else
$newsInd[] = $valI;
}//
$iFa++;
PHDB::update(Form::ANSWER_COLLECTION,
array("_id" => new MongoId($k)) ,
array('$set' => array("answers.".$v["formId"].".answers.murir.results" => $newsInd))
);
}
}
//Rest::json($res); exit;
echo $iFa." fiches actions ";
}else{
echo "Accès réservé au Big Bosses !";
}
}
public function actionUpdateAnswersActionCandidateMissing(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
$answers=PHDB::find(Form::ANSWER_COLLECTION,
array("source.key"=>"ctenat",
'$or' => array(
array( "priorisation" => array('$exists' => 0) ),
array( "priorisation" => array('$nin' => array(
Ctenat::STATUT_ACTION_VALID,
//Ctenat::STATUT_ACTION_MATURATION,
Ctenat::STATUT_ACTION_LAUREAT,
Ctenat::STATUT_ACTION_REFUSE,
Ctenat::STATUT_ACTION_CANDIDAT,
Ctenat::STATUT_ACTION_CONTRACT))),
) ), array("formId", "priorisation", "answers") );
$iTer=0;
$iFa=0;
$listCter = array();
if(!empty($answers)){
foreach($answers as $k => $v){
if(!empty($v["answers"]) &&
!empty($v["formId"])&&
!empty($v["answers"][$v["formId"]]) &&
!empty($v["answers"][$v["formId"]]["answers"]) &&
!empty($v["answers"][$v["formId"]]["answers"]["project"])&&
!empty($v["answers"][$v["formId"]]["answers"]["project"]["id"])){
//Rest::json($v["answers"]); exit;
$project=PHDB::findOneById(Project::COLLECTION,$v["answers"][$v["formId"]]["answers"]["project"]["id"], array("name", "slug"));
$cter=PHDB::findOne(Project::COLLECTION,array("slug"=> $v["formId"]), array("name", "slug"));
$iFa++;
echo "CTER concerné : ".$cter["name"]." : Project -> ".$project["slug"]."<br/>";
//echo "CTER concerné : ".$cter["name"]." : -> ".$cter["slug"]."<br/>";
$prio = "";
if(!empty($v["priorisation"])){
if($v["priorisation"] == "abandoned"){
$prio = Ctenat::STATUT_ACTION_REFUSE;
}else if($v["priorisation"] == "selected"){
$prio = Ctenat::STATUT_ACTION_VALID;
}else if($v["priorisation"] == "reserved"){
$prio = Ctenat::STATUT_ACTION_LAUREAT;
}else if($v["priorisation"] == Ctenat::STATUT_ACTION_MATURATION){
$prio = Ctenat::STATUT_ACTION_LAUREAT;
}
} else {
if( $cter["slug"] == "cteNordArdeche" || $cter["slug"] == "cteSudArdeche" )
$prio = Ctenat::STATUT_ACTION_VALID;
else
$prio = Ctenat::STATUT_ACTION_CANDIDAT;
}
//echo $prio." CTER concerné : ".$cter["name"]." : -> ".$cter["slug"]."<br/>";
if( $prio != ""){
if(!isset($listCter[$cter["slug"]])){
$listCter[$cter["slug"]]["count"] = 1;
$listCter[$cter["slug"]]["projects"][] = $k. " -> ".$project["name"]. " : ".$prio ;
}else{
$listCter[$cter["slug"]]["projects"][] = $k. " -> ".$project["name"]. " : ".$prio;
$listCter[$cter["slug"]]["count"]++;
}
PHDB::update(Form::ANSWER_COLLECTION,
array("_id" => $v["_id"]) ,
array('$set' => array("priorisation" => "Action Candidate"))
array("_id" => new MongoId($k)) ,
array('$set' => array("priorisation" => $prio))
);
}
Ctenat::updatePrioAnswers($k, $v["formId"], $prio, "priorisation");
}
}
}
}
Rest::json($listCter); exit;
echo $iFa." fiches actions ";
}else{
echo "Accès réservé au Big Bosses !";
}
}
public function actionUpdateProjectOpenEditionCteNat(){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]))){
$projects=PHDB::find(Project::COLLECTION, array("source.key"=>"ctenat"));
......@@ -4946,7 +5011,7 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$parentType= Event::COLLECTION;
else
$parentType=$value["parentType"];
$set["parent"]=array($value["parentId"] => array("type"=>$parentType));
$set["parent"]=array($value["parentId"] => array("type"=>$parentType, "name"=>$value["name"]));
}
if(@$value["parentId"]){
......@@ -6781,15 +6846,84 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
}
}
public function actionFinancter($debug=null) {
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) ))
public function actionFinancterLabel() {
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$answers = PHDB::find("answers", array("source.key" => "ctenat",
"answers" => array('$exists' => 1) ) ) ;
//Rest::json($answers); exit;
$resAnswers = array();
$j = 0;
$k = 0;
$i = 0;
foreach ($answers as $keyA => $answer) {
if(!empty($answer["answers"]) &&
!empty($answer["formId"]) &&
!empty($answer["answers"][$answer["formId"]]) &&
!empty($answer["answers"][$answer["formId"]]["answers"]) &&
!empty($answer["answers"][$answer["formId"]]["answers"]["murir"])&&
!empty($answer["answers"][$answer["formId"]]["answers"]["murir"]["planFinancement"]) ){
$pL = $answer["answers"][$answer["formId"]]["answers"]["murir"]["planFinancement"] ;
$newPL = array();
foreach ($pL as $keyPL => $valPL) {
if(!empty($valPL["financer"]) && $valPL["financer"] == "public"){
$valPL["financerType"] = "colfinanceur";
$valPL["financer"] = "";
$i++;
}else if(!empty($valPL["financer"]) && $valPL["financer"] == "private"){
$valPL["financerType"] = "acteursocioeco";
$valPL["financer"] = "";
$k++;
} else if(empty($valPL["financerType"])){
$valPL["financerType"] = $valPL["financer"];
$valPL["financer"] = "";
$j++;
}
$newPL[] = $valPL;
}
$resAnswers[$keyA] = $newPL;
//echo $keyA."<br>";
PHDB::update( "answers",
array("_id"=>new MongoId($keyA)),
array('$set' => array( "answers.".$answer["formId"].".answers.murir.planFinancement" => $newPL ) ) );
}
}
echo "public : ".$i;
echo "private : ".$k;
echo "type : ".$j;
//Rest::json($resAnswers); exit;
}else{
echo "NO NO nooooo";
}
}
public function actionFinancterLIST($debug=null) {
$res = array();
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
foreach (PHDB::distinct( "answers", "formId",array()) as $i => $slug) {
foreach ( PHDB::find("answers", [ "answers.".$slug.".answers.financement" => ['$exists'=>1] ] ) as $id => $a )
{
$res[$id]= $a;
}
}
}
Rest::json($res); exit;
}
public function actionFinancter($debug=null) {
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
foreach (PHDB::distinct( "answers", "formId",array()) as $i => $slug) {
echo "<b>".$slug."</b><br/>";
echo PHDB::count("answers", [ "answers.".$slug.".answers.financement" => ['$exists'=>1] ] )." tag financement<br/>";
echo PHDB::count("answers", [ "answers.".$slug.".answers.murir.budget" => ['$exists'=>1] ] )." plan financement<br/>";
echo PHDB::count("answers", [ "answers.".$slug.".answers.murir.planFinancement" => ['$exists'=>1] ] )." financement<br/>";
echo PHDB::count("answers", [ "answers.".$slug.".answers.murir.budget" => ['$exists'=>1] ] )." budget<br/>";
echo PHDB::count("answers", [ "answers.".$slug.".answers.murir.planFinancement" => ['$exists'=>1] ] )." plan financement<br/>";
foreach ( PHDB::find("answers", [ "answers.".$slug.".answers.financement" => ['$exists'=>1] ] ) as $id => $a )
{
......@@ -6806,8 +6940,8 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array( "answers.".$slug.".answers.murir.budget" => [
"nature" => $fk,
"poste" => "Depense fonctionnement",
"nature" => "fonctionnement",
"poste" => "Dépenses totales de fonctionnement",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6817,41 +6951,44 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array( "answers.".$slug.".answers.murir.budget" => [
"nature" => $fk,
"poste" => "Depense Investissement",
"nature" => "investissement",
"poste" => "Dépenses totales d'investissement",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
"amount2022" => ""
] ) ) );
// else if($fk == 'financeursnonprecises' )
// PHDB::update( "answers",
// array("_id"=>new MongoId($a["_id"])),
// array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
// "nature" => $fk,
// "poste" => "Financements Département",
// "amount2019" => "",
// "amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
// "amount2021" => "",
// "amount2022" => ""
// ]) ) );
// else if($fk == 'autofinancement' )
// PHDB::update( "answers",
// array("_id"=>new MongoId($a["_id"])),
// array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
// "nature" => "acteursocioeco",
// "poste" => "Fonds Propres",
// "amount2019" => "",
// "amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
// "amount2021" => "",
// "amount2022" => ""
// ]) ) );
else if($fk == 'financeursnonprecises' )
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
"financerType" => "autre",
"title" => "Financements Autre",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
"amount2022" => ""
]) ) );
else if($fk == 'autofinancement' )
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
"financerType" => "acteursocioeco",
"title" => "Autofinancement Porteur projet",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
"amount2022" => ""
]) ) );
else if($fk == 'financeur')
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
"nature" => "acteursocioeco",
"poste" => "Divers financements privés",
"financerType" => "acteursocioeco",
"title" => "Divers financements privés",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6861,30 +6998,33 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
"nature" => "acteursocioeco",
"poste" => "Divers financements privés",
"financerType" => "acteursocioeco",
"title" => "Banque",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
"amount2022" => ""
]) ) );
else if($fk == 'colautofinancement)' )
PHDB::update( "answers",
array("_id"=>new MongoId($a["_id"])),
array('$push' => array("answers.".$slug.".answers.murir.planFinancement" => [
"financerType" => "colfinanceur",
"title" => "Autofinancement Collectivité",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",