Gestion de la navigation des 'fiches' s'il y a moins de '10' appels et/ou sms
This commit is contained in:
parent
eb5065ac3e
commit
331775c3a9
|
@ -1,53 +1,53 @@
|
|||
{
|
||||
"logs": [
|
||||
{ "contact":"1", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"2", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"3", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"4", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"5", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"6", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"7", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"8", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"9", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"10", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"11", "date":"2014-05-28T14:43:25", "duration":"0", "direction":"0", "type":"0" },
|
||||
{ "contact":"12", "date":"2014-02-28T15:00:10", "duration":"125", "direction":"1", "type":"1" },
|
||||
{ "contact":"13", "date":"2014-02-15T23:06:46", "duration":"0", "direction":"0", "type":"1" },
|
||||
{ "contact":"14", "date":"2014-02-15T23:06:18", "duration":"0", "direction":"0", "type":"1" },
|
||||
{ "contact":"15", "date":"2014-02-15T21:08:34", "duration":"349", "direction":"1", "type":"1" },
|
||||
{ "contact":"16", "date":"2014-02-15T20:51:38", "duration":"0", "direction":"1", "type":"1" },
|
||||
{ "contact":"17", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" },
|
||||
{ "contact":"18", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"2", "type":"1" },
|
||||
{ "contact":"19", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" },
|
||||
{ "contact":"20", "date":"2014-02-15T19:06:33", "duration":"657", "direction":"1", "type":"1" },
|
||||
{ "contact":"21", "date":"2014-02-15T17:24:18", "duration":"276", "direction":"1", "type":"1" },
|
||||
{ "contact":"22", "date":"2014-02-15T16:34:29", "duration":"36", "direction":"1", "type":"1" }
|
||||
{ "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": [
|
||||
{ "contact":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" },
|
||||
{ "contact":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" },
|
||||
{ "contact":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies":"2", "reltype":"2", "dist":"1" },
|
||||
{ "contact":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies":"3", "reltype":"3", "dist":"2" },
|
||||
{ "contact":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies":"4", "reltype":"4", "dist":"3" },
|
||||
{ "contact":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies":"5", "reltype":"5", "dist":"4" },
|
||||
{ "contact":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies":"6", "reltype":"6", "dist":"5" },
|
||||
{ "contact":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies":"7", "reltype":"7", "dist":"6" },
|
||||
{ "contact":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies":"8", "reltype":"8", "dist":"7" },
|
||||
{ "contact":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" },
|
||||
{ "contact":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" },
|
||||
{ "contact":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" },
|
||||
{ "contact":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" },
|
||||
{ "contact":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" },
|
||||
{ "contact":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" },
|
||||
{ "contact":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" },
|
||||
{ "contact":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" },
|
||||
{ "contact":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" },
|
||||
{ "contact":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" },
|
||||
{ "contact":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" },
|
||||
{ "contact":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" },
|
||||
{ "contact":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" },
|
||||
{ "contact":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" }
|
||||
{ "id":"0", "number":"0102030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" },
|
||||
{ "id":"1", "number":"0502030405", "name":"", "sexe":"0", "age":"1", "studies":"1", "reltype":"1", "dist":"0" },
|
||||
{ "id":"2", "number":"0502030561", "name":"", "sexe":"0", "age":"2", "studies":"2", "reltype":"2", "dist":"1" },
|
||||
{ "id":"3", "number":"0502030717", "name":"", "sexe":"0", "age":"3", "studies":"3", "reltype":"3", "dist":"2" },
|
||||
{ "id":"4", "number":"0502030873", "name":"", "sexe":"0", "age":"4", "studies":"4", "reltype":"4", "dist":"3" },
|
||||
{ "id":"5", "number":"0502031029", "name":"", "sexe":"0", "age":"5", "studies":"5", "reltype":"5", "dist":"4" },
|
||||
{ "id":"6", "number":"0502031185", "name":"", "sexe":"0", "age":"6", "studies":"6", "reltype":"6", "dist":"5" },
|
||||
{ "id":"7", "number":"0502031341", "name":"", "sexe":"0", "age":"7", "studies":"7", "reltype":"7", "dist":"6" },
|
||||
{ "id":"8", "number":"0502031497", "name":"", "sexe":"0", "age":"8", "studies":"8", "reltype":"8", "dist":"7" },
|
||||
{ "id":"9", "number":"0502031653", "name":"", "sexe":"0", "age":"9", "studies":"9", "reltype":"9", "dist":"8" },
|
||||
{ "id":"10", "number":"0502031809", "name":"", "sexe":"0", "age":"10", "studies":"10", "reltype":"10", "dist":"9" },
|
||||
{ "id":"11", "number":"0502031965", "name":"", "sexe":"0", "age":"11", "studies":"11", "reltype":"11", "dist":"10" },
|
||||
{ "id":"12", "number":"0502032121", "name":"", "sexe":"1", "age":"12", "studies":"12", "reltype":"12", "dist":"11" },
|
||||
{ "id":"13", "number":"0502032277", "name":"", "sexe":"1", "age":"13", "studies":"13", "reltype":"13", "dist":"12" },
|
||||
{ "id":"14", "number":"0502032433", "name":"", "sexe":"1", "age":"14", "studies":"14", "reltype":"14", "dist":"13" },
|
||||
{ "id":"15", "number":"0502032589", "name":"", "sexe":"1", "age":"15", "studies":"15", "reltype":"15", "dist":"14" },
|
||||
{ "id":"16", "number":"0502032745", "name":"", "sexe":"1", "age":"16", "studies":"16", "reltype":"16", "dist":"15" },
|
||||
{ "id":"17", "number":"0502032901", "name":"", "sexe":"1", "age":"17", "studies":"17", "reltype":"17", "dist":"16" },
|
||||
{ "id":"18", "number":"0502033057", "name":"", "sexe":"1", "age":"18", "studies":"18", "reltype":"18", "dist":"17" },
|
||||
{ "id":"19", "number":"0502033213", "name":"", "sexe":"1", "age":"19", "studies":"19", "reltype":"19", "dist":"18" },
|
||||
{ "id":"20", "number":"0502033369", "name":"", "sexe":"1", "age":"20", "studies":"20", "reltype":"20", "dist":"19" },
|
||||
{ "id":"21", "number":"0502033525", "name":"", "sexe":"1", "age":"21", "studies":"21", "reltype":"21", "dist":"20" },
|
||||
{ "id":"22", "number":"0502033681", "name":"", "sexe":"1", "age":"22", "studies":"22", "reltype":"22", "dist":"21" }
|
||||
|
||||
]
|
||||
|
||||
|
|
|
@ -1,23 +1,7 @@
|
|||
<?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="1" Number="8012" Name="A" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
|
||||
<Item Id="2" Number="8013" Name="B" Date="2014-05-28T14:43:25" Duration="0" Direction="INCOMING" Type="SMS" />
|
||||
<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>
|
||||
|
|
|
@ -10,10 +10,10 @@ a.uid+'"] ~ h5>input[type="radio"][data-name="sexe"]'),b=0;b<c.length;b++)c[b].v
|
|||
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.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);console.warn("call",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),console.warn("sms",e),d=lsi.get("fiches",e),null==d&&(d=this.defaultData),d.uid=e,d.contact=parseInt(c),lsi.set("fiches",e,d))}e=20>lsi.keys("contacts").length?lsi.keys("contacts").length:
|
||||
20;if(b.length<e)for(c in a){for(a=0;-1<b.indexOf(a)&&a<e;)a++;console.warn("fill",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(b.length>=e)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"))};
|
||||
inputPhoneFiche.prototype.updateNavBar=function(){var a=lsi["export"]("fiches"),b=lsi.keys("fiches").length;if($$("#nav-fiche [data-n]").length!=b){this.nav_container.innerHTML="";for(var c=0;c<b;c++)0==c&&(this.nav_container.innerHTML+="<span>APPELS</span>"),9==c?this.nav_container.innerHTML+='<span data-n="'+c+'" class="lc">'+(c%10+1)+"</span> ":(10==c&&(this.nav_container.innerHTML+='<span class="fc">SMS</span>'),this.nav_container.innerHTML+='<span data-n="'+c+'">'+(c%10+1)+"</span>")}for(var e in a)b=
|
||||
$('#nav-fiche [data-n="'+a[e].uid+'"]'),null!=b&&(!0===a[e].valid?b.addClass("done"):b.remClass("done"));this.nav($('#nav-fiche [data-n="'+this.selected+'"]'))};
|
||||
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(a.cp)||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||
|
||||
"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)};
|
||||
|
|
|
@ -315,6 +315,7 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
// On calcule le rang de la fiche en fonction du classement
|
||||
var ficheIndex = contacts[uid].call;
|
||||
addedFicheUids.push(ficheIndex);
|
||||
console.warn('call', ficheIndex);
|
||||
|
||||
// On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('fiches', ficheIndex);
|
||||
|
@ -335,6 +336,7 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
// On calcule le rang de la fiche en fonction du classement
|
||||
var ficheIndex = 10+contacts[uid].sms;
|
||||
addedFicheUids.push(ficheIndex);
|
||||
console.warn('sms', ficheIndex);
|
||||
|
||||
// On récupère les informations de la FICHE (si elle existe) */
|
||||
var ficheData = lsi.get('fiches', ficheIndex);
|
||||
|
@ -359,16 +361,21 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
|
||||
/* (2) Mise à jour en fonction des contacts APRÈS SAISIE MANUELLE
|
||||
---------------------------------------------------------*/
|
||||
// Nombre maximum de fiches (20, sauf si moins de 20 contacts, dans ce cas, le nombre de contacts);
|
||||
var nbMaxFiche = lsi.keys('contacts').length < 20 ? lsi.keys('contacts').length : 20;
|
||||
|
||||
// Si moins de 10+10 contacts crées, on les complètes en fonction des contacts séquentiellement
|
||||
if( addedFicheUids.length < 20 ){
|
||||
if( addedFicheUids.length < nbMaxFiche ){
|
||||
|
||||
/* (1) Pour chaque CONTACT, on met à jour/crée la FICHE associée*/
|
||||
for( var uid in contacts ){
|
||||
|
||||
/* (2) On cherche un uid de fiche non existant dans l'intervalle 0-19 */
|
||||
var ficheUid = 0;
|
||||
while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < 20 )
|
||||
while( addedFicheUids.indexOf(ficheUid) > -1 && ficheUid < nbMaxFiche )
|
||||
ficheUid++;
|
||||
|
||||
console.warn('fill', ficheUid);
|
||||
// On enregistre le nouvel UID dans les uid crées
|
||||
addedFicheUids.push(ficheUid);
|
||||
|
||||
|
@ -386,7 +393,7 @@ inputPhoneFiche.prototype.sync = function(){
|
|||
|
||||
|
||||
/* (5) Si on a déja crée 10+10 fiches, on arrête */
|
||||
if( addedFicheUids.length >= 20 )
|
||||
if( addedFicheUids.length >= nbMaxFiche )
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -464,24 +471,23 @@ inputPhoneFiche.prototype.nav = function(element){
|
|||
=========================================================*/
|
||||
inputPhoneFiche.prototype.updateNavBar = function(){
|
||||
var ficheData = lsi.export('fiches');
|
||||
var len = lsi.keys('fiches').length;
|
||||
|
||||
|
||||
/* (1) On vérifie si la barre de navigation est à jour */
|
||||
var navBarUpToDate = $$('#nav-fiche [data-n]').length == len;
|
||||
|
||||
|
||||
/* (2) On vide et remplit la barre de nav, si elle n'est pas à jour */
|
||||
if( !navBarUpToDate ){
|
||||
this.nav_container.innerHTML = '';
|
||||
|
||||
for( var i = 0 ; i < len ; i++ ){
|
||||
var keys = Object.keys(ficheData);
|
||||
for( var k = 0 ; k < keys.length ; k++ ){
|
||||
var i = parseInt( keys[k] );
|
||||
|
||||
|
||||
|
||||
// Si 1ère valeur du top 10 des APPELS, on ajoute le bandeau "APPELS"
|
||||
if( i == 0 )
|
||||
this.nav_container.innerHTML += '<span>APPELS</span>';
|
||||
|
||||
// Si fin du top 10 des APPELS, on met un espace et un border-right
|
||||
if( i == 9 )
|
||||
if( i < 10 && k < keys.length-1 && keys[k+1] >= 10 )
|
||||
this.nav_container.innerHTML += '<span data-n="'+i+'" class="lc">'+(i%10 + 1)+'</span> ';
|
||||
|
||||
// Si début du top 10 des SMS, on met le label 'SMS' et un border-left
|
||||
|
@ -493,7 +499,6 @@ inputPhoneFiche.prototype.updateNavBar = function(){
|
|||
}else
|
||||
this.nav_container.innerHTML += '<span data-n="'+i+'">'+(i%10 + 1)+'</span>';
|
||||
}
|
||||
}
|
||||
|
||||
/* (3) On montre les FICHES qui sont correctes */
|
||||
for( var key in ficheData ){
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
function inputPhoneSubject(a,b,c,d,e){this.number=a;this.username=b;this.firstname=c;this.lastname=d;this.store_button=e}inputPhoneSubject.prototype={store_button:this.store_button,number:this.number,username:this.username,firstname:this.firstname,lastname:this.lastname};inputPhoneSubject.prototype.check=function(){var a=0<this.number.value.length;return a=a&&0<this.username.value.length+this.firstname.value.length+this.lastname.value.length};
|
||||
inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("subject",0,{number:this.number.value,username:this.username.value,firstname:this.firstname.value,lastname:this.lastname.value})};
|
||||
inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("subject",0);null==a&&(a={number:"",username:"",firstname:"",lastname:""});this.number.value=a.number;this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
|
||||
function inputPhoneSubject(a,b,c,d,e,f){this.tmp_id=a;this.number=b;this.username=c;this.firstname=d;this.lastname=e;this.store_button=f}inputPhoneSubject.prototype={store_button:this.store_button,tmp_id:this.tmp_id,number:this.number,username:this.username,firstname:this.firstname,lastname:this.lastname};inputPhoneSubject.prototype.check=function(){var a=0<this.number.value.length;return a=a&&0<this.username.value.length+this.firstname.value.length+this.lastname.value.length};
|
||||
inputPhoneSubject.prototype.fieldsToStorage=function(){console.log("SUBJECT: FIELDS TO STORAGE");if(!this.check())return!1;lsi.set("subject",0,{tmp_id:this.tmp_id.value,number:this.number.value,username:this.username.value,firstname:this.firstname.value,lastname:this.lastname.value})};
|
||||
inputPhoneSubject.prototype.storageToFields=function(){console.log("SUBJECT: STORAGE TO FIELDS");var a=lsi.get("subject",0);null==a&&(a={tmp_id:"",number:"",username:"",firstname:"",lastname:""});this.tmp_id.value=a.tmp_id;this.number.value=a.number;this.username.value=a.username;this.firstname.value=a.firstname;this.lastname.value=a.lastname};
|
||||
inputPhoneSubject.prototype.attach=function(){function a(a){b.fieldsToStorage()&&b.storageToFields()}console.log("SUBJECT: ATTACH");lsi.createDataset("subject");var b=this;this.store_button.addEventListener("click",a,!1);this.number.addEventListener("blur",a,!1);this.username.addEventListener("blur",a,!1);this.firstname.addEventListener("blur",a,!1);this.lastname.addEventListener("blur",a,!1);this.storageToFields()};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
/* [0] Constructeur -> définit le conteneur et le bouton d'ajout
|
||||
=========================================================*/
|
||||
function inputPhoneSubject(iNumber, iUsername, iFirstname, iLastname, store_button){
|
||||
function inputPhoneSubject(iTmpId, iNumber, iUsername, iFirstname, iLastname, store_button){
|
||||
this.tmp_id = iTmpId;
|
||||
this.number = iNumber;
|
||||
this.username = iUsername;
|
||||
this.firstname = iFirstname;
|
||||
|
@ -13,6 +14,7 @@ function inputPhoneSubject(iNumber, iUsername, iFirstname, iLastname, store_butt
|
|||
=========================================================*/
|
||||
inputPhoneSubject.prototype = {
|
||||
store_button: this.store_button, // Bouton d'ajout d'un formulaire
|
||||
tmp_id: this.tmp_id,
|
||||
number: this.number,
|
||||
username: this.username,
|
||||
firstname: this.firstname,
|
||||
|
@ -43,6 +45,7 @@ inputPhoneSubject.prototype.fieldsToStorage = function(){
|
|||
|
||||
// {2} On récupère et met en forme les valeurs du deflater //
|
||||
var obj = {
|
||||
tmp_id: this.tmp_id.value,
|
||||
number: this.number.value,
|
||||
username: this.username.value,
|
||||
firstname: this.firstname.value,
|
||||
|
@ -68,9 +71,10 @@ inputPhoneSubject.prototype.storageToFields = function(){
|
|||
var subjectData = lsi.get('subject', 0);
|
||||
|
||||
if( subjectData == null )
|
||||
subjectData = { number: '', username: '', firstname: '', lastname: '' };
|
||||
subjectData = { tmp_id: '', number: '', username: '', firstname: '', lastname: '' };
|
||||
|
||||
// {2} On restore les valeurs //
|
||||
this.tmp_id.value = subjectData.tmp_id;
|
||||
this.number.value = subjectData.number;
|
||||
this.username.value = subjectData.username;
|
||||
this.firstname.value = subjectData.firstname;
|
||||
|
|
|
@ -176,6 +176,10 @@
|
|||
$maxId = $cur_id;
|
||||
}
|
||||
|
||||
// Si on a rien trouvé, on arrête
|
||||
if( $maxId == -1 )
|
||||
break;
|
||||
|
||||
/* (3) On supprime le plus proche qu'on a trouvé et on l'ajoute au tableau trié */
|
||||
array_push($call_sorted, $maxId);
|
||||
|
||||
|
@ -204,10 +208,15 @@
|
|||
$maxId = $cur_id;
|
||||
}
|
||||
|
||||
// Si on a rien trouvé, on arrête
|
||||
if( $maxId == -1 )
|
||||
break;
|
||||
|
||||
/* (3) On supprime le plus proche qu'on a trouvé et on l'ajoute au tableau trié */
|
||||
array_push($sms_sorted, $maxId);
|
||||
|
||||
unset($tmp[$maxId]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -215,7 +224,7 @@
|
|||
=========================================================*/
|
||||
// on crée un id unique pour cet utilisateur
|
||||
$subject_id = sessionManager::sha1($phone_number);
|
||||
// TODO: Enregistrer le journal d'appel dans `/upload/phone_storage/numeroTelSujet.json`
|
||||
|
||||
/* (1) On construit le contenu */
|
||||
$phone_storage = array(
|
||||
'logs' => $call_logs, // Le journal d'appel
|
||||
|
@ -229,7 +238,7 @@
|
|||
/* (3) On l'enregistre dans le fichier */
|
||||
$written = file_put_contents( __ROOT__.'/tmp/phone_storage_'.$subject_id.'.json', $phone_storage);
|
||||
|
||||
|
||||
// Si erreur d'écriture
|
||||
if( $written === false )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError );
|
||||
|
||||
|
@ -240,7 +249,7 @@
|
|||
=========================================================*/
|
||||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'subject_tmp_id' => $subject_id,
|
||||
'tmp_id' => $subject_id,
|
||||
'directory' => $phone_directory,
|
||||
'call' => $call_sorted,
|
||||
'sms' => $sms_sorted
|
||||
|
|
|
@ -10,6 +10,46 @@
|
|||
class input{
|
||||
|
||||
|
||||
/* AFFICHE UN NOM EXPLICITE A PARTIR DE @u username, @f firstname, et @l lastname
|
||||
*
|
||||
*/
|
||||
private static function readableName($u, $f, $l){
|
||||
/* (1) On calcule les tailles des chaines */
|
||||
$ul = strlen($u);
|
||||
$fl = strlen($f);
|
||||
$ll = strlen($l);
|
||||
|
||||
/* (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.' ('.trim($f.' '.$l).')';
|
||||
|
||||
/* (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 trim($f.' '.l);
|
||||
|
||||
/* (7) Si rien -> Inconnu */
|
||||
else
|
||||
return 'Inconnu';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* TRAITE LES DONNÉES D'UN FORMULAIRE DE TYPE TÉLÉPHONIQUE
|
||||
*
|
||||
* @subject<Array> Tableau contenant les données du sujet
|
||||
|
@ -146,7 +186,7 @@
|
|||
|
||||
|
||||
|
||||
/* [5] Enregistrer les données des FICHES dans la base de données
|
||||
/* [5] Enregistrement des données des FICHES dans la base de données
|
||||
=========================================================*/
|
||||
// TODO: Enregistrer les données des fiches dans la base de données
|
||||
|
||||
|
@ -156,21 +196,61 @@
|
|||
|
||||
/* [6] Enregistrement des mini-fiches dans un fichier '.json'
|
||||
=========================================================*/
|
||||
$file = array();
|
||||
// Contiendra le contenu du fichier
|
||||
$file = array( 'logs' => array() );
|
||||
|
||||
/* (1) On enregistre les données des fiches */
|
||||
foreach($mini as $id=>$miniFiche){
|
||||
$data = array(
|
||||
'number' => $contacts[$id]['number'],
|
||||
'username' => $contacts[$id]['username'],
|
||||
'firstname' => $contacts[$id]['firstname'],
|
||||
'lastname' => $contacts[$id]['lastname'],
|
||||
|
||||
// TODO: Finir l'implémentation du fichier XML contenant les données des MINI+des CONTACTS
|
||||
);
|
||||
/* (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 );
|
||||
|
||||
/* (3) On enregistre les contacts */
|
||||
$file['contacts'] = array();
|
||||
|
||||
foreach($mini as $miniData){
|
||||
// On récupère les données du contact associé
|
||||
$contact = $contacts[ $miniData['contact'] ];
|
||||
|
||||
// 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']
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
/* (2) On enregistre les données des mini-fiches */
|
||||
/* (4) On ajoute les données du sujet */
|
||||
$file['subject'] = array(
|
||||
'number' => $subject['number'],
|
||||
'name' => self::readableName($subject['username'], $subject['firstname'], $subject['lastname'])
|
||||
);
|
||||
|
||||
|
||||
// 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);
|
||||
|
||||
/* (6) On l'enregistre dans le fichier */
|
||||
$written = file_put_contents( __ROOT__.'/tmp/phone_storage_'.$subject['tmp_id'].'.json', $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', '/tmp/phone_storage_'.$subject_id.'.json') )
|
||||
return array( 'ModuleError' => ManagerError::ModuleError ); // si erreur -> erreur
|
||||
|
||||
|
||||
/* [n] Gestion du retour
|
||||
|
@ -178,7 +258,6 @@
|
|||
return array(
|
||||
'ModuleError' => ManagerError::Success,
|
||||
'subject_id' => $subject_id,
|
||||
'contacts' => $closest,
|
||||
'created' => $closest_id
|
||||
);
|
||||
}
|
||||
|
|
|
@ -250,7 +250,8 @@
|
|||
|
||||
|
||||
/* (3) Vérification du sujet */
|
||||
$checkSubject = isset($json['subject']['username']) && is_string($json['subject']['username']);
|
||||
$checkSubject = isset($json['subject']['tmp_id']) && ( is_string($json['subject']['tmp_id']) || is_null($json['subject']['tmp_id']) );
|
||||
$checkSubject = $checkSubject && isset($json['subject']['username']) && is_string($json['subject']['username']);
|
||||
$checkSubject = $checkSubject && isset($json['subject']['firstname']) && is_string($json['subject']['firstname']);
|
||||
$checkSubject = $checkSubject && isset($json['subject']['lastname']) && is_string($json['subject']['lastname']);
|
||||
$checkSubject = $checkSubject && isset($json['subject']['number']) && is_string($json['subject']['number']);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"logs": [
|
||||
{
|
||||
"id": 0,
|
||||
"direction": 0,
|
||||
"type": 1,
|
||||
"date": 1401281005,
|
||||
"duration": 0
|
||||
},
|
||||
{
|
||||
"id": 1,
|
||||
"direction": 0,
|
||||
"type": 1,
|
||||
"date": 1401281005,
|
||||
"duration": 0
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"direction": 1,
|
||||
"type": 0,
|
||||
"date": 1392493898,
|
||||
"duration": 0
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"direction": 1,
|
||||
"type": 0,
|
||||
"date": 1392487593,
|
||||
"duration": 657
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"direction": 1,
|
||||
"type": 0,
|
||||
"date": 1392481458,
|
||||
"duration": 276
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"direction": 1,
|
||||
"type": 0,
|
||||
"date": 1392478469,
|
||||
"duration": 36
|
||||
}
|
||||
],
|
||||
"subject": "",
|
||||
"contacts": []
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -60,6 +60,7 @@
|
|||
<h5 data-text="Renseigner au moins un des nominatifs pour chaque contact. (pseudo, prénom et/ou nom)"></h5>
|
||||
<article class='subject-panel'>
|
||||
<h4 class='self color2' data-icon='a'>
|
||||
<input type='hidden' data-name='tmp_id' value=''>
|
||||
<input type='text' data-name='number' id='subject_phone_number' placeholder='Numéro de téléphone'>
|
||||
<input type='text' data-name='username' placeholder='Pseudo'>
|
||||
<input type='text' data-name='firstname' placeholder='Prénom'>
|
||||
|
|
|
@ -2,14 +2,14 @@ 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,c=b&&"INPUT"==a.tagName&&"submit"==a.type,d=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||c||d||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(),(c||b)&&contactManager.storageToFields()}function readableName(a,b,f){var e=b.length,c=f.length;return 0<a.length?0<e+c?a+" ("+(b+" "+f).trim()+")":a:0<e+c?(b+" "+f).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;e<b.call.length;e++){var c=b.directory[b.call[e]],d=c.name.split(" ");lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:e,sms:-1})}for(e=0;e<b.sms.length;e++)c=b.directory[b.sms[e]],-1<b.call.indexOf(b.sms[e])?(d=lsi.get("contacts",c.id),d.sms=e,lsi.set("contacts",c.id,
|
||||
d)):(d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:-1,sms:e}));for(var g in b.directory)g=parseInt(g),-1<b.call.indexOf(g)||-1<b.sms.indexOf(g)||(c=b.directory[g],d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,
|
||||
countcall:c.call,call:-1,sms:-1}));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)})})})})});
|
||||
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="tmp_id"]'),$('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{a=Notification.info("Info","Chargement du journal d'appel");subjectManager.tmp_id.value=b.tmp_id;for(var e=0;e<b.call.length;e++){var c=b.directory[b.call[e]],d=c.name.split(" ");lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:e,sms:-1})}for(e=0;e<b.sms.length;e++)c=b.directory[b.sms[e]],-1<b.call.indexOf(b.sms[e])?
|
||||
(d=lsi.get("contacts",c.id),d.sms=e,lsi.set("contacts",c.id,d)):(d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:-1,sms:e}));for(var g in b.directory)g=parseInt(g),-1<b.call.indexOf(g)||-1<b.sms.indexOf(g)||(c=b.directory[g],d=c.name.split(" "),lsi.set("contacts",c.id,{uid:c.id,number:c.number,username:1==d.length?d[0]:"",firstname:1<d.length?
|
||||
d[0]:"",lastname:1<d.length?d.splice(1).join(" "):"",countsms:c.sms,countcall:c.call,call:-1,sms:-1}));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)})})})})});
|
||||
|
|
|
@ -173,6 +173,7 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
---------------------------------------------------------*/
|
||||
/* (1) On crée une instance du manager du sujet */
|
||||
subjectManager = new inputPhoneSubject(
|
||||
$('article.subject-panel [data-name="tmp_id"]'),
|
||||
$('article.subject-panel [data-name="number"]'),
|
||||
$('article.subject-panel [data-name="username"]'),
|
||||
$('article.subject-panel [data-name="firstname"]'),
|
||||
|
@ -277,6 +278,10 @@ include('/js/includes/input-phone-matrice.js', function(){
|
|||
loadingNotif = Notification.info('Info', 'Chargement du journal d\'appel');
|
||||
|
||||
|
||||
/* (3) On enregistre l'identifiant temporaire du sujet */
|
||||
subjectManager.tmp_id.value = response.tmp_id;
|
||||
|
||||
|
||||
|
||||
/* (3) On crée les 10 contacts les plus APPELÉS */
|
||||
for( var i = 0 ; i < response.call.length ; i++ ){
|
||||
|
|
Loading…
Reference in New Issue