From c1eb819c6ffb7b1dd762ede9b0f3e25f4cc8b3ad Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Thu, 12 May 2016 13:04:09 +0200 Subject: [PATCH] Export excel en passant par .csv (dans automate.php) --- automate.php | 97 ++++++++++++++++++++++++++++-- doc/phone_log.json | 66 ++++++++++---------- doc/phone_log_dict.json | 4 +- js/includes/input-html-data-min.js | 2 +- js/includes/input-html-data.js | 16 ++--- 5 files changed, 136 insertions(+), 49 deletions(-) diff --git a/automate.php b/automate.php index 771d13d..2eb5963 100755 --- a/automate.php +++ b/automate.php @@ -69,12 +69,10 @@ /* [3] Test de la vérification du format de fichier pour l'upload =========================================================*/ - ?> - - + // + // + // // var_dump($_FILES); // // if( isset($_FILES) ){ @@ -85,5 +83,92 @@ // // } + $phone_log = json_decode( file_get_contents('doc/phone_log.json'), true ); + $dict = json_decode( file_get_contents('doc/phone_log_dict.json'), true ); + + // Contiendra le résultat + $output = array( 'call_log' => '', 'contacts' => '' ); + + + + /* [1] Journal d'appel + =========================================================*/ + foreach($phone_log['call_log'] as $i=>$log){ + + /* (1) Colonnes */ + $logid = 0; + if( $i == 0 ) + foreach($log as $key=>$val){ + $output['call_log'] .= ($logid$val){ + + if( isset($dict['call_log'][$key][$val]) ) + $output['call_log'] .= '"'.$dict['call_log'][$key][$val].'"'; + else + $output['call_log'] .= '"'.$val.'"'; + + // Si pas dernier, on met une virgule, sinon retour à la ligne + $output['call_log'] .= ($logid$log){ + + /* (1) Colonnes */ + $logid = 0; + if( $i == 0 ) + foreach($log as $key=>$val){ + $output['contacts'] .= ($logid$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'] .= ($logidopen($fname, ZipArchive::CREATE); + + foreach($output as $name=>$content) + $zip->addFromString($name.'.csv', $content); + + $zip->close(); + + /* [4] On lance le téléchargement + =========================================================*/ + header("Content-type: application/zip"); + header("Content-Disposition: attachment; filename=phone_data.zip"); + header("Pragma: no-cache"); + header("Expires: 0"); + readfile($fname); ?> diff --git a/doc/phone_log.json b/doc/phone_log.json index 9792bd1..72c95f2 100644 --- a/doc/phone_log.json +++ b/doc/phone_log.json @@ -1,27 +1,27 @@ { "call_log": [ - { "contact":"1", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"2", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"3", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"4", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"5", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"6", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"7", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"8", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"9", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"10", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"11", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"INCOMING", "type":"SMS" }, - { "contact":"12", "date":"2014-02-28T15:00:10", "duration":"125", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"13", "date":"2014-02-15T23:06:46", "duration":"0", "direction":"INGOING", "type":"PHONE" }, - { "contact":"14", "date":"2014-02-15T23:06:18", "duration":"0", "direction":"INGOING", "type":"PHONE" }, - { "contact":"15", "date":"2014-02-15T21:08:34", "duration":"349", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"16", "date":"2014-02-15T20:51:38", "duration":"0", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"17", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"18", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"MISSED", "type":"PHONE" }, - { "contact":"19", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"20", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"21", "date":"2014-02-15T17:24:18", "duration":"276", "direction":"OUTGOING", "type":"PHONE" }, - { "contact":"22", "date":"2014-02-15T16:34:29", "duration":"36", "direction":"OUTGOING", "type":"PHONE" } + { "contact":"1", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"2", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"3", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"4", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"5", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"6", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"7", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"8", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"9", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"10", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"11", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "contact":"12", "date":"2014-02-28T15:00:10", "duration":"125", "direction":"1", "type":"1" }, + { "contact":"13", "date":"2014-02-15T23:06:46", "duration":"0", "direction":"0", "type":"1" }, + { "contact":"14", "date":"2014-02-15T23:06:18", "duration":"0", "direction":"0", "type":"1" }, + { "contact":"15", "date":"2014-02-15T21:08:34", "duration":"349", "direction":"1", "type":"1" }, + { "contact":"16", "date":"2014-02-15T20:51:38", "duration":"0", "direction":"1", "type":"1" }, + { "contact":"17", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "contact":"18", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"2", "type":"1" }, + { "contact":"19", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "contact":"20", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "contact":"21", "date":"2014-02-15T17:24:18", "duration":"276", "direction":"1", "type":"1" }, + { "contact":"22", "date":"2014-02-15T16:34:29", "duration":"36", "direction":"1", "type":"1" } ], "contacts": [ @@ -36,17 +36,17 @@ { "contact":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" }, { "contact":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" }, { "contact":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" }, - { "contact":"12", "number":"0502032121", "name":"", "sexe":"0", "age":"12", "studies":"12", "reltype":"12", "dist":"11" }, - { "contact":"13", "number":"0502032277", "name":"", "sexe":"0", "age":"13", "studies":"13", "reltype":"13", "dist":"12" }, - { "contact":"14", "number":"0502032433", "name":"", "sexe":"0", "age":"14", "studies":"14", "reltype":"14", "dist":"13" }, - { "contact":"15", "number":"0502032589", "name":"", "sexe":"0", "age":"15", "studies":"15", "reltype":"15", "dist":"14" }, - { "contact":"16", "number":"0502032745", "name":"", "sexe":"0", "age":"16", "studies":"16", "reltype":"16", "dist":"15" }, - { "contact":"17", "number":"0502032901", "name":"", "sexe":"0", "age":"17", "studies":"17", "reltype":"17", "dist":"16" }, - { "contact":"18", "number":"0502033057", "name":"", "sexe":"0", "age":"18", "studies":"18", "reltype":"18", "dist":"17" }, - { "contact":"19", "number":"0502033213", "name":"", "sexe":"0", "age":"19", "studies":"19", "reltype":"19", "dist":"18" }, - { "contact":"20", "number":"0502033369", "name":"", "sexe":"0", "age":"20", "studies":"20", "reltype":"20", "dist":"19" }, - { "contact":"21", "number":"0502033525", "name":"", "sexe":"0", "age":"21", "studies":"21", "reltype":"21", "dist":"20" }, - { "contact":"22", "number":"0502033681", "name":"", "sexe":"0", "age":"22", "studies":"22", "reltype":"22", "dist":"21" } + { "contact":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" }, + { "contact":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" }, + { "contact":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" }, + { "contact":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" }, + { "contact":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" }, + { "contact":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" }, + { "contact":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" }, + { "contact":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" }, + { "contact":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" }, + { "contact":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" }, + { "contact":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" } ] diff --git a/doc/phone_log_dict.json b/doc/phone_log_dict.json index 9946c51..c53337b 100644 --- a/doc/phone_log_dict.json +++ b/doc/phone_log_dict.json @@ -18,7 +18,9 @@ "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" }, + "studies": { + ".": "Non défini" }, @@ -37,7 +39,7 @@ "dist": { "0": "- de 5 minutes", - "1": "de 5 à 15 minutes", + "1": "de 5 à 15 minutes", "2": "de 15 à 60 minutes", "3": "+ d'une heure" } diff --git a/js/includes/input-html-data-min.js b/js/includes/input-html-data-min.js index 218aa14..da2a4ca 100644 --- a/js/includes/input-html-data-min.js +++ b/js/includes/input-html-data-min.js @@ -1,3 +1,3 @@ var contactBuilder=new HTMLBuilder;contactBuilder.setLayout("

\n\t\n\t\n\t\n\t\n\t\n\t \n\t \n\t \n\t \n\t \n\t \n\t\n

\n\n"); var miniFicheBuilder=new HTMLBuilder;miniFicheBuilder.setLayout("
\n\t\n\t\n\t

@name

\n\t
\t\t@countcall appels\t
\t
\t\t@countsms sms\t
\t
\n\t\t\n\t\t   \n\t
\n\t
\n\t\t\n\t
\n\t
\n\t\t\n\t
\n\t

Type de relation

\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t

O\u00f9 habite t-elle/il\u00a0?

\n\t
\n\t\t\u00c0 combien de temps est-ce de chez vous ?
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n
"); -var ficheBuilder=new HTMLBuilder;ficheBuilder.setLayout("
\n\t\n\t\n\t

@name

\n\t
\t\t@countcall appels\t
\t
\t\t@countsms sms\t
\t
\n\t\t\n\t\t   \n\t
\n\t
\n\t\t\n\t
\n\t
\n\t\t\n\t
\n\t
\n\t\tSituation familiale:
\n\t\t
\n\t\t   
\n\t\t   
\n\t\t   \n\t
\n\t
\n\t\t\n\t
\n\t

Type de relation

\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t

O\u00f9 habite t-elle/il\u00a0?

\n\t
\n\t\t\n\t\t\n\t
\n\t
\n\t\t\u00c0 combien de temps est-ce de chez vous ?
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t
\n\t\tDepuis quand connaissez-vous cette personne ?

\n\t\tmois\n\t\tet    ans.\n\t
\n\t

Contexte de rencontre

\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t

Avec quelle fr\u00e9quence discutez-vous avec cette personne\u00a0?

\n\t
\n\t\tFace \u00e0 face
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tT\u00e9l\u00e9phone ou skype et \u00e9quivalent
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tSMS, et \u00e9quivalents
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tCourrier \u00e9lectronique
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tFacebook ou autre r\u00e9seau social
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t

Comment \u00eates-vous \u00ab\u00a0connect\u00e9\u00a0\u00bb \u00e0 cette personne\u00a0?

\n\t
\n\t\tSes coordonn\u00e9es sont dans votre carnet d\u2019adresse
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tSon num\u00e9ro de mobile est enregistr\u00e9 sur votre mobile (ou vous-m\u00eames \u00eates sur le sien)
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tElle figure parmi vos amis facebook
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tElle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif r\u00e9guli\u00e8rement
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous le suivez sur Twitter
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous communiquez avec cette personne sur Twitter
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous communiquez dans autre r\u00e9seau social : \n\t
\n\t
\n\t\tVous communiquez dans un autre dispositif (blogs, jeu vid\u00e9o ou autre) : \n\t
\n
\n"); +var ficheBuilder=new HTMLBuilder;ficheBuilder.setLayout("
\n\t\n\t\n\t

@name

\n\t
\t\t@countcall appels\t
\t
\t\t@countsms sms\t
\t
\n\t\t\n\t\t   \n\t
\n\t
\n\t\t\n\t
\n\t
\n\t\t\n\t
\n\t
\n\t\tSituation familiale:
\n\t\t
\n\t\t   
\n\t\t   
\n\t\t   \n\t
\n\t
\n\t\t\n\t
\n\t

Type de relation

\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t

O\u00f9 habite t-elle/il\u00a0?

\n\t
\n\t\t\n\t\t\n\t
\n\t
\n\t\t\u00c0 combien de temps est-ce de chez vous ?
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t
\n\t\tDepuis quand connaissez-vous cette personne ?

\n\t\tmois\n\t\tet    ans.\n\t
\n\t

Contexte de rencontre

\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t
\n\t\t   
\n\t\t   
\n\t\t   
\n\t
\n\t

Avec quelle fr\u00e9quence discutez-vous avec cette personne\u00a0?

\n\t
\n\t\tFace \u00e0 face
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tT\u00e9l\u00e9phone ou skype et \u00e9quivalent
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tSMS, et \u00e9quivalents
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tCourrier \u00e9lectronique
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t
\n\t\tFacebook ou autre r\u00e9seau social
\n\t\t   \n\t\t   \n\t\t   \n\t\t   \n\t
\n\t

Comment \u00eates-vous \u00ab\u00a0connect\u00e9\u00a0\u00bb \u00e0 cette personne\u00a0?

\n\t
\n\t\tSes coordonn\u00e9es sont dans votre carnet d\u2019adresse
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tSon num\u00e9ro de mobile est enregistr\u00e9 sur votre mobile (ou vous-m\u00eames \u00eates sur le sien)
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tElle figure parmi vos amis facebook
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tElle figure parmi vos amis facebook et vous interagissez avec elle sur ce dispositif r\u00e9guli\u00e8rement
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous le suivez sur Twitter
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous communiquez avec cette personne sur Twitter
\n\t\t   \n\t\t   \n\t
\n\t
\n\t\tVous communiquez dans autre r\u00e9seau social : \n\t
\n\t
\n\t\tVous communiquez dans un autre dispositif (blogs, jeu vid\u00e9o ou autre) : \n\t
\n
\n"); diff --git a/js/includes/input-html-data.js b/js/includes/input-html-data.js index 73cff19..538e47e 100644 --- a/js/includes/input-html-data.js +++ b/js/includes/input-html-data.js @@ -243,40 +243,40 @@ ficheBuilder.setLayout( "\t\t\n"+