Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Daniel CAZAL
co2
Commits
deaef8e1
Commit
deaef8e1
authored
Nov 26, 2018
by
Raph El
Browse files
Hotfix CP sur Import
parent
9dbd7375
Changes
1
Hide whitespace changes
Inline
Side-by-side
controllers/DatamigrationController.php
View file @
deaef8e1
...
...
@@ -5275,6 +5275,51 @@ if( Role::isSuperAdmin(Role::getRolesUserId(Yii::app()->session["userId"]) )){
echo
"Number of user with preferences modified : "
.
$nbUser
;
}
}
public
function
actionHotfixAddressCPMissing
()
{
if
(
Role
::
isSuperAdmin
(
Role
::
getRolesUserId
(
Yii
::
app
()
->
session
[
"userId"
])
)){
$nbUser
=
0
;
$types
=
array
(
Organization
::
COLLECTION
,
Project
::
COLLECTION
,
Event
::
COLLECTION
);
foreach
(
$types
as
$keyT
=>
$valT
)
{
$elts
=
PHDB
::
find
(
$valT
,
array
(
"modifiedByBatch.HotfixAddressCPMissing"
=>
array
(
'$exists'
=>
0
),
"address.addressCountry"
=>
"FR"
,
"address.postalCode"
=>
array
(
'$exists'
=>
0
)));
//Rest::json($elts); exit;
foreach
(
$elts
as
$keyE
=>
$elt
)
{
$elt
[
"modifiedByBatch"
][]
=
array
(
"HotfixAddressCPMissing"
=>
new
MongoDate
(
time
()));
$city
=
City
::
getById
(
$elt
[
"address"
][
"localityId"
],
array
(
"postalCodes"
));
$cp
=
"NUUUUUUUULLLLLLL"
;
foreach
(
$city
[
"postalCodes"
]
as
$keyPC
=>
$valPC
)
{
$cp
=
$valPC
[
"postalCode"
];
break
;
}
$elt
[
"address"
][
"postalCode"
]
=
$cp
;
echo
"<br/> "
.
$keyE
.
" : "
.
$valT
.
" : "
.
$elt
[
"name"
]
.
" :: "
.
$cp
;
$res
=
PHDB
::
update
(
$valT
,
array
(
"_id"
=>
new
MongoId
(
$keyE
)),
array
(
'$set'
=>
array
(
"address"
=>
$elt
[
"address"
],
"modifiedByBatch"
=>
$elt
[
"modifiedByBatch"
])
)
);
if
(
$res
[
"ok"
]
==
1
){
$nbUser
++
;
}
else
{
echo
"<br/> Error with user id : "
.
$key
;
}
}
}
echo
"Number of user with preferences modified : "
.
$nbUser
;
}
}
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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