Implémentation de toute la page pour rechercher les sujets

This commit is contained in:
xdrm-brackets 2016-05-26 16:33:00 +02:00
parent 67ede5f52a
commit f5d1d7a7e6
26 changed files with 1182 additions and 1611 deletions

View File

@ -89,14 +89,7 @@
/* [4] Test download via AJAX
=========================================================*/
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
var_dump( array_keys($db->index()));
$db->close();
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
var_dump( array_keys($db->index()));
$db->close();
$req = new ModuleRequest('chart/duration', array( 'subject' => 273 ));
$req = new ModuleRequest('subject/search', array( 'name' => 'a' ));
$res = $req->dispatch();

View File

@ -16,7 +16,7 @@
"attributes": { "data-link": "input" },
"children": [
{ "permissions": ["admin"], "text": "Chercher le sujet",
{ "permissions": ["admin"], "text": "Chercher un sujet",
"attributes": { "data-sublink": "survey" } },
{ "permissions": ["admin"], "text": "Données cellulaire",
"attributes": { "data-sublink": "phone" } },

View File

@ -203,6 +203,14 @@
"subject": {
"search": {
"description": "Recherche d'un sujet par nom",
"permissions": ["admin"],
"parameters": {
"name": { "description": "Le nom du sujet", "type": "varchar(1,50)" }
}
},
"getById": {
"description": "Retourne les informations d'un sujet.",
"permissions": ["admin"],

View File

@ -138,8 +138,8 @@
=========================================================*/
& input[type="submit"],
& input[type="button"]{
padding: .2em .5em;
margin: .5em 0;
padding: .3em .5em;
border-radius: 3px;
border: 1px solid $theme-fg;
@ -211,6 +211,9 @@
}
.flat-border{ border-radius: 0; }
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -151,8 +151,8 @@ body{
align-items: middle;
border-radius: 5px;
border: 1px solid lighten($theme-fg, 10);
border-radius: 3px;
border: 1px solid #aaa;
background-color: $header-dark;
@ -166,7 +166,8 @@ body{
// Animation de @hover/@focus
&:hover,
&:focus{
&:focus
&:not([value=""]){
border-color: $theme-fg-primary;
}
@ -176,8 +177,8 @@ body{
/* (2.2) Bouton de connexion */
& > input[type='submit']{
width: 100%;
margin-top: calc( 2em + 3px );
margin-bottom: calc( 2em - 3px );
margin-top: calc( 2em - 3px );
margin-bottom: 2em;
border: 0;
border-top: 3px solid darken($theme-fg-primary, 15);
@ -195,16 +196,16 @@ body{
// Animation de @hover
&:hover, &.hover{
background-color: darken($theme-fg-primary, 10);
margin-top: calc( 2em + 1px );
margin-bottom: calc( 2em + 2px );
border-top-width: 1px;
margin-top: calc( 2em - 2px );
margin-bottom: calc( 2em + 2px );
}
// Animation de clic @active
&:active{
border-top-width: 0;
margin-top: 2em;
margin-bottom: calc( 2em + 3px );
border-top-width: 0;
}
}
@ -215,6 +216,7 @@ body{
/* (3) Mot de passe oublie */
& > #lost-password{
position: absolute;
color: #777;
cursor: pointer;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -175,7 +175,7 @@ fFicheBuilder.setLayout(
"\t<h5 class='nobold color0'>\n"+
"\t\t<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeH_f_@uid' value='0'><label for='sexeH_f_@uid'>Homme</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeF_f_@uid' value='1'><label for='sexeF_f_@uid'>Femme</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeI_f_@uid' value='1'><label for='sexeI_f_@uid'>Indéterminé</label>\n"+
"\t\t&nbsp;&nbsp;&nbsp;<input type='radio' name='sexe_f_@uid' data-name='sexe' id='sexeI_f_@uid' value='2'><label for='sexeI_f_@uid'>Indéterminé</label>\n"+
"\t</h5>\n"+

View File

@ -81,7 +81,7 @@
/* [2] On enregistre les données du sujet
=========================================================*/
$file['subject'] = array(
'id' => $offset + $subject_id,
'id' => $subject_id,
'name' => $subject['username']
);

View File

@ -5,6 +5,7 @@
use \manager\Database;
use \manager\ManagerError;
use \manager\Repo;
use \manager\lightdb;
class subject{
@ -145,12 +146,104 @@
return array( 'ModuleError' => ManagerError::Success );
}
// [x] "login",
// [x] "logout",
// [x] "getById",
// [x] "getAll",
// [x] "create",
// [ ] "remove",
/* RECHERCHE DE SUJETS
*
* @name<String> Nom du sujet recherché
*
* @return results<Array> Tableau contenant les résultats
*
*/
public static function search($params){
extract($params);
// Contiendra les sujets
$subjects = array();
/* [0] Notre fonction de recherche (comparaison)
=========================================================*/
function compareSearch($A, $B){
// {1} On supprime les espaces et tout en minuscule //
$A = str_replace(' ', '', strtolower($A));
$B = str_replace(' ', '', strtolower($B));
// {2} On vérifie si A est dans B et inversement //
if( strpos($A, $B) !== false ) return true;
if( strpos($B, $A) !== false ) return true;
return $A == $B;
}
/* [1] On récupére la liste des sujets pour PHONE
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('phone_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
$sub['phone'] = true;
if( compareSearch($name, $sub['name']) )
$subjects[$id] = $sub;
}
/* (3) On ferme la bd */
$db->close();
/* [2] On récupére la liste des sujets pour FACEBOOK
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('facebook_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
$sub['facebook'] = true;
if( compareSearch($name, $sub['name']) )
$subjects[$id] = $sub;
}
/* (3) On ferme la bd */
$db->close();
/* [3] On récupére la liste des sujets pour SURVEYS
=========================================================*/
/* (1) On initialise et ouvre la bd */
$db = new lightdb('survey_db', __ROOT__.'/src/dynamic/');
$ids = array_keys( $db->index() );
/* (2) On récupère tous les sujets */
foreach($ids as $id){
$sub = $db->fetch($id)['subject'];
$sub['survey'] = true;
if( compareSearch($name, $sub['name']) )
$subjects[$id] = $sub;
}
/* (3) On ferme la bd */
$db->close();
/* [4] Retour des données
=========================================================*/
return array(
'ModuleError' => ManagerError::Success,
'results' => $subjects
);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -4,8 +4,6 @@
use \manager\ManagerError;
use \manager\ResourceDispatcher;
use \manager\Repo;
$somevariable = 'test';
?>
@ -13,11 +11,36 @@
<?php /* [1] ADMIN -> Donnees de questionnaire
=========================================================*/
?><section data-sublink='survey'>
Questionnaire
<h6>Rechercher l'identifiant d'un sujet</h6><br>
<!-- CHAMPS DE RECHERCHE -->
&nbsp;&nbsp;&nbsp;&nbsp;<input type='text' id='search-field' placeholder='Recherche de sujet' data-name='search_subject'>
&nbsp;&nbsp;&nbsp;&nbsp;<input type='button' id='search-subject' class='primary' value='Rechercher'><br><br>
<!-- RESULTATS DE LA RECHERCHE -->
<section data-panel-list>
<!-- Header -->
<div data-header>
<span>Recherche de sujets</span>
</div>
<!-- Description des résultats actifs -->
<div data-description>Liste des sujets classés par noms. Leurs identifiants sont indiqués dans les encadrés.</div>
<!-- Conteneur de la liste des elements -->
<ul data-list></ul>
</section>
</section>
<?php /* [3] ADMIN -> Donnees du Telephone
=========================================================*/
?><section data-sublink='phone'> <!-- IMPORT ou SAISIE -->

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

@ -1,26 +1,29 @@
var cSubjectManager,cContactManager,cMiniManager,cFicheManager,cMatriceManager;
function cDynamicUpdate(b){var a=b instanceof Element,d=a&&"INPUT"==b.tagName&&"submit"==b.type,e=a&&"SPAN"==b.tagName&&("p_nav-mini"==b.parentNode.id||"p_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"p_nav-contact"==b.parentNode.id;if(!d&&!e&&!a&&!0!==b)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();pMiniManager.storageToFields();
pFicheManager.storageToFields();pMatriceManager.storageToFields();(d||a)&&pContactManager.storageToFields()}
include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="username"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(cDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(cDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(cDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(cDynamicUpdate);var b=new ShortcutManager;b.append("s+n+a+k+e",function(){pMatriceManager.snake()});b.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",
function(a){a={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:a.target.files[0]};api.send(a,function(a){console.log(a);var b=null;if(0!=a.ModuleError)9==a.ModuleError?Notification.error("Erreur","Il est n\u00e9cessaire de saisir les informations du <b>sujet</b> avant d'exporter son journal d'appel"):Notification.error("Erreur",a.ModuleError);else{b=Notification.info("Info","Chargement du journal d'appel");pSubjectManager.tmp_id.value=a.tmp_id;pSubjectManager.fieldsToStorage();
pSubjectManager.storageToFields();for(var f=0;f<a.call.length;f++){var c=a.directory[a.call[f]];lsi.set("p_contacts",c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:f,sms:-1})}for(f=0;f<a.sms.length;f++)if(c=a.directory[a.sms[f]],-1<a.call.indexOf(a.sms[f])){var h=lsi.get("p_contacts",c.id);h.sms=f;lsi.set("p_contacts",c.id,h)}else lsi.set("p_contacts",c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:-1,sms:f});for(var g in a.directory)g=
parseInt(g),-1<a.call.indexOf(g)||-1<a.sms.indexOf(g)||(c=a.directory[g],lsi.set("p_contacts",c.id,{uid:c.id,number:c.number,username:c.name,countsms:c.sms,countcall:c.call,call:-1,sms:-1}));pContactManager.storageToFields();cDynamicUpdate(!0);null!=b&&b.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");
var sField=$("#search-field"),sSubmit=$("#search-subject"),sList=$('section[data-sublink="survey"] ul[data-list]');
sSubmit.addEventListener("click",function(a){api.send({path:"subject/search",name:sField.value},function(c){if(0!=c.ModuleError)return Notification.error("Erreur","La recherche a \u00e9chou\u00e9."),!1;console.log(c);var b="",a;for(a in c.results)b+="<li data-element data-id='"+a+"'>",b+="<div data-user><span>SUJET</span></div>",b+="<div> <span data-prefix='Identifiant'><span class='flag'>"+a+"</span></span> </div>",b+="<div> <span data-prefix='Nom'>"+c.results[a].name+"</span> </div>",b+="<div> <span><input type='checkbox' id='s_"+
a+"' "+(null!=c.results[a].survey?"checked":"")+" disabled><label for='s_"+a+"'>ResTIC</label>",b+="</span> </div>",b+="<div> <span><input type='checkbox' id='s_"+a+"' "+(null!=c.results[a].facebook?"checked":"")+" disabled><label for='s_"+a+"'>Tacebook</label>",b+="</span> </div>",b+="<div> <span><input type='checkbox' id='s_"+a+"' "+(null!=c.results[a].phone?"checked":"")+" disabled><label for='s_"+a+"'>Cellulaire</label>",b+="</span> </div>",b+="</li>";sList.innerHTML=b})},!1);
var pSubjectManager,pContactManager,pMiniManager,pFicheManager,pMatriceManager;
function pDynamicUpdate(a){var c=a instanceof Element,b=c&&"INPUT"==a.tagName&&"submit"==a.type,e=c&&"SPAN"==a.tagName&&("p_nav-mini"==a.parentNode.id||"p_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"p_nav-contact"==a.parentNode.id;if(!b&&!e&&!c&&!0!==a)return!1;console.log("> dynamic update");pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();pContactManager.fieldsToStorage();pMatriceManager.fieldsToStorage();pFicheManager.sync();pMiniManager.sync();pMiniManager.storageToFields();
pFicheManager.storageToFields();pMatriceManager.storageToFields();(b||c)&&pContactManager.storageToFields()}
include("/js/includes/input-phone-subject-min.js",function(){include("/js/includes/input-phone-contact-min.js",function(){include("/js/includes/input-phone-mini-min.js",function(){include("/js/includes/input-phone-fiche-min.js",function(){include("/js/includes/input-phone-matrice-min.js",function(){pSubjectManager=new inputPhoneSubject($('[data-sublink="phone"] article.subject-panel [data-name="tmp_id"]'),$('[data-sublink="phone"] article.subject-panel [data-name="number"]'),$('[data-sublink="phone"] article.subject-panel [data-name="username"]'),
$('[data-sublink="phone"] article.subject-panel [data-name="submit"]'));pSubjectManager.attach();pContactManager=new inputPhoneContact($('[data-sublink="phone"] article.contact-panel'),$('[data-sublink="phone"] #p_nav-contact'));pContactManager.attach(pDynamicUpdate);pMiniManager=new inputPhoneMini($('[data-sublink="phone"] article.mini-relation-panel'),$('[data-sublink="phone"] #p_nav-mini'));pMiniManager.attach(pDynamicUpdate);pFicheManager=new inputPhoneFiche($('[data-sublink="phone"] article.relation-panel'),
$('[data-sublink="phone"] #p_nav-fiche'));pFicheManager.attach(pDynamicUpdate);pMatriceManager=new inputPhoneMatrice($('[data-sublink="phone"] article.matrice-panel'));pMatriceManager.attach(pDynamicUpdate);var a=new ShortcutManager;a.append("s+n+a+k+e",function(){pMatriceManager.snake()});a.listen();$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("click",function(c){c.target.value=null},!1);$('[data-sublink="phone"] input#p_call_log-import[type="file"]').addEventListener("change",
function(c){c={path:"upload/call_log",phone_number:$('[data-sublink="phone"] #p_subject_phone_number').value,file:c.target.files[0]};api.send(c,function(b){console.log(b);var c=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{c=Notification.info("Info","Chargement du journal d'appel");pSubjectManager.tmp_id.value=b.tmp_id;pSubjectManager.fieldsToStorage();
pSubjectManager.storageToFields();for(var a=0;a<b.call.length;a++){var d=b.directory[b.call[a]];lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:a,sms:-1})}for(a=0;a<b.sms.length;a++)if(d=b.directory[b.sms[a]],-1<b.call.indexOf(b.sms[a])){var g=lsi.get("p_contacts",d.id);g.sms=a;lsi.set("p_contacts",d.id,g)}else lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:a});for(var f in b.directory)f=
parseInt(f),-1<b.call.indexOf(f)||-1<b.sms.indexOf(f)||(d=b.directory[f],lsi.set("p_contacts",d.id,{uid:d.id,number:d.number,username:d.name,countsms:d.sms,countcall:d.call,call:-1,sms:-1}));pContactManager.storageToFields();pDynamicUpdate(!0);null!=c&&c.click();Notification.success("OK","Chargement termin\u00e9")}})},!1);$('[data-sublink="phone"] #p_clear-all').addEventListener("click",function(a){lsi.clear("p_subject");lsi.clear("p_contacts");lsi.clear("p_mini-fiches");lsi.clear("p_fiches");lsi.clear("p_matrice");
pSubjectManager.storageToFields();pContactManager.storageToFields();pMiniManager.storageToFields();pFicheManager.storageToFields();pMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="phone"] #p_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),
fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};var b=$('[data-sublink="phone"] #p_download-target');b.download="local-phone-data.json";b.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));b.click()},!1);$('[data-sublink="phone"] #p_import-all').addEventListener("click",function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="phone"] #p_local-upload').addEventListener("change",
function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();
pMatriceManager.storageToFields();cDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,e;for(e in a)if(!isNaN(e)&&(b++,
pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1);$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pSubjectManager.fieldsToStorage();pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,e;for(e in a)if(!isNaN(e)&&(b++,
!a[e].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(e in a)if(!a[e].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(e)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;e={path:"input/phone",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};
api.send(e,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1)})})})})});var fSubjectManager,fContactManager,fMiniManager,fFicheManager,fMatriceManager;
function fDynamicUpdate(b){var a=b instanceof Element,d=a&&"INPUT"==b.tagName&&"submit"==b.type,e=a&&"SPAN"==b.tagName&&("f_nav-mini"==b.parentNode.id||"f_nav-fiche"==b.parentNode.id),a=a&&"SPAN"==b.tagName&&"f_nav-contact"==b.parentNode.id;if(!d&&!e&&!a&&!0!==b)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(d||a)&&fContactManager.storageToFields()}
function fDynamicUpdate(a){var c=a instanceof Element,b=c&&"INPUT"==a.tagName&&"submit"==a.type,e=c&&"SPAN"==a.tagName&&("f_nav-mini"==a.parentNode.id||"f_nav-fiche"==a.parentNode.id),c=c&&"SPAN"==a.tagName&&"f_nav-contact"==a.parentNode.id;if(!b&&!e&&!c&&!0!==a)return!1;console.log("> dynamic update");fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();fContactManager.fieldsToStorage();fMatriceManager.fieldsToStorage();fFicheManager.sync();fMiniManager.sync();fMiniManager.storageToFields();
fFicheManager.storageToFields();fMatriceManager.storageToFields();(b||c)&&fContactManager.storageToFields()}
include("/js/includes/input-facebook-subject-min.js",function(){include("/js/includes/input-facebook-contact-min.js",function(){include("/js/includes/input-facebook-mini-min.js",function(){include("/js/includes/input-facebook-fiche-min.js",function(){include("/js/includes/input-facebook-matrice-min.js",function(){fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="username"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]'));
fSubjectManager.attach();fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'),$('[data-sublink="facebook"] #f_nav-contact'));fContactManager.attach(fDynamicUpdate);fMiniManager=new inputFacebookMini($('[data-sublink="facebook"] article.mini-relation-panel'),$('[data-sublink="facebook"] #f_nav-mini'));fMiniManager.attach(fDynamicUpdate);fFicheManager=new inputFacebookFiche($('[data-sublink="facebook"] article.relation-panel'),$('[data-sublink="facebook"] #f_nav-fiche'));
fFicheManager.attach(fDynamicUpdate);fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(b){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();
fMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(b){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");b={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var a=$('[data-sublink="facebook"] #f_download-target');
a.download="local-facebook-data.json";a.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(b));a.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(b){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(b){b.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(b){b={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_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("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(b){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;b=lsi["export"]("f_mini-fiches");var a=0,d;for(d in b)if(!isNaN(d)&&(a++,!b[d].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+a+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;b=lsi["export"]("f_fiches");for(d in b)if(!b[d].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(d)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),!1;d={path:"input/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(d,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
fFicheManager.attach(fDynamicUpdate);fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel'));fMatriceManager.attach(fDynamicUpdate);$('[data-sublink="facebook"] #f_clear-all').addEventListener("click",function(a){lsi.clear("f_subject");lsi.clear("f_contacts");lsi.clear("f_mini-fiches");lsi.clear("f_fiches");lsi.clear("f_matrice");fSubjectManager.storageToFields();fContactManager.storageToFields();fMiniManager.storageToFields();fFicheManager.storageToFields();
fMatriceManager.storageToFields();Notification.success("OK","Les donn\u00e9es ont \u00e9t\u00e9 supprim\u00e9es")},!1);$('[data-sublink="facebook"] #f_export-all').addEventListener("click",function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargement de la sauvegarde");a={subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};var c=$('[data-sublink="facebook"] #f_download-target');
c.download="local-facebook-data.json";c.href="data:application/octet-stream,"+encodeURIComponent(JSON.stringify(a));c.click()},!1);$('[data-sublink="facebook"] #f_import-all').addEventListener("click",function(a){$('[data-sublink="facebook"] #f_local-upload').click()},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("click",function(a){a.target.value=null},!1);$('[data-sublink="facebook"] #f_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="facebook"] #f_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("f_subject",0,a.local_data.subject);lsi["import"]("f_contacts",a.local_data.contacts);lsi["import"]("f_mini-fiches",a.local_data.mini);lsi["import"]("f_fiches",a.local_data.fiches);lsi.set("f_matrice",0,a.local_data.matrice);fSubjectManager.storageToFields();fContactManager.storageToFields();fMatriceManager.storageToFields();fDynamicUpdate(!0)})},!1);$('[data-sublink="facebook"] #f_submit-all').addEventListener("click",
function(a){console.log("> GATHERING ALL DATA");fSubjectManager.fieldsToStorage();fContactManager.fieldsToStorage();fMiniManager.fieldsToStorage();fFicheManager.fieldsToStorage();if(!fSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("f_mini-fiches");var c=0,b;for(b in a)if(!isNaN(b)&&(c++,!a[b].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+c+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;a=lsi["export"]("f_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/facebook",subject:lsi["export"]("f_subject")[0],contacts:lsi["export"]("f_contacts"),mini:lsi["export"]("f_mini-fiches"),fiches:lsi["export"]("f_fiches"),matrice:lsi["export"]("f_matrice")[0]};api.send(b,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),
!1;console.log(a)},!1)},!1)})})})})});

View File

@ -1,18 +1,87 @@
/*=========================================================*/
/*********** Gestion du formulaire téléphonique ************/
/*=========== Gestion de la recherche de sujet ============*/
/*=========================================================*/
var sField = $('#search-field');
var sSubmit = $('#search-subject');
var sList = $('section[data-sublink="survey"] ul[data-list]');
sSubmit.addEventListener('click', function(e){
/* (1) On construit la requête */
var request = {
path: 'subject/search',
name: sField.value
};
/* (2) On effectue la requête */
api.send(request, function(response){
// Si erreur
if( response.ModuleError != 0 ){
Notification.error('Erreur', 'La recherche a échoué.')
return false;
}
console.log(response);
/* (3) On remplit la liste des résultats */
var htmlContent = '';
for( var id in response.results ){
htmlContent += "<li data-element data-id='"+id+"'>";
htmlContent += "<div data-user><span>SUJET</span></div>";
htmlContent += "<div> <span data-prefix='Identifiant'><span class='flag'>"+id+"</span></span> </div>";
htmlContent += "<div> <span data-prefix='Nom'>"+response.results[id].name+"</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].survey!=null)?'checked':'')+" disabled><label for='s_"+id+"'>ResTIC</label>";
htmlContent += "</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].facebook!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Tacebook</label>";
htmlContent += "</span> </div>";
htmlContent += "<div> <span><input type='checkbox' id='s_"+id+"' "+((response.results[id].phone!=null)?'checked':'')+" disabled><label for='s_"+id+"'>Cellulaire</label>";
htmlContent += "</span> </div>";
htmlContent += "</li>";
}
sList.innerHTML = htmlContent;
});
}, false);
/*=========================================================*/
/*========== Gestion du formulaire téléphonique ===========*/
/*=========================================================*/
/* [1] Initialisation des utilitaires et variables
=========================================================*
/* (1) Initialisation des managers */
var cSubjectManager;
var cContactManager;
var cMiniManager;
var cFicheManager;
var cMatriceManager;
var pSubjectManager;
var pContactManager;
var pMiniManager;
var pFicheManager;
var pMatriceManager;
/* (2) Fonctions utiles */
function cDynamicUpdate(target){
function pDynamicUpdate(target){
/* (0) Vérification de la cohérence de la @target
@ -69,17 +138,13 @@ function cDynamicUpdate(target){
/* [2] Inclusion des scripts externes et lancement
=========================================================*/
include('/js/includes/input-phone-subject-min.js', function(){
include('/js/includes/input-phone-contact-min.js', function(){
include('/js/includes/input-phone-mini-min.js', function(){
include('/js/includes/input-phone-fiche-min.js', function(){
// TODO: Use 'min' version
include('/js/includes/input-phone-matrice.js', function(){
include('/js/includes/input-phone-matrice-min.js', function(){
/* (1) Gestion du formulaire du sujet
@ -108,7 +173,7 @@ include('/js/includes/input-phone-matrice.js', function(){
);
/* (2) On le démarre */
pContactManager.attach(cDynamicUpdate);
pContactManager.attach(pDynamicUpdate);
@ -121,7 +186,7 @@ include('/js/includes/input-phone-matrice.js', function(){
);
/* (2) On le démarre */
pMiniManager.attach(cDynamicUpdate);
pMiniManager.attach(pDynamicUpdate);
/* (4) Gestion des fiches relation
@ -133,7 +198,7 @@ include('/js/includes/input-phone-matrice.js', function(){
);
/* (2) On le démarre */
pFicheManager.attach(cDynamicUpdate);
pFicheManager.attach(pDynamicUpdate);
/* (5) Gestion de la matrice de relations
@ -144,7 +209,7 @@ include('/js/includes/input-phone-matrice.js', function(){
);
/* (2) On le démarre */
pMatriceManager.attach(cDynamicUpdate);
pMatriceManager.attach(pDynamicUpdate);
// Listener pour snake
@ -280,7 +345,7 @@ include('/js/includes/input-phone-matrice.js', function(){
/* (8) On met à jour l'affichage */
pContactManager.storageToFields();
cDynamicUpdate(true);
pDynamicUpdate(true);
/* (9) On notifie la fin du chargement */
@ -389,7 +454,7 @@ include('/js/includes/input-phone-matrice.js', function(){
pSubjectManager.storageToFields();
pContactManager.storageToFields();
pMatriceManager.storageToFields();
cDynamicUpdate(true);
pDynamicUpdate(true);
});
@ -552,7 +617,7 @@ include('/js/includes/input-phone-matrice.js', function(){
/*=========================================================*/
/************ Gestion du formulaire facebook ***************/
/*=========== Gestion du formulaire facebook ==============*/
/*=========================================================*/
/* [1] Initialisation des utilitaires et variables
@ -622,10 +687,6 @@ function fDynamicUpdate(target){
/* [2] Inclusion des scripts externes et lancement
=========================================================*/
include('/js/includes/input-facebook-subject-min.js', function(){