'parser' pour le 'csv' implémenté

'download/phone' renvoie 'contacts.csv' + 'logs.csv' + 'dict.csv'
This commit is contained in:
xdrm-brackets 2016-05-13 14:59:18 +02:00
parent bbbad320e7
commit b95369b946
7 changed files with 363 additions and 125 deletions

View File

@ -25,29 +25,51 @@
], ],
"contacts": [ "contacts": [
{ "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, { "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies1":"1", "reltype":"1", "dist":"0" },
{ "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, { "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies1":"1", "reltype":"1", "dist":"0" },
{ "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies":"2", "reltype":"2", "dist":"1" }, { "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies1":"2", "reltype":"2", "dist":"1" },
{ "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies":"3", "reltype":"3", "dist":"2" }, { "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies1":"3", "reltype":"3", "dist":"2" },
{ "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies":"4", "reltype":"4", "dist":"3" }, { "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies1":"4", "reltype":"4", "dist":"3" },
{ "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies":"5", "reltype":"5", "dist":"4" }, { "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies1":"5", "reltype":"5", "dist":"4" },
{ "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies":"6", "reltype":"6", "dist":"5" }, { "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies1":"6", "reltype":"6", "dist":"5" },
{ "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies":"7", "reltype":"7", "dist":"6" }, { "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies1":"7", "reltype":"7", "dist":"6" },
{ "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies":"8", "reltype":"8", "dist":"7" }, { "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies1":"8", "reltype":"8", "dist":"7" },
{ "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" }, { "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies1":"9", "reltype":"9", "dist":"8" },
{ "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" }, { "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies1":"10", "reltype":"autretext", "dist":"9" },
{ "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" }, { "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies1":"11", "reltype":"11", "dist":"10" },
{ "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" }, { "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies1":"12", "reltype":"12", "dist":"11" },
{ "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" }, { "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies1":"13", "reltype":"13", "dist":"12" },
{ "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" }, { "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies1":"14", "reltype":"14", "dist":"13" },
{ "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" }, { "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies1":"15", "reltype":"15", "dist":"14" },
{ "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" }, { "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies1":"16", "reltype":"16", "dist":"15" },
{ "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" }, { "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies1":"17", "reltype":"17", "dist":"16" },
{ "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" }, { "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies1":"18", "reltype":"18", "dist":"17" },
{ "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" }, { "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies1":"19", "reltype":"19", "dist":"18" },
{ "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" }, { "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies1":"20", "reltype":"20", "dist":"19" },
{ "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" }, { "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies1":"21", "reltype":"21", "dist":"20" },
{ "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" } { "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies1":"22", "reltype":"22", "dist":"21" },
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"0", "dist":"0",
"job":"82",
"famsit":"1",
"city":"Toulouse",
"cp":"31000",
"duration":["2","5"],
"context":"0",
"freq":["4","9","14","19","24"],
"connect":["1","3","5","7","9","11"],
"connectExtra":["",""]},
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"autretext", "dist":"0",
"job":"82",
"famsit":"1",
"city":"Toulouse",
"cp":"31000",
"duration":["2","5"],
"context":"special1ou2ou3",
"freq":["4","9","14","19","24"],
"connect":["1","3","5","7","9","11"],
"connectExtra":["",""]}
], ],
"relations": { "relations": {

View File

@ -10,17 +10,20 @@
"contacts": { "contacts": {
"sexe": { "0":"Homme", "1":"Femme" }, "sexe": { "0":"Homme", "1":"Femme" },
"age": { "age": {
".": "NA",
"0": "5 à 10", "1": "10 à 15", "2": "15 à 20", "3": "20 à 25", "4": "25 à 30", "0": "5 à 10", "1": "10 à 15", "2": "15 à 20", "3": "20 à 25", "4": "25 à 30",
"5": "30 à 35", "6": "35 à 40", "7": "40 à 45", "8": "45 à 50", "9": "50 à 55", "5": "30 à 35", "6": "35 à 40", "7": "40 à 45", "8": "45 à 50", "9": "50 à 55",
"10": "55 à 60", "11": "60 à 65", "12": "65 à 70", "13": "70 à 75", "14": "75 à 80", "10": "55 à 60", "11": "60 à 65", "12": "65 à 70", "13": "70 à 75", "14": "75 à 80",
"15": "80 à 85", "16": "85 à 90", "17": "90 à 95", "18": "95 à 100" "15": "80 à 85", "16": "85 à 90", "17": "90 à 95", "18": "95 à 100"
}, },
"studies": { "studies1": {
".": "Non défini", ".": "NA",
"0": "Inconnu", "0": "Inconnu",
"1": "< BAC", "1": "< BAC",
"2": "BAC", "2": "BAC",
@ -29,6 +32,60 @@
"5": "BAC+4 et plus" "5": "BAC+4 et plus"
}, },
"studies2": {
".": "Non défini",
"0": "Inconnue",
"01": "Pas de scolarité",
"02": "Aucun diplôme mais scolarité jusqu'en école primaire ou au collège",
"03": "Aucun diplôme mais scolarité au-delà du collège",
"04": "Certificat d'études primaires (CEP)",
"05": "BEPC, brevet élémentaire, brevet des collèges",
"06": "Certificat d'aptitudes professionnelles (CAP), brevet de compagnon, y compris CAPA",
"07": "Brevet d'études professionnelles (BEP), y compris BEPA et diplômes agricoles (BAA, BPA) Diplômes sociaux (aide-soignante, auxiliaire de puériculture, travailleuse familiale)",
"08": "Baccalauréat général, brevet supérieur BAC ( L, ES, S ou A, B , C, D, D, E )",
"09": "Bac technologique ou professionnel, brevet professionnel ou de technicien BAC (STI, STL, SMS, STT ou F, G, H)</option>\n BEC, BEI, BEH, capacité en droit</option>\n Brevet de technicien agricole (BTA)",
"10": "Diplôme universitaire de 1er cycle BTS, DUT, DEUG</option>\n Diplôme des professions sociales ou de santé, d'infirmier(ère)</option>\n Diplôme universitaire propédeutique, DUEL, DUES, DEUG, PCEM",
"11": "Diplôme universitaire de 2ème ou 3ème cycle MASTER, DOCTORAT (y compris médecine, pharmacie, dentaire),</option>\n Maîtrise, DEA, DESS,</option>\n CAPES, CAPET, agrégation</option>\n Diplôme d'ingénieur, d'une grande école, etc."
},
"job": {
"10": "Agriculteurs exploitants (Agriculteurs, maraîchers, viticulteurs…)",
"21": "Artisans (Maçons, électriciens, couturiers, boulangers, garagistes, coiffeurs…)",
"22": "Commerçants et assimilés (Commerçants en détail ou en gros, buralistes, cafetiers, agents immobiliers…)",
"23": "Chefs d'entreprise de 10 salariés ou plus",
"31": "Professions libérales et assimilés (Médecins, avocats, notaires, architectes libéraux…)",
"32": "Cadres de la fonction publique, professions intellectuelles et artistiques (Personnels administratifs de catégorie A, professeurs de lenseignement secondaire ou supérieur, médecins hospitaliers, artistes…)",
"36": "Cadres d'entreprise (Cadres administratifs, cadres commerciaux, ingénieurs…)",
"41": "Professions intermédiaires de l'enseignement, de la santé, de la fonction publique et assimilés (Personnels administratifs de catégorie B, instituteurs, infirmiers, travailleurs sociaux…)",
"46": "Professions intermédiaires administratives et commerciales des entreprises (Comptables, chargés de clientèles…)",
"47": "Techniciens (Techniciens détudes, techniciens de contrôle, dessinateurs en bâtiment, géomètres…)",
"48": "Contremaîtres, agents de maîtrise (Conducteurs de travaux, chefs déquipe…)",
"51": "Employés de la fonction publique (Personnels de catégorie C, agents administratifs, agents de service…)",
"54": "Employés administratifs d'entreprise (Secrétaires, agents daccueil…)",
"55": "Employés de commerce (Vendeurs, caissiers…)",
"56": "Personnels des services directs aux particuliers (Serveurs, coiffeurs, assistantes maternelles…)",
"61": "Ouvriers qualifiés de type industriel ou artisanal (Mécaniciens, chauffeurs, cuisiniers…)",
"66": "Ouvriers non qualifiés de type industriel ou artisanal (Ouvrier de production, manœuvres…)",
"69": "Ouvriers agricoles (Bergers, ouvriers de la viticulture, bûcherons, ouvrier forestiers…)",
"71": "Anciens agriculteurs exploitants",
"72": "Anciens artisans, commerçants, chefs d'entreprise",
"73": "Anciens cadres",
"74": "Anciennes professions intermédiaires",
"75": "Anciens employés",
"76": "Anciens ouvriers",
"81": "Chômeurs n'ayant jamais travaillé",
"82": "Inactifs divers (autres que retraités)"
},
"famsit": {
"0": "Seul",
"1": "Seul avec enfant(s)",
"2": "En couple sans enfants",
"3": "En couple avec enfants"
},
"reltype": { "reltype": {
"0": "Père, mère ou équivalent", "0": "Père, mère ou équivalent",
"1": "Frère ou soeur", "1": "Frère ou soeur",
@ -36,8 +93,8 @@
"3": "Relation amoureuse", "3": "Relation amoureuse",
"4": "Collègue", "4": "Collègue",
"5": "Voisin", "5": "Voisin",
"6": "Ami", "6": "Ami proche",
"7": "Ami proche", "7": "Ami",
"8": "Relation de service (médecin, ...)", "8": "Relation de service (médecin, ...)",
"9": "Inconnu" "9": "Inconnu"
}, },
@ -47,8 +104,29 @@
"1": "de 5 à 15 minutes", "1": "de 5 à 15 minutes",
"2": "de 15 à 60 minutes", "2": "de 15 à 60 minutes",
"3": "+ d'une heure" "3": "+ d'une heure"
},
"freq": {
"0": "plusieurs fois par semaine", "5": "plusieurs fois par semaine", "10": "plusieurs fois par semaine", "15": "plusieurs fois par semaine", "20": "plusieurs fois par semaine",
"1": "1 fois par semaine", "6": "1 fois par semaine", "11": "1 fois par semaine", "16": "1 fois par semaine", "21": "1 fois par semaine",
"2": "1 fois par mois", "7": "1 fois par mois", "12": "1 fois par mois", "17": "1 fois par mois", "22": "1 fois par mois",
"3": "1 fois par an ou moins", "8": "1 fois par an ou moins", "13": "1 fois par an ou moins", "18": "1 fois par an ou moins", "23": "1 fois par an ou moins",
"4": "Jamais", "9": "Jamais", "14": "Jamais", "19": "Jamais", "24": "Jamais"
},
"connect": {
"0": "Oui", "1": "Non",
"2": "Oui", "3": "Non",
"4": "Oui", "5": "Non",
"6": "Oui", "7": "Non",
"8": "Oui", "9": "Non",
"10": "Oui", "11": "Non"
} }
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -111,8 +111,8 @@ miniFicheBuilder.setLayout(
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype3_mini_@uid' value='3'><label for='reltype3_mini_@uid'>Relation amoureuse</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype3_mini_@uid' value='3'><label for='reltype3_mini_@uid'>Relation amoureuse</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype4_mini_@uid' value='4'><label for='reltype4_mini_@uid'>Collègue</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype4_mini_@uid' value='4'><label for='reltype4_mini_@uid'>Collègue</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype5_mini_@uid' value='5'><label for='reltype5_mini_@uid'>Voisin</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype5_mini_@uid' value='5'><label for='reltype5_mini_@uid'>Voisin</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype6_mini_@uid' value='6'><label for='reltype6_mini_@uid'>Ami</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype6_mini_@uid' value='6'><label for='reltype6_mini_@uid'>Ami proche</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype7_mini_@uid' value='7'><label for='reltype7_mini_@uid'>Ami proche</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype7_mini_@uid' value='7'><label for='reltype7_mini_@uid'>Ami</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype8_mini_@uid' value='8'><label for='reltype8_mini_@uid'>Relation de service (médecin, ...)</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype8_mini_@uid' value='8'><label for='reltype8_mini_@uid'>Relation de service (médecin, ...)</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype9_mini_@uid' value='9'><label for='reltype9_mini_@uid'>Inconnu</label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype9_mini_@uid' value='9'><label for='reltype9_mini_@uid'>Inconnu</label><br>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype10_mini_@uid' value='10'><label for='reltype10_mini_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+ "\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='reltype_mini_@uid' data-name='reltype' id='reltype10_mini_@uid' value='10'><label for='reltype10_mini_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+

View File

@ -10,6 +10,112 @@
class download{ class download{
/* CONSTRUIT UN CONTENU CSV A PARTIR DES DONNEES @DATA ET DU DICTIONNAIRE @DICT
*
* @data<Array> Tableau contenant les valeurs
* @dict<Array> Tableau contenant le dictionnaire des valeurs
*
* @return csvContent<String> Retourne le contenu CSV associé
*
*/
private static function parseCSV($data, $dict){
$output = ''; // Contiendra le résultat
$dictKeys = array_keys($dict); // Contient les clés de @dict
/* [0] On récupère toutes les colonnes
=========================================================*/
$columns = array(); // Contiendra les colonnes
/* (1) Pour chaque set de @data */
foreach($data as $dataset){
$keys = array();
/* (2) Pour chaque champ de chaque set de @data, on ajoute les clés */
foreach($dataset as $key=>$value){
// {1} Si c'est un tableau -> on ajoute les sous-clés //
if( is_array($value) )
foreach($value as $subIndex=>$subValue)
array_push( $keys, "${key}_$subIndex" );
// {2} Si c'est une valeur simple -> on ajoute la clé //
else
array_push( $keys, $key );
}
/* (3) On ajoute à chaque fois les clés du set à la liste des colonnes */
$columns = array_unique( array_merge( $columns, $keys ) );
}
// var_dump($columns);
/* [1] On ajoute les colonnes à la sortie
=========================================================*/
foreach($columns as $i=>$column)
$output .= ($i < count($columns)-1) ? "$column," : "$column\n\r";
/* [2] On récupère les valeurs et on les ajoute à la sortie
=========================================================*/
/* (1) Pour chaque set de @data */
foreach($data as $dataset){
/* (2) Pour chaque colonne */
foreach($columns as $c=>$column){
/* (3) On décompose la colonne (ne change que si elle l'est) */
$col = explode('_', $column);
$composed = true;
// Si il n'existe pas une 2me partie numérique, on annule la décomposition
if( !isset($col[1]) || !is_numeric($col[1]) ){
$col = array( $column );
$composed = false;
}
/* (4) Si la colonne existe dans le set actuel */
if( isset($dataset[$col[0]]) ){
/* (5) Si c'est une valeur composée, on récupère la valeur */
if( $composed && isset($dataset[$col[0]][$col[1]]) )
// {1} Si valeur dans le dictionnaire, on fait modulo le nombre de choix possibles //
if( isset($dict[$col[0]]) )
$output .= "\"".( $dataset[$col[0]][$col[1]] % count($dict[$col[0]]) )."\"";
// {2} Si pas dans le dictionnaire, on laisse la valeur //
else
$output .= "\"".$dataset[$col[0]][$col[1]]."\"";
/* (6) Si la valeur n'est pas composée, on récupère la valeur */
elseif( !$composed )
$output .= "\"".$dataset[$col[0]]."\"";
}
// On ajoute une virgule sauf à la dernière valeur
$output .= ($c < count($columns)-1) ? "," : "";
}
$output .= "\r\n";
}
return $output;
}
public static function phone($params){ public static function phone($params){
extract($params); extract($params);
@ -33,74 +139,23 @@
// Contiendra le résultat /* [2] On construit le CSV
$output = array( 'logs' => '', 'contacts' => '' );
// Dans le parsage en CSV, ajouter les valeurs du dictionnaire en option (paramétrable)
/* [1] Journal d'appel
=========================================================*/ =========================================================*/
foreach($phone_log['logs'] as $i=>$log){ $output = array(
'logs' => self::parseCSV($phone_log['logs'], $dict['logs']),
'contacts' => self::parseCSV($phone_log['contacts'], $dict['contacts']),
'dict' => ''
);
/* (1) Colonnes */ /* [3] On construit le fichier du dictionnaire
$logid = 0;
if( $i == 0 )
foreach($log as $key=>$val){
$output['logs'] .= ($logid<count($log)-1) ? '"'.$key.'",' : '"'.$key.'"'."\r\n";
$logid++;
}
/* (2) Valeurs */
$logid = 0;
foreach($log as $key=>$val){
if( isset($dict['logs'][$key][$val]) )
$output['logs'] .= '"'.$dict['logs'][$key][$val].'"';
else
$output['logs'] .= '"'.$val.'"';
// Si pas dernier, on met une virgule, sinon retour à la ligne
$output['logs'] .= ($logid<count($log)-1) ? ',' : ''."\r\n";
$logid++;
}
}
/* [2] Contacts
=========================================================*/ =========================================================*/
foreach($phone_log['contacts'] as $i=>$log){ foreach($dict as $ds=>$dataset)
foreach($dataset as $f=>$field)
/* (1) Colonnes */ foreach($field as $key=>$value)
$logid = 0; $output['dict'] .= "\"$ds\",\"$f\",\"$key\",\"$value\"\r\n";
if( $i == 0 )
foreach($log as $key=>$val){
$output['contacts'] .= ($logid<count($log)-1) ? '"'.$key.'",' : $key.'"'."\r\n";
$logid++;
}
/* (2) Valeurs */
$logid = 0;
foreach($log as $key=>$val){
if( isset($dict['contacts'][$key][$val]) )
$output['contacts'] .= '"'.$dict['contacts'][$key][$val].'"';
else
$output['contacts'] .= '"'.$val.'"';
// Si pas dernier, on met une virgule, sinon retour à la ligne
$output['contacts'] .= ($logid<count($log)-1) ? ',' : ''."\r\n";
$logid++;
}
}
/* [4] Création de l'archive
/* [3] Création de l'archive
=========================================================*/ =========================================================*/
$zip = new \ZipArchive(); $zip = new \ZipArchive();
$fname = '/tmp/'.time().'.zip'; $fname = '/tmp/'.time().'.zip';
@ -112,7 +167,7 @@
$zip->close(); $zip->close();
/* [4] On lance le téléchargement /* [5] On lance le téléchargement
=========================================================*/ =========================================================*/
return array( return array(
'ModuleError' => ManagerError::Success, 'ModuleError' => ManagerError::Success,

View File

@ -25,31 +25,39 @@
], ],
"contacts": [ "contacts": [
{ "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, { "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies1":"1", "reltype":"1", "dist":"0" },
{ "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, { "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies1":"1", "reltype":"1", "dist":"0" },
{ "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies":"2", "reltype":"2", "dist":"1" }, { "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies1":"2", "reltype":"2", "dist":"1" },
{ "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies":"3", "reltype":"3", "dist":"2" }, { "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies1":"3", "reltype":"3", "dist":"2" },
{ "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies":"4", "reltype":"4", "dist":"3" }, { "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies1":"4", "reltype":"4", "dist":"3" },
{ "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies":"5", "reltype":"5", "dist":"4" }, { "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies1":"5", "reltype":"5", "dist":"4" },
{ "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies":"6", "reltype":"6", "dist":"5" }, { "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies1":"6", "reltype":"6", "dist":"5" },
{ "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies":"7", "reltype":"7", "dist":"6" }, { "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies1":"7", "reltype":"7", "dist":"6" },
{ "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies":"8", "reltype":"8", "dist":"7" }, { "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies1":"8", "reltype":"8", "dist":"7" },
{ "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" }, { "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies1":"9", "reltype":"9", "dist":"8" },
{ "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" }, { "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies1":"10", "reltype":"autretext", "dist":"9" },
{ "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" }, { "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies1":"11", "reltype":"11", "dist":"10" },
{ "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" }, { "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies1":"12", "reltype":"12", "dist":"11" },
{ "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" }, { "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies1":"13", "reltype":"13", "dist":"12" },
{ "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" }, { "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies1":"14", "reltype":"14", "dist":"13" },
{ "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" }, { "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies1":"15", "reltype":"15", "dist":"14" },
{ "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" }, { "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies1":"16", "reltype":"16", "dist":"15" },
{ "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" }, { "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies1":"17", "reltype":"17", "dist":"16" },
{ "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" }, { "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies1":"18", "reltype":"18", "dist":"17" },
{ "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" }, { "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies1":"19", "reltype":"19", "dist":"18" },
{ "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" }, { "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies1":"20", "reltype":"20", "dist":"19" },
{ "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" }, { "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies1":"21", "reltype":"21", "dist":"20" },
{ "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" } { "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies1":"22", "reltype":"22", "dist":"21" },
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"0", "dist":"0", "job":"82","famsit":"1", "city":"Toulouse", "cp":"31000", "duration":["2","5"],"context":"0", "freq":["4","9","14","19","24"], "connect":["1","3","5","7","9","11"], "connectExtra":["",""]},
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"autretext", "dist":"0", "job":"82","famsit":"1", "city":"Toulouse", "cp":"31000", "duration":["2","5"],"context":"special1ou2ou3", "freq":["4","9","14","19","24"], "connect":["1","3","5","7","9","11"], "connectExtra":["",""]}
],
"relations": {
"0": ["1", "4", "6", "8"],
"5": ["cd 4", "5", "6"]
}
]
} }

View File

@ -10,17 +10,20 @@
"contacts": { "contacts": {
"sexe": { "0":"Homme", "1":"Femme" }, "sexe": { "0":"Homme", "1":"Femme" },
"age": { "age": {
".": "NA",
"0": "5 à 10", "1": "10 à 15", "2": "15 à 20", "3": "20 à 25", "4": "25 à 30", "0": "5 à 10", "1": "10 à 15", "2": "15 à 20", "3": "20 à 25", "4": "25 à 30",
"5": "30 à 35", "6": "35 à 40", "7": "40 à 45", "8": "45 à 50", "9": "50 à 55", "5": "30 à 35", "6": "35 à 40", "7": "40 à 45", "8": "45 à 50", "9": "50 à 55",
"10": "55 à 60", "11": "60 à 65", "12": "65 à 70", "13": "70 à 75", "14": "75 à 80", "10": "55 à 60", "11": "60 à 65", "12": "65 à 70", "13": "70 à 75", "14": "75 à 80",
"15": "80 à 85", "16": "85 à 90", "17": "90 à 95", "18": "95 à 100" "15": "80 à 85", "16": "85 à 90", "17": "90 à 95", "18": "95 à 100"
}, },
"studies": { "studies1": {
".": "Non défini", ".": "NA",
"0": "Inconnu", "0": "Inconnu",
"1": "< BAC", "1": "< BAC",
"2": "BAC", "2": "BAC",
@ -29,6 +32,61 @@
"5": "BAC+4 et plus" "5": "BAC+4 et plus"
}, },
"studies2": {
".": "NA",
"0": "Inconnue",
"01": "Pas de scolarité",
"02": "Aucun diplôme mais scolarité jusqu'en école primaire ou au collège",
"03": "Aucun diplôme mais scolarité au-delà du collège",
"04": "Certificat d'études primaires (CEP)",
"05": "BEPC, brevet élémentaire, brevet des collèges",
"06": "Certificat d'aptitudes professionnelles (CAP), brevet de compagnon, y compris CAPA",
"07": "Brevet d'études professionnelles (BEP), y compris BEPA et diplômes agricoles (BAA, BPA) Diplômes sociaux (aide-soignante, auxiliaire de puériculture, travailleuse familiale)",
"08": "Baccalauréat général, brevet supérieur BAC ( L, ES, S ou A, B , C, D, D, E )",
"09": "Bac technologique ou professionnel, brevet professionnel ou de technicien BAC (STI, STL, SMS, STT ou F, G, H)</option>\n BEC, BEI, BEH, capacité en droit</option>\n Brevet de technicien agricole (BTA)",
"10": "Diplôme universitaire de 1er cycle BTS, DUT, DEUG</option>\n Diplôme des professions sociales ou de santé, d'infirmier(ère)</option>\n Diplôme universitaire propédeutique, DUEL, DUES, DEUG, PCEM",
"11": "Diplôme universitaire de 2ème ou 3ème cycle MASTER, DOCTORAT (y compris médecine, pharmacie, dentaire),</option>\n Maîtrise, DEA, DESS,</option>\n CAPES, CAPET, agrégation</option>\n Diplôme d'ingénieur, d'une grande école, etc."
},
"job": {
".": "NA",
"10": "Agriculteurs exploitants (Agriculteurs, maraîchers, viticulteurs…)",
"21": "Artisans (Maçons, électriciens, couturiers, boulangers, garagistes, coiffeurs…)",
"22": "Commerçants et assimilés (Commerçants en détail ou en gros, buralistes, cafetiers, agents immobiliers…)",
"23": "Chefs d'entreprise de 10 salariés ou plus",
"31": "Professions libérales et assimilés (Médecins, avocats, notaires, architectes libéraux…)",
"32": "Cadres de la fonction publique, professions intellectuelles et artistiques (Personnels administratifs de catégorie A, professeurs de lenseignement secondaire ou supérieur, médecins hospitaliers, artistes…)",
"36": "Cadres d'entreprise (Cadres administratifs, cadres commerciaux, ingénieurs…)",
"41": "Professions intermédiaires de l'enseignement, de la santé, de la fonction publique et assimilés (Personnels administratifs de catégorie B, instituteurs, infirmiers, travailleurs sociaux…)",
"46": "Professions intermédiaires administratives et commerciales des entreprises (Comptables, chargés de clientèles…)",
"47": "Techniciens (Techniciens détudes, techniciens de contrôle, dessinateurs en bâtiment, géomètres…)",
"48": "Contremaîtres, agents de maîtrise (Conducteurs de travaux, chefs déquipe…)",
"51": "Employés de la fonction publique (Personnels de catégorie C, agents administratifs, agents de service…)",
"54": "Employés administratifs d'entreprise (Secrétaires, agents daccueil…)",
"55": "Employés de commerce (Vendeurs, caissiers…)",
"56": "Personnels des services directs aux particuliers (Serveurs, coiffeurs, assistantes maternelles…)",
"61": "Ouvriers qualifiés de type industriel ou artisanal (Mécaniciens, chauffeurs, cuisiniers…)",
"66": "Ouvriers non qualifiés de type industriel ou artisanal (Ouvrier de production, manœuvres…)",
"69": "Ouvriers agricoles (Bergers, ouvriers de la viticulture, bûcherons, ouvrier forestiers…)",
"71": "Anciens agriculteurs exploitants",
"72": "Anciens artisans, commerçants, chefs d'entreprise",
"73": "Anciens cadres",
"74": "Anciennes professions intermédiaires",
"75": "Anciens employés",
"76": "Anciens ouvriers",
"81": "Chômeurs n'ayant jamais travaillé",
"82": "Inactifs divers (autres que retraités)"
},
"famsit": {
"0": "Seul",
"1": "Seul avec enfant(s)",
"2": "En couple sans enfants",
"3": "En couple avec enfants"
},
"reltype": { "reltype": {
"0": "Père, mère ou équivalent", "0": "Père, mère ou équivalent",
"1": "Frère ou soeur", "1": "Frère ou soeur",
@ -36,8 +94,8 @@
"3": "Relation amoureuse", "3": "Relation amoureuse",
"4": "Collègue", "4": "Collègue",
"5": "Voisin", "5": "Voisin",
"6": "Ami", "6": "Ami proche",
"7": "Ami proche", "7": "Ami",
"8": "Relation de service (médecin, ...)", "8": "Relation de service (médecin, ...)",
"9": "Inconnu" "9": "Inconnu"
}, },
@ -47,8 +105,25 @@
"1": "de 5 à 15 minutes", "1": "de 5 à 15 minutes",
"2": "de 15 à 60 minutes", "2": "de 15 à 60 minutes",
"3": "+ d'une heure" "3": "+ d'une heure"
},
"freq": {
"0": "plusieurs fois par semaine",
"1": "1 fois par semaine",
"2": "1 fois par mois",
"3": "1 fois par an ou moins",
"4": "Jamais"
},
"connect": {
"0": "Oui",
"1": "Non"
} }
} }
} }