Gestion de la sélection d'un id-sujet déja existant

This commit is contained in:
xdrm-brackets 2016-05-27 12:13:19 +02:00
parent a71fdcd7c8
commit 40f156bedf
11 changed files with 731 additions and 722 deletions

File diff suppressed because one or more lines are too long

View File

@ -16,6 +16,7 @@ pContactBuilder.setLayout(
"\t<span class='select-container nobold'><select data-name='existing'>\n"+
"\t\t<option value='.' disabled selected>Contact existant</option>\n"+
"@existinglist"+
"\t\t<option value='2'>Jean</option>\n"+
"\t\t<option value='3'>Blaise</option>\n"+
"\t\t<option value='4'>Roger</option>\n"+

View File

@ -1,4 +1,4 @@
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return 0<=a.username.length};
function inputPhoneContact(a,b){this.container=a;this.nav_container=b}inputPhoneContact.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null};inputPhoneContact.prototype.check=function(a){return 0<a.username.length};
inputPhoneContact.prototype.fieldsToStorage=function(){console.log("CONTACTS: FIELDS TO STORAGE");for(var a=$$('[data-sublink="phone"] article.contact-panel .new-contact'),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input"],["data-name"])).deflate();if(this.check(c)){var d={uid:parseInt(c.uid),number:c.number,username:c.username,call:parseInt(c.call),sms:parseInt(c.sms),countcall:parseInt(c.countcall),countsms:parseInt(c.countsms)};d.hash=crc32(JSON.stringify(d));lsi.set("p_contacts",parseInt(c.uid),
d)}}};
inputPhoneContact.prototype.add=function(a){console.log("CONTACTS: ADD");if(null==a||null==a.uid||isNaN(a.uid))return!1;a.number=null!=a.number?a.number:"";a.username=null!=a.username?a.username:"";a.call=null!=a.call?a.call:-1;a.sms=null!=a.sms?a.sms:-1;a.countcall=null!=a.countcall?a.countcall:0;a.countsms=null!=a.countsms?a.countsms:0;this.container.innerHTML+=pContactBuilder.build(a);a=$$('[data-sublink="phone"] article.contact-panel .new-contact');for(var b=this,c=0;c<a.length;c++)a[c].removeEventListener("click",function(a){b.nav(a.target);

View File

@ -20,7 +20,7 @@ inputPhoneContact.prototype = {
=========================================================*/
inputPhoneContact.prototype.check = function(deflated){
/* On retourne la validité du formulaire */
return deflated.username.length >= 0;
return deflated.username.length > 0;
}

View File

@ -18,16 +18,63 @@
*
*/
public static function getAll(){
/* [1] On recupere les donnees des sujets
// Contiendra les sujets
$subjects = array();
/* [1] On récupére la liste des sujets
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
$sub['creation'] = date('d/m/Y H:i:s', $sub['creation']);
$subjects[$id] = $sub;
}
/* [2] On récupére la liste des sujets pour PHONE
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On ferme la bd */
$db->close();
/* (3) 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;
/* [2] Gestion du retour
/* [3] On récupére la liste des sujets pour FACEBOOK
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On ferme la bd */
$db->close();
/* (3) 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] Gestion du retour
=========================================================*/
return array(
'ModuleError' => ManagerError::Success,
'subjects' => $subjects_data
'subjects' => $subjects
);
}
@ -186,7 +233,7 @@
}
/* [1] On récupére la liste des sujets pour PHONE
/* [2] On récupére la liste des sujets pour PHONE
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
@ -203,7 +250,7 @@
/* [2] On récupére la liste des sujets pour FACEBOOK
/* [3] On récupére la liste des sujets pour FACEBOOK
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');

View File

@ -1 +1,2 @@
{"subject":{"id":1,"name":"Jean-Michel","creation":1464337747}}
{"subject":{"id":284,"name":"Julien","creation":1464343075}}

View File

@ -1 +1 @@
{"1":{"line":0,"hash":"b7ec0c5b00bda3ab9b6924938a247bbfe8b46fa2"}}
{"1":{"line":0,"hash":"b7ec0c5b00bda3ab9b6924938a247bbfe8b46fa2"},"284":{"line":1,"hash":"e8781daaaf4e4cd40c0525977a92428524b0f302"}}

View File

@ -1 +1 @@
283
284

View File

@ -43,6 +43,15 @@
<?php /* [3] ADMIN -> Donnees du Telephone
=========================================================*/
/* (1) On récupére la liste de tous les sujets */
$getAll = new ModuleRequest('subject/getAll', array());
$getAllR = $getAll->dispatch();
$allSub = array();
if( $getAllR->error == ManagerError::Success )
$allSub = $getAllR->get('subjects');
?><section data-sublink='phone'> <!-- IMPORT ou SAISIE -->
<section data-timeline>
@ -71,7 +80,14 @@
<article class='subject-panel'>
<h4 class='self color2' data-icon='a'>
<input type='hidden' data-name='tmp_id' value=''>
<input type='number' data-name='subject_id' placeholder='Identifiant'>
<span class='select-container nobold'><select data-name='subject_id'>
<option value='.' disabled selected>Identifiant</option>
<?php foreach($allSub as $id=>$data)
echo "<option value='$id'>".$data['name']."</option>";
?>
</select></span>
<input type='text' data-name='number' id='p_subject_phone_number' placeholder='Numéro de téléphone'>
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
</h4>
@ -189,7 +205,14 @@
<span data-space></span>
<article class='subject-panel'>
<h4 class='self color2' data-icon='a'>
<input type='text' data-name='subject_id' placeholder='Identifiant'>
<span class='select-container nobold'><select data-name='subject_id'>
<option value='.' disabled selected>Identifiant</option>
<?php foreach($allSub as $id=>$data)
echo "<option value='$id'>".$data['name']."</option>";
?>
</select></span>
<input type='submit' class='primary' data-name='submit' data-store value='Enregistrer'>
</h4>
</article>

52
view/js/input-min.js vendored
View File

@ -1,24 +1,24 @@
var sField=$("#search-field"),sSubmit=$("#search-subject"),sList=$('section[data-sublink="survey"] ul[data-list]');
sSubmit.addEventListener("click",function(b){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="",b;for(b in a.results)c+="<li data-element data-id='"+b+"'>",c+="<div data-user><span>SUJET</span></div>",c+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+b+"'></span> </div>",c+="<div> <span data-prefix='Nom'>"+
a.results[b].name+"</span> </div>",c+="<div> <span data-prefix='Cr\u00e9ation'>"+a.results[b].creation+"</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].phone?"checked":"")+" disabled><label for='s_"+b+"'>Cellulaire</label>",c+="</span> </div>",c+="<div> <span><input type='checkbox' id='s_"+b+"' "+(null!=a.results[b].facebook?"checked":"")+" disabled><label for='s_"+b+"'>Facebook</label>",c+="</span> </div>",c+="</li>";sList.innerHTML=c})},!1);
sSubmit.addEventListener("click",function(c){api.send({path:"subject/search",name:sField.value},function(b){if(0!=b.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(b);var a="",e;for(e in b.results)a+="<li data-element data-id='"+e+"'>",a+="<div data-user><span>SUJET</span></div>",a+="<div> <span><input type='text' readonly style='text-align: center' onclick='this.select()' class='flag' value='"+e+"'></span> </div>",a+="<div> <span data-prefix='Nom'>"+
b.results[e].name+"</span> </div>",a+="<div> <span data-prefix='Cr\u00e9ation'>"+b.results[e].creation+"</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+e+"' "+(null!=b.results[e].phone?"checked":"")+" disabled><label for='s_"+e+"'>Cellulaire</label>",a+="</span> </div>",a+="<div> <span><input type='checkbox' id='s_"+e+"' "+(null!=b.results[e].facebook?"checked":"")+" disabled><label for='s_"+e+"'>Facebook</label>",a+="</span> </div>",a+="</li>";sList.innerHTML=a})},!1);
var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager;
function pDynamicUpdate(b){var a=b instanceof Element,c=a&&"INPUT"==b.tagName&&"submit"==b.type,g=a&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!c&&!g&&!a&&!0!==b)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();pMiniManager.storageToFields();
pFicheManager.storageToFields();pMatriceManager.storageToFields();(c||a)&&pContactManager.storageToFields()}
include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var b=new ShortcutManager;b.append("s+n+a+k+e",function(){pMatriceManager.snake()});b.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",
function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur","Il est n\u00e9cessaire de saisir les informations du <b>sujet</b> avant d'exporter son journal d'appel"):Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");pSubjectManager.tmp_id.value=a.tmp_id;pSubjectManager.fieldsToStorage();
pSubjectManager.storageToFields();for(var e=0;e<a.call.length;e++){var d=a.directory[a.call[e]];lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:e,sms:-1})}for(e=0;e<a.sms.length;e++)if(d=a.directory[a.sms[e]],-1<a.call.indexOf(a.sms[e])){var f=lsi.get("p_contacts",d.id);f.sms=e;lsi.set("p_contacts",d.id,f)}else lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:e});for(var h in a.directory)h=
parseInt(h),-1<a.call.indexOf(h)||-1<a.sms.indexOf(h)||(d=a.directory[h],lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:-1}));pContactManager.storageToFields();pDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");
pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),
fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",
function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();
pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,g;for(g in a)if(!isNaN(g)&&(b++,
!a[g].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(g in a)if(!a[g].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(g)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;g={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};
api.send(g,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)})})})})});var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(b){var a=b instanceof Element,c=a&&"INPUT"==b.tagName&&"submit"==b.type,g=a&&"SPAN"==b.tagName&&("f_nav-mini"==b.parentNode.id||"f_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"f_nav-contact"==b.parentNode.id;if(!c&&!g&&!a&&!0!==b)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(c||a)&&fContactManager.storageToFields()}
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact-min.js",function(){include("/js/includes/input-facebook-mini-min.js",function(){include("/js/includes/input-facebook-fiche-min.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));
function pDynamicUpdate(c){var b=c instanceof Element,a=b&&"INPUT"==c.tagName&&"submit"==c.type,e=b&&"SPAN"==c.tagName&&("p_nav-mini"==c.parentNode.id||"p_nav-fiche"==c.parentNode.id),b=b&&"SPAN"==c.tagName&&"p_nav-contact"==c.parentNode.id;if(!a&&!e&&!b&&!0!==c)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();pMiniManager.storageToFields();
pFicheManager.storageToFields();pMatriceManager.storageToFields();(a||b)&&pContactManager.storageToFields()}var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(c){var b=c instanceof Element,a=b&&"INPUT"==c.tagName&&"submit"==c.type,e=b&&"SPAN"==c.tagName&&("f_nav-mini"==c.parentNode.id||"f_nav-fiche"==c.parentNode.id),b=b&&"SPAN"==c.tagName&&"f_nav-contact"==c.parentNode.id;if(!a&&!e&&!b&&!0!==c)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(a||b)&&fContactManager.storageToFields()}
api.send({path:"subject/getAll"},function(c){if(0!=c.ModuleError)return Notification.error("Erreur",c.ModuleError),!1;lsi.createDataset("all-subjects");lsi["import"]("all-subjects",c.subjects);include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=
new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);
pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var b=new ShortcutManager;b.append("s+n+a+k+e",
function(){pMatriceManager.snake()});b.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur",
"Il est n\u00e9cessaire de saisir les informations du <b>sujet</b> avant d'exporter son journal d'appel"):Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");pSubjectManager.tmp_id.value=a.tmp_id;pSubjectManager.fieldsToStorage();pSubjectManager.storageToFields();for(var c=0;c<a.call.length;c++){var d=a.directory[a.call[c]];lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:c,sms:-1})}for(c=
0;c<a.sms.length;c++)if(d=a.directory[a.sms[c]],-1<a.call.indexOf(a.sms[c])){var k=lsi.get("p_contacts",d.id);k.sms=c;lsi.set("p_contacts",d.id,k)}else lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:c});for(var h in a.directory)h=parseInt(h),-1<a.call.indexOf(h)||-1<a.sms.indexOf(h)||(d=a.directory[h],lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:-1}));pContactManager.storageToFields();
pDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},
!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));
b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",
a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();
pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention",
"La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;c={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_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)})})})})});include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact-min.js",function(){include("/js/includes/input-facebook-mini-min.js",function(){include("/js/includes/input-facebook-fiche-min.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));
fSubjectManager.attach();fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));
fFicheManager.attach(fDynamicUpdate);fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(b){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();
fMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={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]};var a=$('[data-sublink="facebook"] #f_download-target');
@ -26,10 +26,10 @@ a.download="local-facebook-data.json";a.href="data:application/octet-stream,"+en
api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(b){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;b=lsi["export"]("f_mini-fiches");var a=0,c;for(c in b)if(!isNaN(c)&&(a++,!b[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+a+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;b=lsi["export"]("f_fiches");for(c in b)if(!b[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(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;console.log(a)},!1)},!1)})})})})});
function testRoutinePhone(b){var a=lsi["export"]("p_contacts"),c=lsi["export"]("p_mini-fiches"),g=lsi["export"]("p_fiches"),e=0;if(null!=b&&b)for(var d in c)isNaN(d)||(b="",null!=a[d]&&(b=a[d].username),c=$('#p_nav-mini [data-n="'+d+'"]'),c.click(),$("#unknown_min_p_"+d).checked=0==b.length,0==b.length?($("#sexeI_mini_p_"+d).checked=!0,$('input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="age"]').value=e%19,$('input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="studies"]').value=0,
$("#reltype9_mini_p_"+d).checked=!0):(b=["H","F"][Math.floor(e%2)],$("#sexe"+b+"_mini_p_"+d).checked=!0,$('input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="age"]').value=e%19,$('input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="studies"]').value=1+e%6,b=e%10,9==b?($("#reltype10_mini_p_"+d).checked=!0,$('input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+b+"_mini_p_"+d).checked=!0,e++));for(var f in g)isNaN(f)||(c=$('#p_nav-fiche [data-n="'+
f+'"]'),c.click(),b=["H","F","I"][Math.floor(e%3)],$("#sexe"+b+"_p_"+f).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="age"]').value=e%19,a="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(" "),a=a[e%a.length],$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 select[data-name="job"]').value=a,a=(e%12).toString(),1==a.length&&(a="0"+a),$('article.fiche-relation > input[data-name="uid"][value="'+
f+'"] ~ h5 select[data-name="studies"]').value=a,b=e%9,8==b?($("#reltype10_p_"+f).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+b+"_p_"+f).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="city"]').value=(10+e).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="cp"]').value=(1E4+e).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+
f+'"] ~ h5 input[data-name="quartier"]').value=e,$("#loc"+["A","B","C","D"][Math.floor(e%4)]+"_p_"+f).checked=!0,a=$$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="duration"]'),a[0].value=e.toString(),a[1].value=1+e.toString(),a=e%14,$("article.fiche-relation #contexte"+a+"_p_"+f).checked=!0,g=$$('article.fiche-relation > input[data-name="uid"][value="'+f+'"] ~ h5 input[data-name="contextSpecial"]'),11==a&&(g[0].value="internet"),12==a&&(g[1].value="association"),
13==a&&(g[2].value="autre"),e++)};
!1;console.log(a)},!1)},!1)})})})})})});
function testRoutinePhone(c){var b=lsi["export"]("p_contacts"),a=lsi["export"]("p_mini-fiches"),e=lsi["export"]("p_fiches"),f=0;if(null!=c&&c)for(var g in a)isNaN(g)||(c="",null!=b[g]&&(c=b[g].username),a=$('#p_nav-mini [data-n="'+g+'"]'),a.click(),$("#unknown_min_p_"+g).checked=0==c.length,0==c.length?($("#sexeI_mini_p_"+g).checked=!0,$('input[data-name="uid"][value="'+g+'"] ~ h5 select[data-name="age"]').value=f%19,$('input[data-name="uid"][value="'+g+'"] ~ h5 select[data-name="studies"]').value=0,
$("#reltype9_mini_p_"+g).checked=!0):(c=["H","F"][Math.floor(f%2)],$("#sexe"+c+"_mini_p_"+g).checked=!0,$('input[data-name="uid"][value="'+g+'"] ~ h5 select[data-name="age"]').value=f%19,$('input[data-name="uid"][value="'+g+'"] ~ h5 select[data-name="studies"]').value=1+f%6,c=f%10,9==c?($("#reltype10_mini_p_"+g).checked=!0,$('input[data-name="uid"][value="'+g+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+c+"_mini_p_"+g).checked=!0,f++));for(var d in e)isNaN(d)||(a=$('#p_nav-fiche [data-n="'+
d+'"]'),a.click(),c=["H","F","I"][Math.floor(f%3)],$("#sexe"+c+"_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="age"]').value=f%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[f%b.length],$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 select[data-name="job"]').value=b,b=(f%12).toString(),1==b.length&&(b="0"+b),$('article.fiche-relation > input[data-name="uid"][value="'+
d+'"] ~ h5 select[data-name="studies"]').value=b,c=f%9,8==c?($("#reltype10_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="reltypeSpecial"]').value="autre"):$("#reltype"+c+"_p_"+d).checked=!0,$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="city"]').value=(10+f).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="cp"]').value=(1E4+f).toString(),$('article.fiche-relation > input[data-name="uid"][value="'+
d+'"] ~ h5 input[data-name="quartier"]').value=f,$("#loc"+["A","B","C","D"][Math.floor(f%4)]+"_p_"+d).checked=!0,b=$$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="duration"]'),b[0].value=f.toString(),b[1].value=1+f.toString(),b=f%14,$("article.fiche-relation #contexte"+b+"_p_"+d).checked=!0,e=$$('article.fiche-relation > input[data-name="uid"][value="'+d+'"] ~ h5 input[data-name="contextSpecial"]'),11==b&&(e[0].value="internet"),12==b&&(e[1].value="association"),
13==b&&(e[2].value="autre"),f++)};

View File

@ -64,12 +64,7 @@ sSubmit.addEventListener('click', function(e){
/*=========================================================*/
/*========== Gestion du formulaire téléphonique ===========*/
/*=========================================================*/
/* [1] Initialisation des utilitaires et variables
/* [1] Initialisation des utilitaires et variables PHONE
=========================================================*
/* (1) Initialisation des managers */
var pSubjectManager;
@ -131,14 +126,93 @@ function pDynamicUpdate(target){
/* [2] Initialisation des utilitaires et variables FACEBEOOK
=========================================================*
/* (1) Initialisation des managers */
var fSubjectManager;
var fContactManager;
var fMiniManager;
var fFicheManager;
var fMatriceManager;
/* (2) Fonctions utiles */
function fDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
}
/* [2] Inclusion des scripts externes et lancement
/* [3] On récupère la liste des sujets
=========================================================*/
api.send({ path: 'subject/getAll' }, function(allSubjectsResponse){
// Si erreur
if( allSubjectsResponse.ModuleError != 0){
Notification.error('Erreur', allSubjectsResponse.ModuleError);
return false;
}
// On enregistre la liste des sujets existants
lsi.createDataset('all-subjects');
lsi.import('all-subjects', allSubjectsResponse.subjects);
/*=========================================================*/
/*========== Gestion du formulaire téléphonique ===========*/
/*=========================================================*/
include('/js/includes/input-phone-subject-min.js', function(){
include('/js/includes/input-phone-contact-min.js', function(){
include('/js/includes/input-phone-mini-min.js', function(){
@ -549,145 +623,9 @@ include('/js/includes/input-phone-matrice-min.js', function(){
/*=========================================================*/
/*=========== Gestion du formulaire facebook ==============*/
/*=========================================================*/
/* [1] Initialisation des utilitaires et variables
=========================================================*
/* (1) Initialisation des managers */
var fSubjectManager;
var fContactManager;
var fMiniManager;
var fFicheManager;
var fMatriceManager;
/* (2) Fonctions utiles */
function fDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
---------------------------------------------------------*/
var isElement = target instanceof Element;
var isSaveButton = isElement && target.tagName == 'INPUT' && target.type == 'submit';
var isNavButton = isElement && target.tagName == 'SPAN' && (target.parentNode.id == 'f_nav-mini' || target.parentNode.id == 'f_nav-fiche');
var isNavContact = isElement && target.tagName == 'SPAN' && target.parentNode.id == 'f_nav-contact';
// Si erreur, on retourne une erreur
if( !isSaveButton && !isNavButton && !isNavContact && target !== true )
return false;
console.log('> dynamic update');
/* (1) On enregistre les MINI fiches relation */
fMiniManager.fieldsToStorage();
/* (2) On enregister les FICHES relation */
fFicheManager.fieldsToStorage();
/* (3) On enregistre les CONTACTS */
fContactManager.fieldsToStorage();
/* (4) On enregistre la MATRICE */
fMatriceManager.fieldsToStorage();
/* (5) On synchronise les FICHE avec les CONTACTS */
// 1. On synchronise les `mini` et `fiches` associées en fonction de la dernière date de modification
// 2. On synchronise les `fiches` dupliquées en fonction de la dernière date de modification
fFicheManager.sync();
/* (6) On synchronise les MINI avec les CONTACTS */
// Supprime les contacts déja dans les FICHES
fMiniManager.sync();
/* (7) On affiche le tout */
fMiniManager.storageToFields();
fFicheManager.storageToFields();
fMatriceManager.storageToFields();
/* (8) On met à jour les contacts si on les a modifié on si on navigue dans les contacts */
if( isSaveButton || isNavContact )
fContactManager.storageToFields();
}
/* [2] Inclusion des scripts externes et lancement
=========================================================*/
include('/js/includes/input-facebook-subject-min.js', function(){
include('/js/includes/input-facebook-contact-min.js', function(){
include('/js/includes/input-facebook-mini-min.js', function(){
@ -936,8 +874,7 @@ include('/js/includes/input-facebook-matrice-min.js', function(){
});