Commit b4d6b0a5 authored by Raph El's avatar Raph El

Hotfix

parent a6eaf082
......@@ -6804,40 +6804,70 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
$answers = PHDB::find("answers", array("source.key" => "ctenat",
"answers" => array('$exists' => 1) ) ) ;
Rest::json($answers);
//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"]["planFinancement"]) ){
$pL = $answer["answers"][$answer["formId"]]["answers"]["planFinancement"] ;
!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["nature"]) && $valPL["nature"] == "public"){
$valPL["nature"] = "colfinanceur";
echo "public<br>";
}else if(!empty($valPL["nature"]) && $valPL["nature"] == "private"){
$valPL["nature"] = "acteursocioeco";
echo "private<br>";
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[$keyPL] = $valPL;
$newPL[] = $valPL;
}
echo $keyA."<br>";
// PHDB::update( "answers",
// array("_id"=>new MongoId($keyA)),
// array('$set' => array( "answers.".$slug.".answers.planFinancement" => $newPL ) ) );
$resAnswers[$keyA] = $newPL;
//echo $keyA."<br>";
PHDB::update( "answers",
array("_id"=>new MongoId($keyA)),
array('$set' => array( "answers.".$answer["formId"].".answers.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) {
......@@ -6863,8 +6893,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" => [
"financer" => $fk,
"title" => "Depense fonctionnement",
"nature" => "fonctionnement",
"poste" => "Dépenses totales de fonctionnement",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6874,8 +6904,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 Investissement",
"nature" => "investissement",
"poste" => "Dépenses totales d'investissement",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6885,8 +6915,9 @@ 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" => "autre",
"poste" => "Financements Autre",
"financerType" => "autre",
"title" => "Financements Autre",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6896,8 +6927,9 @@ 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" => "Autofinancement Porteur projet",
"financerType" => "acteursocioeco",
"title" => "Autofinancement Porteur projet",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6907,8 +6939,9 @@ 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" => "Divers financements privés",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6918,8 +6951,9 @@ 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" => "Banque",
"financerType" => "acteursocioeco",
"title" => "Banque",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6929,8 +6963,9 @@ 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" => "colfinanceur",
"poste" => "Autofinancement Collectivité",
"financerType" => "colfinanceur",
"title" => "Autofinancement Collectivité",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6940,8 +6975,9 @@ 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" => $fk,
"poste" => "Total financements collectivités",
"financerType" => $fk,
"title" => "Total financements collectivités",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6951,8 +6987,9 @@ 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" => "departement",
"poste" => "Total Financements Département",
"financerType" => "departement",
"title" => "Total Financements Département",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6962,8 +6999,9 @@ 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" => $fk,
"poste" => "Total Financements Région",
"financerType" => $fk,
"title" => "Total Financements Région",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6973,8 +7011,9 @@ 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" => $fk,
"poste" => "Total Services et agences de l'état",
"financerType" => $fk,
"title" => "Total Services et agences de l'état",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6984,8 +7023,9 @@ 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" => $fk,
"poste" => "Total Financements ADEME",
"financerType" => $fk,
"title" => "Total Financements ADEME",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -6995,8 +7035,9 @@ 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" => "bdt",
"poste" => "Total financements Banque des territoires",
"financerType" => "bdt",
"title" => "Total financements Banque des territoires",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -7006,8 +7047,9 @@ 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" => $fk,
"poste" => "Total Financement Europe",
"financerType" => $fk,
"title" => "Total Financement Europe",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -7017,8 +7059,9 @@ 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" => "Chambre consulaire",
"financerType" => "acteursocioeco",
"title" => "Chambre consulaire",
"financer" => "",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -7028,8 +7071,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.planFinancement" => [
"nature" => $fk,
"poste" => "Acteurs socio-économiques",
"financerType" => $fk,
"title" => "Acteurs socio-économiques",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -7039,8 +7082,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.planFinancement" => [
"nature" => "acteursocioecot",
"poste" => "Fondations",
"financerType" => "acteursocioecot",
"title" => "Fondations",
"amount2019" => "",
"amount2020" => $a[ "answers"][ $slug ][ "answers"][ "financement"][$fk]["total"],
"amount2021" => "",
......@@ -7066,10 +7109,5 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
//Rest::json($tags); exit;
//echo "Number of project modified : ".$nbUser;
}
}
}
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@ co2/datamigration/ModifyCostumDB
*** CTENAT
co2/datamigration/UpdateAnswersIndicateurs
co2/datamigration/
co2/datamigration/FinancterLabel
co2/datamigration/Financter
/////////////////////////// BASH VERSION 0.99 /////////////////////////////////////
......
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