/********************** * @function ObjUnite * @description unite - camion /voiture de service * @constructor * @param {Object} global objet global **********************/ function ObjUnite(global) { this.mag_num; this.date; this.hre; this.EmployeNom = ""; this.EmployeNumero = ""; this.uniteNumero = ""; this.kmParcours = 0; this.kmPrevus = 0; this.kmPrevusIsReady = false; this.lat = null; this.lng = null; this.routeparcourue = null; this.xmlAngleDirection = null; this.arretPrevu = null; this.boolRoutePrevue = false; this.arretNonPrevu = null; this.global = global; this.routeCorrigee = null; this.routeCorrigeeNameArray = new Array; } /********************** * @function init * @description initialisation des elements de l'unite **********************/ ObjUnite.prototype.init = function () { }; /********************** * @function afficherUniteData * @description afficher l'unite sur la carte dans le menu gauche **********************/ ObjUnite.prototype.afficherUniteData = function () { var carte = this.global.obtenirObjMap(); var coucheCarte = this.global.obtenirObjCarteCouche(); // center la carte sur l'unite carte.assignerCentre(this.lat, this.lng); // afficher le marker sur la carte coucheCarte.ajouterUniteMarker(this.lat, this.lng, this.mag_num, this.EmployeNom); }; /********************** * @function obtenirUniteArretPrevuData * @description obtenir les coord des arrets prevus **********************/ ObjUnite.prototype.obtenirUniteArretPrevuData = function () { $.blockUI(); var me = this; var todayNow = new Date(); var date_set = todayNow.getDate() + "/" + (todayNow.getMonth() + 1) + "/" + todayNow.getFullYear(); with ({me: this}) { $.ajax({ type: "GET", url: "/ajax/ma_livraison_camions.php?" + "dateset=" + date_set + "&rdData1=" + getRandomForAjax(), dataType: "xml", success: function (xml) { try { me.arretPrevu = xml2json.parser($.XMLtoStr(xml)); me.obtenirUniteArretPrevuDataWithOwenData(); } finally { $.unblockUI(); } }, error: function (result) { $.unblockUI(); } }); } }; /********************** * @function obtenirUniteArretPrevuDataWithOwenData * @description obtenir les coord des arrets prevus et geocodage * @param {json} response resultat geocodage **********************/ ObjUnite.prototype.obtenirUniteArretPrevuDataWithOwenData = function () { var coucheCarte = this.global.obtenirObjCarteCouche(); var layout = this.global.obtenirObjLayout(); var arretPrevuData = this.arretPrevu['root']['destinations']['destination']; if (typeof (arretPrevuData) == "undefined") { arretPrevuData = null; } else { if (typeof (arretPrevuData.length) == "undefined") { arretPrevuData = [arretPrevuData]; } coucheCarte.ajouterArretPrevu(arretPrevuData); if (this.boolRoutePrevue) { coucheCarte.ajouterRoutePrevue(arretPrevuData); } else { coucheCarte.enleverRoutePrevue(); } } }; /********************** * @function afficherUniteArretPrevuCarte * @description afficher ou pas les arrets prevus * @param {boolean} afficher * @return {boolean} afficher ou pas sur la carte **********************/ ObjUnite.prototype.afficherUniteArretPrevuCarte = function (afficher) { var coucheCarte = this.global.obtenirObjCarteCouche(); if (afficher) { if (this.arretPrevu == null) { this.obtenirUniteArretPrevuData(); } else { var data = this.arretPrevu['root']['destinations']['destination']; coucheCarte.ajouterArretPrevu(data); if (this.boolRoutePrevue) coucheCarte.ajouterRoutePrevue(data); } } else { coucheCarte.enleverArretPrevu(); coucheCarte.enleverRoutePrevue(); } return true; }; /********************** * @function afficherRoutePrevue * @description obtenir Afficher Route Prevue * @param {boolean} afficher * @return {boolean} **********************/ ObjUnite.prototype.afficherRoutePrevue = function (afficher) { this.boolRoutePrevue = afficher; var coucheCarte = this.global.obtenirObjCarteCouche(); if (afficher) { if (this.arretPrevu == null) { this.obtenirUniteArretPrevuData(); } else { var data = this.arretPrevu['root']['destinations']['destination']; coucheCarte.ajouterArretPrevu(data); if (this.boolRoutePrevue) coucheCarte.ajouterRoutePrevue(data); } } else { coucheCarte.enleverRoutePrevue(); } return true; }; /********************** * @function supprimerAll * @description supprimer All **********************/ ObjUnite.prototype.supprimerAll = function () { var coucheCarte = this.global.obtenirObjCarteCouche(); coucheCarte.enleverRoutePrevue(); coucheCarte.enleverUniteMarker(); }; /********************** * @function obtenirAll * @description obtenir All **********************/ ObjUnite.prototype.obtenirAll = function (arretPrevue) { this.init(); if (arretPrevue) this.obtenirUniteArretPrevuData(); }; /********************** * @function actualiserData * @description actualiser l'information sur l'unite **********************/ ObjUnite.prototype.actualiserData = function () { this.supprimerAll(); this.obtenirAll(true); };