Fix de l'upload de données locales + vérifications

This commit is contained in:
xdrm-brackets 2016-11-06 12:11:52 +01:00
parent 3c66937ec7
commit 07e000d8e3
4 changed files with 856 additions and 5 deletions

View File

@ -173,8 +173,7 @@
/* (3) Vérification du sujet */ /* (3) Vérification du sujet */
$checkSubject = isset($json['subject']['tmp_id']) && ( is_string($json['subject']['tmp_id']) || is_null($json['subject']['tmp_id']) ); $checkSubject = isset($json['subject']['subject_id']) && is_numeric($json['subject']['subject_id']);
$checkSubject = $checkSubject && isset($json['subject']['subject_id']) && is_numeric($json['subject']['subject_id']);
// Erreur des attributs du sujet incorrects ou manquants // Erreur des attributs du sujet incorrects ou manquants
if( !$checkSubject ) if( !$checkSubject )
@ -187,7 +186,7 @@
$checkContact = $checkContact && isset($contact['username']) && is_string($contact['username']); $checkContact = $checkContact && isset($contact['username']) && is_string($contact['username']);
// Existing ou username.length > 0 // Existing ou username.length > 0
$checkContact = $checkContact && isset($contact['existing']); $checkContact = $checkContact && isset($contact['existing']);
$checkContact = $checkContact && ( is_numeric($contact['existing']) || strlen($contact['username']) > 0 ); $checkContact = $checkContact && ( strlen($contact['username']) > 0 || intval($contact['existing']) == $contact['existing'] );
// $checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']); // $checkContact = $checkContact && isset($contact['sms']) && is_numeric($contact['sms']);
// $checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']); // $checkContact = $checkContact && isset($contact['call']) && is_numeric($contact['call']);
// $checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']); // $checkContact = $checkContact && isset($contact['countsms']) && is_numeric($contact['countsms']);

View File

@ -0,0 +1,852 @@
{
"subject": {
"subject_id": "1"
},
"contacts": {
"0": {
"uid": 0,
"username": "Ismael",
"existing": ".",
"hash": 1627075103
},
"1": {
"uid": 1,
"username": "Rosa",
"existing": ".",
"hash": 498192491
},
"2": {
"uid": 2,
"username": "Judith",
"existing": ".",
"hash": 1451575763
},
"3": {
"uid": 3,
"username": "Alex",
"existing": ".",
"hash": 2660323475
},
"4": {
"uid": 4,
"username": "Adri",
"existing": ".",
"hash": 2559488290
},
"5": {
"uid": 5,
"username": "Fred",
"existing": ".",
"hash": 4039469544
},
"6": {
"uid": 6,
"username": "Shanone",
"existing": ".",
"hash": 28222849
},
"7": {
"uid": 7,
"username": "Manon",
"existing": ".",
"hash": 336712847
},
"8": {
"uid": 8,
"username": "Java",
"existing": ".",
"hash": 1359920097
},
"9": {
"uid": 9,
"username": "Thalees",
"existing": ".",
"hash": 2826325950
},
"10": {
"uid": 10,
"username": "Crème",
"existing": ".",
"hash": 4211503315
},
"11": {
"uid": 11,
"username": "Margaux",
"existing": ".",
"hash": 3915760272
},
"12": {
"uid": 12,
"username": "Anthony",
"existing": ".",
"hash": 410858384
},
"13": {
"uid": 13,
"username": "Lino",
"existing": ".",
"hash": 2457771762
}
},
"mini": {},
"fiches": {
"0": {
"sexe": "0",
"age": "0",
"job": "10",
"famsit": "0",
"studies": "",
"reltype": "0",
"reltypeSpecial": "",
"city": "10",
"quartier": "0",
"cp": "10000",
"loc": "0",
"duration": [
"0",
"10"
],
"context": "0",
"contextSpecial": [
"",
"",
""
],
"freq": [
"2",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 0,
"contact": 0,
"hash": 3977448909,
"valid": true,
"timestamp": 1478429171540
},
"1": {
"sexe": "1",
"age": "1",
"job": "21",
"famsit": "0",
"studies": "01",
"reltype": "1",
"reltypeSpecial": "",
"city": "11",
"quartier": "1",
"cp": "10001",
"loc": "1",
"duration": [
"1",
"11"
],
"context": "1",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 1,
"contact": 1,
"hash": 3439453096,
"valid": true,
"timestamp": 1478429171592
},
"2": {
"sexe": "2",
"age": "2",
"job": "22",
"famsit": "0",
"studies": "02",
"reltype": "2",
"reltypeSpecial": "",
"city": "12",
"quartier": "2",
"cp": "10002",
"loc": "2",
"duration": [
"2",
"12"
],
"context": "2",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 2,
"contact": 2,
"hash": 2538679406,
"valid": true,
"timestamp": 1478429171636
},
"3": {
"sexe": "0",
"age": "3",
"job": "23",
"famsit": "0",
"studies": "03",
"reltype": "3",
"reltypeSpecial": "",
"city": "13",
"quartier": "3",
"cp": "10003",
"loc": "3",
"duration": [
"3",
"13"
],
"context": "3",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 3,
"contact": 3,
"hash": 1448962210,
"valid": true,
"timestamp": 1478429171695
},
"4": {
"sexe": "1",
"age": "4",
"job": "31",
"famsit": "0",
"studies": "04",
"reltype": "4",
"reltypeSpecial": "",
"city": "14",
"quartier": "4",
"cp": "10004",
"loc": "0",
"duration": [
"4",
"14"
],
"context": "4",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 4,
"contact": 4,
"hash": 3000740570,
"valid": true,
"timestamp": 1478429171741
},
"5": {
"sexe": "2",
"age": "5",
"job": "32",
"famsit": "0",
"studies": "05",
"reltype": "5",
"reltypeSpecial": "",
"city": "15",
"quartier": "5",
"cp": "10005",
"loc": "1",
"duration": [
"5",
"15"
],
"context": "5",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 5,
"contact": 5,
"hash": 1185776066,
"valid": true,
"timestamp": 1478429171805
},
"6": {
"sexe": "0",
"age": "6",
"job": "36",
"famsit": "0",
"studies": "06",
"reltype": "6",
"reltypeSpecial": "",
"city": "16",
"quartier": "6",
"cp": "10006",
"loc": "2",
"duration": [
"6",
"16"
],
"context": "6",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 6,
"contact": 6,
"hash": 3580676315,
"valid": true,
"timestamp": 1478429171858
},
"7": {
"sexe": "1",
"age": "7",
"job": "41",
"famsit": "0",
"studies": "07",
"reltype": "7",
"reltypeSpecial": "",
"city": "17",
"quartier": "7",
"cp": "10007",
"loc": "3",
"duration": [
"7",
"17"
],
"context": "7",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 7,
"contact": 7,
"hash": 3989377397,
"valid": true,
"timestamp": 1478429171905
},
"8": {
"sexe": "2",
"age": "8",
"job": "46",
"famsit": "0",
"studies": "08",
"reltype": "10",
"reltypeSpecial": "autre",
"city": "18",
"quartier": "8",
"cp": "10008",
"loc": "0",
"duration": [
"8",
"18"
],
"context": "8",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 8,
"contact": 8,
"hash": 594979660,
"valid": true,
"timestamp": 1478429171955
},
"9": {
"sexe": "0",
"age": "9",
"job": "47",
"famsit": "0",
"studies": "09",
"reltype": "0",
"reltypeSpecial": "",
"city": "19",
"quartier": "9",
"cp": "10009",
"loc": "1",
"duration": [
"9",
"19"
],
"context": "9",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 9,
"contact": 9,
"hash": 1585642677,
"valid": true,
"timestamp": 1478429172030
},
"10": {
"sexe": "1",
"age": "10",
"job": "48",
"famsit": "0",
"studies": "10",
"reltype": "1",
"reltypeSpecial": "",
"city": "20",
"quartier": "10",
"cp": "10010",
"loc": "2",
"duration": [
"10",
"110"
],
"context": "10",
"contextSpecial": [
"",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 10,
"contact": 10,
"hash": 350296051,
"valid": true,
"timestamp": 1478429172091
},
"11": {
"sexe": "2",
"age": "11",
"job": "51",
"famsit": "0",
"studies": "11",
"reltype": "2",
"reltypeSpecial": "",
"city": "21",
"quartier": "11",
"cp": "10011",
"loc": "3",
"duration": [
"11",
"111"
],
"context": "11",
"contextSpecial": [
"internet",
"",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 11,
"contact": 11,
"hash": 2556603658,
"valid": true,
"timestamp": 1478429172141
},
"12": {
"sexe": "0",
"age": "12",
"job": "54",
"famsit": "0",
"studies": "",
"reltype": "3",
"reltypeSpecial": "",
"city": "22",
"quartier": "12",
"cp": "10012",
"loc": "0",
"duration": [
"12",
"112"
],
"context": "12",
"contextSpecial": [
"",
"association",
""
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 12,
"contact": 12,
"hash": 1254626617,
"valid": true,
"timestamp": 1478429172191
},
"13": {
"sexe": "1",
"age": "13",
"job": "55",
"famsit": "0",
"studies": "01",
"reltype": "4",
"reltypeSpecial": "",
"city": "23",
"quartier": "13",
"cp": "10013",
"loc": "1",
"duration": [
"13",
"113"
],
"context": "13",
"contextSpecial": [
"",
"",
"autre"
],
"freq": [
"4",
"9",
"14",
"19",
"24"
],
"connect": [
"1",
"3",
"5",
"7",
"9",
"11"
],
"connectSpecial": [
"",
""
],
"uid": 13,
"contact": 13,
"hash": 1821404092,
"valid": true,
"timestamp": 1478429175971
}
},
"matrice": {
"0": [
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"1": [
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
],
"2": [
3,
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"3": [
4,
5,
6,
7,
8,
9,
10,
11,
12
],
"4": [
5,
6,
7,
8,
9,
10,
11,
12
],
"5": [
6,
7,
8,
9,
10,
11,
12
],
"6": [
7,
8,
9,
11,
12
],
"7": [
8,
9,
10,
11,
12
],
"8": [
9,
10,
11,
12
],
"9": [
10,
11,
12
],
"10": [
11
]
}
}

View File

@ -308,7 +308,7 @@ var phoneRoutine = function(){
var request = { var request = {
path: 'input/facebook', path: 'input/facebook',
subject: lsi.export('p_subject')[0]['subject_id'], subject: lsi.export('p_subject')[0],
contacts: lsi.export('p_contacts'), contacts: lsi.export('p_contacts'),
mini: lsi.export('p_mini-fiches'), mini: lsi.export('p_mini-fiches'),
fiches: lsi.export('p_fiches'), fiches: lsi.export('p_fiches'),

View File

@ -9,7 +9,7 @@ function(a){Notification.info("INFORMATION","Lancement du t\u00e9l\u00e9chargeme
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", function(a){$('[data-sublink="phone"] #p_local-upload').click()},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("click",function(a){a.target.value=null},!1),$('[data-sublink="phone"] #p_local-upload').addEventListener("change",function(a){a={path:"upload/local_data",file:$('[data-sublink="phone"] #p_local-upload').files[0]};api.send(a,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("Erreur",a.ModuleError),!1;lsi.set("p_subject",0,a.local_data.subject);lsi["import"]("p_contacts",
a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1),$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage(); a.local_data.contacts);lsi["import"]("p_mini-fiches",a.local_data.mini);lsi["import"]("p_fiches",a.local_data.fiches);lsi.set("p_matrice",0,a.local_data.matrice);pSubjectManager.storageToFields();pContactManager.storageToFields();pMatriceManager.storageToFields();pDynamicUpdate(!0)})},!1),$('[data-sublink="phone"] #p_submit-all').addEventListener("click",function(a){console.log("> GATHERING ALL DATA");pContactManager.fieldsToStorage();pMiniManager.fieldsToStorage();pFicheManager.fieldsToStorage();
if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"), if(!pSubjectManager.check())return Notification.warning("Attention","Vous devez saisir les informations du <i>sujet</i>"),!1;a=lsi["export"]("p_mini-fiches");var b=0,c;for(c in a)if(!isNaN(c)&&(b++,!a[c].valid))return Notification.warning("Attention","La <i>fiche rapide</i> <b>"+b+"</b> est incompl\u00e8te et/ou incorrecte"),!1;a=lsi["export"]("p_fiches");for(c in a)if(!a[c].valid)return Notification.warning("Attention","La <i>fiche compl\u00e8te</i> <b>"+(parseInt(c)+1)+"</b> est incompl\u00e8te et/ou incorrecte"),
!1;c={path:"input/facebook",subject:lsi["export"]("p_subject")[0].subject_id,contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1),console.groupEnd())}; !1;c={path:"input/facebook",subject:lsi["export"]("p_subject")[0],contacts:lsi["export"]("p_contacts"),mini:lsi["export"]("p_mini-fiches"),fiches:lsi["export"]("p_fiches"),matrice:lsi["export"]("p_matrice")[0]};api.send(c,function(a){console.log(a);if(0!=a.ModuleError)return Notification.error("ERREUR",a.ModuleError),!1;Notification.success("OK","L'identifiant du sujet est <strong>"+a.subject_id+"</strong> ! Tout s'est bien d\u00e9roul\u00e9.",1E4);console.log(a)},!1)},!1),console.groupEnd())};
include("/js/includes/input-phone-subject.js",function(){pLoaded[0]=1;phoneRoutine()});include("/js/includes/input-phone-contact.js",function(){pLoaded[1]=1;phoneRoutine()});include("/js/includes/input-phone-mini.js",function(){pLoaded[2]=1;phoneRoutine()});include("/js/includes/input-phone-fiche.js",function(){pLoaded[3]=1;phoneRoutine()});include("/js/includes/input-phone-matrice.js",function(){pLoaded[4]=1;phoneRoutine()}); include("/js/includes/input-phone-subject.js",function(){pLoaded[0]=1;phoneRoutine()});include("/js/includes/input-phone-contact.js",function(){pLoaded[1]=1;phoneRoutine()});include("/js/includes/input-phone-mini.js",function(){pLoaded[2]=1;phoneRoutine()});include("/js/includes/input-phone-fiche.js",function(){pLoaded[3]=1;phoneRoutine()});include("/js/includes/input-phone-matrice.js",function(){pLoaded[4]=1;phoneRoutine()});
var fAlready=0,fLoaded=[0,0,0,0,0],facebookRoutine=function(){!Math.min.apply(Math,fLoaded)|fAlready||(fAlready=1,console.groupEnd(),console.group("[facebook] Initialization"),fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')),fSubjectManager.attach(fDynamicUpdate),fContactManager=new inputFacebookContact($('[data-sublink="facebook"] article.contact-panel'), var fAlready=0,fLoaded=[0,0,0,0,0],facebookRoutine=function(){!Math.min.apply(Math,fLoaded)|fAlready||(fAlready=1,console.groupEnd(),console.group("[facebook] Initialization"),fSubjectManager=new inputFacebookSubject($('[data-sublink="facebook"] article.subject-panel [data-name="subject_id"]'),$('[data-sublink="facebook"] article.subject-panel [data-name="submit"]')),fSubjectManager.attach(fDynamicUpdate),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.top_size=20,fFicheManager.attach(fDynamicUpdate),fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-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.top_size=20,fFicheManager.attach(fDynamicUpdate),fMatriceManager=new inputFacebookMatrice($('[data-sublink="facebook"] article.matrice-panel')),