#13; Interface fonctionnelle, il est possible de récupèrer indépendemment les contacts FACEBOOK/PHONE/SURVEY et en les combinant. 'download/multiple' prends les paramètres 'facebook', 'phone', 'survey' et combine les valeurs (id_sujets)
This commit is contained in:
parent
4562652a12
commit
74d7063460
15
automate.php
15
automate.php
|
@ -93,14 +93,14 @@
|
|||
/* [4] Test download via AJAX
|
||||
=========================================================*/
|
||||
// $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
||||
$req = new ModuleRequest('download/multiple', array('subjects'=>array(1, 273, 341)));
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
var_dump( array_keys($db->index()) );
|
||||
$db->close();
|
||||
|
||||
$res = $req->download();
|
||||
|
||||
if( $res->error != ManagerError::Success )
|
||||
var_dump( ManagerError::explicit($res->error) );
|
||||
|
||||
var_dump($res);
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
var_dump( array_keys($db->index()) );
|
||||
$db->close();
|
||||
|
||||
|
||||
// $start = microtime(true);
|
||||
|
@ -260,7 +260,4 @@
|
|||
//
|
||||
// $db->close();
|
||||
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
var_dump( $db->index() );
|
||||
|
||||
?>
|
||||
|
|
|
@ -254,7 +254,9 @@
|
|||
"permissions": ["admin"],
|
||||
"options": { "download": true },
|
||||
"parameters": {
|
||||
"subjects": { "description": "Identifiants des sujets à intégrer.", "type": "array<id>" }
|
||||
"phone": { "description": "Identifiants des sujets d'enquêtes téléphoniques à intégrer.", "type": "array<id>", "optional": true },
|
||||
"facebook": { "description": "Identifiants des sujets d'enquêtes téléphoniques à intégrer.", "type": "array<id>", "optional": true },
|
||||
"survey": { "description": "Identifiants des sujets d'enquêtes téléphoniques à intégrer.", "type": "array<id>", "optional": true }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,6 +121,11 @@
|
|||
public static function multiple($params){
|
||||
extract($params);
|
||||
|
||||
/* (0) Gestion du formattage des paramètres */
|
||||
$phone_subjects = !is_array($phone) ? array() : $phone;
|
||||
$facebook_subjects = !is_array($facebook) ? array() : $facebook;
|
||||
$survey_subjects = !is_array($survey) ? array() : $survey;
|
||||
|
||||
|
||||
/* [0] On récupère le dictionnaire
|
||||
=========================================================*/
|
||||
|
@ -154,9 +159,9 @@
|
|||
// On ouvre une instance de la base de données
|
||||
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
|
||||
|
||||
/* [2] On construit les fichiers de chaque sujet
|
||||
/* [2] On construit les fichiers de chaque sujet DE TELEPHONE
|
||||
=========================================================*/
|
||||
foreach($subjects as $s=>$subjectId){
|
||||
foreach($phone_subjects as $s=>$subjectId){
|
||||
|
||||
/* (1) On récupère les données du sujet en cours */
|
||||
$subjectData = $db->fetch($subjectId);
|
||||
|
@ -180,7 +185,73 @@
|
|||
$db->close();
|
||||
|
||||
|
||||
/* [3] On ajoute le dictionnaire
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// On ouvre une instance de la base de données
|
||||
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
|
||||
|
||||
/* [3] On construit les fichiers de chaque sujet DE FACEBOOK
|
||||
=========================================================*/
|
||||
foreach($facebook_subjects as $s=>$subjectId){
|
||||
|
||||
/* (1) On récupère les données du sujet en cours */
|
||||
$subjectData = $db->fetch($subjectId);
|
||||
|
||||
// Si on ne trouve rien, on passe au suivant
|
||||
if( $subjectData === false )
|
||||
continue;
|
||||
|
||||
/* (2) On complète les relations */
|
||||
$output['common_']['relations'] .= self::parseCSV($subjectData['relations'], array(), strlen($output['common_']['relations']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
||||
|
||||
/* (3) On ajoute les contacts à la liste */
|
||||
$output['common_']['contacts'] .= self::parseCSV($subjectData['contacts'], $dict['contacts'], strlen($output['common_']['contacts']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
||||
|
||||
}
|
||||
|
||||
// On ferme l'instance de la base de données
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// On ouvre une instance de la base de données
|
||||
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
|
||||
|
||||
/* [4] On construit les fichiers de chaque sujet DE FORMULAIRE
|
||||
=========================================================*/
|
||||
foreach($facebook_subjects as $s=>$subjectId){
|
||||
|
||||
/* (1) On récupère les données du sujet en cours */
|
||||
$subjectData = $db->fetch($subjectId);
|
||||
|
||||
// Si on ne trouve rien, on passe au suivant
|
||||
if( $subjectData === false )
|
||||
continue;
|
||||
|
||||
/* (2) On complète les relations */
|
||||
$output['common_']['relations'] .= self::parseCSV($subjectData['relations'], array(), strlen($output['common_']['relations']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
||||
|
||||
/* (3) On ajoute les contacts à la liste */
|
||||
$output['common_']['contacts'] .= self::parseCSV($subjectData['contacts'], $dict['contacts'], strlen($output['common_']['contacts']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
||||
|
||||
}
|
||||
|
||||
// On ferme l'instance de la base de données
|
||||
$db->close();
|
||||
|
||||
|
||||
|
||||
|
||||
/* [5] On ajoute le dictionnaire
|
||||
=========================================================*/
|
||||
$output['common_']['dict'] .= "\"sheet\";\"field\";\"key\";\"value\"\r\n";
|
||||
foreach($dict as $ds=>$dataset)
|
||||
|
@ -189,7 +260,7 @@
|
|||
$output['common_']['dict'] .= "\"$ds\";\"$f\";\"$key\";\"$value\"\r\n";
|
||||
|
||||
|
||||
/* [4] Création de l'archive
|
||||
/* [6] Création de l'archive
|
||||
=========================================================*/
|
||||
$zip = new \ZipArchive();
|
||||
$fname = '/tmp/'.time().'.zip';
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"1":{"line":0,"hash":"b4dcd4020e3843bda4df499b6af29099c0dd5f47"},"69":{"line":1,"hash":"9efeeb367af4ef8c789164647c4f5c0035878d87"},"137":{"line":2,"hash":"3b48331c50740299531e82effd3126d2ffc12e6a"}}
|
||||
{"1":{"line":0,"hash":"b4dcd4020e3843bda4df499b6af29099c0dd5f47"},"137":{"line":1,"hash":"3b48331c50740299531e82effd3126d2ffc12e6a"}}
|
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
|||
{"1":{"line":0,"hash":"423bda798fbf4363a61d945e936c6a11ce9ac057"},"69":{"line":1,"hash":"785691cf7be9f8b18eb1a298db3187bdc86c4884"},"137":{"line":2,"hash":"47fc53f817eded81eecd15b2e042722d52bd8513"},"205":{"line":3,"hash":"0a296a89a05509be912fefda7fdcc2692a244208"},"273":{"line":4,"hash":"1b9c3317ae25f49f6cfdee6aa34fcbc381c3a7a7"},"341":{"line":5,"hash":"8857d8b1c8e7fbcb455847bdf3c9fd34e34ef217"}}
|
||||
{"1":{"line":0,"hash":"423bda798fbf4363a61d945e936c6a11ce9ac057"},"69":{"line":1,"hash":"785691cf7be9f8b18eb1a298db3187bdc86c4884"},"205":{"line":2,"hash":"0a296a89a05509be912fefda7fdcc2692a244208"},"273":{"line":3,"hash":"1b9c3317ae25f49f6cfdee6aa34fcbc381c3a7a7"},"341":{"line":4,"hash":"8857d8b1c8e7fbcb455847bdf3c9fd34e34ef217"}}
|
|
@ -0,0 +1 @@
|
|||
[]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
header("Content-Type: application/zip; charset=utf-8");
|
||||
header("Content-Disposition: attachment; filename=export_21_05_2016_.zip");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
readfile('/var/www/socioview/tmp/content_57406292d5726.php');
|
||||
unlink('/var/www/socioview/tmp/content_57406292d5726.php');
|
||||
unlink(__FILE__);
|
||||
?>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
header("Content-Type: application/zip; charset=utf-8");
|
||||
header("Content-Disposition: attachment; filename=export_21_05_2016_.zip");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
readfile('/var/www/socioview/tmp/content_57406350c8e54.php');
|
||||
unlink('/var/www/socioview/tmp/content_57406350c8e54.php');
|
||||
unlink(__FILE__);
|
||||
?>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
header("Content-Type: application/zip; charset=utf-8");
|
||||
header("Content-Disposition: attachment; filename=export_21_05_2016_.zip");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
readfile('/var/www/socioview/tmp/content_574063b253600.php');
|
||||
unlink('/var/www/socioview/tmp/content_574063b253600.php');
|
||||
unlink(__FILE__);
|
||||
?>
|
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
header("Content-Type: application/zip; charset=utf-8");
|
||||
header("Content-Disposition: attachment; filename=export_21_05_2016_.zip");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
readfile('/var/www/socioview/tmp/content_574063c5818b3.php');
|
||||
unlink('/var/www/socioview/tmp/content_574063c5818b3.php');
|
||||
unlink(__FILE__);
|
||||
?>
|
|
@ -1,2 +1,3 @@
|
|||
var subjectList=$("#subject-list"),subjectAdd=$("#add-subject"),exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);subjectAdd.addEventListener("click",function(a){a=document.createElement("input");a.type="number";a.dataset.name="subjects";a.placeholder="Sujet";a.style="width: 5em; display: block;";subjectList.appendChild(a)},!1);
|
||||
$("#export-form #export-all").addEventListener("click",function(a){var b=(new FormDeflater(subjectList,["input"],["data-name"])).deflate().subjects;a=[];for(var c=0;c<b.length;c++)0<b[c].length&&!isNaN(b[c])&&a.push(b[c]);b=exportDeflater.deflate();"1"!=b.phone&&"1"!=b.facebook||api.send({path:"download/multiple",subjects:a},function(a){if(0!=a.ModuleError)return!1;document.location=a.link;Notification.success("OK","Lancement du t\u00e9l\u00e9chargement..")})},!1);
|
||||
$("#export-form #export-all").addEventListener("click",function(a){var b=(new FormDeflater(subjectList,["input"],["data-name"])).deflate().subjects;a=[];b instanceof Array||(b=[b]);for(var c=0;c<b.length;c++)0<b[c].length&&!isNaN(b[c])&&a.push(b[c]);b=exportDeflater.deflate();c={path:"download/multiple"};"1"==b.phone&&(c.phone=a);"1"==b.facebook&&(c.facebook=a);"1"==b.survey&&(c.survey=a);api.send(c,function(a){if(0!=a.ModuleError)return!1;document.location=a.link;Notification.success("OK","Lancement du t\u00e9l\u00e9chargement..")})},
|
||||
!1);
|
||||
|
|
|
@ -36,29 +36,45 @@ $('#export-form #export-all').addEventListener('click', function(e){
|
|||
|
||||
// {2} On supprime les valeurs incorrectes //
|
||||
var subjects = [];
|
||||
// Si on a q'une valeur, on la met en tableau
|
||||
if( !(subjectDeflated instanceof Array) )
|
||||
subjectDeflated = [subjectDeflated];
|
||||
|
||||
for( var i = 0 ; i < subjectDeflated.length ; i++ )
|
||||
if( subjectDeflated[i].length > 0 && !isNaN(subjectDeflated[i]) )
|
||||
subjects.push( subjectDeflated[i] );
|
||||
|
||||
|
||||
// {3} On récupère les types de données que l'on veut //
|
||||
var deflated = exportDeflater.deflate();
|
||||
|
||||
// {4} Si téléchargement de données //
|
||||
if( deflated.phone == '1' || deflated.facebook == '1' ){
|
||||
|
||||
/* (4) On construit la requête */
|
||||
var request = { path: 'download/multiple' };
|
||||
|
||||
// Si données CELLULAIRES
|
||||
if( deflated.phone == '1' )
|
||||
request.phone = subjects;
|
||||
|
||||
// Si données FACEBOOK
|
||||
if( deflated.facebook == '1' )
|
||||
request.facebook = subjects;
|
||||
|
||||
// Si données QUESTIONNAIRES
|
||||
if( deflated.survey == '1' )
|
||||
request.survey = subjects;
|
||||
|
||||
|
||||
api.send({ 'path': 'download/multiple', 'subjects': subjects }, function(res){
|
||||
/* (5) On lance la requête */
|
||||
api.send(request, function(res){
|
||||
|
||||
// Si erreur
|
||||
if( res.ModuleError != 0 )
|
||||
return false;
|
||||
// Si erreur
|
||||
if( res.ModuleError != 0 )
|
||||
return false;
|
||||
|
||||
// Sinon on lance le téléchargement
|
||||
document.location = res.link;
|
||||
// Sinon on lance le téléchargement
|
||||
document.location = res.link;
|
||||
|
||||
Notification.success('OK', 'Lancement du téléchargement..');
|
||||
});
|
||||
Notification.success('OK', 'Lancement du téléchargement..');
|
||||
});
|
||||
|
||||
}
|
||||
}, false);
|
||||
|
|
Loading…
Reference in New Issue