Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
co2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
516
Issues
516
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
External Wiki
External Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pixel Humain
co2
Commits
b4d6b0a5
Commit
b4d6b0a5
authored
Oct 21, 2019
by
Raph El
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hotfix
parent
a6eaf082
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
96 additions
and
58 deletions
+96
-58
controllers/DatamigrationController.php
controllers/DatamigrationController.php
+95
-57
docs/devLog.org
docs/devLog.org
+1
-1
No files found.
controllers/DatamigrationController.php
View file @
b4d6b0a5
...
...
@@ -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"
=>
"Depens
e fonctionnement"
,
"
nature"
=>
"fonctionnement"
,
"
poste"
=>
"Dépenses totales d
e 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"
=>
"D
epense I
nvestissement"
,
"nature"
=>
"investissement"
,
"poste"
=>
"D
épenses totales d'i
nvestissement"
,
"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"
=>
[
"
natur
e"
=>
$fk
,
"
post
e"
=>
"Acteurs socio-économiques"
,
"
financerTyp
e"
=>
$fk
,
"
titl
e"
=>
"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"
=>
[
"
natur
e"
=>
"acteursocioecot"
,
"
post
e"
=>
"Fondations"
,
"
financerTyp
e"
=>
"acteursocioecot"
,
"
titl
e"
=>
"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
docs/devLog.org
View file @
b4d6b0a5
...
...
@@ -9,7 +9,7 @@ co2/datamigration/ModifyCostumDB
*** CTENAT
co2/datamigration/UpdateAnswersIndicateurs
co2/datamigration/
co2/datamigration/
FinancterLabel
co2/datamigration/Financter
/////////////////////////// BASH VERSION 0.99 /////////////////////////////////////
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment