Merge branch 'dev' of https://git.xdrm.io/xdrm-brackets/nxtic
This commit is contained in:
commit
7526e780ad
|
@ -1,3 +1,5 @@
|
||||||
.ftpconfig
|
.ftpconfig
|
||||||
sftp-config.json
|
sftp-config.json
|
||||||
phpunit/coverage/
|
phpunit/coverage/
|
||||||
|
#/public_html/tmp/*
|
||||||
|
#/build/lightdb/storage/*/data
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
/* [1] On definit les chemins absolus si c'est pas deja fait
|
/* [1] On definit les chemins absolus si c'est pas deja fait
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) );
|
if( !defined('__ROOT__') ) define('__ROOT__', dirname(__FILE__) );
|
||||||
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
|
if( !defined('__CONFIG__') ) define('__CONFIG__', __ROOT__.'/config' );
|
||||||
if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' );
|
if( !defined('__BUILD__') ) define('__BUILD__', __ROOT__.'/build' );
|
||||||
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
|
if( !defined('__PUBLIC__') ) define('__PUBLIC__', __ROOT__.'/public_html' );
|
||||||
if( !defined('__TMP__') ) define('__TMP__', __ROOT__.'/public_html/tmp' );
|
if( !defined('__TMP__') ) define('__TMP__', __ROOT__.'/public_html/tmp' );
|
||||||
|
|
||||||
|
|
||||||
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
|
/* ACTIVE LE DEBUGGAGE (WARNING + EXCEPTION)
|
||||||
|
|
|
@ -193,12 +193,12 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( $fromAjax ){
|
if( $fromAjax ){
|
||||||
|
|
||||||
|
$tmpfname = 'download_'.uniqid().'.php';
|
||||||
$tmpfname = '/tmp/download_'.uniqid().'.php';
|
$link = '/tmp/'.$tmpfname;
|
||||||
$bodyfname = __BUILD__.'/tmp/content_'.uniqid().'.php';
|
$bodyfname = __TMP__.'/content_'.uniqid().'.php';
|
||||||
|
|
||||||
/* (1) On crée le fichier temporaire */
|
/* (1) On crée le fichier temporaire */
|
||||||
$tmpfnameroot = __BUILD__.$tmpfname;
|
$tmpfnameroot = __TMP__.'/'.$tmpfname;
|
||||||
$tmpfile = fopen($tmpfnameroot, 'w');
|
$tmpfile = fopen($tmpfnameroot, 'w');
|
||||||
|
|
||||||
fwrite($tmpfile, '<?php'.PHP_EOL);
|
fwrite($tmpfile, '<?php'.PHP_EOL);
|
||||||
|
@ -227,7 +227,7 @@
|
||||||
chmod($tmpfnameroot, 0775);
|
chmod($tmpfnameroot, 0775);
|
||||||
|
|
||||||
$response = new ModuleResponse(ManagerError::Success);
|
$response = new ModuleResponse(ManagerError::Success);
|
||||||
$response->append('link', $tmpfname);
|
$response->append('link', $link);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
|
|
||||||
|
|
|
@ -130,9 +130,6 @@
|
||||||
/* DOWNLOAD D'UN FICHIER CONTENANT LES DONNEES SELECTIONNEES
|
/* DOWNLOAD D'UN FICHIER CONTENANT LES DONNEES SELECTIONNEES
|
||||||
*
|
*
|
||||||
* @subjects<Array> Liste des identifiants des sujets à prendre en compte
|
* @subjects<Array> Liste des identifiants des sujets à prendre en compte
|
||||||
* @phone<Boolean> Si TRUE, prend en compte les données des questionnaires cellulaires
|
|
||||||
* @facebook<Boolean> Si TRUE, prend en compte les données des questionnaires facebook
|
|
||||||
* @survey<Boolean> Si TRUE, prend en compte les données des questionnaires ResTIC
|
|
||||||
* @all<Boolean> Si TRUE, prend en compte tous les sujets (annule @subjects)
|
* @all<Boolean> Si TRUE, prend en compte tous les sujets (annule @subjects)
|
||||||
*
|
*
|
||||||
* @return data<File> Retourne une archive .zip contenant toutes les données sélectionnées
|
* @return data<File> Retourne une archive .zip contenant toutes les données sélectionnées
|
||||||
|
@ -142,15 +139,12 @@
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
/* (0) Gestion du formattage des paramètres */
|
/* (0) Gestion du formattage des paramètres */
|
||||||
$subjects = !is_array($subjects) ? [] : $subjects;
|
$subjects = !is_array($subjects) ? [] : $subjects;
|
||||||
$phone = !is_bool($phone) ? false : $phone;
|
$all = !is_bool($all) ? false : $all;
|
||||||
$facebook = !is_bool($facebook) ? false : $facebook;
|
|
||||||
$survey = !is_bool($survey) ? false : $survey;
|
|
||||||
$all = !is_bool($all) ? false : $all;
|
|
||||||
|
|
||||||
/* [0] On récupère le dictionnaire
|
/* [0] On récupère le dictionnaire
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$dict = file_get_contents(__BUILD__.'/src/dynamic/dictionary.json');
|
$dict = file_get_contents(__BUILD__.'/lightdb/storage/dictionary.json');
|
||||||
|
|
||||||
/* (2) Si une erreur pour le fichier de conf */
|
/* (2) Si une erreur pour le fichier de conf */
|
||||||
if( $dict === false )
|
if( $dict === false )
|
||||||
|
@ -164,158 +158,113 @@
|
||||||
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
return [ 'ModuleError' => ManagerError::ParsingFailed ];
|
||||||
|
|
||||||
|
|
||||||
/* [1] On construit l'arborescence des données
|
/* [1] Initialisation
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
/* (1) Fichiers de sortie */
|
||||||
$output = [
|
$output = [
|
||||||
'common_' => [
|
'contacts.fiche' => '', // contiendra les contacts et leurs données fiches
|
||||||
'contacts' => '',
|
'contacts.mini' => '', // contiendra les contacts et leurs données mini
|
||||||
'relations' => '',
|
'relations' => '', // contiendra les relations
|
||||||
'dict' => ''
|
'dict' => '' // contiendra le dictionnaire de valeurs
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/* (2) Base de données */
|
||||||
|
$subjectdb = new lightdb('subject');
|
||||||
|
$contactdb = new lightdb('contact');
|
||||||
|
|
||||||
|
|
||||||
/* [2] On construit les fichiers de chaque sujet DE TELEPHONE
|
/* [2] On construit la liste des sujets
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( $phone ){ // Si @phone vaut TRUE
|
$subjectindexes = array_keys($subjectdb->index());
|
||||||
|
$subjectids = [];
|
||||||
|
|
||||||
// On ouvre une instance de la base de données
|
/* (1) On récupère tous les sujets si c'est spécifié */
|
||||||
$db = new lightdb('phone_db');
|
if( $all )
|
||||||
|
|
||||||
// Si on doit prendre tous les sujets, on les récupère
|
$subjectids = $subjectindexes;
|
||||||
if( $all )
|
|
||||||
$subjects = array_keys( $db->index() );
|
|
||||||
|
|
||||||
// Pour chaque sujet
|
/* (2) Sinon on retire les ids incorrects */
|
||||||
foreach($subjects as $s=>$subjectId){
|
else
|
||||||
|
|
||||||
/* (1) On récupère les données du sujet en cours */
|
foreach($subjects as $i=>$id)
|
||||||
$subjectData = $db->fetch($subjectId);
|
if( in_array($id, $subjectindexes) )
|
||||||
|
$subjectids[] = intval($id);
|
||||||
|
|
||||||
// Si on ne trouve rien, on passe au suivant
|
|
||||||
if( $subjectData === false )
|
|
||||||
|
/* (3) Si aucun sujet restant -> error */
|
||||||
|
if( count($subjectids) === 0 )
|
||||||
|
return ['ModuleError' => ManagerError::ParamError];
|
||||||
|
|
||||||
|
|
||||||
|
/* [3] Export contacts/relations des sujets selectionnés
|
||||||
|
=========================================================*/
|
||||||
|
foreach($subjectids as $subid){
|
||||||
|
|
||||||
|
/* (1) On récupère les données du sujet */
|
||||||
|
$subject = $subjectdb->fetch($subid);
|
||||||
|
|
||||||
|
// si pas trouvé -> suivant
|
||||||
|
if( $subject === false )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* (2) Si aucun contact -> suivant */
|
||||||
|
if( !isset($subject['contacts']) || !is_array($subject['contacts']) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* (3) Pour chaque contact */
|
||||||
|
foreach($subject['contacts'] as $c=>$contactid){
|
||||||
|
|
||||||
|
// {3.1} On récupère le contact //
|
||||||
|
$contact = $contactdb->fetch($contactid);
|
||||||
|
|
||||||
|
// si pas trouvé -> suivant
|
||||||
|
if( $contact === false )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* (3) On complète les relations */
|
// {3.2} On ajoute le contact au fichier des FICHES //
|
||||||
$output['common_']['relations'] .= self::parseCSV($subjectData['relations'], [], strlen($output['common_']['relations']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
if( array_key_exists('studies2', $contact) )
|
||||||
|
// On affiche les colonnes pour le premier contact uniquement
|
||||||
|
$output['contacts.fiche'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['contacts.fiche']) == 0 );
|
||||||
|
|
||||||
/* (4) On ajoute les contacts à la liste */
|
// {3.3} On ajoute le contact au fichier des MINI //
|
||||||
$output['common_']['contacts'] .= self::parseCSV($subjectData['contacts'], $dict['contacts'], strlen($output['common_']['contacts']) == 0 ); // On affiche les colonnes pour la première fois uniquement
|
if( array_key_exists('studies1', $contact) )
|
||||||
|
// On affiche les colonnes pour le premier contact uniquement
|
||||||
|
$output['contacts.mini'] .= self::parseCSV([$contact], $dict['contacts'], strlen($output['contacts.mini']) == 0 );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On ferme l'instance de la base de données
|
/* (4) Si aucune relation -> suivant */
|
||||||
$db->close();
|
if( !isset($subject['relations']) || !is_array($subject['relations']) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* (5) On ajoute les relations */
|
||||||
|
$output['relations'] .= self::parseCSV($subject['relations'], [], strlen($output['relations']) == 0 );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] On construit les fichiers de chaque sujet DE FACEBOOK
|
|
||||||
=========================================================*/
|
|
||||||
if( $facebook ){ // Si @facebook vaut TRUE
|
|
||||||
|
|
||||||
// On ouvre une instance de la base de données
|
|
||||||
$db = new lightdb('facebook_db');
|
|
||||||
|
|
||||||
// Si on doit prendre tous les sujets, on les récupère
|
|
||||||
if( $all )
|
|
||||||
$subjects = array_keys( $db->index() );
|
|
||||||
|
|
||||||
// Pour chaque sujet
|
|
||||||
foreach($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'], [], 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();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] On construit les fichiers de chaque sujet DE FORMULAIRE
|
|
||||||
=========================================================*/
|
|
||||||
if( $survey ){ // Si @survey vaut TRUE
|
|
||||||
|
|
||||||
// On ouvre une instance de la base de données
|
|
||||||
$db = new lightdb('survey_db');
|
|
||||||
|
|
||||||
// Si on doit prendre tous les sujets, on les récupère
|
|
||||||
if( $all )
|
|
||||||
$subjects = array_keys( $db->index() );
|
|
||||||
|
|
||||||
// Pour chaque sujet
|
|
||||||
foreach($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'], [], 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
|
/* [5] On ajoute le dictionnaire
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$output['common_']['dict'] .= "\"sheet\";\"field\";\"key\";\"value\"\r\n";
|
$output['dict'] .= "\"sheet\";\"field\";\"key\";\"value\"\r\n";
|
||||||
foreach($dict as $ds=>$dataset)
|
foreach($dict as $ds=>$dataset)
|
||||||
foreach($dataset as $f=>$field)
|
foreach($dataset as $f=>$field)
|
||||||
foreach($field as $key=>$value)
|
foreach($field as $key=>$value)
|
||||||
$output['common_']['dict'] .= "\"$ds\";\"$f\";\"$key\";\"$value\"\r\n";
|
$output['dict'] .= "\"$ds\";\"$f\";\"$key\";\"$value\"\r\n";
|
||||||
|
|
||||||
|
|
||||||
/* [6] Création de l'archive
|
/* [6] Création de l'archive
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$fname = '/tmp/'.time().'.zip';
|
$fname = __TMP__.'/'.time().'.zip';
|
||||||
$zip->open($fname, \ZipArchive::CREATE);
|
$zip->open($fname, \ZipArchive::CREATE);
|
||||||
|
|
||||||
foreach($output as $folder=>$files){
|
|
||||||
|
|
||||||
foreach($files as $file=>$content)
|
foreach($output as $file=>$content)
|
||||||
if( strlen($content) > 0 )
|
if( strlen($content) > 0 )
|
||||||
$zip->addFromString($folder.$file.'.csv', $content);
|
$zip->addFromString($file.'.csv', $content);
|
||||||
}
|
|
||||||
|
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
|
||||||
|
@ -565,7 +514,7 @@
|
||||||
/* [6] Création de l'archive
|
/* [6] Création de l'archive
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$zip = new \ZipArchive();
|
$zip = new \ZipArchive();
|
||||||
$fname = '/tmp/'.time().'.zip';
|
$fname = __TMP__.'/'.time().'.zip';
|
||||||
$zip->open($fname, \ZipArchive::CREATE);
|
$zip->open($fname, \ZipArchive::CREATE);
|
||||||
|
|
||||||
foreach($output as $folder=>$files){
|
foreach($output as $folder=>$files){
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -38,7 +38,7 @@
|
||||||
/* [1] On récupére la liste des sujets
|
/* [1] On récupére la liste des sujets
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('survey_db');
|
$db = new lightdb('subject');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On récupère tous les sujets */
|
/* (2) On récupère tous les sujets */
|
||||||
|
@ -47,37 +47,18 @@
|
||||||
|
|
||||||
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
||||||
$subjects[$id] = $sub;
|
$subjects[$id] = $sub;
|
||||||
}
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
|
/* (3) Si enquête PHONE passée */
|
||||||
/* [2] On récupére la liste des sujets pour PHONE
|
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('phone', $sub['surveys']) )
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('phone_db');
|
|
||||||
$ids = array_keys( $db->index() );
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
|
||||||
foreach($subjects as $id=>$data)
|
|
||||||
if( in_array($id, $ids) ) // Si dans phone
|
|
||||||
$subjects[$id]['phone'] = true;
|
$subjects[$id]['phone'] = true;
|
||||||
|
|
||||||
|
/* (4) Si enquête FACEBOOK passée */
|
||||||
|
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('facebook', $sub['surveys']) )
|
||||||
|
|
||||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('facebook_db');
|
|
||||||
$ids = array_keys( $db->index() );
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
|
||||||
foreach($subjects as $id=>$data)
|
|
||||||
if( in_array($id, $ids) ) // Si dans facebook
|
|
||||||
$subjects[$id]['facebook'] = true;
|
$subjects[$id]['facebook'] = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
/* [4] Gestion du retour
|
/* [4] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
|
@ -102,12 +83,12 @@
|
||||||
|
|
||||||
|
|
||||||
// Contiendra les sujets
|
// Contiendra les sujets
|
||||||
$subjects = [];
|
$contacts = [];
|
||||||
|
|
||||||
/* [1] On récupére la liste des sujets
|
/* [1] On récupére la liste des sujets
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('survey_db');
|
$db = new lightdb('subject');
|
||||||
$fetch = $db->fetch($subject_id);
|
$fetch = $db->fetch($subject_id);
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
@ -116,44 +97,29 @@
|
||||||
return [ 'ModuleError' => ManagerError::ModuleError ];
|
return [ 'ModuleError' => ManagerError::ModuleError ];
|
||||||
|
|
||||||
/* (3) On enregistre ses contacts s'il en a */
|
/* (3) On enregistre ses contacts s'il en a */
|
||||||
if( isset($fetch['contacts']) )
|
$db = new lightdb('contact');
|
||||||
foreach($fetch['contacts'] as $contact)
|
|
||||||
$subjects[$contact['id']] = $contact;
|
|
||||||
|
|
||||||
|
if( isset($fetch['contacts']) ){
|
||||||
|
|
||||||
/* [2] On récupére la liste des contacts saisis dans PHONE
|
foreach($fetch['contacts'] as $contactId){
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
$contact = $db->fetch($contactId);
|
||||||
$db = new lightdb('phone_db');
|
// si le contact n'est pas trouvé -> passe au suivant
|
||||||
$fetch = $db->fetch($subject_id);
|
if( $contact === false )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$contacts[$contactId] = $contact;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
/* (2) Si on trouve des contacts, on les ajoute */
|
|
||||||
if( $fetch !== false && isset($fetch['contacts']) )
|
|
||||||
foreach($fetch['contacts'] as $contact)
|
|
||||||
$subjects[$contact['id']] = $contact;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('facebook_db');
|
|
||||||
$fetch = $db->fetch($subject_id);
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
/* (2) Si on trouve des contacts, on les ajoute */
|
|
||||||
if( $fetch !== false && isset($fetch['contacts']) )
|
|
||||||
foreach($fetch['contacts'] as $contact)
|
|
||||||
$subjects[$contact['id']] = $contact;
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Gestion du retour
|
/* [4] Gestion du retour
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
'ModuleError' => ManagerError::Success,
|
'ModuleError' => ManagerError::Success,
|
||||||
'subjects' => $subjects
|
'subjects' => $contacts
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,13 +155,14 @@
|
||||||
$data = [ 'subject' => [
|
$data = [ 'subject' => [
|
||||||
'id' => $newId,
|
'id' => $newId,
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'creation' => time()
|
'creation' => time(),
|
||||||
|
'surveys' => []
|
||||||
]];
|
]];
|
||||||
|
|
||||||
/* [2] On crée le sujet dans SURVEYS
|
/* [2] On crée le sujet dans SURVEYS
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('survey_db');
|
$db = new lightdb('subject');
|
||||||
$db->insert( $newId, $data );
|
$db->insert( $newId, $data );
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
@ -256,7 +223,7 @@
|
||||||
/* [1] On récupére la liste des sujets
|
/* [1] On récupére la liste des sujets
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On initialise et ouvre la bd */
|
/* (1) On initialise et ouvre la bd */
|
||||||
$db = new lightdb('survey_db');
|
$db = new lightdb('subject');
|
||||||
$ids = array_keys( $db->index() );
|
$ids = array_keys( $db->index() );
|
||||||
|
|
||||||
/* (2) On récupère tous les sujets */
|
/* (2) On récupère tous les sujets */
|
||||||
|
@ -266,41 +233,18 @@
|
||||||
|
|
||||||
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
|
||||||
$subjects[$id] = $sub;
|
$subjects[$id] = $sub;
|
||||||
|
|
||||||
|
/* (3) Si enquête PHONE passée */
|
||||||
|
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('phone', $sub['surveys']) )
|
||||||
|
$subjects[$id]['phone'] = true;
|
||||||
|
|
||||||
|
/* (4) Si enquête FACEBOOK passée */
|
||||||
|
if( isset($sub['surveys']) && is_array($sub['surveys']) && in_array('facebook', $sub['surveys']) )
|
||||||
|
$subjects[$id]['facebook'] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
/* [2] On récupére la liste des sujets pour PHONE
|
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('phone_db');
|
|
||||||
$ids = array_keys( $db->index() );
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
/* (2) Si un des sujets de 'survey' est dans PHONE, on ajoute la mention */
|
|
||||||
foreach($subjects as $id=>$data)
|
|
||||||
if( in_array($id, $ids) ) // Si dans phone
|
|
||||||
$subjects[$id]['phone'] = true;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] On récupére la liste des sujets pour FACEBOOK
|
|
||||||
=========================================================*/
|
|
||||||
/* (1) On initialise et ouvre la bd */
|
|
||||||
$db = new lightdb('facebook_db');
|
|
||||||
$ids = array_keys( $db->index() );
|
|
||||||
$db->close();
|
|
||||||
|
|
||||||
/* (2) Si un des sujets de 'survey' est dans FACBEOOK, on ajoute la mention */
|
|
||||||
foreach($subjects as $id=>$data)
|
|
||||||
if( in_array($id, $ids) ) // Si dans facebook
|
|
||||||
$subjects[$id]['facebook'] = true;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [4] Retour des données
|
/* [4] Retour des données
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -70,8 +70,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EFFECTUE UN UPLOAD D'UN fichier
|
/* EFFECTUE UN UPLOAD D'UN fichier
|
||||||
*
|
*
|
||||||
* @prefix<String> Préfixe (dossier parent) du fichier
|
* @prefix<String> Préfixe (dossier parent) du fichier
|
||||||
|
@ -125,20 +123,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL
|
/* IMPORT D'UNE SAUVEGARDE DE FORMULAIRE LOCAL
|
||||||
*
|
*
|
||||||
* @file<FILE> Pointeur vers $_FILES['']
|
* @file<FILE> Pointeur vers $_FILES['']
|
||||||
|
@ -291,31 +275,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,14 @@
|
||||||
class lightdb{
|
class lightdb{
|
||||||
|
|
||||||
// REPERTOIRE RACINE DE TOUTES LES BDD
|
// REPERTOIRE RACINE DE TOUTES LES BDD
|
||||||
public static function default_root(){ return __BUILD__.'/lightdb/storage/'; }
|
public static function default_root(){ return __BUILD__.'/lightdb/storage'; }
|
||||||
|
|
||||||
// ATTRIBUTS
|
// ATTRIBUTS
|
||||||
private $root;
|
private $root;
|
||||||
private $dbname;
|
private $dbname;
|
||||||
private $dir;
|
private $dir;
|
||||||
private $index;
|
private $index;
|
||||||
|
private $date;
|
||||||
private $driver;
|
private $driver;
|
||||||
private $line;
|
private $line;
|
||||||
|
|
||||||
|
@ -53,17 +54,18 @@
|
||||||
$index = json_decode( $fIndex->fgets(), true );
|
$index = json_decode( $fIndex->fgets(), true );
|
||||||
|
|
||||||
// Si erreur de parsage, on retourne une erreur
|
// Si erreur de parsage, on retourne une erreur
|
||||||
if( is_null($index) ) return;
|
if( is_null($index) ) throw new \Exception('[lightdb] index is null');
|
||||||
$this->index = $index;
|
$this->index = $index;
|
||||||
|
|
||||||
/* [3] Initialisation du gestionnaire d'acces (SplFileObject)
|
/* [3] Initialisation du gestionnaire d'acces (SplFileObject)
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) Si le fichier n'existe pas, on le crée */
|
/* (1) Si le fichier n'existe pas, on le crée */
|
||||||
if( !file_exists($this->dir.'data') )
|
$this->data = $this->dir.'data';
|
||||||
file_put_contents($this->dir.'data', '' );
|
if( !file_exists($this->data) )
|
||||||
|
file_put_contents($this->data, '' );
|
||||||
|
|
||||||
/* (2) On place un 'driver' sur le fichier */
|
/* (2) On place un 'driver' sur le fichier */
|
||||||
$this->driver = new \SplFileObject($this->dir.'data', 'r+');
|
$this->driver = new \SplFileObject($this->data, 'r+');
|
||||||
// $this->driver->setFlags( \SplFileObject::SKIP_EMPTY );
|
// $this->driver->setFlags( \SplFileObject::SKIP_EMPTY );
|
||||||
|
|
||||||
/* (3) On récupère le nombre de lignes */
|
/* (3) On récupère le nombre de lignes */
|
||||||
|
@ -75,19 +77,39 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function close(){ $this->driver = null; }
|
public function close(){ $this->driver = null; }
|
||||||
|
|
||||||
/* RETOURNE LA LISTE DES INDEX
|
|
||||||
|
|
||||||
|
|
||||||
|
/* FLUSH LA BDD (erase all)
|
||||||
*
|
*
|
||||||
* @i<String> Index pour lequel on veut la ligne et le hash
|
*/
|
||||||
|
public function flush(){
|
||||||
|
/* (1) On flush les index */
|
||||||
|
$fIndex = new \SplFileObject($this->dir.'index', 'w');
|
||||||
|
$fIndex->fwrite('[]');
|
||||||
|
$fIndex = null;
|
||||||
|
$this->line = 0;
|
||||||
|
$this->index = [];
|
||||||
|
|
||||||
|
/* (2) On flush les data */
|
||||||
|
file_put_contents($this->dir.'data', '' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* RETOURNE UN INDEX
|
||||||
|
*
|
||||||
|
* @i<String> [OPT] Index pour lequel on veut la ligne et le hash
|
||||||
*
|
*
|
||||||
* @return Index<Array> Tableau associatif contenant le hash et la ligne
|
* @return Index<Array> Tableau associatif contenant le hash et la ligne
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function index($i=null){
|
public function index($i=null){
|
||||||
return is_numeric($i) ? $this->index : $this->index;
|
return is_numeric($i) ? $this->index[$i] : $this->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,8 +140,8 @@
|
||||||
|
|
||||||
/* (3) On enregistre l'index */
|
/* (3) On enregistre l'index */
|
||||||
$this->index[$key] = [
|
$this->index[$key] = [
|
||||||
'line' => $this->line - 1,
|
'line' => $this->line - 1//,
|
||||||
'hash' => sha1($json_data)
|
//'hash' => sha1($json_data)
|
||||||
];
|
];
|
||||||
|
|
||||||
/* (4) On enregistre le fichier index */
|
/* (4) On enregistre le fichier index */
|
||||||
|
@ -156,8 +178,8 @@
|
||||||
|
|
||||||
/* (3) On enregistre les index */
|
/* (3) On enregistre les index */
|
||||||
$this->index[$key] = [
|
$this->index[$key] = [
|
||||||
'line' => $this->line - 1,
|
'line' => $this->line - 1//,
|
||||||
'hash' => sha1($json_data)
|
//'hash' => sha1($json_data)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,12 +276,14 @@
|
||||||
$this->driver->seek(0);
|
$this->driver->seek(0);
|
||||||
|
|
||||||
// On recopie toutes les lignes sauf celle à supprimer dans un fichier temporaire
|
// On recopie toutes les lignes sauf celle à supprimer dans un fichier temporaire
|
||||||
while( $this->driver->key() < $this->line ){
|
foreach($this->driver as $key=>$content){
|
||||||
|
// Only valuable lines (not the last linebreak)
|
||||||
|
if( $key >= $this->line ) break;
|
||||||
|
|
||||||
if( $this->driver->key() != $line )
|
// On n'écrit pas la ligne à supprimer
|
||||||
$tmpfile->fwrite( $this->driver->current() );
|
if( $key != $line )
|
||||||
|
$tmpfile->fwrite( $content );
|
||||||
|
|
||||||
$this->driver->next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// On décrémente le nb de lignes
|
// On décrémente le nb de lignes
|
||||||
|
@ -313,6 +337,9 @@
|
||||||
$keyLines[$key] = $this->index[$key]['line'];
|
$keyLines[$key] = $this->index[$key]['line'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( count($keyLines) == 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
/* [2] On trie les clés en fonction de leur ligne
|
/* [2] On trie les clés en fonction de leur ligne
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
$sorted = [];
|
$sorted = [];
|
||||||
|
@ -343,13 +370,14 @@
|
||||||
$this->driver->seek(0);
|
$this->driver->seek(0);
|
||||||
|
|
||||||
/* (2) On recopie toutes les lignes sauf celles à supprimer dans un fichier temporaire */
|
/* (2) On recopie toutes les lignes sauf celles à supprimer dans un fichier temporaire */
|
||||||
while( $this->driver->key() < $this->line ){
|
foreach($this->driver as $key=>$content){
|
||||||
|
// Only valuable lines (not the last linebreak)
|
||||||
|
if( $key >= $this->line ) break;
|
||||||
|
|
||||||
// Si la ligne en cours n'est pas dans la liste des lignes à supprimer
|
// On n'écrit pas la ligne à supprimer
|
||||||
if( !in_array($this->driver->key(), $sorted) )
|
if( !in_array($key, $sorted) )
|
||||||
$tmpfile->fwrite( $this->driver->current() ); // On l'écrit dans le nouveau fichier
|
$tmpfile->fwrite( $content );
|
||||||
|
|
||||||
$this->driver->next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpfile = null;
|
$tmpfile = null;
|
||||||
|
@ -388,46 +416,4 @@
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* RENVOIE LES DONNEES ASSOCIEES A UN CHAMP DE RECHERCHE
|
|
||||||
*
|
|
||||||
* @nomParam<typeParam> Description du param
|
|
||||||
*
|
|
||||||
* @return nomRetour<typeRetour> Description du retour
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public function filter($data){
|
|
||||||
/* (1) Si @data est un tableau associatif */
|
|
||||||
if( is_array($data) ){
|
|
||||||
|
|
||||||
$filtered = [];
|
|
||||||
foreach($this->index as $i=>$indexData){
|
|
||||||
$this->driver->seek( $indexData['line'] );
|
|
||||||
$dbData = json_decode( $this->driver->fgets(), true );
|
|
||||||
|
|
||||||
foreach($data as $key=>$value)
|
|
||||||
if( isset($dbData[$key]) && preg_match("#$value#", $dbData[$key]) ){
|
|
||||||
$filtered[$i] = $dbData;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $filtered;
|
|
||||||
|
|
||||||
|
|
||||||
/* (2) Sinon on compare @data en tant que valeur simple */
|
|
||||||
}else{
|
|
||||||
|
|
||||||
$this->tmp = sha1( json_encode($data) );
|
|
||||||
return array_filter($this->index, [$this, 'simpleFilter']);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
protected function simpleFilter($e){ return $e['hash'] == $this->tmp; }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
{"id":2,"name":"contact-x","sexe":"1","age":"6","studies2":"01","reltype":"7","dist":"1","job":"82","famsit":"0","city":"35","cp":"10025","quartier":"25","duration":["25","125"],"context":"11","contextExtra":["internet","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":3,"name":"contact-1","sexe":"0","age":"6","studies2":"06","reltype":"6","dist":"2","job":"36","famsit":"0","city":"16","cp":"10006","quartier":"6","duration":["6","16"],"context":"6","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":4,"name":"contact-2","sexe":"1","age":"7","studies2":"07","reltype":"7","dist":"3","job":"41","famsit":"0","city":"17","cp":"10007","quartier":"7","duration":["7","17"],"context":"7","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":5,"name":"contact-3","sexe":"2","age":"8","studies2":"08","reltype":"autre","dist":"0","job":"46","famsit":"0","city":"18","cp":"10008","quartier":"8","duration":["8","18"],"context":"8","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":6,"name":"contact-4","sexe":"0","age":"9","studies2":"09","reltype":"0","dist":"1","job":"47","famsit":"0","city":"19","cp":"10009","quartier":"9","duration":["9","19"],"context":"9","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":7,"name":"contact-5","sexe":"1","age":"10","studies2":"10","reltype":"1","dist":"2","job":"48","famsit":"0","city":"20","cp":"10010","quartier":"10","duration":["10","110"],"context":"10","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":8,"name":"contact-6","sexe":"2","age":"11","studies2":"11","reltype":"2","dist":"3","job":"51","famsit":"0","city":"21","cp":"10011","quartier":"11","duration":["11","111"],"context":"11","contextExtra":["internet","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":9,"name":"contact-7","sexe":"0","age":"12","studies2":"","reltype":"3","dist":"0","job":"54","famsit":"0","city":"22","cp":"10012","quartier":"12","duration":["12","112"],"context":"12","contextExtra":["","association",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":10,"name":"contact-8","sexe":"1","age":"13","studies2":"01","reltype":"4","dist":"1","job":"55","famsit":"0","city":"23","cp":"10013","quartier":"13","duration":["13","113"],"context":"13","contextExtra":["","","autre"],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":11,"name":"contact-9","sexe":"2","age":"14","studies2":"02","reltype":"5","dist":"2","job":"56","famsit":"0","city":"24","cp":"10014","quartier":"14","duration":["14","114"],"context":"0","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":12,"name":"contact-10","sexe":"0","age":"15","studies2":"03","reltype":"6","dist":"3","job":"61","famsit":"0","city":"25","cp":"10015","quartier":"15","duration":["15","115"],"context":"1","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":13,"name":"contact-11","sexe":"1","age":"16","studies2":"04","reltype":"7","dist":"0","job":"66","famsit":"0","city":"26","cp":"10016","quartier":"16","duration":["16","116"],"context":"2","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":14,"name":"contact-12","sexe":"2","age":"17","studies2":"05","reltype":"autre","dist":"1","job":"69","famsit":"0","city":"27","cp":"10017","quartier":"17","duration":["17","117"],"context":"3","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":15,"name":"contact-13","sexe":"0","age":"18","studies2":"06","reltype":"0","dist":"2","job":"71","famsit":"0","city":"28","cp":"10018","quartier":"18","duration":["18","118"],"context":"4","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":16,"name":"contact-14","sexe":"1","age":"0","studies2":"07","reltype":"1","dist":"3","job":"72","famsit":"0","city":"29","cp":"10019","quartier":"19","duration":["19","119"],"context":"5","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":17,"name":"contact-15","sexe":"2","age":"1","studies2":"08","reltype":"2","dist":"0","job":"73","famsit":"0","city":"30","cp":"10020","quartier":"20","duration":["20","120"],"context":"6","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":18,"name":"contact-16","sexe":"0","age":"2","studies2":"09","reltype":"3","dist":"1","job":"74","famsit":"0","city":"31","cp":"10021","quartier":"21","duration":["21","121"],"context":"7","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":19,"name":"contact-17","sexe":"1","age":"3","studies2":"10","reltype":"4","dist":"2","job":"75","famsit":"0","city":"32","cp":"10022","quartier":"22","duration":["22","122"],"context":"8","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":20,"name":"contact-18","sexe":"2","age":"4","studies2":"11","reltype":"5","dist":"3","job":"76","famsit":"0","city":"33","cp":"10023","quartier":"23","duration":["23","123"],"context":"9","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":21,"name":"contact-19","sexe":"0","age":"5","studies2":"","reltype":"6","dist":"0","job":"81","famsit":"0","city":"34","cp":"10024","quartier":"24","duration":["24","124"],"context":"10","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":23,"name":"contact-21","sexe":"2","age":"7","studies2":"02","reltype":"autre","dist":"2","job":"10","famsit":"0","city":"36","cp":"10026","quartier":"26","duration":["26","126"],"context":"12","contextExtra":["","association",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":24,"name":"contact-22","sexe":"0","age":"8","studies2":"03","reltype":"0","dist":"3","job":"21","famsit":"0","city":"37","cp":"10027","quartier":"27","duration":["27","127"],"context":"13","contextExtra":["","","autre"],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":25,"name":"contact-23","sexe":"1","age":"9","studies2":"04","reltype":"1","dist":"0","job":"22","famsit":"0","city":"38","cp":"10028","quartier":"28","duration":["28","128"],"context":"0","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":26,"name":"contact-24","sexe":"2","age":"10","studies2":"05","reltype":"2","dist":"1","job":"23","famsit":"0","city":"39","cp":"10029","quartier":"29","duration":["29","129"],"context":"1","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":27,"name":"contact-25","sexe":"0","age":"11","studies2":"06","reltype":"3","dist":"2","job":"31","famsit":"0","city":"40","cp":"10030","quartier":"30","duration":["30","130"],"context":"2","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":28,"name":"contact-26","sexe":"1","age":"12","studies2":"07","reltype":"4","dist":"3","job":"32","famsit":"0","city":"41","cp":"10031","quartier":"31","duration":["31","131"],"context":"3","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":29,"name":"contact-27","sexe":"2","age":"13","studies2":"08","reltype":"5","dist":"0","job":"36","famsit":"0","city":"42","cp":"10032","quartier":"32","duration":["32","132"],"context":"4","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":30,"name":"contact-28","sexe":"0","age":"14","studies2":"09","reltype":"6","dist":"1","job":"41","famsit":"0","city":"43","cp":"10033","quartier":"33","duration":["33","133"],"context":"5","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":31,"name":"contact-29","sexe":"1","age":"15","studies2":"10","reltype":"7","dist":"2","job":"46","famsit":"0","city":"44","cp":"10034","quartier":"34","duration":["34","134"],"context":"6","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":32,"name":"contact-30","sexe":"2","age":"16","studies2":"11","reltype":"autre","dist":"3","job":"47","famsit":"0","city":"45","cp":"10035","quartier":"35","duration":["35","135"],"context":"7","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":33,"name":"contact-31","sexe":"0","age":"17","studies2":"","reltype":"0","dist":"0","job":"48","famsit":"0","city":"46","cp":"10036","quartier":"36","duration":["36","136"],"context":"8","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":34,"name":"contact-32","sexe":"1","age":"18","studies2":"01","reltype":"1","dist":"1","job":"51","famsit":"0","city":"47","cp":"10037","quartier":"37","duration":["37","137"],"context":"9","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":35,"name":"contact-33","sexe":"2","age":"0","studies2":"02","reltype":"2","dist":"2","job":"54","famsit":"0","city":"48","cp":"10038","quartier":"38","duration":["38","138"],"context":"10","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":36,"name":"contact-34","sexe":"0","age":"1","studies2":"03","reltype":"3","dist":"3","job":"55","famsit":"0","city":"49","cp":"10039","quartier":"39","duration":["39","139"],"context":"11","contextExtra":["internet","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":37,"name":"contact-35","sexe":"1","age":"2","studies2":"04","reltype":"4","dist":"0","job":"56","famsit":"0","city":"50","cp":"10040","quartier":"40","duration":["40","140"],"context":"12","contextExtra":["","association",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":38,"name":"contact-36","sexe":"2","age":"3","studies2":"05","reltype":"5","dist":"1","job":"61","famsit":"0","city":"51","cp":"10041","quartier":"41","duration":["41","141"],"context":"13","contextExtra":["","","autre"],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":39,"name":"contact-37","sexe":"0","age":"4","studies2":"06","reltype":"6","dist":"2","job":"66","famsit":"0","city":"52","cp":"10042","quartier":"42","duration":["42","142"],"context":"0","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":40,"name":"contact-38","sexe":"1","age":"5","studies2":"07","reltype":"7","dist":"3","job":"69","famsit":"0","city":"53","cp":"10043","quartier":"43","duration":["43","143"],"context":"1","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":41,"name":"contact-39","sexe":"2","age":"6","studies2":"08","reltype":"autre","dist":"0","job":"71","famsit":"0","city":"54","cp":"10044","quartier":"44","duration":["44","144"],"context":"2","contextExtra":["","",""],"freq":["4","9","14","19","24"],"connect":["1","3","5","7","9","11"],"connectExtra":["",""]}
|
||||||
|
{"id":43,"name":"contact-41","sexe":"1","age":"","studies1":"2","reltype":"1","dist":"."}
|
||||||
|
{"id":44,"name":"contact-42","sexe":"0","age":"2","studies1":"3","reltype":"2","dist":"."}
|
||||||
|
{"id":45,"name":"contact-43","sexe":"1","age":"3","studies1":"4","reltype":"3","dist":"."}
|
||||||
|
{"id":46,"name":"contact-44","sexe":"0","age":"4","studies1":"5","reltype":"4","dist":"."}
|
|
@ -0,0 +1 @@
|
||||||
|
{"2":{"line":0},"3":{"line":1},"4":{"line":2},"5":{"line":3},"6":{"line":4},"7":{"line":5},"8":{"line":6},"9":{"line":7},"10":{"line":8},"11":{"line":9},"12":{"line":10},"13":{"line":11},"14":{"line":12},"15":{"line":13},"16":{"line":14},"17":{"line":15},"18":{"line":16},"19":{"line":17},"20":{"line":18},"21":{"line":19},"23":{"line":20},"24":{"line":21},"25":{"line":22},"26":{"line":23},"27":{"line":24},"28":{"line":25},"29":{"line":26},"30":{"line":27},"31":{"line":28},"32":{"line":29},"33":{"line":30},"34":{"line":31},"35":{"line":32},"36":{"line":33},"37":{"line":34},"38":{"line":35},"39":{"line":36},"40":{"line":37},"41":{"line":38},"43":{"line":39},"44":{"line":40},"45":{"line":41},"46":{"line":42}}
|
|
@ -11,6 +11,7 @@
|
||||||
|
|
||||||
|
|
||||||
"contacts": {
|
"contacts": {
|
||||||
|
|
||||||
"sexe": { "0":"Homme", "1":"Femme", "2":"Indéterminé" },
|
"sexe": { "0":"Homme", "1":"Femme", "2":"Indéterminé" },
|
||||||
"age": {
|
"age": {
|
||||||
".": "NA",
|
".": "NA",
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
||||||
{"1":{"line":0,"hash":"ae55953b70b63b6665ea13aef65aef8da8b8c834"},"3":{"line":1,"hash":"e264f35e79e354f1dcadc0bc6b9c2b07dc214ee2"}}
|
|
File diff suppressed because one or more lines are too long
|
@ -1 +0,0 @@
|
||||||
{"3":{"line":0,"hash":"e9aff02e50eb56a848c3580c8a119a5cbe0ec64b"}}
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,7 @@
|
||||||
|
Contient les équivalences :
|
||||||
|
|
||||||
|
id_subject => {
|
||||||
|
"subject": [données du sujet]
|
||||||
|
"contact": [liste des id des contacts],
|
||||||
|
"relations": [liste des relations]
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
{"1":{"line":0}}
|
|
@ -1,8 +0,0 @@
|
||||||
{"subject":{"id":1,"name":"Caroline","creation":1464788890}}
|
|
||||||
{"subject":{"id":2,"name":"Cl\u00e9ment","creation":1464788893}}
|
|
||||||
{"subject":{"id":3,"name":"Coralie","creation":1464788897}}
|
|
||||||
{"subject":{"id":4,"name":"Laurent","creation":1464788899}}
|
|
||||||
{"subject":{"id":5,"name":"Emilie","creation":1464788903}}
|
|
||||||
{"subject":{"id":6,"name":"C\u00e9line","creation":1464788905}}
|
|
||||||
{"subject":{"id":7,"name":"Pierre","creation":1464788908}}
|
|
||||||
{"subject":{"id":8,"name":"Boris","creation":1464788910}}
|
|
|
@ -1 +0,0 @@
|
||||||
{"1":{"line":0,"hash":"9798c2b945e222c48bff804d9819c0d98e88d257"},"2":{"line":1,"hash":"8192621a7f0013e137e63edffdadea6ab7f69565"},"3":{"line":2,"hash":"a7b9d5cf6cfb41c0b100d91d053032bdad3a80da"},"4":{"line":3,"hash":"ef73002b8217c3c3b87a62b8ae4c69b3994c114f"},"5":{"line":4,"hash":"5cf77d4e920f1b418bf78484bc1766fb84baabb9"},"6":{"line":5,"hash":"356e841ad04cb0f553fe47eab88bf550d6853c60"},"7":{"line":6,"hash":"7d070210aed5df40ee7e2ca4b54f29c672d32a89"},"8":{"line":7,"hash":"9e4936de2cf03d46135bbac3589a1e3ce68fb406"}}
|
|
|
@ -1 +1 @@
|
||||||
3901
|
51
|
|
@ -75,6 +75,9 @@
|
||||||
/* Erreur au niveau javascript */
|
/* Erreur au niveau javascript */
|
||||||
//const JavascriptError = 19; // -> géré en js
|
//const JavascriptError = 19; // -> géré en js
|
||||||
|
|
||||||
|
// Already done error
|
||||||
|
const Already = 20;
|
||||||
|
|
||||||
|
|
||||||
/* EXPLICITE UN CODE D'ERREUR
|
/* EXPLICITE UN CODE D'ERREUR
|
||||||
*
|
*
|
||||||
|
@ -109,6 +112,7 @@
|
||||||
case self::PermissionError: return "Vous n'avez pas la permission d'effectuer cette action."; break;
|
case self::PermissionError: return "Vous n'avez pas la permission d'effectuer cette action."; break;
|
||||||
case self::UploadError: return "Une erreur d'upload est survenue."; break;
|
case self::UploadError: return "Une erreur d'upload est survenue."; break;
|
||||||
case self::FormatError: return "Le fichier n'est pas au bon format."; break;
|
case self::FormatError: return "Le fichier n'est pas au bon format."; break;
|
||||||
|
case self::Already: return "Action déja effectuée."; break;
|
||||||
|
|
||||||
default: return "Description d'erreur inconnue..."; break;
|
default: return "Description d'erreur inconnue..."; break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,9 +246,6 @@
|
||||||
"options": { "download": true },
|
"options": { "download": true },
|
||||||
"parameters": {
|
"parameters": {
|
||||||
"subjects": { "description": "Identifiants des sujets d'enquêtes à intégrer.", "type": "array<id>", "optional": true },
|
"subjects": { "description": "Identifiants des sujets d'enquêtes à intégrer.", "type": "array<id>", "optional": true },
|
||||||
"phone": { "description": "Si vaut TRUE, renvoie les sujets cellulaires.", "type": "boolean", "optional": true },
|
|
||||||
"facebook": { "description": "Si vaut TRUE, renvoie les sujet facebook.", "type": "boolean", "optional": true },
|
|
||||||
"survey": { "description": "Si vaut TRUE, renvoie les sujets ResTIC.", "type": "boolean", "optional": true },
|
|
||||||
"all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true }
|
"all": { "description": "Si vaut TRUE, renvoie tous les sujets enregistrés.", "type": "boolean", "optional": true }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -124,7 +124,7 @@ body{
|
||||||
width: 35em;
|
width: 35em;
|
||||||
height: 10em;
|
height: 10em;
|
||||||
|
|
||||||
background: url('/src/static/iconv3.svg') center center no-repeat;
|
background: url('/src/static/iconv4.png') center center no-repeat;
|
||||||
background-size: auto 100%;
|
background-size: auto 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -0,0 +1,55 @@
|
||||||
|
<?php define('__ROOT__', dirname(__DIR__));
|
||||||
|
|
||||||
|
require_once __ROOT__.'/autoloader.php';
|
||||||
|
|
||||||
|
debug();
|
||||||
|
|
||||||
|
use \lightdb\core\lightdb;
|
||||||
|
|
||||||
|
$sl = new lightdb('subject');
|
||||||
|
$cl = new lightdb('contact');
|
||||||
|
|
||||||
|
$LOG = true;
|
||||||
|
|
||||||
|
if( $LOG ){
|
||||||
|
|
||||||
|
$sub = $sl->fetch(1);
|
||||||
|
|
||||||
|
var_dump( count($sub['relations']) );
|
||||||
|
|
||||||
|
foreach($sub['relations'] as $rel){
|
||||||
|
if( $rel['idA'] == 1 )
|
||||||
|
$Aname = $sub['subject']['name'];
|
||||||
|
else
|
||||||
|
$Aname = $cl->fetch((int)$rel['idA'])['name'];
|
||||||
|
|
||||||
|
echo $Aname.'('.$rel['idA'].') + '.$cl->fetch((int)$rel['idB'])['name'].'('.$rel['idB'].') = '.$rel['type']."<br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
/* [1] Remove contacts
|
||||||
|
=========================================================*/
|
||||||
|
$sub = $sl->fetch(1);
|
||||||
|
|
||||||
|
$cl->deleteAll( $sub['contacts'] );
|
||||||
|
|
||||||
|
$cl->flush(); // security
|
||||||
|
|
||||||
|
/* [2] Reset subject
|
||||||
|
=========================================================*/
|
||||||
|
|
||||||
|
unset( $sub['contacts'] );
|
||||||
|
unset( $sub['relations'] );
|
||||||
|
$sub['subject']['surveys'] = [];
|
||||||
|
|
||||||
|
$sl->delete(1);
|
||||||
|
$sl->insert(1, $sub);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$sl->close();
|
||||||
|
$cl->close();
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -21,11 +21,12 @@ $pers = $request->answer();
|
||||||
<section data-sublink='export'>
|
<section data-sublink='export'>
|
||||||
|
|
||||||
<section id='export-form'>
|
<section id='export-form'>
|
||||||
<h4>Exporter les données au format .csv</h4>
|
<h6>Exporter les données au format .csv</h6>
|
||||||
|
<br><br>
|
||||||
|
|
||||||
<strong>Choix des sujets</strong>
|
<u><strong>Choix des sujets</strong></u><br>
|
||||||
<br><input type='radio' name='export_subject-group' data-name='group' id='export_group_0' value='all' ><label for='export_group_0'>Tous les sujets</label>
|
<br><input type='radio' name='export_subject-group' data-name='group' id='export_group_0' value='all' checked><label for='export_group_0'>Tous les sujets</label>
|
||||||
<br><input type='radio' name='export_subject-group' data-name='group' id='export_group_1' value='sel' checked><label for='export_group_1'>Les sujets selectionnés uniquement</label>
|
<br><input type='radio' name='export_subject-group' data-name='group' id='export_group_1' value='sel' ><label for='export_group_1'>Les sujets selectionnés uniquement</label>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
|
||||||
<article style='display: inline;' id='export_subject-list'>
|
<article style='display: inline;' id='export_subject-list'>
|
||||||
|
@ -33,10 +34,10 @@ $pers = $request->answer();
|
||||||
</article>
|
</article>
|
||||||
<input type='button' id='export_add-subject' class='primary' value='+' style='padding:.2em .6em; margin: .5em 0'>
|
<input type='button' id='export_add-subject' class='primary' value='+' style='padding:.2em .6em; margin: .5em 0'>
|
||||||
|
|
||||||
<br><br><br><strong>Types de données</strong>
|
<!-- <br><br><br><strong>Types de données</strong>
|
||||||
<br><br><input type='checkbox' data-name='phone' value='1' id='export_phone_0' ><label for='export_phone_0'>Données cellulaires</label>
|
<br><br><input type='checkbox' data-name='phone' value='1' id='export_phone_0' checked><label for='export_phone_0'>Données cellulaires</label>
|
||||||
<br><br><input type='checkbox' data-name='facebook' value='1' id='export_facebook_0'><label for='export_facebook_0'>Données Facebook</label>
|
<br><br><input type='checkbox' data-name='facebook' value='1' id='export_facebook_0' checked><label for='export_facebook_0'>Données Facebook</label>
|
||||||
<br><br><input type='checkbox' data-name='restic' value='1' id='export_restic_0' ><label for='export_restic_0'>Données <i>Lab Surveys</i></label>
|
<br><br><input type='checkbox' data-name='restic' value='1' id='export_restic_0' checked><label for='export_restic_0'>Données <i>Lab Surveys</i></label> -->
|
||||||
|
|
||||||
<br><br><input type='submit' class='primary hover' style='padding:.5em 2em;' value='Télécharger' id='export_export-all'>
|
<br><br><input type='submit' class='primary hover' style='padding:.5em 2em;' value='Télécharger' id='export_export-all'>
|
||||||
</section>
|
</section>
|
||||||
|
|
|
@ -51,16 +51,10 @@ $('#export-form #export_export-all').addEventListener('click', function(e){
|
||||||
/* (4) On construit la requête */
|
/* (4) On construit la requête */
|
||||||
var request = {
|
var request = {
|
||||||
path: 'download/multiple',
|
path: 'download/multiple',
|
||||||
phone: deflated.phone == '1', // VRAI si on veut les données téléphoniques
|
subjects: subjects,
|
||||||
facebook: deflated.facebook == '1', // VRAI si on veut les données facebook
|
|
||||||
survey: deflated.survey == '1', // VRAI si on veut les données ResTIC
|
|
||||||
all: deflated.group == 'all' // VRAI si on veut TOUS les sujets
|
all: deflated.group == 'all' // VRAI si on veut TOUS les sujets
|
||||||
};
|
};
|
||||||
|
|
||||||
// On ajoute les sujets s'il y en a
|
|
||||||
if( deflated.group != 'all' && subjects.length > 0 )
|
|
||||||
request.subjects = subjects;
|
|
||||||
|
|
||||||
|
|
||||||
/* (5) On lance la requête */
|
/* (5) On lance la requête */
|
||||||
api.send(request, function(res){
|
api.send(request, function(res){
|
||||||
|
|
|
@ -36,6 +36,8 @@ var tmpSubjectSearchListener = function(e){
|
||||||
/* (2) On effectue la requête */
|
/* (2) On effectue la requête */
|
||||||
api.send(request, function(response){
|
api.send(request, function(response){
|
||||||
|
|
||||||
|
console.warn(response);
|
||||||
|
|
||||||
// Si erreur
|
// Si erreur
|
||||||
if( response.ModuleError != 0 ){
|
if( response.ModuleError != 0 ){
|
||||||
Notification.error('Erreur', 'La recherche a échoué.')
|
Notification.error('Erreur', 'La recherche a échoué.')
|
||||||
|
@ -659,10 +661,11 @@ var pDynamicUpdate = function(target){
|
||||||
// Supprime les contacts déja dans les FICHES
|
// Supprime les contacts déja dans les FICHES
|
||||||
pMiniManager.sync();
|
pMiniManager.sync();
|
||||||
|
|
||||||
/* (7) On récupère tous les amis du sujet */
|
/* (7) On récupère tous les "amis" du sujet */
|
||||||
if( target === true ){
|
if( target === true ){
|
||||||
|
|
||||||
api.send({ path: 'subject/getFriends', subject_id: pSubjectManager.subject_id.value }, function(response){
|
api.send({ path: 'subject/getFriends', subject_id: pSubjectManager.subject_id.value }, function(response){
|
||||||
|
console.warn('xx', response);
|
||||||
// Si erreur, on quitte
|
// Si erreur, on quitte
|
||||||
if( response.ModuleError != 0 ){
|
if( response.ModuleError != 0 ){
|
||||||
console.groupEnd();
|
console.groupEnd();
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
var exportSubjectList=$("#export_subject-list"),exportSubjectAdd=$("#export_add-subject"),exportDeflater=new FormDeflater(document.getElementById("export-form"),["input"],["data-name"]);exportSubjectAdd.addEventListener("click",function(b){b=document.createElement("input");b.type="number";b.dataset.name="subjects";b.placeholder="Sujet";b.style="width: 5em; display: block;";exportSubjectList.appendChild(b)},!1);
|
||||||
|
$("#export-form #export_export-all").addEventListener("click",function(b){var a=(new FormDeflater(exportSubjectList,["input"],["data-name"])).deflate().subjects;b=[];a instanceof Array||(a=[a]);for(var c=0;c<a.length;c++)0<a[c].length&&!isNaN(a[c])&&b.push(a[c]);a=exportDeflater.deflate();api.send({path:"download/multiple",subjects:b,all:"all"==a.group},function(a){if(0!=a.ModuleError)return!1;document.location=a.link;Notification.success("OK","Lancement du t\u00e9l\u00e9chargement..")})},!1);
|
||||||
|
var chartsSubjectList=$("#charts_subject-list"),chartsSubjectAdd=$("#charts_add-subject"),chartsDeflater=new FormDeflater(document.getElementById("charts-form"),["input"],["data-name"]);chartsSubjectAdd.addEventListener("click",function(b){b=document.createElement("input");b.type="number";b.dataset.name="subjects";b.placeholder="Sujet";b.style="width: 5em; display: block;";chartsSubjectList.appendChild(b)},!1);
|
||||||
|
$("#charts-form #charts_export-all").addEventListener("click",function(b){var a=(new FormDeflater(chartsSubjectList,["input"],["data-name"])).deflate().subjects;b=[];a instanceof Array||(a=[a]);for(var c=0;c<a.length;c++)0<a[c].length&&!isNaN(a[c])&&b.push(a[c]);a=chartsDeflater.deflate();c={path:"download/chart",phone:"1"==a.phone,facebook:"1"==a.facebook,survey:"1"==a.survey,all:"all"==a.group};"all"!=a.group&&0<b.length&&(c.subjects=b);api.send(c,function(a){if(0!=a.ModuleError)return!1;document.location=
|
||||||
|
a.link;Notification.success("OK","Lancement du t\u00e9l\u00e9chargement..")})},!1);
|
|
@ -1,5 +1,5 @@
|
||||||
var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null,input_ts=Date.now();sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');
|
var sField,sSubmit,sList,pSubjectManager=null,pContactManager=null,pMiniManager=null,pFicheManager=null,pMatriceManager=null,fSubjectManager=null,fContactManager=null,fMiniManager=null,fFicheManager=null,fMatriceManager=null,input_ts=Date.now();sField=$("#search-field");sSubmit=$("#search-subject");sList=$('section[data-sublink="survey"] ul[data-list]');
|
||||||
var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c=[],g;for(g in a.results)c.push("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+
|
var tmpSubjectSearchListener=function(a){api.send({path:"subject/search",name:sField.value},function(a){console.warn(a);if(0!=a.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(a);var c=[],g;for(g in a.results)c.push("<li data-element data-id='"+g+"'>"),c.push("<div data-user><span>SUJET</span></div>"),c.push("<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+g+"'></span> </div>"),c.push("<div> <span data-prefix='Nom'>"+
|
||||||
a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML=
|
a.results[g].name+"</span> </div>"),c.push("<div> <span data-prefix='Cr\u00e9ation'>"+a.results[g].creation+"</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].phone?"checked":"")+" disabled><label for='s_"+g+"'>Cellulaire</label>"),c.push("</span> </div>"),c.push("<div> <span><input type='checkbox' id='s_"+g+"' "+(null!=a.results[g].facebook?"checked":"")+" disabled><label for='s_"+g+"'>Facebook</label>"),c.push("</span> </div>"),c.push("</li>");sList.innerHTML=
|
||||||
c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);tmpSubjectSearchListener();
|
c.join("")})};sSubmit.addEventListener("click",tmpSubjectSearchListener,!1);sField.addEventListener("keypress",function(a){13===a.keyCode&&tmpSubjectSearchListener(a)},!1);tmpSubjectSearchListener();
|
||||||
var pAlready=0,pLoaded=[0,0,0,0,0],phoneRoutine=function(){!Math.min.apply(Math,pLoaded)|pAlready||(pAlready=1,console.groupEnd(),console.group("[phone] Initialization"),pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')),pSubjectManager.attach(pDynamicUpdate),pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact')),
|
var pAlready=0,pLoaded=[0,0,0,0,0],phoneRoutine=function(){!Math.min.apply(Math,pLoaded)|pAlready||(pAlready=1,console.groupEnd(),console.group("[phone] Initialization"),pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]')),pSubjectManager.attach(pDynamicUpdate),pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact')),
|
||||||
|
@ -21,10 +21,10 @@ pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManag
|
||||||
(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",
|
(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",
|
||||||
1E4);console.log(a)},!1)},!1),console.groupEnd())};include("/js/includes/input-facebook-subject.js",function(){fLoaded[0]=1;facebookRoutine()});include("/js/includes/input-facebook-contact.js",function(){fLoaded[1]=1;facebookRoutine()});include("/js/includes/input-facebook-mini.js",function(){fLoaded[2]=1;facebookRoutine()});include("/js/includes/input-facebook-fiche.js",function(){fLoaded[3]=1;facebookRoutine()});include("/js/includes/input-facebook-matrice.js",function(){fLoaded[4]=1;facebookRoutine()});
|
1E4);console.log(a)},!1)},!1),console.groupEnd())};include("/js/includes/input-facebook-subject.js",function(){fLoaded[0]=1;facebookRoutine()});include("/js/includes/input-facebook-contact.js",function(){fLoaded[1]=1;facebookRoutine()});include("/js/includes/input-facebook-mini.js",function(){fLoaded[2]=1;facebookRoutine()});include("/js/includes/input-facebook-fiche.js",function(){fLoaded[3]=1;facebookRoutine()});include("/js/includes/input-facebook-matrice.js",function(){fLoaded[4]=1;facebookRoutine()});
|
||||||
var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.groupEnd();console.groupEnd();console.group("[phone] Dynamic Update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();
|
var pDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.groupEnd();console.groupEnd();console.group("[phone] Dynamic Update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();
|
||||||
pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:pSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return console.groupEnd(),!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields();pMiniManager.updateNavBar();pFicheManager.updateNavBar()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),pMiniManager.updateNavBar(),
|
pMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:pSubjectManager.subject_id.value},function(a){console.warn("xx",a);if(0!=a.ModuleError)return console.groupEnd(),!1;lsi["import"]("p_friends",a.subjects);pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();pContactManager.storageToFields();pMiniManager.updateNavBar();pFicheManager.updateNavBar()}):(pMiniManager.storageToFields(),pFicheManager.storageToFields(),pMatriceManager.storageToFields(),
|
||||||
pFicheManager.updateNavBar(),(c||b)&&pContactManager.storageToFields());console.groupEnd()},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.groupEnd();console.groupEnd();console.group("[facebook] Dynamic Update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();
|
pMiniManager.updateNavBar(),pFicheManager.updateNavBar(),(c||b)&&pContactManager.storageToFields());console.groupEnd()},fDynamicUpdate=function(a){var b=a instanceof Element,c=b&&"INPUT"==a.tagName&&"submit"==a.type,g=b&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!c&&!g&&!b&&!0!==a)return!1;console.groupEnd();console.groupEnd();console.group("[facebook] Dynamic Update");fMiniManager.fieldsToStorage();
|
||||||
fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return console.groupEnd(),!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),fMatriceManager.storageToFields(),
|
fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();!0===a?api.send({path:"subject/getFriends",subject_id:fSubjectManager.subject_id.value},function(a){if(0!=a.ModuleError)return console.groupEnd(),!1;lsi["import"]("f_friends",a.subjects);fMiniManager.storageToFields();fFicheManager.storageToFields();fMatriceManager.storageToFields();fContactManager.storageToFields()}):(fMiniManager.storageToFields(),fFicheManager.storageToFields(),
|
||||||
(c||b)&&fContactManager.storageToFields());console.groupEnd()};function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}
|
fMatriceManager.storageToFields(),(c||b)&&fContactManager.storageToFields());console.groupEnd()};function testContactsPhone(){for(var a=0;45>a;a++)0==a%20?lsi.set("p_contacts",a,{uid:a,username:"contact-x"}):lsi.set("p_contacts",a,{uid:a,username:"contact-"+a})}
|
||||||
function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
|
function testRoutinePhone(a){var b=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),d=0;if(null!=a&&a)for(var f in c)isNaN(f)||(a="",null!=b[f]&&(a=b[f].username),c=$('#p_nav-mini [data-n="'+f+'"]'),c.click(),$("#unknown_min_p_"+f).checked=0==a.length,0==a.length?($("#sexeI_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=
|
||||||
0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+
|
0,$("#reltype9_mini_p_"+f).checked=!0):(a=["H","F"][Math.floor(d%2)],$("#sexe"+a+"_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=d%19,$('input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="studies"]').value=1+d%6,a=d%10,9==a?($("#reltype10_mini_p_"+f).checked=!0,$('input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+a+"_mini_p_"+f).checked=!0,d++));for(var e in g)isNaN(e)||(c=$('#p_nav-fiche [data-n="'+
|
||||||
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
|
e+'"]'),c.click(),a=["H","F","I"][Math.floor(d%3)],$("#sexe"+a+"_p_"+e).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="age"]').value=d%19,b="10 21 22 23 31 32 36 41 46 47 48 51 54 55 56 61 66 69 71 72 73 74 75 76 81 82".split(" "),b=b[d%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+e+'"] ~ h5 select[data-name="job"]').value=b,b=(d%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
|
||||||
|
|
Loading…
Reference in New Issue