diff --git a/automate.php b/automate.php index b664b2f..d288f1c 100755 --- a/automate.php +++ b/automate.php @@ -83,100 +83,11 @@ // // } - function uploadZippedPhoneData(){ - $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); - } - - - - $req = new ModuleRequest('call_log/unserialize', array('phone_number'=>'05 05 05 05 05')); + $req = new ModuleRequest('download/phone', array('subjects'=>[1])); $res = $req->dispatch(); - var_dump( $res->get('sms') ); ?> diff --git a/config/modules.json b/config/modules.json index 800dae4..f51a22a 100755 --- a/config/modules.json +++ b/config/modules.json @@ -231,5 +231,17 @@ } } + }, + + + "download": { + + "phone": { + "description": "Download des données relatives à une enquête téléphonique.", + "permissions": ["admin"], + "parameters": { + "subjects": { "description": "Identifiants des sujets à intégrer.", "type": "array" } + } + } } } diff --git a/js/includes/input-phone-fiche-min.js b/js/includes/input-phone-fiche-min.js index 8915439..26f4987 100644 --- a/js/includes/input-phone-fiche-min.js +++ b/js/includes/input-phone-fiche-min.js @@ -10,8 +10,8 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;binput[type="radio"][data-name="loc"]');for(b=0;binput[type="radio"][data-name="context"]');for(b=0;binput[type="radio"][data-name="freq"]');for(b=0;binput[type="radio"][data-name="connect"]');for(b=0;blsi.keys("contacts").length?lsi.keys("contacts").length: -20;if(b.length=e)break}for(var f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))}; +inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b=[],c;for(c in a){if(-1lsi.keys("contacts").length?lsi.keys("contacts").length:20;if(b.length=e)break}for(var f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))}; inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;cAPPELS");10>e&&c'+(e%10+1)+"  ":(10==e&&(this.nav_container.innerHTML+='SMS'),this.nav_container.innerHTML+=''+(e%10+1)+"")}for(var d in a)b= $('#nav-fiche [data-n="'+a[d].uid+'"]'),null!=b&&(!0===a[d].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))}; diff --git a/js/includes/input-phone-fiche.js b/js/includes/input-phone-fiche.js index 78048b9..9fa0675 100644 --- a/js/includes/input-phone-fiche.js +++ b/js/includes/input-phone-fiche.js @@ -315,7 +315,6 @@ inputPhoneFiche.prototype.sync = function(){ // On calcule le rang de la fiche en fonction du classement var ficheIndex = contacts[uid].call; addedFicheUids.push(ficheIndex); - console.warn('call', ficheIndex); // On récupère les informations de la FICHE (si elle existe) */ var ficheData = lsi.get('fiches', ficheIndex); @@ -336,7 +335,6 @@ inputPhoneFiche.prototype.sync = function(){ // On calcule le rang de la fiche en fonction du classement var ficheIndex = 10+contacts[uid].sms; addedFicheUids.push(ficheIndex); - console.warn('sms', ficheIndex); // On récupère les informations de la FICHE (si elle existe) */ var ficheData = lsi.get('fiches', ficheIndex); @@ -375,7 +373,6 @@ inputPhoneFiche.prototype.sync = function(){ while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche ) ficheUid++; - console.warn('fill', ficheUid); // On enregistre le nouvel UID dans les uid crées addedFicheUids.push(ficheUid); diff --git a/manager/module/download.php b/manager/module/download.php new file mode 100644 index 0000000..72d7b20 --- /dev/null +++ b/manager/module/download.php @@ -0,0 +1,119 @@ + '', '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){ + + /* (1) Colonnes */ + $logid = 0; + if( $i == 0 ) + foreach($log as $key=>$val){ + $output['logs'] .= ($logid$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$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); + exit(); + } + + } + + +?> diff --git a/manager/module/input.php b/manager/module/input.php index 5a6f5d4..d349875 100644 --- a/manager/module/input.php +++ b/manager/module/input.php @@ -249,7 +249,7 @@ return array( 'ModuleError' => ManagerError::ModuleError ); /* (7) On renomme le fichier avec le nouvel identifiant */ - if( !rename('/tmp/phone_storage_'.$subject['tmp_id'].'.json', '/tmp/phone_storage_'.$subject_id.'.json') ) + if( !rename('/tmp/phone_storage_'.$subject['tmp_id'].'.json', '/src/upload/phone_storage/'.$subject_id.'.json') ) return array( 'ModuleError' => ManagerError::ModuleError ); // si erreur -> erreur diff --git a/manager/server.php b/manager/server.php deleted file mode 100644 index fc032c8..0000000 --- a/manager/server.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/src/upload/phone_storage/7153c4268a97aaa111a596746e8a404aecdffa64.json b/src/upload/phone_storage/7153c4268a97aaa111a596746e8a404aecdffa64.json new file mode 100644 index 0000000..5d6193c --- /dev/null +++ b/src/upload/phone_storage/7153c4268a97aaa111a596746e8a404aecdffa64.json @@ -0,0 +1,55 @@ +{ + "logs": [ + { "id":"1", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"2", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"3", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"4", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"5", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"6", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"7", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"8", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"9", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"10", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"11", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" }, + { "id":"12", "date":"2014-02-28T15:00:10", "duration":"125", "direction":"1", "type":"1" }, + { "id":"13", "date":"2014-02-15T23:06:46", "duration":"0", "direction":"0", "type":"1" }, + { "id":"14", "date":"2014-02-15T23:06:18", "duration":"0", "direction":"0", "type":"1" }, + { "id":"15", "date":"2014-02-15T21:08:34", "duration":"349", "direction":"1", "type":"1" }, + { "id":"16", "date":"2014-02-15T20:51:38", "duration":"0", "direction":"1", "type":"1" }, + { "id":"17", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "id":"18", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"2", "type":"1" }, + { "id":"19", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "id":"20", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" }, + { "id":"21", "date":"2014-02-15T17:24:18", "duration":"276", "direction":"1", "type":"1" }, + { "id":"22", "date":"2014-02-15T16:34:29", "duration":"36", "direction":"1", "type":"1" } + ], + + "contacts": [ + { "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, + { "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" }, + { "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies":"2", "reltype":"2", "dist":"1" }, + { "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies":"3", "reltype":"3", "dist":"2" }, + { "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies":"4", "reltype":"4", "dist":"3" }, + { "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies":"5", "reltype":"5", "dist":"4" }, + { "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies":"6", "reltype":"6", "dist":"5" }, + { "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies":"7", "reltype":"7", "dist":"6" }, + { "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies":"8", "reltype":"8", "dist":"7" }, + { "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" }, + { "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" }, + { "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" }, + { "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" }, + { "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" }, + { "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" }, + { "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" }, + { "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" }, + { "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" }, + { "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" }, + { "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" }, + { "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" }, + { "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" }, + { "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" } + + ] + + +}