Implémentation de la création du fichier complet et du son export suite à un formulaire validé ('input/phone', et 'download/phone')
This commit is contained in:
parent
e79e2c3f07
commit
ac3b8217e4
|
@ -87,7 +87,7 @@
|
|||
|
||||
|
||||
// Lancement du téléchargement
|
||||
$req = new ModuleRequest('download/phone', array('subjects'=>[1]));
|
||||
$req = new ModuleRequest('download/phone', array('subjects'=>[200]));
|
||||
$res = $req->dispatch();
|
||||
|
||||
?>
|
||||
|
|
|
@ -200,11 +200,11 @@
|
|||
"description": "Enregistre les données d'une enquête téléphonique.",
|
||||
"permissions": ["admin"],
|
||||
"parameters": {
|
||||
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "array" },
|
||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" },
|
||||
"matrice": { "description": "Matrice contenant les relations entre les plus proches contacts", "type": "array<array>" }
|
||||
"subject": { "description": "Données sur le sujet de l'enquête.", "type": "array" },
|
||||
"contacts": { "description": "Données des contacts de l'enquête.", "type": "array<array>" },
|
||||
"mini": { "description": "Mini fiches relations sur les contacts de l'enquête.", "type": "array<array>" },
|
||||
"fiches": { "description": "Fiches relation sur les plus proches contacts de l'enquête.", "type": "array<array>" },
|
||||
"matrice": { "description": "Matrice contenant les relations entre les plus proches contacts", "type": "array<array>", "optional": true }
|
||||
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -314,7 +314,7 @@ ficheBuilder.setLayout(
|
|||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype5_@uid' value='5'><label for='reltype5_@uid'>Voisin</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype6_@uid' value='6'><label for='reltype6_@uid'>Ami proche</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype7_@uid' value='7'><label for='reltype7_@uid'>Ami</label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype8_@uid' value='8'><label for='reltype8_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+
|
||||
"\t\t <input type='radio' name='reltype_@uid' data-name='reltype' id='reltype10_@uid' value='10'><label for='reltype10_@uid'>Autre : <input type='text' data-name='reltypeSpecial' placeholder='coéquipier de tennis, ..' value='@reltypespecial'></label><br>\n"+
|
||||
"\t</h5>\n"+
|
||||
|
||||
"\t<h4 data-icon='m'>Où habite t-elle/il ?</h4>\n"+
|
||||
|
|
|
@ -15,5 +15,5 @@ inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["
|
|||
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;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches");this.nav_container.innerHTML="";for(var b=Object.keys(a),c=0;c<b.length;c++){var e=parseInt(b[c]);0==e&&(this.nav_container.innerHTML+="<span>APPELS</span>");10>e&&c<b.length-1&&10<=b[c+1]?this.nav_container.innerHTML+='<span data-n="'+e+'" class="lc">'+(e%10+1)+"</span> ":(10==e&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+e+'">'+(e%10+1)+"</span>")}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+'"]'))};
|
||||
inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"8"==a.reltype&&2>a.reltypeSpecial.length||
|
||||
inputPhoneFiche.prototype.check=function(a){if(2>a.city.length||isNaN(parseInt(a.duration[0]))&&0<a.duration[0].length||isNaN(parseInt(a.duration[1]))&&0<a.duration[1].length||0==a.duration[0].length+a.duration[1].length||"."==a.job||"."==a.studies||"."==a.age||""==a.sexe||""==a.famsit||""==a.reltype||""==a.loc||""==a.context)return!1;for(var b=0;b<a.freq.length;b++)if(""==a.freq[b])return!1;for(b=0;b<a.connect.length;b++)if(""==a.connect[b])return!1;return"10"==a.reltype&&2>a.reltypeSpecial.length||
|
||||
"11"==a.context&&2>a.contextSpecial[0].length||"12"==a.context&&2>a.contextSpecial[1].length||"13"==a.context&&2>a.contextSpecial[2].length?!1:!0};inputPhoneFiche.prototype.attach=function(a){console.log("FICHE: ATTACH");lsi.createDataset("fiches");this.storageToFields();this.handler=a;var b=this,b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};
|
||||
|
|
|
@ -577,7 +577,7 @@ inputPhoneFiche.prototype.check = function(ficheData){
|
|||
|
||||
// {4} <input> dépendant d'un choix d'un <input> radio //
|
||||
// 16. TYPE DE RELATION si autre est coché (indice 8), reltypeSpecial doit avoir au moins 2 caractère
|
||||
if( ficheData.reltype == '8' && ficheData.reltypeSpecial.length < 2 )
|
||||
if( ficheData.reltype == '10' && ficheData.reltypeSpecial.length < 2 )
|
||||
return false;
|
||||
// 17. CONTEXTE DE RELATION si est coché indice 11, contactSpecial[0] doit avoir au moins 2 caractères
|
||||
if( ficheData.context == '11' && ficheData.contextSpecial[0].length < 2 )
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
/* [1] On ajoute les colonnes à la sortie
|
||||
=========================================================*/
|
||||
foreach($columns as $i=>$column)
|
||||
$output .= ($i < count($columns)-1) ? "\"$column\";" : "\"$column\"";
|
||||
$output .= ($i < count($columns)-1) ? "\"$column\";" : "\"$column\"\r\n";
|
||||
|
||||
|
||||
|
||||
|
@ -140,9 +140,10 @@
|
|||
/* [2] On construit le CSV
|
||||
=========================================================*/
|
||||
$output = array(
|
||||
'logs' => self::parseCSV($phone_log['logs'], $dict['logs']),
|
||||
'contacts' => self::parseCSV($phone_log['contacts'], $dict['contacts']),
|
||||
'dict' => ''
|
||||
'logs' => self::parseCSV($phone_log['logs'], $dict['logs']),
|
||||
'contacts' => self::parseCSV($phone_log['contacts'], $dict['contacts']),
|
||||
'relations' => self::parseCSV($phone_log['relations'], null),
|
||||
'dict' => ''
|
||||
);
|
||||
|
||||
/* [3] On construit le fichier du dictionnaire
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
/* (6) Si @firstname et/ou @lastname -> firstname lastname*/
|
||||
if( $fl+$ll > 0 )
|
||||
return trim($f.' '.l);
|
||||
return trim($f.' '.$l);
|
||||
|
||||
/* (7) Si rien -> Inconnu */
|
||||
else
|
||||
|
@ -63,123 +63,127 @@
|
|||
public static function phone($params){
|
||||
extract($params);
|
||||
|
||||
|
||||
// TODO: Tout enregistrer dans le .json et non dans la bdd
|
||||
/* [1] On crée le sujet de l'enquête
|
||||
=========================================================*/
|
||||
/* (1) On rédige la requête */
|
||||
$create_subject_request = new ModuleRequest('subject/create', array(
|
||||
'username' => $subject['username'],
|
||||
'firstname' => $subject['firstname'],
|
||||
'lastname' => $subject['lastname'],
|
||||
'number' => $subject['number']
|
||||
));
|
||||
// $create_subject_request = new ModuleRequest('subject/create', array(
|
||||
// 'username' => $subject['username'],
|
||||
// 'firstname' => $subject['firstname'],
|
||||
// 'lastname' => $subject['lastname'],
|
||||
// 'number' => $subject['number']
|
||||
// ));
|
||||
//
|
||||
// /* (2) On exécute la requête (création) */
|
||||
// $create_subject_response = $create_subject_request->dispatch();
|
||||
//
|
||||
// /* (3) Gestion de l'erreur, si erreur de création */
|
||||
// if( $create_subject_response->error != ManagerError::Success )
|
||||
// return array( 'ModuleError' => $create_subject_response->error );
|
||||
//
|
||||
// /* (4) On récupère l'id du sujet */
|
||||
// $subject_id = $create_subject_response->get('id_subject');
|
||||
//
|
||||
//
|
||||
//
|
||||
// /* [2] On extrait les contacts des 2 top 10 (sans duplication)
|
||||
// =========================================================*/
|
||||
// $closest = array();
|
||||
//
|
||||
// foreach($fiches as $i=>$fiche){
|
||||
// /* (1) Si le contact n'est pas déja enregistré, on l'enregistre */
|
||||
// if( !array_key_exists($fiche['contact'], $closest) )
|
||||
// $closest[ $fiche['contact'] ] = array();
|
||||
//
|
||||
// /* (2) Si c'est un lien par CALL, on l'ajoute */
|
||||
// if( $i < 10 )
|
||||
// array_push( $closest[ $fiche['contact'] ], 'CALL' );
|
||||
// /* (3) Si c'est un lien par SMS, on l'ajoute */
|
||||
// else
|
||||
// array_push( $closest[ $fiche['contact'] ], 'SMS' );
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
// /* [3] On crée les contacts les plus proches
|
||||
// =========================================================*/
|
||||
// $closest_id = array();
|
||||
// // Pour chacun des top 10*2 plus proches
|
||||
// foreach($closest as $contact=>$relations){
|
||||
//
|
||||
// /* (1) On rédige la requête de création de sujet*/
|
||||
// $create_contact_request = new ModuleRequest('subject/create', array(
|
||||
// 'username' => $contacts[$contact]['username'],
|
||||
// 'firstname' => $contacts[$contact]['firstname'],
|
||||
// 'lastname' => $contacts[$contact]['lastname'],
|
||||
// 'number' => $contacts[$contact]['number']
|
||||
// ));
|
||||
//
|
||||
// /* (2) On exécute la requête (création) */
|
||||
// $create_contact_response = $create_contact_request->dispatch();
|
||||
//
|
||||
// /* (3) Gestion de l'erreur, si erreur de création */
|
||||
// if( $create_contact_response->error != ManagerError::Success )
|
||||
// return array( 'ModuleError' => $create_contact_response->error );
|
||||
//
|
||||
// /* (4) On récupère l'id du sujet */
|
||||
// $closest_id[$contact] = $create_contact_response->get('id_subject');
|
||||
//
|
||||
//
|
||||
//
|
||||
// /* [4] On crée les relations avec le sujet de l'enquête
|
||||
// =========================================================*/
|
||||
// /* (1) Relation de type _CALL_ */
|
||||
// if( in_array('CALL', $relations) ){
|
||||
// $call_rel_request = new Repo('subject/link', array( $subject_id, $closest_id[$contact], '_CALL_' ));
|
||||
//
|
||||
// $call_rel_response = $call_rel_request->answer();
|
||||
//
|
||||
// // Si erreur de création de relation
|
||||
// if( $call_rel_response === false )
|
||||
// return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /* (2) Relation de type _SMS_ */
|
||||
// if( in_array('SMS', $relations) ){
|
||||
// $sms_rel_request = new Repo('subject/link', array( $subject_id, $closest_id[$contact], '_SMS_' ));
|
||||
//
|
||||
// $sms_rel_response = $sms_rel_request->answer();
|
||||
//
|
||||
// // Si erreur de création de relation
|
||||
// if( $sms_rel_response === false )
|
||||
// return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /* [4] Ajout des relations de la matrice
|
||||
// =========================================================*/
|
||||
// // Pour chacun des top 10*2 plus proches
|
||||
// foreach($closest as $A=>$rels){
|
||||
//
|
||||
// // Pour chaque relation avec le contact actuel (s'il y en a)
|
||||
// if( isset($matrice[$A]) && is_array($matrice[$A]) ){
|
||||
// foreach($matrice[$A] as $B){
|
||||
// $relation_request = new Repo('subject/link', array( $closest_id[$A], $closest_id[$B], '' ));
|
||||
//
|
||||
// $relation_response = $relation_request->answer();
|
||||
//
|
||||
// // Si erreur de création de relation
|
||||
// if( $relation_response === false )
|
||||
// return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
//
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
$subject_id = '200';
|
||||
|
||||
/* (2) On exécute la requête (création) */
|
||||
$create_subject_response = $create_subject_request->dispatch();
|
||||
|
||||
/* (3) Gestion de l'erreur, si erreur de création */
|
||||
if( $create_subject_response->error != ManagerError::Success )
|
||||
return array( 'ModuleError' => $create_subject_response->error );
|
||||
|
||||
/* (4) On récupère l'id du sujet */
|
||||
$subject_id = $create_subject_response->get('id_subject');
|
||||
|
||||
|
||||
|
||||
/* [2] On extrait les contacts des 2 top 10 (sans duplication)
|
||||
=========================================================*/
|
||||
$closest = array();
|
||||
|
||||
foreach($fiches as $i=>$fiche){
|
||||
/* (1) Si le contact n'est pas déja enregistré, on l'enregistre */
|
||||
if( !array_key_exists($fiche['contact'], $closest) )
|
||||
$closest[ $fiche['contact'] ] = array();
|
||||
|
||||
/* (2) Si c'est un lien par CALL, on l'ajoute */
|
||||
if( $i < 10 )
|
||||
array_push( $closest[ $fiche['contact'] ], 'CALL' );
|
||||
/* (3) Si c'est un lien par SMS, on l'ajoute */
|
||||
else
|
||||
array_push( $closest[ $fiche['contact'] ], 'SMS' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* [3] On crée les contacts les plus proches
|
||||
=========================================================*/
|
||||
$closest_id = array();
|
||||
// Pour chacun des top 10*2 plus proches
|
||||
foreach($closest as $contact=>$relations){
|
||||
|
||||
/* (1) On rédige la requête de création de sujet*/
|
||||
$create_contact_request = new ModuleRequest('subject/create', array(
|
||||
'username' => $contacts[$contact]['username'],
|
||||
'firstname' => $contacts[$contact]['firstname'],
|
||||
'lastname' => $contacts[$contact]['lastname'],
|
||||
'number' => $contacts[$contact]['number']
|
||||
));
|
||||
|
||||
/* (2) On exécute la requête (création) */
|
||||
$create_contact_response = $create_contact_request->dispatch();
|
||||
|
||||
/* (3) Gestion de l'erreur, si erreur de création */
|
||||
if( $create_contact_response->error != ManagerError::Success )
|
||||
return array( 'ModuleError' => $create_contact_response->error );
|
||||
|
||||
/* (4) On récupère l'id du sujet */
|
||||
$closest_id[$contact] = $create_contact_response->get('id_subject');
|
||||
|
||||
|
||||
|
||||
/* [4] On crée les relations avec le sujet de l'enquête
|
||||
=========================================================*/
|
||||
/* (1) Relation de type _CALL_ */
|
||||
if( in_array('CALL', $relations) ){
|
||||
$call_rel_request = new Repo('subject/link', array( $subject_id, $closest_id[$contact], '_CALL_' ));
|
||||
|
||||
$call_rel_response = $call_rel_request->answer();
|
||||
|
||||
// Si erreur de création de relation
|
||||
if( $call_rel_response === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
|
||||
}
|
||||
|
||||
/* (2) Relation de type _SMS_ */
|
||||
if( in_array('SMS', $relations) ){
|
||||
$sms_rel_request = new Repo('subject/link', array( $subject_id, $closest_id[$contact], '_SMS_' ));
|
||||
|
||||
$sms_rel_response = $sms_rel_request->answer();
|
||||
|
||||
// Si erreur de création de relation
|
||||
if( $sms_rel_response === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [4] Ajout des relations de la matrice
|
||||
=========================================================*/
|
||||
// Pour chacun des top 10*2 plus proches
|
||||
foreach($closest as $A=>$rels){
|
||||
|
||||
// Pour chaque relation avec le contact actuel (s'il y en a)
|
||||
if( isset($matrice[$A]) && is_array($matrice[$A]) ){
|
||||
foreach($matrice[$A] as $B){
|
||||
$relation_request = new Repo('subject/link', array( $closest_id[$A], $closest_id[$B], '' ));
|
||||
|
||||
$relation_response = $relation_request->answer();
|
||||
|
||||
// Si erreur de création de relation
|
||||
if( $relation_response === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// on hash son id
|
||||
$subject_id = sessionManager::sha1($subject_id);
|
||||
|
||||
|
||||
|
||||
|
@ -194,62 +198,128 @@
|
|||
|
||||
|
||||
|
||||
/* [6] Enregistrement des mini-fiches dans un fichier '.json'
|
||||
/* [0] On récupère les logs s'ils existent
|
||||
=========================================================*/
|
||||
// Contiendra le contenu du fichier
|
||||
$file = array( 'logs' => array() );
|
||||
|
||||
|
||||
/* (1) Si on a déja crée le fichier avec le journal d'appel dedans, on le récupère */
|
||||
$storage_already = is_string($subject['tmp_id']) && strlen($subject['tmp_id']) == 40;
|
||||
|
||||
/* (2) Si on a déja crée le fichier, on essaie de récupérer son contenu */
|
||||
if( $storage_already )
|
||||
$file = json_decode( file_get_contents('/tmp/phone_storage_'.$subject['tmp_id'].'.json'), true );
|
||||
/* (2) On définit les 2 fichiers utiles */
|
||||
$filename = array(
|
||||
'old' => __ROOT__.'/tmp/phone_storage_'.$subject['tmp_id'].'.json',
|
||||
'new' => __ROOT__.'/src/upload/phone_storage/'.$subject_id.'.json'
|
||||
);
|
||||
|
||||
/* (3) On enregistre les contacts */
|
||||
|
||||
/* (3) Si on a déja crée le fichier, on essaie de récupérer son contenu */
|
||||
if( $storage_already ){
|
||||
$file = json_decode( file_get_contents($filename['old']), true );
|
||||
|
||||
// erreur
|
||||
if( $file == null )
|
||||
return array( 'ModuleRequest' => ManagerError::ParsingFailed );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* [1] On enregistre les données du sujet
|
||||
=========================================================*/
|
||||
$file['subject'] = array(
|
||||
'id' => $subject_id,
|
||||
'number' => $subject['number'],
|
||||
'name' => self::readableName($subject['username'], $subject['firstname'], $subject['lastname'])
|
||||
);
|
||||
|
||||
|
||||
/* [2] On enregistre les contacts des MINI
|
||||
=========================================================*/
|
||||
$file['contacts'] = array();
|
||||
|
||||
foreach($mini as $miniData){
|
||||
// On récupère les données du contact associé
|
||||
$contact = $contacts[ $miniData['contact'] ];
|
||||
$contact = $contacts[ $miniData['uid'] ];
|
||||
|
||||
// On remplit les données qui iront dans le fichier pour ce contact
|
||||
array_push($file['contacts'], array(
|
||||
'id' => $miniData['contact'],
|
||||
'number' => $contact['number'],
|
||||
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
|
||||
'sexe' => $miniData['sexe'],
|
||||
'age' => $miniData['age'],
|
||||
'studies' => $miniData['studies'],
|
||||
'reltype' => $miniData['reltype'],
|
||||
'dist' => $miniData['loc']
|
||||
'id' => $miniData['uid'],
|
||||
'number' => $contact['number'],
|
||||
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
|
||||
'sexe' => $miniData['sexe'],
|
||||
'age' => $miniData['age'],
|
||||
'studies1' => $miniData['studies'],
|
||||
'reltype' => ($miniData['reltype']==10) ? $miniData['reltypeSpecial'] : $miniData['reltype'], // si 'autre' -> valeur, sinon le code
|
||||
'dist' => $miniData['loc']
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/* (4) On ajoute les données du sujet */
|
||||
$file['subject'] = array(
|
||||
'number' => $subject['number'],
|
||||
'name' => self::readableName($subject['username'], $subject['firstname'], $subject['lastname'])
|
||||
);
|
||||
|
||||
/* [3] On enregistre les contacts des FICHES
|
||||
=========================================================*/
|
||||
foreach($fiches as $ficheData){
|
||||
// On récupère les données du contact associé
|
||||
$contact = $contacts[ $ficheData['uid'] ];
|
||||
|
||||
// On remplit les données qui iront dans le fichier pour ce contact
|
||||
array_push($file['contacts'], array(
|
||||
'id' => $ficheData['uid'],
|
||||
'number' => $contact['number'],
|
||||
'name' => self::readableName($contact['username'], $contact['firstname'], $contact['lastname']),
|
||||
'sexe' => $ficheData['sexe'],
|
||||
'age' => $ficheData['age'],
|
||||
'studies2' => $ficheData['studies'],
|
||||
'reltype' => ($ficheData['reltype']==10) ? $ficheData['reltypeSpecial'] : $ficheData['reltype'], // si 'autre' -> valeur, sinon le code
|
||||
'dist' => $ficheData['loc'],
|
||||
'job' => $ficheData['job'],
|
||||
'famsit' => $ficheData['famsit'],
|
||||
'city' => $ficheData['city'],
|
||||
'cp' => $ficheData['cp'],
|
||||
'duration' => $ficheData['duration'],
|
||||
'context' => $ficheData['context'],
|
||||
'contextExtra' => $ficheData['contextSpecial'],
|
||||
'freq' => $ficheData['freq'],
|
||||
'connect' => $ficheData['connect'],
|
||||
'connectExtra' => $ficheData['connectSpecial']
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* [4] On enregistre les relations de la MATRICE
|
||||
=========================================================*/
|
||||
$file['relations'] = array();
|
||||
|
||||
foreach($matrice as $A=>$Bs)
|
||||
foreach($Bs as $B)
|
||||
array_push($file['relations'], array(
|
||||
'idA' => $A,
|
||||
'idB' => $B
|
||||
));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// on crée un id unique pour cet utilisateur à partir de son numéro
|
||||
$subject_id = (string) $subject_id;
|
||||
|
||||
/* (5) On met le contenu en json */
|
||||
$file = json_encode($file, JSON_PRETTY_PRINT);
|
||||
$file = json_encode($file);
|
||||
|
||||
/* (6) On l'enregistre dans le fichier */
|
||||
$written = file_put_contents( __ROOT__.'/tmp/phone_storage_'.$subject['tmp_id'].'.json', $file);
|
||||
$written = file_put_contents( $filename['old'], $file);
|
||||
|
||||
// Si erreur d'écriture
|
||||
if( $written === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
|
||||
/* (7) On renomme le fichier avec le nouvel identifiant */
|
||||
if( !rename('/tmp/phone_storage_'.$subject['tmp_id'].'.json', '/src/upload/phone_storage/'.$subject_id.'.json') )
|
||||
if( !rename($filename['old'], $filename['new']) )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError ); // si erreur -> erreur
|
||||
|
||||
|
||||
|
@ -257,8 +327,7 @@
|
|||
=========================================================*/
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'subject_id' => $subject_id,
|
||||
'created' => $closest_id
|
||||
'subject_id' => $subject_id
|
||||
);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -1,85 +0,0 @@
|
|||
{
|
||||
"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", "studies1":"1", "reltype":"1", "dist":"0" },
|
||||
{ "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies1":"1", "reltype":"1", "dist":"0" },
|
||||
{ "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies1":"2", "reltype":"2", "dist":"1" },
|
||||
{ "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies1":"3", "reltype":"3", "dist":"2" },
|
||||
{ "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies1":"4", "reltype":"4", "dist":"3" },
|
||||
{ "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies1":"5", "reltype":"5", "dist":"4" },
|
||||
{ "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies1":"6", "reltype":"6", "dist":"5" },
|
||||
{ "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies1":"7", "reltype":"7", "dist":"6" },
|
||||
{ "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies1":"8", "reltype":"8", "dist":"7" },
|
||||
{ "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies1":"9", "reltype":"9", "dist":"8" },
|
||||
{ "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies1":"10", "reltype":"autretext", "dist":"9" },
|
||||
{ "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies1":"11", "reltype":"11", "dist":"10" },
|
||||
{ "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies1":"12", "reltype":"12", "dist":"11" },
|
||||
{ "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies1":"13", "reltype":"13", "dist":"12" },
|
||||
{ "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies1":"14", "reltype":"14", "dist":"13" },
|
||||
{ "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies1":"15", "reltype":"15", "dist":"14" },
|
||||
{ "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies1":"16", "reltype":"16", "dist":"15" },
|
||||
{ "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies1":"17", "reltype":"17", "dist":"16" },
|
||||
{ "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies1":"18", "reltype":"18", "dist":"17" },
|
||||
{ "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies1":"19", "reltype":"19", "dist":"18" },
|
||||
{ "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies1":"20", "reltype":"20", "dist":"19" },
|
||||
{ "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies1":"21", "reltype":"21", "dist":"20" },
|
||||
{ "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies1":"22", "reltype":"22", "dist":"21" },
|
||||
|
||||
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"0", "dist":"0",
|
||||
"job":"82",
|
||||
"famsit":"1",
|
||||
"city":"Toulouse",
|
||||
"cp":"31000",
|
||||
"duration":["2","5"],
|
||||
"context":"11",
|
||||
"contextExtra": ["facebook", "", ""],
|
||||
"freq":["4","9","14","19","24"],
|
||||
"connect":["1","3","5","7","9","11"],
|
||||
"connectExtra":["",""]},
|
||||
|
||||
{ "id":"23", "number":"0606060606", "name":"", "sexe":"0", "age":".", "studies2":".", "reltype":"autretext", "dist":"0",
|
||||
"job":"82",
|
||||
"famsit":"1",
|
||||
"city":"Toulouse",
|
||||
"cp":"31000",
|
||||
"duration":["2","5"],
|
||||
"context":"10",
|
||||
"contextExtra": ["", "", ""],
|
||||
"freq":["4","9","14","19","24"],
|
||||
"connect":["1","3","5","7","9","11"],
|
||||
"connectExtra":["",""]}
|
||||
],
|
||||
|
||||
"relations": {
|
||||
"0": ["1", "4", "6", "8"],
|
||||
"5": ["cd 4", "5", "6"]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue