Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kohinos-tav
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
agplv3
kohinos-tav
Commits
10fc99b5
Commit
10fc99b5
authored
Jul 29, 2026
by
Damien Moulard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to update adherents external data via import
parent
5574b117
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
23 deletions
+36
-23
ImportExternalAdherentData.php
src/Command/ImportExternalAdherentData.php
+23
-16
ImportExternalAdherentDatedData.php
src/Command/ImportExternalAdherentDatedData.php
+13
-7
No files found.
src/Command/ImportExternalAdherentData.php
View file @
10fc99b5
...
...
@@ -19,7 +19,17 @@ use Twig\Environment;
use
Symfony\Component\Console\Input\InputArgument
;
/**
* This command is used to import data to complete external adherents data
* This command is used to import non dated external adherents data
*
* Expected format:
* - email adhérent
* - tranche d’âge (type de donnée = 1 [i.e. moins 30 ans] / 2 [i.e. entre 30 et 59 ans] / 3 [i.e. plus de 59 ans])
* - année de naissance (type de donnée : 1994)
* - groupe A/R (âge/revenu ; type de donnée : chiffre de 1 à 12)
* - Groupe F/R (foyer/revenu ; type de donnée : chiffre de 1 à 16)
* - ID externe (type de donnée : CC1-47 / Tir1VAG-176 / TirVag2-259 / PV1-32)
* - Cohorte (type de donnée : CC / PV / Tir1 / Tir2)
* - membre CC / ancien membre CC (type de données : 1 / 2)
*/
class
ImportExternalAdherentData
extends
Command
{
...
...
@@ -93,8 +103,8 @@ class ImportExternalAdherentData extends Command
];
if
((
$handle
=
fopen
(
$csvFilePath
,
"r"
))
!==
FALSE
)
{
while
((
$row
=
fgetcsv
(
$handle
,
1000
,
"
\t
"
))
!==
FALSE
)
{
if
(
$row
[
0
]
===
'mail'
)
{
while
((
$row
=
fgetcsv
(
$handle
,
1000
,
"
;
"
))
!==
FALSE
)
{
if
(
$row
[
0
]
===
'mail'
||
$row
[
0
]
===
'email adhérent'
)
{
// headers row
continue
;
}
...
...
@@ -120,37 +130,34 @@ class ImportExternalAdherentData extends Command
$data
=
$data
[
0
];
}
#If a field is already stored in database, do not update it
#If no data is provided in the file cell, do not fill (let it empty)
if
(
!
$data
->
getExternalDataAgeGroup
()
&&
$row
[
1
]
!==
""
)
{
# If no data is provided in the file cell, do not fill (leave it empty / do not update)
if
(
$row
[
1
]
!==
""
)
{
$data
->
setExternalDataAgeGroup
(
$ageGroups
[
$row
[
1
]]);
$updated
=
true
;
}
if
(
!
$data
->
getBirthYear
()
&&
$row
[
2
]
!==
""
)
{
if
(
$row
[
2
]
!==
""
)
{
$data
->
setBirthYear
(
intval
(
$row
[
2
]));
$updated
=
true
;
}
if
(
!
$data
->
getAgeIncomeRatioGroup
()
&&
$row
[
3
]
!==
""
)
{
if
(
$row
[
3
]
!==
""
)
{
$data
->
setAgeIncomeRatioGroup
(
intval
(
$row
[
3
]));
$updated
=
true
;
}
if
(
!
$data
->
getHouseholdIncomeRatioGroup
()
&&
$row
[
4
]
!==
""
)
{
if
(
$row
[
4
]
!==
""
)
{
$data
->
setHouseholdIncomeRatioGroup
(
intval
(
$row
[
4
]));
$updated
=
true
;
}
if
(
!
$data
->
getExternalId
()
&&
$row
[
5
]
!==
""
)
{
if
(
$row
[
5
]
!==
""
)
{
$data
->
setExternalId
(
$row
[
5
]);
$updated
=
true
;
}
if
(
!
$data
->
getCohort
()
&&
$row
[
6
]
!==
""
)
{
if
(
$row
[
6
]
!==
""
)
{
$data
->
setCohort
(
$row
[
6
]);
$updated
=
true
;
}
if
(
count
(
$row
)
>
7
)
{
if
(
!
$data
->
getExternalDataCCMemberStatus
()
&&
$row
[
7
]
!==
""
)
{
$data
->
setExternalDataCCMemberStatus
(
$ccStatus
[
$row
[
7
]]);
$updated
=
true
;
}
if
(
count
(
$row
)
>
7
&&
$row
[
7
]
!==
""
)
{
$data
->
setExternalDataCCMemberStatus
(
$ccStatus
[
$row
[
7
]]);
$updated
=
true
;
}
if
(
$updated
)
{
...
...
src/Command/ImportExternalAdherentDatedData.php
View file @
10fc99b5
...
...
@@ -17,7 +17,14 @@ use Twig\Environment;
use
Symfony\Component\Console\Input\InputArgument
;
/**
* This command is used to import data to complete external adherents data
* This command is used to import adherents external dated data (data that depends on a specific year)
*
* Expected format:
* - email adhérent
* - part uc (nombre de part uc dans le foyer ; type de donnée : 1,8)
* - Année données revenus
* - Revenu annuel (type de donnée : 25000 (no space, no currency))
* - Revenu annuel (type de donnée : 2300 (no space, no currency))
*/
class
ImportExternalAdherentDatedData
extends
Command
{
...
...
@@ -65,7 +72,7 @@ class ImportExternalAdherentDatedData extends Command
if
((
$handle
=
fopen
(
$csvFilePath
,
"r"
))
!==
FALSE
)
{
while
((
$row
=
fgetcsv
(
$handle
,
1000
,
";"
))
!==
FALSE
)
{
if
(
$row
[
0
]
===
'mail'
)
{
if
(
$row
[
0
]
===
'mail'
||
$row
[
0
]
===
'email adhérent'
)
{
// headers row
continue
;
}
...
...
@@ -100,17 +107,16 @@ class ImportExternalAdherentDatedData extends Command
$datedData
=
$datedData
[
0
];
}
#If a field is already stored in database, do not update it
#If no data is provided in the file cell, do not fill (let it empty)
if
(
!
$datedData
->
getHouseholdUnitShares
()
&&
$row
[
1
]
!==
""
)
{
# If no data is provided in the file cell, do not fill (let it empty)
if
(
$row
[
1
]
!==
""
)
{
$datedData
->
setHouseholdUnitShares
(
floatval
(
$row
[
1
]));
$updated
=
true
;
}
if
(
!
$datedData
->
getAnnualIncome
()
&&
$row
[
3
]
!==
""
)
{
if
(
$row
[
3
]
!==
""
)
{
$datedData
->
setAnnualIncome
(
intval
(
$row
[
3
]));
$updated
=
true
;
}
if
(
!
$datedData
->
getMonthlyIncome
()
&&
$row
[
4
]
!==
""
)
{
if
(
$row
[
4
]
!==
""
)
{
$datedData
->
setMonthlyIncome
(
intval
(
$row
[
4
]));
$updated
=
true
;
}
...
...
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