Commit f2ddcc2e authored by Eric Seigne's avatar Eric Seigne
Browse files

agenda -> encode / decode

parent 8f2a071f
......@@ -46,12 +46,14 @@
<label for="distance">Km</label>
<input required name="distance" id="distance" type="number" inputmode="decimal" placeholder="Entrez ici la distance en km" value="" style="text-overflow: 'km';">
<ons-list style="clear: both;">
<input required name="label" id="label" type="text" placeholder="Objet: Déplacement client..." value="">
<div id="interobjets"></div>
<input required name="label" id="label" style="width: 100%; float: unset;" type="text" placeholder="Objet: Déplacement client..." value="">
<ons-list>
<ons-list-item id="listeObjets" expandable data-role="listview" data-filter="true" data-filter-reveal="true" data-input="#label">
Favoris...
</ons-list-item>
</ons-list>
<div id="interobjets"></div>
<ons-button modifier="material large" onclick="checkForm();">Valider</ons-button>
</ons-col>
......
......@@ -50,7 +50,7 @@ html+="</ul>";html+="<ons-button modifier='material large' onclick="+'"'+"create
+");"+'"'+" class='menubutton'><i class='zmdi zmdi-car'></i> Créer la fiche d'IK</ons-button>";}}
$(formField).append(html);}
function onErrorAgendaIK(msg){ons.notification.alert("Erreur d'accès à l'agenda"+JSON.stringify(msg),{title:"Erreur"});}
function createIK(titre,ladate,message,arrivee,depart){dataIK={label:titre+" "+message,ladate:ladate,arrivee:arrivee,depart:depart,};myDebug("avant le Goto : "+JSON.stringify(dataIK));gotoPage("frais-ik.html",true);}
function createIK(titre,ladate,message,arrivee,depart){dataIK={label:encodeURI(titre)+" "+encodeURI(message),ladate:ladate,arrivee:encodeURI(arrivee),depart:encodeURI(depart),};gotoPage("frais-ik.html",true);}
function sendForm(){myDebug("sendForm ");showWait();$.ajaxSetup({timeout:10000,headers:{'X-CSRF-TOKEN':localGetData("api_token")}});if(document.getElementById('ladate')){myDebug("on a ladate : "+document.getElementById('ladate').value);localStoreData("ladate",document.getElementById('ladate').value);}
var moyenPaiement=null;var els=document.getElementsByName('moyenPaiement');for(var i=0;i<els.length;i++){if(els[i].checked){moyenPaiement=els[i].value;myDebug("on a moyenPaiement : "+moyenPaiement);localStoreData("moyenPaiement",moyenPaiement);break;}}
var formdata=new FormData($("#leform")[0]);formdata.append('_token',localGetData("api_token"));if(document.getElementById('updateID').value==0){var hasImage=document.getElementById('smallImage');if(hasImage!==null){var file=document.getElementById('smallImage').getAttribute("src");if(file!=""){let typeFraisObj=document.getElementById('leform').typeFrais;globalTypeFrais="autre";if(typeFraisObj!==null){globalTypeFrais=typeFraisObj.value;}
......@@ -177,7 +177,7 @@ return r;}
function feedObjets(objets){if((typeof objets!='undefined')&&(objets!==null)&&(objets!="")){for(var i=0;i<objets.length&&i<15;i++){$('#listeObjets').append('<div class=\"expandable-content list-item__expandable-content\"><a href="#" onclick="selectLabel(\''+objets[i]+'\');">'+objets[i]+'</a></div>');}}}
function selectLabel(objet){if((typeof objet!='undefined')&&(objet!==null)&&(objet!="")){$('#label').val(objet);$('#listeObjets').hide();}}
function setPageTitle(titre){globalCurrentTitle=titre;$('#titreDoliScan').replaceWith('<div id="titreDoliScan" class="left" onclick="fn.back();"><i class="zmdi chevron-circle-left"></i> '+titre+'</div>');}
function completePageIKAfterGoto(dataIK){myDebug("completePageIKAfterGoto ...");let date=new Date(dataIK.ladate);document.getElementById('ladate').value=date.toDateInputValue();document.getElementById('label').value=dataIK.label;document.getElementById('arrivee').value=dataIK.arrivee;document.getElementById('depart').value=dataIK.depart;}
function completePageIKAfterGoto(dataIK){myDebug("completePageIKAfterGoto ...");let date=new Date(dataIK.ladate);document.getElementById('ladate').value=date.toDateInputValue();document.getElementById('label').value=decodeURI(dataIK.label);document.getElementById('arrivee').value=decodeURI(dataIK.arrivee);document.getElementById('depart').value=decodeURI(dataIK.depart);}
function completePageAfterGoto(dataLDF){myDebug("completePageAfterGoto ...");document.getElementById("updateID").value=dataLDF['sid'];document.getElementById("photoFacturette").value="UPDATE";fieldsToValidate=['nom','arrivee','depart','distance','label','ladate','ttc','typeFrais','moyenPaiement','photoFacturette','tvaVal1','tvaVal2','tvaVal3','tvaVal4'];for(let i=0;i<fieldsToValidate.length;i++){field=fieldsToValidate[i];switch(field){case 'photoFacturette':$("#smallImage").attr("src",dataLDF[field]);break;case 'moyenPaiement':break;default:if(document.getElementById(field)){document.getElementById(field).value=dataLDF[field];}}}}
ons.ready(function(){$('#label').keyup(function(){$('#listeObjets').show();});window.fn={};window.fn.open=function(){let onsRightMenu=document.getElementById('rightmenu');onsRightMenu.open();};window.fn.load=function(page){historique(page);let content=document.getElementById('maincontent');let onsRightMenu=document.getElementById('rightmenu');content.load(page).then(onsRightMenu.close.bind(onsRightMenu));};window.fn.back=function(){listeContent=JSON.parse(localGetData("history"));if(Array.isArray(listeContent)&&(listeContent.length>1)){var currentPage=listeContent.pop();var prevPage=listeContent.pop();let onsContent=document.getElementById('maincontent');if(prevPage==""){if(globalCurrentTitle=="DoliSCAN"){askQuitOrGoto("menu.html");}
else{cleanHistorique();globalCurrentTitle="DoliSCAN";onsContent.load("menu.html");}}
......@@ -265,9 +265,9 @@ function ProgressBar(ele){this.thisEle=$(ele);this.fileAdded=function(){myDebug(
function addLocalStorageEntry(liste,entry){if((typeof liste!='undefined')&&(liste!==null)&&(liste!="")){if((typeof entry!='undefined')&&(entry!==null)&&(entry!="")){var listeContent=JSON.parse(localGetData(liste));if(Array.isArray(listeContent)){listeContent.push(entry);listeContent=myUniqueSort(listeContent);}
else{listeContent=new Array(entry);}
localStoreData(liste,JSON.stringify(listeContent));}}}
function localStoreData(key,value){myDebug('localStoreData : '+key+' et '+value);if(key=='history'){return;}
function localStoreData(key,value){localStorage.setItem(key,value);if(key=='history'){return;}
if(globalDB==null){if(typeof window.sqlitePlugin!='undefined'){globalDB=window.sqlitePlugin.openDatabase({name:'doliscan.db',location:'default',androidDatabaseProvider:'system'},function(){myDebug("SQL : re-ouverture OK");});}}
if(globalDB!==null){globalDB.transaction(function(tx){tx.executeSql('DELETE FROM config WHERE key=?;',[key],function(res){},function(error){myDebug(' SQL delete error: '+error.message);});});if(value!==null){globalDB.transaction(function(tx){tx.executeSql('INSERT INTO config VALUES(?,?);',[key,value],function(res){myDebug(" SQL insert ok for "+key+":"+value+", "+res.insertId+"id, rows affected: "+res.rowsAffected);},function(error){myDebug(' SQL insert error: '+error.message);});});}
if(globalDB!==null){globalDB.transaction(function(tx){tx.executeSql('DELETE FROM config WHERE key=?;',[key],function(res){},function(error){myDebug(' SQL delete error: '+error.message);});});if(value!==null){globalDB.transaction(function(tx){tx.executeSql('INSERT INTO config VALUES(?,?);',[key,value],function(res){},function(error){myDebug(' SQL insert error: '+error.message);});});}
else{myDebug(" SQL ERR: Accès à globalDB impossible pour stocker "+key+" val "+value);}}}
function localGetData(key){if((typeof localStorage.getItem(key)!='undefined')&&(localStorage.getItem(key)!==null)&&(localStorage.getItem(key)!=null)&&(localStorage.getItem(key)!='null')&&(localStorage.getItem(key)!="")&&(localStorage.getItem(key)!=undefined)){myDebug('localGetData : '+key+' -> '+localStorage.getItem(key));return localStorage.getItem(key);}
myDebug("localGetData: on retourne null pour "+key)
......
......@@ -229,17 +229,11 @@ function onErrorAgendaIK(msg) {
function createIK(titre, ladate, message, arrivee, depart) {
//Il manque depart
dataIK = {
label: titre + " " + message,
label: encodeURI(titre) + " " + encodeURI(message),
ladate: ladate,
arrivee: arrivee,
depart: depart,
arrivee: encodeURI(arrivee),
depart: encodeURI(depart),
};
// dataIKL['label'] = titre + " " + message;
// dataIKL['ladate'] = ladate;
// dataIKL['arrivee'] = arrivee;
// dataIKL['depart'] = depart;
myDebug("avant le Goto : " + JSON.stringify(dataIK));
// myDebug("avant le Goto : " + JSON.stringify(dataIK));
gotoPage("frais-ik.html", true);
// puis completePageIKAfterGoto
}
......@@ -294,9 +294,9 @@ function completePageIKAfterGoto(dataIK) {
let date = new Date(dataIK.ladate);
document.getElementById('ladate').value = date.toDateInputValue();
document.getElementById('label').value = dataIK.label;
document.getElementById('arrivee').value = dataIK.arrivee;
document.getElementById('depart').value = dataIK.depart;
document.getElementById('label').value = decodeURI(dataIK.label);
document.getElementById('arrivee').value = decodeURI(dataIK.arrivee);
document.getElementById('depart').value = decodeURI(dataIK.depart);
//Reset l'objet pour eviter tout pb futur
// dataIK = "";
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment