DONE*​: Correction de l'affichage des noms (`readableName(u, f, l)`) + Nettoyage de `html-data` + Correction de l'erreur pour un `petit` journal d'appel ou avec des `names` `null` dans le journal d'appel

This commit is contained in:
xdrm-brackets 2016-05-11 22:02:20 +02:00
parent 79de8cc5bf
commit 14d20c4b2d
13 changed files with 153 additions and 1089 deletions

View File

@ -69,17 +69,17 @@
/* [3] Test de la vérification du format de fichier pour l'upload
=========================================================*/
// ?>
?>
<!-- <form action='' method='POST' enctype='multipart/form-data'>
<input type='file' name='file'>
<input type='submit' value='Upload'>
</form> -->
<?php //
<?php
// var_dump($_FILES);
//
// if( isset($_FILES) ){
//
// $request = new ModuleRequest('upload/local_data', array() );
// $request = new ModuleRequest('upload/call_log', array('phone_number'=>'01 02 03 04 05') );
// $response = $request->dispatch();
// var_dump( ManagerError::explicit($response->error) );
//

View File

@ -1,23 +1,23 @@
<?xml version='1.0' encoding='UTF-8' standalone='yes' ?><Logs>
<Item Id="1" Number="8012" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="2" Number="8013" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="3" Number="8014" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="4" Number="8015" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="5" Number="8016" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="6" Number="8017" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="7" Number="8018" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="8" Number="8019" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="9" Number="8020" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="10" Number="8021" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="11" Number="8022" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="12" Number="+33631202761" Name="Thomas Hopquin" Date="2014-02-28T15:00:10" Duration="125" Direction="OUTGOING" Type="PHONE" />
<Item Id="13" Number="0681585322" Name="maxime colo thales" Date="2014-02-15T23:06:46" Duration="0" Direction="INGOING" Type="PHONE" />
<Item Id="14" Number="0678593540" Name="nicolas colo thales" Date="2014-02-15T23:06:18" Duration="0" Direction="INGOING" Type="PHONE" />
<Item Id="15" Number="0627557790" Name="Sophie" Date="2014-02-15T21:08:34" Duration="349" Direction="OUTGOING" Type="PHONE" />
<Item Id="16" Number="0627557790" Name="Sophie" Date="2014-02-15T20:51:38" Duration="0" Direction="OUTGOING" Type="PHONE" />
<Item Id="17" Number="+33607516488" Name="Morgane P1" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="18" Number="+33607515488" Name="Morgane P2" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="19" Number="+33607514488" Name="Morgane P3" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="20" Number="+33607517488" Name="Morgane P4" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="21" Number="0642468206" Name="Perrine Petit" Date="2014-02-15T17:24:18" Duration="276" Direction="OUTGOING" Type="PHONE" />
<Item Id="22" Number="+33603900774" Name="Maman" Date="2014-02-15T16:34:29" Duration="36" Direction="OUTGOING" Type="PHONE" /></Logs>
<Item Id="1" Number="8012" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="2" Number="8013" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="3" Number="8014" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="4" Number="8015" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="5" Number="8016" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="6" Number="8017" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="7" Number="8018" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="8" Number="8019" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="9" Number="8020" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="10" Number="8021" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="11" Number="8022" Name="" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
<Item Id="12" Number="+33631202761" Name="Thomas Hopquin" Date="2014-02-28T15:00:10" Duration="125" Direction="OUTGOING" Type="PHONE" />
<Item Id="13" Number="0681585322" Name="maxime colo thales" Date="2014-02-15T23:06:46" Duration="0" Direction="INGOING" Type="PHONE" />
<Item Id="14" Number="0678593540" Name="nicolas colo thales" Date="2014-02-15T23:06:18" Duration="0" Direction="INGOING" Type="PHONE" />
<Item Id="15" Number="0627557790" Name="Sophie" Date="2014-02-15T21:08:34" Duration="349" Direction="OUTGOING" Type="PHONE" />
<Item Id="16" Number="0627557790" Name="Sophie" Date="2014-02-15T20:51:38" Duration="0" Direction="OUTGOING" Type="PHONE" />
<Item Id="17" Number="+33607516488" Name="Morgane P1" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="18" Number="+33607515488" Name="Morgane P2" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="19" Number="+33607514488" Name="Morgane P3" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="20" Number="+33607517488" Name="Morgane P4" Date="2014-02-15T19:06:33" Duration="657" Direction="OUTGOING" Type="PHONE" />
<Item Id="21" Number="0642468206" Name="Perrine Petit" Date="2014-02-15T17:24:18" Duration="276" Direction="OUTGOING" Type="PHONE" />
<Item Id="22" Number="+33603900774" Name="Maman" Date="2014-02-15T16:34:29" Duration="36" Direction="OUTGOING" Type="PHONE" /></Logs>

File diff suppressed because one or more lines are too long

View File

@ -46,12 +46,9 @@ miniFicheBuilder.setLayout(
"<article class='mini-fiche-relation'>\n"+
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
"\t<input type='hidden' data-name='firstname' value='@firstname'>\n"+
"\t<input type='hidden' data-name='lastname' value='@lastname'>\n"+
"\t<input type='hidden' data-name='username' value='@username'>\n"+
"\t<span data-space></span>\n"+
"\t<h4 data-icon='a' class='color2'>@firstname @lastname @username</h4>\n"+
"\t<h4 data-icon='a' class='color2'>@name</h4>\n"+
"\t<h5 class='nobold color0'>"+
"\t\t@countcall appels"+
@ -200,11 +197,8 @@ ficheBuilder.setLayout(
"\t<input type='hidden' data-name='contact' value='@contact'>\n"+
"\t<input type='hidden' data-name='uid' value='@uid'>\n"+
"\t<input type='hidden' data-name='firstname' value='@firstname'>\n"+
"\t<input type='hidden' data-name='lastname' value='@lastname'>\n"+
"\t<input type='hidden' data-name='username' value='@username'>\n"+
"\t<h4 data-icon='a' class='color2'>@firstname @lastname @username</h4>\n"+
"\t<h4 data-icon='a' class='color2'>@name</h4>\n"+
"\t<h5 class='nobold color0'>"+
"\t\t@countcall appels"+

View File

@ -1,15 +1,15 @@
function inputPhoneFiche(a,b){this.container=a;this.nav_container=b}inputPhoneFiche.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"H",age:".",job:".",famsit:"0",studies:".",reltype:"0",reltypeSpecial:"",city:"",cp:"",loc:"0",duration:["",""],context:"0",contextSpecial:["","",""],freq:["0","4","8","12","16"],connect:"1 3 5 7 9 11".split(" "),connectSpecial:["",""],timestamp:0,valid:!1}};
inputPhoneFiche.prototype.fieldsToStorage=function(){console.log("FICHE: FIELDS TO STORAGE");for(var a=$$("article.relation-panel .fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;c={contact:parseInt(c.contact),uid:parseInt(c.uid),sexe:c.sexe,age:c.age,job:c.job,famsit:c.famsit,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,
city:c.city,cp:c.cp,loc:c.loc,duration:c.duration,context:c.context,contextSpecial:c.contextSpecial,freq:c.freq,connect:c.connect,connectSpecial:c.connectSpecial,hash:e};c.valid=this.check(c);0<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("fiches",c.uid,c)}}};
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||null==a.contact)return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?a.contextSpecial[0]:
this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;a.studies=null!=a.studies?
a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("contacts",a.contact);if(!1===
b)return!1;this.container.innerHTML+=ficheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});
b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=
b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");
c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');
for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
inputPhoneFiche.prototype.add=function(a){console.log("FICHE: ADD");if(null==a.uid||isNaN(a.uid)||null==a.contact||isNaN(a.contact))return!1;a.city=null!=a.city?a.city:this.defaultData.city;a.cp=null!=a.cp?a.cp:this.defaultData.cp;a.duration[0]=null!=a.duration[0]?a.duration[0]:this.defaultData.duration[0];a.duration[1]=null!=a.duration[1]?a.duration[1]:this.defaultData.duration[1];a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.contextSpecial[0]=null!=a.contextSpecial[0]?
a.contextSpecial[0]:this.defaultData.contextSpecial[0];a.contextSpecial[1]=null!=a.contextSpecial[1]?a.contextSpecial[1]:this.defaultData.contextSpecial[1];a.contextSpecial[2]=null!=a.contextSpecial[2]?a.contextSpecial[2]:this.defaultData.contextSpecial[2];a.connectSpecial[0]=null!=a.connectSpecial[0]?a.connectSpecial[0]:this.defaultData.connectSpecial[0];a.connectSpecial[1]=null!=a.connectSpecial[1]?a.connectSpecial[1]:this.defaultData.connectSpecial[1];a.job=null!=a.job?a.job:this.defaultData.job;
a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.famsit=null!=a.famsit?a.famsit:this.defaultData.famsit;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.loc=null!=a.loc?a.loc:this.defaultData.loc;a.context=null!=a.context?a.context:this.defaultData.context;a.freq=null!=a.freq?a.freq:this.defaultData.freq;a.connect=null!=a.connect?a.connect:this.defaultData.connect;var b=lsi.get("contacts",
a.contact);if(!1===b)return!1;this.container.innerHTML+=ficheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),countcall:b.countcall,countsms:b.countsms,uid:a.uid,contact:a.contact,city:a.city,cp:a.cp,duration0:a.duration[0],duration1:a.duration[1],reltypespecial:a.reltypeSpecial,contextspecial0:a.contextSpecial[0],contextspecial1:a.contextSpecial[1],contextspecial2:a.contextSpecial[2],connectspecial0:a.connectSpecial[0],connectspecial1:a.connectSpecial[1]});b=$('article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>span>select[data-name="job"]>option[value="'+a.job+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.fiche-relation input[data-name="uid"][value="'+
a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="famsit"]');for(b=0;b<c.length;b++)c[b].value==a.famsit?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');
for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="context"]');for(b=0;b<c.length;b++)c[b].value==a.context?
c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="freq"]');for(b=0;b<c.length;b++)-1<a.freq.indexOf(c[b].value)?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="connect"]');for(b=0;b<c.length;b++)-1<a.connect.indexOf(c[b].value)?c[b].setAttribute("checked",
"checked"):c[b].removeAttribute("checked")};inputPhoneFiche.prototype.storageToFields=function(){console.log("FICHE: STORAGE TO FIELDS");var a=lsi["export"]("fiches");this.container.innerHTML="";for(var b in a)a[b].uid==this.selected&&this.add(a[b]);this.updateNavBar()};
inputPhoneFiche.prototype.sync=function(){console.log("FICHE: SYNC");var a=lsi["export"]("contacts"),b=[],c;for(c in a){if(-1<a[c].call){var e=a[c].call;b.push(e);var d=lsi.get("fiches",e);null==d&&(d=this.defaultData);d.uid=e;d.contact=parseInt(c);lsi.set("fiches",e,d)}-1<a[c].sms&&(e=10+a[c].sms,b.push(e),d=lsi.get("fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("fiches",e,d))}if(20>b.length)for(c in a){for(a=0;-1<b.indexOf(a)&&20>a;)a++;b.push(a);d=lsi.get("fiches",
a);null==d&&(d=this.defaultData);d.uid=a;d.contact=parseInt(c);lsi.set("fiches",a,d);if(20<=b.length)break}for(var f in d)b=lsi.get("contacts",d[f].contact),null!=b&&-1!=b.sms&&-1!=b.call&&(b=10>parseInt(f)?10+b.sms:b.call,b=d[b],b.timestamp>=d[f].timestamp||(c=d[f],c.uid=b.uid,lsi.set("fiches",b.uid,c)))};
inputPhoneFiche.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-fiche"!=a.parentNode.id)return!1;for(var b=$$("#nav-fiche > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};

View File

@ -127,7 +127,7 @@ inputPhoneFiche.prototype.add = function(objectData){
console.log('FICHE: ADD');
// Si pas d'UID ou d'UID de contact, on retourne une erreur
if( objectData.uid == null || objectData.contact == null )
if( objectData.uid == null || isNaN(objectData.uid) || objectData.contact == null || isNaN(objectData.contact) )
return false;
/* (0) Gestion du formattage des valeur */
@ -168,9 +168,7 @@ inputPhoneFiche.prototype.add = function(objectData){
// {5} Création physique //
this.container.innerHTML += ficheBuilder.build({
firstname: associatedContact.firstname,
lastname: associatedContact.lastname,
username: (associatedContact.username.length==0) ? '' : '('+associatedContact.username+')',
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,

View File

@ -1,5 +1,5 @@
function inputPhoneMatrice(a){this.container=a}inputPhoneMatrice.prototype={container:this.container};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var g in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][g]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("matrice",0,d)};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("fiches"),d=lsi.get("matrice",0),b=lsi["export"]("contacts"),g=[],c;for(c in a)-1==g.indexOf(a[c].contact)&&g.push(a[c].contact);a="<table class='line'>";for(c=0;c<g.length;c++){var e=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=e.firstname+" "+e.lastname,a+=0<e.username.length?" ("+e.username+")":"",a+="</td>"):a+="<td></td>";for(var h=0;h<g.length;h++)if(h<g.length-
1){var f=b[h];0==c?(a+="<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=f.firstname+" "+f.lastname,a+=0<f.username.length?" ("+f.username+")":"",a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+e.uid+"_"+f.uid+"' data-name='"+e.uid+"' value='"+f.uid+"' id='matrice_"+e.uid+"_"+f.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+e.uid+"_"+f.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=
a+"</table>"};inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};
inputPhoneMatrice.prototype.fieldsToStorage=function(){console.log("MATRICE: FIELDS TO STORAGE");var a=(new FormDeflater(this.container,["input"],["data-name"])).deflate();crc32(JSON.stringify(a));var d={},b;for(b in a)if(a[b]instanceof Array)for(var e in a[b])null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b][e]));else null!==a[b]&&(null==d[b]&&(d[b]=[]),d[b].push(parseInt(a[b])));lsi.set("matrice",0,d)};
inputPhoneMatrice.prototype.storageToFields=function(){console.log("MATRICE: STORAGE TO FIELDS");var a=lsi["export"]("fiches"),d=lsi.get("matrice",0),b=lsi["export"]("contacts"),e=[],c;for(c in a)-1==e.indexOf(a[c].contact)&&e.push(a[c].contact);a="<table class='line'>";for(c=0;c<e.length;c++){var f=b[c],a=a+"<tr>";0<c?(a+='<td style="text-align: right;">',a+=readableName(f.username,f.firstname,f.lastname),a+="</td>"):a+="<td></td>";for(var h=0;h<e.length;h++)if(h<e.length-1){var g=b[h];0==c?(a+=
"<td>",a+='<span style="writing-mode: vertical-lr; text-align: right;">',a+=readableName(g.username,g.firstname,g.lastname),a+="</span>"):h<c?(a+="<td>",a+="<input type='checkbox' name='matrice_"+f.uid+"_"+g.uid+"' data-name='"+f.uid+"' value='"+g.uid+"' id='matrice_"+f.uid+"_"+g.uid+"'",null!=d[c]&&-1<d[c].indexOf(h)&&(a+=" checked"),a+=" >",a+="<label for='matrice_"+f.uid+"_"+g.uid+"'></label>"):a+="<td class='hidden'>";a+="</td>"}a+="</tr>"}this.container.innerHTML=a+"</table>"};
inputPhoneMatrice.prototype.attach=function(){console.log("MATRICE: ATTACH");lsi.createDataset("matrice");this.storageToFields();var a=this;this.container.addEventListener("click",function(d){a.fieldsToStorage();a.storageToFields()},!1)};

View File

@ -108,8 +108,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
if( A > 0 ){ // Noms sur la première ligne (abscisses)
matrice_html += '<td style="text-align: right;">';
matrice_html += conA.firstname+' '+conA.lastname
matrice_html += (conA.username.length>0) ? ' ('+conA.username+')' : '';
matrice_html += readableName(conA.username, conA.firstname, conA.lastname);
matrice_html += '</td>';
}else // Sinon,
matrice_html += '<td></td>';
@ -122,8 +121,7 @@ inputPhoneMatrice.prototype.storageToFields = function(){
if( A == 0 ){
matrice_html += '<td>';
matrice_html += '<span style="writing-mode: vertical-lr; text-align: right;">';
matrice_html += conB.firstname+' '+conB.lastname;
matrice_html += (conB.username.length>0) ? ' ('+conB.username+')' : '';
matrice_html += readableName(conB.username, conB.firstname, conB.lastname),
matrice_html += '</span>';
// {4} Valeurs des relations (boutons) //

View File

@ -1,11 +1,11 @@
function inputPhoneMini(a,b){this.container=a;this.nav_container=b}inputPhoneMini.prototype={container:this.container,nav_container:this.nav_container,selected:0,handler:null,defaultData:{sexe:"H",age:".",studies:".",loc:"0",reltype:"0",reltypeSpecial:"",timestamp:0,valid:!1}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:parseInt(c.uid),firstname:d.firstname,lastname:d.lastname,username:d.username,sexe:c.sexe,age:c.age,studies:c.studies,
reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,loc:c.loc,hash:e};c.valid=this.check(c);0<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("mini-fiches",c.uid,c)}}};
inputPhoneMini.prototype.fieldsToStorage=function(){console.log("MINI FICHE: FIELDS TO STORAGE");for(var a=$$("article.mini-relation-panel .mini-fiche-relation"),b=0;b<a.length;b++){var c=(new FormDeflater(a[b],["input","select"],["data-name"])).deflate(),e=crc32(JSON.stringify(c)),d=lsi.get("mini-fiches",c.uid);if(!1!==d){if(null!=d.hash&&d.hash==e)break;console.warn("> MINI UPDATE");c={uid:parseInt(c.uid),sexe:c.sexe,age:c.age,studies:c.studies,reltype:c.reltype,reltypeSpecial:c.reltypeSpecial,
loc:c.loc,hash:e};c.valid=this.check(c);0<diff(d,c,["hash","valid","timestamp"]).length&&(console.log(diff(d,c,["hash","valid","timestamp"])),console.warn("> FICHE UPDATE"),c.timestamp=Date.now());lsi.set("mini-fiches",c.uid,c)}}};
inputPhoneMini.prototype.add=function(a){console.log("MINI FICHE: ADD");if(null==a||null==a.uid)return!1;a.age=null!=a.age?a.age:this.defaultData.age;a.sexe=null!=a.sexe?a.sexe:this.defaultData.sexe;a.studies=null!=a.studies?a.studies:this.defaultData.studies;a.reltype=null!=a.reltype?a.reltype:this.defaultData.reltype;a.reltypeSpecial=null!=a.reltypeSpecial?a.reltypeSpecial:this.defaultData.reltypeSpecial;a.loc=null!=a.loc?a.loc:this.defaultData.loc;var b=lsi.get("contacts",a.uid);if(!1===b)return!1;
this.container.innerHTML+=miniFicheBuilder.build({firstname:b.firstname,lastname:b.lastname,username:0==b.username.length?"":"("+b.username+")",countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+
this.container.innerHTML+=miniFicheBuilder.build({name:readableName(b.username,b.firstname,b.lastname),countcall:b.countcall,countsms:b.countsms,uid:a.uid,reltypespecial:a.reltypeSpecial});b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="studies"]>option[value="'+a.studies+'"]');null!=b&&b.setAttribute("selected","selected");b=$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>span>select[data-name="age"]>option[value="'+
a.age+'"]');null!=b&&b.setAttribute("selected","selected");for(var c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].value==a.sexe?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="reltype"]');for(b=0;b<c.length;b++)c[b].value==a.reltype?c[b].setAttribute("checked","checked"):
c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);this.container.innerHTML="";this.add(a);this.updateNavBar()};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b=lsi["export"]("fiches"),c=[],e;for(e in b)-1==c.indexOf(b[e].contact)&&c.push(b[e].contact);for(var d in a)-1<c.indexOf(parseInt(d))?lsi.del("mini-fiches",d):(console.warn(d,c,c.indexOf(parseInt(d)),lsi["export"]("mini-fiches")),a=lsi.get("mini-fiches",d),null==a&&(a=this.defaultData,a.valid=!1),a.uid=parseInt(d),lsi.set("mini-fiches",d,a))};
c[b].removeAttribute("checked");c=$$('article.mini-fiche-relation input[data-name="uid"][value="'+a.uid+'"] ~ h5>input[type="radio"][data-name="loc"]');for(b=0;b<c.length;b++)c[b].value==a.loc?c[b].setAttribute("checked","checked"):c[b].removeAttribute("checked")};inputPhoneMini.prototype.storageToFields=function(){console.log("MINI FICHE: STORAGE TO FIELDS");var a=lsi.get("mini-fiches",this.selected);if(null==a)return this.updateNavBar(),!1;this.container.innerHTML="";this.add(a);this.updateNavBar()};
inputPhoneMini.prototype.sync=function(){console.log("MINI FICHE: SYNC");var a=lsi["export"]("contacts"),b=lsi["export"]("fiches"),c=[],e;for(e in b)-1==c.indexOf(b[e].contact)&&c.push(b[e].contact);for(var d in a)-1<c.indexOf(parseInt(d))?lsi.del("mini-fiches",d):(b=0==a[d].username.length+a[d].firstname.length+a[d].lastname.length?d.toString()+"-":d,e=lsi.get("mini-fiches",b),null==e&&(e=this.defaultData,e.valid=!1,isNaN(b)&&(e.reltype="9")),e.uid=parseInt(d),lsi.set("mini-fiches",b,e))};
inputPhoneMini.prototype.nav=function(a){if(null==a||!1===a.getData("n")||isNaN(a.getData("n"))||"nav-mini"!=a.parentNode.id)return!1;for(var b=$$("#nav-mini > span.active"),c=0;c<b.length;c++)b[c].remClass("active");a.addClass("active");this.selected=parseInt(a.getData("n"))};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches");Object.keys(a);this.nav_container.innerHTML="";var b=0,c;for(c in a)this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>";for(c in a)b=$('#nav-mini [data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))};
inputPhoneMini.prototype.updateNavBar=function(){var a=lsi["export"]("mini-fiches");this.nav_container.innerHTML="";var b=0,c;for(c in a)isNaN(c)||(this.nav_container.innerHTML+='<span data-n="'+c+'">'+ ++b+"</span>");for(c in a)isNaN(c)||(b=$('#nav-mini [data-n="'+a[c].uid+'"]'),null!=b&&(!0===a[c].valid?b.addClass("done"):b.remClass("done")));this.nav($('#nav-mini [data-n="'+this.selected+'"]'))};
inputPhoneMini.prototype.check=function(a){return""==a.sexe||"."==a.studies||"."==a.age||""==a.loc||""==a.reltype||"8"==a.reltype&&2>a.reltypeSpecial.length?!1:!0};inputPhoneMini.prototype.attach=function(a){console.log("MINI FICHE: ATTACH");lsi.createDataset("mini-fiches");this.storageToFields();this.handler=a;var b=this;this.nav_container.addEventListener("click",function(a){b.nav(a.target);b.handler(a.target)},!1)};

View File

@ -63,9 +63,6 @@ inputPhoneMini.prototype.fieldsToStorage = function(){
var obj = {
uid: parseInt(deflated.uid),
firstname: existingData.firstname,
lastname: existingData.lastname,
username: existingData.username,
sexe: deflated.sexe, // [0] Homme, [1] Femme
age: deflated.age,
studies: deflated.studies,
@ -133,9 +130,7 @@ inputPhoneMini.prototype.add = function(objectData){
// {2} Création physique //
this.container.innerHTML += miniFicheBuilder.build({
firstname: associatedContact.firstname,
lastname: associatedContact.lastname,
username: (associatedContact.username.length==0) ? '' : '('+associatedContact.username+')',
name: readableName(associatedContact.username, associatedContact.firstname, associatedContact.lastname),
countcall: associatedContact.countcall,
countsms: associatedContact.countsms,
uid: objectData.uid,
@ -190,6 +185,12 @@ inputPhoneMini.prototype.storageToFields = function(){
// {1} Pour chaque contact du 'localStorage' //
var miniData = lsi.get('mini-fiches', this.selected);
// Si on a rien trouvé, on ne fait rien
if( miniData == null ){
this.updateNavBar();
return false;
}
// On réinitialise le HTML
this.container.innerHTML = '';
@ -237,17 +238,25 @@ inputPhoneMini.prototype.sync = function(){
lsi.del('mini-fiches', key);
continue;
}
console.warn(key, ignoredContacts, ignoredContacts.indexOf(parseInt(key)), lsi.export('mini-fiches'));
/* (5) Si le contact n'a aucun nominatif, on met inconnu par défaut, mais on ne l'affiche pas */
var noName = contactData[key].username.length+contactData[key].firstname.length+contactData[key].lastname.length == 0;
// On rajoute un '.' après pour dire qu'on affichera pas
var uid = noName ? key.toString()+'-' : key;
/* (5) On récupère les informations de la MINI (si elle existe) */
var miniData = lsi.get('mini-fiches', key);
var miniData = lsi.get('mini-fiches', uid);
/* (6) Si la MINI fiche n'exise pas, on la crée avec les valeurs par défaut */
if( miniData == null ){
miniData = this.defaultData;
miniData.valid = false;
// Si aucun nom, on met 'inconnu' par défaut pour la fiche de relation
if( isNaN(uid) )
miniData.reltype = '9';
}
/* (7) On met à jour la MINI fiche */
@ -255,7 +264,7 @@ inputPhoneMini.prototype.sync = function(){
/* (8) On enregistre les modification */
lsi.set('mini-fiches', key, miniData);
lsi.set('mini-fiches', uid, miniData);
}
@ -297,7 +306,6 @@ inputPhoneMini.prototype.nav = function(element){
=========================================================*/
inputPhoneMini.prototype.updateNavBar = function(){
var miniData = lsi.export('mini-fiches');
var len = Object.keys(miniData).length;
/* (1) On vide et remplit la barre de nav, si elle n'est pas à jour */
@ -305,12 +313,17 @@ inputPhoneMini.prototype.updateNavBar = function(){
var i = 0;
for( var key in miniData )
this.nav_container.innerHTML += '<span data-n="'+key+'">'+(++i)+'</span>';
if( !isNaN(key) ) // On affiche que les clés numériques
this.nav_container.innerHTML += '<span data-n="'+key+'">'+(++i)+'</span>';
/* (2) On montre les MINI fiches qui sont correctes dans la navbar */
for( var key in miniData ){
// Si la clé n'est pas numérique, on ne gère pas
if( isNaN(key) )
continue;
var currentElement = $('#nav-mini [data-n="'+miniData[key].uid+'"]');
if( currentElement == null )

File diff suppressed because it is too large Load Diff

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

@ -1,15 +1,15 @@
var subjectManager,contactManager,miniManager,ficheManager,matriceManager;
function dynamicUpdate(a){var b=a instanceof Element,f=b&&"SPAN"==a.tagName&&"switch-left"==a.className,e=b&&"SPAN"==a.tagName&&"switch-both"==a.className,g=b&&"INPUT"==a.tagName&&"submit"==a.type,c=b&&"SPAN"==a.tagName&&("nav-mini"==a.parentNode.id||"nav-fiche"==a.parentNode.id),b=b&&"SPAN"==a.tagName&&"nav-contact"==a.parentNode.id;if(!(e||f||g||c||b)&&!0!==a)return!1;if(e)console.log("> switch firstname <-> lastname"),f=a.parentNode,a=f.children[8],f=f.children[10],e=a.value,a.value=f.value,f.value=
e;else if(f){console.log("> switch firstname+lastname -> username");f=a.parentNode;e=f.children[6];a=f.children[8];f=f.children[10];if(0<e.value.length||0==a.value.length&&0==f.value.length)return!1;e.value=a.value+" "+f.value;a.value="";f.value=""}else console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),matriceManager.fieldsToStorage(),ficheManager.sync(),miniManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),
matriceManager.storageToFields(),(g||b)&&contactManager.storageToFields()}
function dynamicUpdate(b){var a=b instanceof Element,e=a&&"SPAN"==b.tagName&&"switch-left"==b.className,f=a&&"SPAN"==b.tagName&&"switch-both"==b.className,g=a&&"INPUT"==b.tagName&&"submit"==b.type,c=a&&"SPAN"==b.tagName&&("nav-mini"==b.parentNode.id||"nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"nav-contact"==b.parentNode.id;if(!(f||e||g||c||a)&&!0!==b)return!1;if(f)console.log("> switch firstname <-> lastname"),e=b.parentNode,b=e.children[8],e=e.children[10],f=b.value,b.value=e.value,e.value=
f;else if(e){console.log("> switch firstname+lastname -> username");e=b.parentNode;f=e.children[6];b=e.children[8];e=e.children[10];if(0<f.value.length||0==b.value.length&&0==e.value.length)return!1;f.value=b.value+" "+e.value;b.value="";e.value=""}else console.log("> dynamic update"),miniManager.fieldsToStorage(),ficheManager.fieldsToStorage(),contactManager.fieldsToStorage(),matriceManager.fieldsToStorage(),ficheManager.sync(),miniManager.sync(),miniManager.storageToFields(),ficheManager.storageToFields(),
matriceManager.storageToFields(),(g||a)&&contactManager.storageToFields()}function readableName(b,a,e){var f=a.length,g=e.length;return 0<b.length?0<f+g?b+" ("+(a+" "+e).trim()+")":b:0<f+g?(a+" "+e).trim():"Inconnu"}
include("/js/includes/input-phone-subject.js",function(){include("/js/includes/input-phone-contact.js",function(){include("/js/includes/input-phone-mini.js",function(){include("/js/includes/input-phone-fiche.js",function(){include("/js/includes/input-phone-matrice.js",function(){subjectManager=new inputPhoneSubject($('article.subject-panel [data-name="number"]'),$('article.subject-panel [data-name="username"]'),$('article.subject-panel [data-name="firstname"]'),$('article.subject-panel [data-name="lastname"]'),
$('article.subject-panel [data-name="submit"]'));subjectManager.attach();contactManager=new inputPhoneContact($("article.contact-panel"),$("#nav-contact"));contactManager.attach(dynamicUpdate);miniManager=new inputPhoneMini($("article.mini-relation-panel"),$("#nav-mini"));miniManager.attach(dynamicUpdate);ficheManager=new inputPhoneFiche($("article.relation-panel"),$("#nav-fiche"));ficheManager.attach(dynamicUpdate);matriceManager=new inputPhoneMatrice($("article.matrice-panel"));matriceManager.attach(dynamicUpdate);
$('input#call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('input#call_log-import[type="file"]').addEventListener("change",function(a){a={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:a.target.files[0]};api.send(a,function(b){console.log(b);var a=null;if(0!=b.ModuleError)9==b.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",
b.ModuleError);else{for(var a=Notification.info("Info","Chargement du journal d'appel"),e=0,g=[],c=0;c<b.calls.length&&10>c;c++)g.push(b.calls[c].number);for(c=0;c<g.length;c++){var d=b.directory[g[c]].name.split(" ");lsi.set("contacts",e,{uid:e,number:g[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[g[c]].sms,countcall:b.directory[g[c]].calls,call:c,sms:-1});e++}for(var h=[],c=0;c<b.sms.length&&10>c;c++)h.push(b.sms[c].number);
for(c=0;c<h.length;c++)if(d=g.indexOf(h[c]),-1<d){var l=lsi.get("contacts",d);l.sms=c;lsi.set("contacts",d,l)}else d=b.directory[h[c]].name.split(" "),lsi.set("contacts",e,{uid:e,number:h[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[h[c]].sms,countcall:b.directory[h[c]].calls,call:-1,sms:c}),e++;for(var k in b.directory)-1<g.indexOf(k)||-1<h.indexOf(k)||(d=(null===b.directory[k].name?"":b.directory[k].name).split(" "),
lsi.set("contacts",e,{uid:e,number:k,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:b.directory[k].sms,countcall:b.directory[k].calls,call:-1,sms:-1}),e++);contactManager.storageToFields();dynamicUpdate(!0);null!=a&&a.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$("#clear-all").addEventListener("click",function(a){lsi.clear("subject");lsi.clear("contacts");lsi.clear("mini-fiches");lsi.clear("fiches");lsi.clear("matrice");
subjectManager.storageToFields();contactManager.storageToFields();miniManager.storageToFields();ficheManager.storageToFields();matriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$("#export-all").addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),
matrice:lsi["export"]("matrice")[0]};var b=$("#download-target");b.download="local-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$("#import-all").addEventListener("click",function(a){$("#local-upload").click()},!1);$("#local-upload").addEventListener("click",function(a){a.target.value=null},!1);$("#local-upload").addEventListener("change",function(a){a={path:"upload/local_data",file:$("#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("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);lsi.set("matrice",0,a.local_data.matrice);subjectManager.storageToFields();contactManager.storageToFields();matriceManager.storageToFields();dynamicUpdate(!0)})},!1);$("#submit-all").addEventListener("click",function(a){console.log("> GATHERING ALL DATA");
subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();if(!subjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("mini-fiches");for(var b in a)if(!a[b].valid)return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+(parseInt(b)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("fiches");for(b in a)if(!a[b].valid)return Notification.warning("Attention",
"La <i>fiche compl\u00e8te</i> <b>"+(parseInt(b)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;b={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};api.send(b,function(a){if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})});
$('input#call_log-import[type="file"]').addEventListener("click",function(b){b.target.value=null},!1);$('input#call_log-import[type="file"]').addEventListener("change",function(b){b={path:"upload/call_log",phone_number:$("#subject_phone_number").value,file:b.target.files[0]};api.send(b,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{for(var b=Notification.info("Info","Chargement du journal d'appel"),f=0,g=[],c=0;c<a.calls.length&&10>c;c++)g.push(a.calls[c].number);for(c=0;c<g.length;c++){var d=a.directory[g[c]].name.split(" ");lsi.set("contacts",f,{uid:f,number:g[c],username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:a.directory[g[c]].sms,countcall:a.directory[g[c]].calls,call:c,sms:-1});f++}console.warn(1);for(var h=[],c=0;c<a.sms.length&&10>c;c++)h.push(a.sms[c].number);
for(c=0;c<h.length;c++)if(d=g.indexOf(h[c]),-1<d){var l=lsi.get("contacts",d);l.sms=c;lsi.set("contacts",d,l)}else d=[""],null!=a.directory[h[c]].name&&(d=a.directory[h[c]].name.split(" ")),lsi.set("contacts",f,{uid:f,number:h[c],username:0<d.length?d[0]:"",firstname:0<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:a.directory[h[c]].sms,countcall:a.directory[h[c]].calls,call:-1,sms:c}),f++;for(var k in a.directory)-1<g.indexOf(k)||-1<h.indexOf(k)||(d=(null===a.directory[k].name?
"":a.directory[k].name).split(" "),lsi.set("contacts",f,{uid:f,number:k,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:a.directory[k].sms,countcall:a.directory[k].calls,call:-1,sms:-1}),f++);console.warn(3);contactManager.storageToFields();dynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$("#clear-all").addEventListener("click",function(b){lsi.clear("subject");lsi.clear("contacts");lsi.clear("mini-fiches");
lsi.clear("fiches");lsi.clear("matrice");subjectManager.storageToFields();contactManager.storageToFields();miniManager.storageToFields();ficheManager.storageToFields();matriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$("#export-all").addEventListener("click",function(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),
mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};var a=$("#download-target");a.download="local-data.json";a.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));a.click()},!1);$("#import-all").addEventListener("click",function(b){$("#local-upload").click()},!1);$("#local-upload").addEventListener("click",function(b){b.target.value=null},!1);$("#local-upload").addEventListener("change",function(b){b={path:"upload/local_data",
file:$("#local-upload").files[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("subject",0,a.local_data.subject);lsi["import"]("contacts",a.local_data.contacts);lsi["import"]("mini-fiches",a.local_data.mini);lsi["import"]("fiches",a.local_data.fiches);lsi.set("matrice",0,a.local_data.matrice);subjectManager.storageToFields();contactManager.storageToFields();matriceManager.storageToFields();dynamicUpdate(!0)})},!1);$("#submit-all").addEventListener("click",
function(b){console.log("> GATHERING ALL DATA");subjectManager.fieldsToStorage();contactManager.fieldsToStorage();miniManager.fieldsToStorage();ficheManager.fieldsToStorage();if(!subjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;b=lsi["export"]("mini-fiches");for(var a in b)if(!b[a].valid)return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+(parseInt(a)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;b=lsi["export"]("fiches");
for(a in b)if(!b[a].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(a)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a={path:"input/phone",subject:lsi["export"]("subject")[0],contacts:lsi["export"]("contacts"),mini:lsi["export"]("mini-fiches"),fiches:lsi["export"]("fiches"),matrice:lsi["export"]("matrice")[0]};api.send(a,function(a){if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;console.log(a)},!1)},!1)})})})})});

View File

@ -113,6 +113,39 @@ function dynamicUpdate(target){
/* AFFICHE UN NOM EXPLICITE A PARTIR DE @u username, @f firstname, et @l lastname
*
*/
function readableName(u, f, l){
/* (1) On calcule les tailles des chaines */
var ul = u.length,
fl = f.length,
ll = l.length;
/* (2) Si @username n'est pas vide */
if( ul > 0 ){
/* (3) Si @username+(@firstname et/ou @lastname) -> username (firstname lastname) */
if( fl+ll > 0 )
return u+' ('+(f+' '+l).trim()+')';
/* (4) Si @username uniquement -> username */
else
return u;
/* (5) Si pas @username */
}else{
/* (6) Si @firstname et/ou @lastname -> firstname lastname*/
if( fl+ll > 0 )
return (f+' '+l).trim();
/* (7) Si rien -> Inconnu */
else
return 'Inconnu';
}
}
@ -128,6 +161,7 @@ function dynamicUpdate(target){
/* [2] Inclusion des scripts externes et lancement
=========================================================*/
// TODO: Mettre les versions minifiées
include('/js/includes/input-phone-subject.js', function(){
include('/js/includes/input-phone-contact.js', function(){
include('/js/includes/input-phone-mini.js', function(){
@ -270,6 +304,7 @@ include('/js/includes/input-phone-matrice.js', function(){
uid++;
}
console.warn(1);
@ -289,14 +324,17 @@ include('/js/includes/input-phone-matrice.js', function(){
continue;
}
var splittedName = response.directory[most_sms[i]].name.split(' ');
var splittedName = [''];
if( response.directory[most_sms[i]].name != null )
splittedName = response.directory[most_sms[i]].name.split(' ');
lsi.set('contacts', uid, {
uid: uid,
number: most_sms[i],
username: splittedName.length == 1 ? splittedName[0] : '', // Si un seul mot -> pseudo
firstname: splittedName.length > 1 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom
username: splittedName.length > 0 ? splittedName[0] : '', // Si un seul mot -> pseudo
firstname: splittedName.length > 0 ? splittedName[0] : '', // Si plusieurs mots -> le 1er est le prénom
lastname: splittedName.length > 1 ? splittedName.splice(1).join(' ') : '', // et les autres sont le nom
countsms: response.directory[most_sms[i]].sms, // Nombre de sms
countcall: response.directory[most_sms[i]].calls, // Nombre d'appels
call: -1, // classement dans le top 10 des APPELS
@ -339,6 +377,7 @@ include('/js/includes/input-phone-matrice.js', function(){
uid++;
}
console.warn(3);
/* (8) On met à jour l'affichage */
contactManager.storageToFields();