')
$("#spinnerContainer").show();
// Assoxiation des fonctions callbacks
if (this.Callbacks != null) {
if (this.Callbacks.selectedPlaceValidHandler != null)
this.selectedPlaceValid = this.Callbacks.selectedPlaceValidHandler;
if (this.Callbacks.selectedPlaceErrorHandler != null)
this.selectedPlaceError = this.Callbacks.selectedPlaceErrorHandler;
if (this.Callbacks.loadPlanErrorHandler != null)
this.loadPlanError = this.Callbacks.loadPlanErrorHandler;
}
this.GetApartePlan();
};
this.GetApartePlan = function () {
var map = this;
var resultMap = null;
var initOptions = JSON.stringify(map.Options);
$.ajax({
url: map.Options.Url + 'getmapinformations',
method: 'GET',
data: { 'entries': initOptions }, //ur data to be sent to server
dataType: 'json',
crossDomain: true,
async: true,
contentType: 'application/json, charset=utf-8',
success: function (result) {
resultMap = map.displayPlan(result, map.Options.Container, map);
if (map.Options.IsWidget) {
map.Options.idInterfaceFlag = result.Data.WidgetInterfaceFlag;
map.Options.IdFlagGroup = result.Data.WidgetFlagGroup;
map.Options.IdSession = result.Data.WidgetSession;
}
// Désactivation du clic droit sur le conteneur
$('.aparteMapContainer').bind('contextmenu', function (e) {
return false;
});
$("#spinnerContainer").hide();
},
error: function (xhr, status) {
var i = 0;
}
});
};
function customFormatString(value) {
var firstSplit = value.split('T');
var dateSplit = firstSplit[0].split("-");
var yyyy = dateSplit[0];
var MM = dateSplit[1];
var dd = dateSplit[2];
var hourSplit = firstSplit[1].split(":");
var HH = hourSplit[0];
var mm = hourSplit[1];
var ss = hourSplit[2];
var concat = dd + "/" + MM + "/" + yyyy + " " + HH + "h" + mm;
return concat;
}
this.displayPlan = function (ajaxResult, idDivContainer, map) {
var container = $("#" + idDivContainer);
if (window.innerWidth < 768) {
this.isMobile = true;
}
var res = ajaxResult.Data;
if (res.ErrorCode != 0) {
if (this.loadPlanError != null) {
this.loadPlanError(res.ErrorStatus);
}
}
// Chargement des infos séance dans la div recap
var date = new Date(res.CatalogContentsDetail.CatalogContent.Startdate);
var toto = date.toUTCString();
var tesDate = new Date(date.toUTCString());
this.CatalogDetail = res.CatalogDetail;
this.CatalogContentsDetail = res.CatalogContentsDetail;
var choiceDetail = '';
choiceDetail += '
';
//}
if (!maxReached) {
var nbAvailable = 0;
for (var i = 0; i < Place.ListAvailablePrices.length; i++) {
// dans le cas d'un abo check si reste dispo
// on parcourt la liste des places flagées, on regarde le nombre de dispos
// -> affichage du tarif selon dispo
var flagAuthorized = true;
if (this.VenueRate != null) {
for (var j = 0; j < this.VenueRate.length; j++) {
// si le tarif est dans les dispos
if (this.VenueRate[j].ID_Generic == Place.ListAvailablePrices[i].ID_rate) {
var countFlag = 0;
for (var k = 0; k < this.ListSelectedSeats.length; k++) {
var selSeat = this.ListSelectedSeats[k];
if (selSeat.IdRate == this.VenueRate[j].ID_Generic) countFlag++;
}
if (this.VenueRate[j].Nb == countFlag) {
flagAuthorized = false;
nbAvailable++;
break;
}
}
}
}
var price = Place.ListAvailablePrices[i];
if (flagAuthorized) {
if (price.RateComment != null && price.RateComment.length != 0)
ratesInside += '
';
}
if (!maxReached) {
for (var i = 0; i < Place.ListAvailablePrices.length; i++) {
var price = Place.ListAvailablePrices[i];
// dans le cas d'un abo check si reste dispo
var flagAuthorized = true;
if (this.VenueRate != null) {
for (var j = 0; j < this.VenueRate.length; j++) {
// si le tarif est dans les dispos
if (this.VenueRate[j].ID_Generic == Place.ListAvailablePrices[i].ID_rate) {
var countFlag = 0;
for (var k = 0; k < this.ListSelectedSeats.length; k++) {
var selSeat = this.ListSelectedSeats[k];
if (selSeat.IdRate == this.VenueRate[j].ID_Generic) countFlag++;
}
if (this.VenueRate[j].Nb == countFlag) {
flagAuthorized = false;
break;
}
}
}
}
if (flagAuthorized) {
//if (price.RateComment != null)
// ratesInside += '
' + price.RateComment + '
';
//else
// ratesInside += '
';
if (rateInRuleToAdd != 0 && rateInRuleToAdd.id == price.ID_rate) {
if (price.RateComment != null) {
ratesInside += '
Le maximum de ' + that.NbArtMax + ' place(s) par commande est atteint
';
$("#ok").hide();
}
ratesInside += '
';
divRates.append(ratesInside);
isPopUpVisible = true;
isPopupClicked = true;
$("#divButtons").show();
}
else {
idRate = 0;
that.FlagSeat();
}
}
}
this.DisplayPopupBlockRatesFixed = function (x, y, event, Place) {
if (!isPopupClicked) {
isVisible = false;
var tranche = 0;
var divWidth = $("#divRecapMap").width() + 20;
var divHeight = $("#divRecapMap").height() + 20;
if (my < divHeight)
$("#divRecapMap").css('top', y + 20 + 'px');
else
$("#divRecapMap").css('top', y - divHeight + 'px');
if (mx < divWidth) tranche = -20;
else
tranche = $("#divRecapMap").width() + 20;
$("#divRecapMap").css('left', (x - tranche) + 'px');
//$("#divRecapMap").fadeIn();
$("#divRecapMap").css('display', 'table');
// Contruction des tableaux descr + tarifs
var block = 0;
var rang = Place.rank;
var place = Place.seat;
var categ = '';
for (var i = 0; i < this.listCategories.length; i++) {
if (Place.I_Category == this.listCategories[i].id) {
categ = this.listCategories[i].name;
break;
}
}
Place.categ = categ;
var divDesc = $("#divDescription");
divDesc.empty();
if (block > 0) {
}
else {
var insideDesc = '
Catégorie
';
insideDesc += '
' + categ + '
';
insideDesc += '
';
}
divDesc.append(insideDesc);
var divRates = $("#divRates");
divRates.empty();
divRates.css('overflow-y', 'auto');
var ratesInside = '
';
for (var i = 0; i < Place.ListAvailablePrices.length; i++) {
var price = Place.ListAvailablePrices[i];
if (price.RateComment != null)
ratesInside += '
' + price.RateComment + '
';
else
ratesInside += '
';
}
ratesInside += '
';
divRates.append(ratesInside);
isPopUpVisible = true;
isPopupClicked = true;
////$("#divRecapMap").css('display', 'table');
$("#divButtons").show();
}
}
this.HidePopupRates = function () {
$("#divRecapMap").hide();
///$("#divRecapMap").css('display', 'none');
$("#unselectSeat").hide();
$("#ok").hide();
idRate = 0;
isPopUpVisible = false;
isPopupClicked = false;
}
this.myUpMini = function (e) {
if (event.type == "touchend") {
planIsMoving = false;
that.DrawPlan();
}
else {
if (planIsMoving) {
planIsMoving = false;
that.DrawPlan();
}
}
event.preventDefault();
}
this.myDownMini = function (event) {
if (event.type == "touchstart") {
getMouseEventMini(event);
planIsMoving = true;
that.MovePlanViaMini();
event.stopPropagation();
}
else {
getMouseEventMini(event);
if (getButtonEvent(event) == 1) {
planIsMoving = true;
that.MovePlanViaMini();
//drawdebugmini();
}
else {
that.CenterPlanViaMini();
that.RecalculPlanPlaceCoordonnee();
that.DrawPlan();
that.DrawMiniPlan();
//DrawToolBar();
that.IsZoomed = false;
}
event.preventDefault();
}
}
this.CenterPlanViaMini = function () {
if (that == null) that = this;
var z1 = (that.WIDTH) / (that.rect.x2 - that.rect.x1);
var z2 = (that.HEIGHT) / (that.rect.y2 - that.rect.y1);
if (z1 > z2)
that.zoom = round(z2, 2);
else
that.zoom = round(z1, 2);
// cas du zoom optimal à l'origine
if (that.zoom > 1.2) {
that.IsZoomed = true;
}
var centerx = that.WIDTH / 2;
var centery = that.HEIGHT / 2;
var zoomx = (that.rect.x2 - that.rect.x1) / that.MiniPlanWidth;
var zoomy = (that.rect.y2 - that.rect.y1) / that.MiniPlanHeight;
that.decalX = round(((that.MiniPlanWidth / 2) * zoomx * that.zoom) - (centerx), 0);
that.decalY = round(((that.MiniPlanHeight / 2) * zoomy * that.zoom) - (centery), 0);
}
var isonwheel = false;
this.myOnWheel = function (event) {
event.preventDefault();
event.stopPropagation();
if (isonwheel) return;
if (isPopupClicked)
return;
isonwheel = true;
lastDownTarget = event.target;
if (event.currentTarget.nodeName != "CANVAS") return;
var delta = 0;
if (!event) /* For IE. */
event = window.event;
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta / 120;
} else if (event.detail) { /** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
delta = -event.detail / 3;
}
OldPlanZoom = that.zoom;
if (delta > 0)
that.zoom += 0.9;
else
that.zoom -= 0.9;
if (that.zoom < 1.1) {
that.zoom = 1.1;
}
else if (that.WidthSeat * that.zoom > 35) {
that.zoom = round(35 / that.WidthSeat, 1);
}
var centerx = (that.WIDTH / 2);
var centery = (that.HEIGHT / 2);
var zoomx = (that.rect.x2 - that.rect.x1) / (that.WIDTH);
var zoomy = (that.rect.y2 - that.rect.y1) / (that.HEIGHT);
that.decalX = ((mx) * (zoomx) * that.zoom) - (centerx);
that.decalY = ((my) * (zoomy) * that.zoom) - (centery);
that.decalX -= (mx - (that.WIDTH / 2));
that.decalY -= (my - (that.HEIGHT / 2));
that.decalX = round(that.decalX, 0);
that.decalY = round(that.decalY, 0);
that.RecalculPlanPlaceCoordonnee();
that.DrawPlan();
isonwheel = false;
}
this.myUp = function (e) {
//getMouseEvent(e);
//if (event.type == "touchstart" || event.type == "touchend" || event.type == "touchmove") {
if (touchDown == true) {
var canvas = document.getElementById("canvasPlaces");
var Place = that.FindPlace(mx, my)
if (Place == null) {
that.HidePopupRates();
$("#ok").hide();
}
else {
if (Place.inBlock) {
var block = Place.Block;
var blockwidth = (block.maxx * that.zoom) - (block.minx * that.zoom);
var blockheight = (block.maxy * that.zoom) - (block.miny * that.zoom);
that.ctxSelection.DrawSelectionBlock((block.minx * that.zoom) - that.decalX, (block.miny * that.zoom) - that.decalY, blockwidth, blockheight, 0, that);
DisplayPopupBlockRatesFixed(event.clientX, event.clientY, event, Place);
SelectedPlace = Place;
}
else {
if (Place.s == 0) {
SelectedPlace = Place;
that.ctxSelection.DrawSelection((Place.x * that.zoom) - that.decalX, (Place.y * that.zoom) - that.decalY, that.WidthSeat * that.zoom, that.WidthSeat * that.zoom, Place.s, that);
// Si un seul tarif => sélection directe
if (Place.ListAvailablePrices.length >= 2)
that.DisplayPopupRatesFixed(event.clientX, event.clientY, event, Place);
else {
var rateInRuleToAdd = RefreshRates(that.RuleList, that.listRates, that.listCategories, Place.I_Category);
Place.idRate = Place.ListAvailablePrices[0].ID_rate;
if (rateInRuleToAdd != 0 && rateInRuleToAdd.id == Place.idRate)
that.DisplayPopupRatesFixed(event.clientX, event.clientY, event, Place);
else {
idRate = Place.ListAvailablePrices[0].ID_rate;
that.FlagSeat();
idRate = 0;
}
}
}
}
}
}
}
var isMoving = false;
this.myMove = function (e) {
e.preventDefault();
e.stopPropagation();
if (isPopupClicked)
return;
lastDownTarget = e.target;
if (e.currentTarget.nodeName != "CANVAS") return;
getMouseEvent(e);
touchDown = false;
if (isMoving) return;
isMoving = true;
if (event.type == "touchstart" || event.type == "touchend" || event.type == "touchmove") {
that.HidePopupRates(); $("#ok").hide();
that.decalX += ((oldmx - mx));
that.decalY += ((oldmy - my));
translationX += ((oldmx - mx));
translationY += ((oldmy - my));
that.decalX = round(that.decalX, 0);
that.decalY = round(that.decalY, 0);
that.DrawPlan();
oldmx = mx;
oldmy = my;
}
else {
var btn = getButtonEvent(e);
if (btn == 1) {
that.decalX += ((oldmx - mx));
that.decalY += ((oldmy - my));
translationX += ((oldmx - mx));
translationY += ((oldmy - my));
that.decalX = round(that.decalX, 0);
that.decalY = round(that.decalY, 0);
that.DrawPlan();
oldmx = mx;
oldmy = my;
}
}
isMoving = false;
//}
//else
//{
// var btn = getButtonEvent(e);
// if (btn == 0) {
// if (that.IsZoomed) {
// var canvas = document.getElementById("canvasPlaces");
// if (!isPopupClicked)
// that.ctxSelection.clearSelection(0, 0, that.WIDTH, that.HEIGHT);
// var Place = that.FindPlace(mx, my);
// if (Place == null) {
// $("#mapContainer").css('cursor', 'default');
// if (OldPlace != null) {
// that.ctxSelection.clearSelection((OldPlace.x * that.zoom) - that.decalX, (OldPlace.y * that.zoom) - that.decalY, that.WidthSeat * that.zoom, that.WidthSeat * that.zoom);
// }
// that.HidePopupRates(); $("#ok").hide();
// OldPlace = null;
// }
// else {
// $("#mapContainer").css('cursor', 'pointer');
// if (Place.inBlock) {
// var block = Place.Block;
// var blockwidth = (block.maxx * that.zoom) - (block.minx * that.zoom);
// var blockheight = (block.maxy * that.zoom) - (block.miny * that.zoom);
// that.ctxSelection.DrawSelectionBlock((block.minx * that.zoom) - that.decalX, (block.miny * that.zoom) - that.decalY, blockwidth, blockheight, 0, that);
// that.DisplayPopupBlockRates(e.clientX, e.clientY, e, Place);
// }
// else {
// if (that.IsZoomed) {
// if (Place.s === 0) {
// that.ctxSelection.DrawSelectionBlock((Place.x * that.zoom) - that.decalX, (Place.y * that.zoom) - that.decalY, that.WidthSeat * that.zoom, that.WidthSeat * that.zoom, Place.s, that);
// that.DisplayPopupRates(e.clientX, e.clientY, e, Place);
// }
// else {
// that.ctxSelection.DrawSelectionDisabled((Place.x * that.zoom) - that.decalX, (Place.y * that.zoom) - that.decalY, that.WidthSeat * that.zoom, that.WidthSeat * that.zoom, Place.s, that);
// that.HidePopupRates();
// }
// OldPlace = Place;
// }
// }
// }
// }
// else {
// $("#mapContainer").css('cursor', 'zoom-in');
// }
// }
// if (btn == 2) {
// that.decalX += ((oldmx - mx));
// that.decalY += ((oldmy - my));
// translationX += ((oldmx - mx));
// translationY += ((oldmy - my));
// that.decalX = round(that.decalX, 0);
// that.decalY = round(that.decalY, 0);
// that.DrawPlan();
// }
// oldmx = mx;
// oldmy = my;
//}
}
this.ClearInfoBulle = function () {
if (!infobulledisplay) return;
this.ctxTooltip.canvas.width = this.ctxTooltip.canvas.width;
}
/* good version */
this.drawMaskMiniPlan = function () {
this.ctxMiniplan2.canvas.width = this.ctxMiniplan2.canvas.width;
this.ctxMiniplan2.beginPath();
this.ctxMiniplan2.fillStyle = "rgba(200,200,200,0.5)";
this.ctxMiniplan2.fillRect(0, 0, this.MiniPlanWidth, this.MiniPlanHeight);
this.ctxMiniplan2.closePath();
var zoomx = (this.rect.x2 - this.rect.x1) / this.MiniPlanWidth;
var zoomy = (this.rect.y2 - this.rect.y1) / this.MiniPlanHeight;
var radius = 2;
var w = (this.WIDTH / zoomx) / this.zoom;
var h = (this.HEIGHT / zoomy) / this.zoom;
var x = (this.decalX / zoomx) / this.zoom
var y = (this.decalY / zoomy) / this.zoom
this.ctxMiniplan2.clearRect(x, y, w, h);
this.ctxMiniplan2.beginPath();
this.ctxMiniplan2.moveTo(x + radius, y);
this.ctxMiniplan2.lineTo(x + w - radius, y);
this.ctxMiniplan2.quadraticCurveTo(x + w, y, x + w, y + radius);
this.ctxMiniplan2.lineTo(x + w, y + h - radius);
this.ctxMiniplan2.quadraticCurveTo(x + w, y + h, x + w - radius, y + h);
this.ctxMiniplan2.lineTo(x + radius, y + h);
this.ctxMiniplan2.quadraticCurveTo(x, y + h, x, y + h - radius);
this.ctxMiniplan2.lineTo(x, y + radius);
this.ctxMiniplan2.quadraticCurveTo(x, y, x + radius, y);
this.ctxMiniplan2.lineWidth = 2;
this.ctxMiniplan2.strokeStyle = 'black';
this.ctxMiniplan2.stroke();
this.ctxMiniplan2.closePath();
//if (this.isMobile) {
// this.ctxMiniMoveplan.canvas.width = this.ctxMiniMoveplan.canvas.width;
// this.ctxMiniMoveplan.save();
// this.ctxMiniMoveplan.beginPath();
// this.ctxMiniMoveplan.arc(x + w / 2, y + h / 2, 16, 0, 2 * Math.PI, false);
// this.ctxMiniMoveplan.fillStyle = 'gray';
// this.ctxMiniMoveplan.fill();
// this.ctxMiniMoveplan.lineWidth = 1;
// this.ctxMiniMoveplan.strokeStyle = '#003300';
// this.ctxMiniMoveplan.stroke();
// this.ctxMiniMoveplan.closePath();
// var x2 = 0;
// var y2 = 0;
// var height2 = this.MiniPlanHeight;
// var width2 = this.MiniPlanWidth;
// var radius2 = 0;
// this.ctxMiniMoveplan.restore();
//}
}
this.myMoveMini = function (event) {
event.stopPropagation();
event.preventDefault();
getMouseEventMini(event);
if (planIsMoving) {
that.MovePlanViaMini();
}
}
this.IsInNNBlock = function (Place) {
var found = false;
for (var i = 0; i < this.listPlacesWithNNBlocksFull.length; i++) {
var placeInList = this.listPlacesWithNNBlocksFull[i];
if (Place.id == placeInList.id) {
found = true;
}
else {
found = false;
}
}
return found;
}
this.MovePlanViaMini = function () {
var centerx = that.WIDTH / 2;
var centery = that.HEIGHT / 2;
var zoomx = (that.rect.x2 - that.rect.x1) / that.MiniPlanWidth;
var zoomy = (that.rect.y2 - that.rect.y1) / that.MiniPlanHeight;
that.decalX = round((mxMini * zoomx * that.zoom) - (centerx), 2);
that.decalY = round((myMini * zoomy * that.zoom) - (centery), 2);
that.DrawPlan();
}
this.Release = function () {
that.HidePopupRates();
$("#mapContainer").css('cursor', 'default');
$("#ok").hide();
$("#divButtons").hide();
that.DrawPlan();
}
this.FlagSeat = function () {
var cataContDetail = that.CatalogContentsDetail;
var thePlace = SelectedPlace;
var datas = new JsonSelectionResult();
datas.ID_CatalogContent = cataContDetail.CatalogContent.ID_CatalogContent;
datas.ID_Article = thePlace.id;
datas.IdPhysical = thePlace.IdPhysical;
datas.IDSession = that.Options.IdSession;
datas.ID_InterfaceFlag = that.Options.idInterfaceFlag;
datas.ID_FlagGroup = that.Options.IdFlagGroup;
datas.ID_Rate = idRate;
datas.zoom = that.zoom;
datas.ListCc = that.ListCc;
datas.ListAboRates = that.VenueRate;
datas.HasRules = that.HasRules;
datas.NbMaxOrder = that.NbArtMax;
datas.OrderNbArticle = that.OrderNbArticle;
datas.LoyaltyBarcode = "";
datas.IsNnBlock = false;
var options = JSON.stringify(that.Options);
var theAction = 'ADD';
if (idRate == 0)
theAction == 'REMOVE';
// si la place est rajoutée > ajout dans la liste des id
if (that.ListSelectedSeats == null) {
that.ListSelectedSeats = [];
}
if (datas.Action == 'ADD' && datas.ID_Rate != 0) {
if (cataContDetail.RuleList != null && cataContDetail.RuleList.length > 0) {
for (cptrule = 0; cptrule < cataContDetail.RuleList.length; cptrule++) {
if (cataContDetail.RuleList[cptrule].ID_Rate == datas.ID_Rate) {
if (cataContDetail.RuleList[cptrule].RulePropertyList != null && cataContDetail.RuleList[cptrule].RulePropertyList.length > 0) {
for (cptproperty = 0; cptproperty < cataContDetail.RuleList[cptrule].RulePropertyList.length; cptproperty++) {
if (cataContDetail.RuleList[cptrule].RulePropertyList[cptproperty].ObjectType == 'CHECK_LOYALTY_RATE_RULE') {
if ($("#idloyaltycard").val() == "") {
alert("Merci d'indiquer un numéro de carte de fidélité valide !");
return;
}
else {
datas.LoyaltyBarcode = $("#idloyaltycard").val();
break;
}
}
}
}
}
}
}
}
// ajout de la place
var placeFound = false;
// si déjà dans la liste -> remove || add
for (var i = 0; i < that.ListSelectedSeats.length; i++) {
if (SelectedPlace.id === that.ListSelectedSeats[i].id) {
placeFound = true;
break;
}
}
if (placeFound) {
theAction = 'REMOVE';
that.ListUnselectedSeats.push(SelectedPlace);
datas.ListIdUnselected.push(SelectedPlace.id);
datas.ID_Rate = 0;
//Suppression de la liste des selected
var templist = [];
for (var i = 0; i < that.ListSelectedSeats.length; i++) {
if (SelectedPlace.id != that.ListSelectedSeats[i].id) {
templist.push(that.ListSelectedSeats[i]);
}
}
that.ListSelectedSeats = templist;
}
else {
SelectedPlace.Selected = true;
theAction = 'ADD';
that.ListSelectedSeats.push(SelectedPlace);
}
datas.ListIdSelected = [];
//for (var i = 0; i < that.ListSelectedSeats.length; i++) {
// datas.ListIdSelected.push(that.ListSelectedSeats[i].id);
//}
for (var j = 0; j < that.ListZones.length; j++) {
for (var k = 0; k < that.ListZones[j].ListSeats.length; k++) {
if (that.ListZones[j].ListSeats[k].Selected && that.ListZones[j].ListSeats[k].id != SelectedPlace.id) {
datas.ListIdSelected.push(that.ListZones[j].ListSeats[k].id);
}
}
}
datas.ListIdSelected.push(SelectedPlace.id);
datas.Action = theAction;
if (datas.HasRules == true && idRate == 0) {
theAction = 'REMOVE';
alert('ATTENTION : Certains tarifs sont soumis à des règles de gestion. Votre sélection va être vidée intégralement.');
}
var infoPlace = JSON.stringify(datas);
$.ajax({
url: that.Options.Url + 'FlagSeat',
method: 'GET',
data: { 'options': options, 'datas': infoPlace }, //ur data to be sent to server
dataType: 'json',
crossDomain: true,
async: true,
contentType: 'application/json, charset=utf-8',
success: function (result) {
$("#ok").hide();
that.OrderNbArticle = result.Data.OrderNbArticle;
if (result.Data.ErrorCode == 999) {
alert("Merci d'indiquer un numéro de carte de fidélité valide !");
that.ListSelectedSeats = [];
thePlace.Selected = false;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
return;
}
if (result.Data.ErrorCode == -1) {
alert(result.Data.ErrorStatus);
that.ListSelectedSeats = [];
thePlace.Selected = false;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
return;
}
if (result.Data.ErrorCode == -2) {
alert(result.Data.ErrorStatus);
that.ListSelectedSeats = [];
thePlace.Selected = false;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
return;
}
if (result.Data.ListAboRates != null) {
that.VenueRate = result.Data.ListAboRates;
}
if (theAction == 'ADD') {
that.ListSelectedSeats = [];
if (result.Data.FlagOk) {
for (var i = 0; i < result.Data.ListSelectedSeats.length; i++) {
// Modif de la place -> selected
for (var j = 0; j < that.ListZones.length; j++) {
for (var k = 0; k < that.ListZones[j].ListSeats.length; k++) {
if (that.ListZones[j].ListSeats[k].id === result.Data.ListSelectedSeats[i].id) {
if (theAction == 'ADD') {
that.ListZones[j].ListSeats[k].Selected = true;
// Récupération du montant
result.Data.ListSelectedSeats[i].Amount = 0;
if (that.ListZones[j].ListSeats[k].ListAvailablePrices != null && that.ListZones[j].ListSeats[k].ListAvailablePrices.length > 0) {
for (var price = 0; price < that.ListZones[j].ListSeats[k].ListAvailablePrices.length; price++) {
if (that.ListZones[j].ListSeats[k].ListAvailablePrices[price].ID_rate == result.Data.ListSelectedSeats[i].IdRate) {
result.Data.ListSelectedSeats[i].Amount = that.ListZones[j].ListSeats[k].ListAvailablePrices[price].Amount;
}
}
}
}
else
that.ListZones[j].ListSeats[k].Selected = false;
}
}
}
}
that.ListSelectedSeats = result.Data.ListSelectedSeats;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
// formatage de la place pour affichage
var listRates = that.listRates;
var listCateg = that.listCategories;
for (var i = 0; i < listRates.length; i++) {
for (var j = 0; j < that.ListSelectedSeats.length; j++) {
if (that.ListSelectedSeats[j].IdRate == listRates[i].id) {
that.ListSelectedSeats[j].RateName = listRates[i].name;
//that.ListSelectedSeats[j].Amount = listRates[i].amount;
}
}
}
for (var i = 0; i < listCateg.length; i++) {
for (var j = 0; j < that.ListSelectedSeats.length; j++) {
if (that.ListSelectedSeats[j].I_Category == listCateg[i].id) {
that.ListSelectedSeats[j].CategName = listCateg[i].name;
that.ListSelectedSeats[j].CategColor = listCateg[i].color;
}
}
}
for (var j = 0; j < that.ListSelectedSeats.length; j++) { that.ListSelectedSeats[j].ID_FlagGroup = result.Data.ID_FlagGroup; }
if (that.selectedPlaceValid != null) {
that.selectedPlaceValid(that.ListSelectedSeats);
}
}
else {
// si max par commande
if (that.NbArtMax == that.OrderNbArticle) {
alert('Vous avez atteint le nombre de places maximum par commande');
}
else {
for (var j = 0; j < that.ListZones.length; j++) {
for (var k = 0; k < that.ListZones[j].ListSeats.length; k++) {
if (that.ListZones[j].ListSeats[k].id === SelectedPlace.id) {
that.ListZones[j].ListSeats[k].s = 100;
that.ListZones[j].ListSeats[k].Selected = false;
}
}
}
that.ListSelectedSeats = result.Data.ListSelectedSeats;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
if (that.selectedPlaceError != null) {
that.selectedPlaceError();
}
}
}
}
else {
if (result.Data.FlagOk) {
// si déselection + règles de gestion
if (!datas.HasRules) {
// On enlève la place de la liste des selected
// Modif de la place -> selected
// On passe la place à false dans la liste de toutes les places du plan
for (var j = 0; j < that.ListZones.length; j++) {
for (var k = 0; k < that.ListZones[j].ListSeats.length; k++) {
if (that.ListZones[j].ListSeats[k].id === SelectedPlace.id) {
that.ListZones[j].ListSeats[k].Selected = false;
}
}
}
// On la retire de la liste des places du panier
var templist = [];
for (var i = 0; i < that.ListSelectedSeats.length; i++) {
if (that.ListSelectedSeats[i].id != SelectedPlace.id) {
templist.push(that.ListSelectedSeats[i]);
}
}
that.ListSelectedSeats = templist;
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
if (that.selectedPlaceValid != null) {
that.selectedPlaceValid(that.ListSelectedSeats);
}
}
else {
for (var j = 0; j < that.ListZones.length; j++) {
for (var k = 0; k < that.ListZones[j].ListSeats.length; k++) {
that.ListZones[j].ListSeats[k].Selected = false;
}
}
that.ListSelectedSeats = [];
that.HidePopupRates(); $("#ok").hide();
that.DrawPlan();
if (that.selectedPlaceValid != null) {
that.selectedPlaceValid(that.ListSelectedSeats);
}
}
}
}
},
error: function (xhr, status) {
var i = 0;
}
});
}
}
var WebPlanOptions = function () {
this.Url = '',
this.WsBufferVersion = '',
this.Institution = 0,
this.Container = '',
this.IdSeance = 0,
this.IdManif = 0,
this.IdFlagGroup = 0,
this.NonNum = false,
this.IdMarqueBlanche = 0,
this.IdAwpLogin = 0,
this.IdAwpLoginS = 0,
this.IDP = 0,
this.Block = 0,
this.NbArtMax = 0,
this.SubRate = '',
this.NbArticleCc = 0,
this.idInterfaceFlag = 0,
this.IdSession = 0,
this.Pack = false,
this.Scc = false,
this.IdSub = 0
this.Ins = '',
this.IdGenericForm = 0;
this.ListCc = [0];
this.NbMaxCmd = 0;
this.IsWidget = true;
this.Distanciation = 0;
};
var WebPlanFunctions = function () {
this.selectedPlaceValid = null,
this.loadPlanError = null,
this.selectedPlaceError = null
};
var JsonSelectionResult = function () {
this.FlagOk = false,
this.ErrorCode = 0,
this.ErrorStatus = '',
this.ID_CatalogContent = 0,
this.ID_Article = 0,
this.IDSession = 0,
this.ID_FlagGroup = 0,
this.OrderNbArticle = 0,
this.NbToFlag = 0,
this.ID_Rate = 0,
this.ID_InterfaceFlag = 0,
this.NbMaxOrder = 0,
this.ID_FlagArticle = 0
this.ListSelected = [];
this.ListIdSelected = [];
this.ListIdUnselected = [];
this.Action = 'ADD';
this.IsNnBlock = false;
this.IdBlock = 0;
this.IdPhysical = 0;
this.ListAboRates = [];
this.HasRules = false;
this.LoyaltyBarcode = "";
};
var BlockNN = function () {
this.x = 0;
this.y = 0;
this.width = 0;
this.height = 0;
this.idBlock = 0;
this.IdCategory = 0;
this.listPlacesIn = [];
this.ListAvailablePrices = [];
}
// CANVAS DEFAULTS + INTERACTIONS --
var infobulledisplay;
var Draw_texth = 0;
var Draw_text = "";
var oldfillstyle = "";
var oldstrokestyle = "";
var idRate = 0;
function SetRate(val) {
idRate = val;
$("#rate_" + idRate).find("input").prop('checked', true);
$("#tableRates").find("tr").removeClass("RateSelected");
$("#rate_" + idRate).addClass("RateSelected");
if (val != 0) {
$("#ok").show();
$("#cancel").show();
}
}
function decompress(result) {
if (result == null) return null;
var a = [];
var propCount = result.Columns.length;
var propNames = result.Columns;
for (var i = 0, l = result.Values.length; i < l; i++) {
var values = result.Values[i];
var o = {};
for (var j = propCount; j--;) {
o[propNames[j]] = values[j]
}
a[a.length] = o;
}
return a;
}
function decompressListCategory(result) {
if (result == null) return null;
var a = [];
var propCount = result.Columns.length;
var propNames = result.Columns; M
for (var i = 0, l = result.Values.length; i < l; i++) {
var values = result.Values[i];
var o = {};
for (var j = propCount; j--;) {
o[propNames[j]] = values[j]
}
o['lighterColor'] = lighterColor(o['color'], 0.2);
o['darkerColor'] = darkerColor(o['color'], 0.2);
a[a.length] = o;
}
return a;
}
function decompressSeat(result) {
if (result == null) return null;
var a = [];
var propCount = result.Columns.length;
var propNames = result.Columns;
for (var i = 0, l = result.Values.length; i < l; i++) {
try {
var values = result.Values[i];
var o = {};
for (var j = propCount; j--;) {
o[propNames[j]] = values[j]
}
//o['isDisabled'] = false;
o['isFlag'] = false;
//o['rotation'] = round( o['rotation'] * Math.PI / 180,2);
o['rotation'] = round(o['rotation'] * Math.PI / 180, 2);
o['Amount'] = 0.0;
o['displayX'] = 0.0;
o['displayY'] = 0.0;
o['sel'] = false;
o['ID_Rate'] = 0;
o['ID_Rule'] = 0;
o['id_physical'] = o['id'];
if (o['I_Category'] > 0)
o['ID_Category'] = Plan.listCategories[o['I_Category'] - 1].id;
else
o['ID_Category'] = 0;
if (o['I_Category'] > 0) {
o['color'] = Plan.listCategories[o['I_Category'] - 1].color;
o['lighterColor'] = Plan.listCategories[o['I_Category'] - 1].lighterColor;
//o['lighterColor'] = Plan.listCategories[o['I_Category'] - 1].lighterColor;
}
else {
o['color'] = "RGB(180,180,180)";
o['lighterColor'] = "RGB(200,200,200)";
}
if (o['isDisabled'] > 1) {
o['accessControl'] = 1;
}
else {
o['accessControl'] = 0;
}
if (o['isDisabled'] == 2 || o['isDisabled'] == 0)
o['isDisabled'] = 0;
else
o['isDisabled'] = 1;
if (o['I_PrimaryEnvelope'] > 0) {
o['ID_PrimaryEnvelope'] = Plan.ListReserve[o['I_PrimaryEnvelope'] - 1].id;
o['color2'] = Plan.ListReserve[o['I_PrimaryEnvelope'] - 1].color;
}
else {
o['ID_PrimaryEnvelope'] = 0;
o['color2'] = 0;
}
o['ID_Disabled'] = Plan.ListSeatProperties[o['I_Property']].ID_Disabled;
o['ID_PrimaryEnvelopeOld'] = o['ID_PrimaryEnvelope'];
o['ID_DisabledOld'] = o['ID_Disabled'];
CalculeZonesCenter(o);
a[a.length] = o;
}
catch (e) {
alert(i + " " + o['I_Category']);
}
}
return a;
}
function round(v, nb) {
var i = Math.pow(10, nb)
v *= i;
v = Math.round(v);
v = v / i;
return v;
}
function DrawInfoBulle(place, Plan) {
var text = [];
var i = 0;
var reserve = "";
var color = "";
infobulledisplay = true;
//Plan.ctxTooltip.clearRect(0, 0, Plan.WIDTH, Plan.HEIGHT);
Plan.ctxTooltip.canvas.width = Plan.ctxTooltip.canvas.width;
//Plan.ctxTooltip.DrawTooltip(Place.rank + ' ' + Place.seat, mx, my - 20);
//if (place.ID_PrimaryEnvelope > 0) {
// reserve = findReserveName(place.ID_PrimaryEnvelope);
// color = findReserveColor(place.ID_PrimaryEnvelope);
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Designation > 0) {
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Designation);
// i++;
//}
//if (place.ID_Category > 0) {
// text[i] = findCategName(place.ID_Category);
// i++;
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Tribune > 0) //if (place.ID_Tribune > 0) {
//{
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Tribune);
// i++;
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Floor > 0) //if (place.ID_Floor > 0) {
//{
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Floor);
// i++;
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Block > 0) //if (place.ID_Block > 0) {
//{
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Block);
// i++;
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Door > 0) //if (place.ID_Door > 0)
//{
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Door);
// i++;
//}
//if (Plan.ListSeatProperties[place.I_Property].ID_Access > 0) {
// text[i] = findGeneric(Plan.ListSeatProperties[place.I_Property].ID_Access);
// i++;
//}
Plan.ctxTooltip.Infobulle('TEST', '', 'cuicui', mx + 5, my + 5, color);
}
function decompressZones() {
if (Plan.ListZones == null) return;
Plan.listDecoupeZones = [];
for (var i = 0, l = Plan.ListZones.length; i < l; i++) {
Plan.ListZones[i].ListSeats = decompressSeat(Plan.ListZones[i].ListSeats);
}
}
CanvasRenderingContext2D.prototype.DrawTooltip = function (text, x, y) {
var metrics = this.measureText(text);
var width = metrics.width + 15;
var height = 18;
var radius = 4;
this.font = '8pt Arial';
this.lineWidth = 2;
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
//this.stroke();
this.fillStyle = '#000';
this.fill();
this.fillStyle = '#fff';
this.textAlign = 'center';
this.fillText(text, x + (width / 2), y + height - 4);
this.closePath();
}
CanvasRenderingContext2D.prototype.Drawinfo = function (x, y, width, height, text, fillcolor) {
var initial_x = x;
var initial_y = y;
var total_width = width;
var total_height = height;
color = "#F00";
var radius = height / 2;
var fontsize = round((height / 7) * 3, 0);
this.font = fontsize + "pt Verdana";
//"#4DA4F3"
//var progress_lingrad = this.createLinearGradient(0, y + height, 0, 0);
var progress_lingrad = this.createLinearGradient(0, y + height, 0, y);
progress_lingrad.addColorStop(0, "#4DA4F3");
progress_lingrad.addColorStop(0.4, "#ADD9FF");
progress_lingrad.addColorStop(1, "#9ED1FF");
this.fillStyle = progress_lingrad;
this.save();
// Define the shadows
this.shadowOffsetX = 6;
this.shadowOffsetY = 6;
this.shadowBlur = 10;
this.shadowColor = "#333";
// first grey layer
this.fillStyle = "rgba(189,189,189,1)";
this.fillStyle = "#36c";
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.arc(x + width - radius, y + radius, radius, -Math.PI / 2, Math.PI / 2, false);
this.lineTo(x + radius, y + height);
this.arc(x + radius, y + radius, radius, Math.PI / 2, 3 * Math.PI / 2, false);
this.closePath();
this.fill();
this.restore();
// second layer with gradient
// remove the shadow
this.shadowColor = "rgba(0,0,0,0)";
//var lingrad = this.createLinearGradient(0, y + height, 0, 0);
var lingrad = this.createLinearGradient(0, y + height, 0, y);
lingrad.addColorStop(0, lighterColor(fillcolor, 0.1));
lingrad.addColorStop(0.4, lighterColor(fillcolor, 0.5));
lingrad.addColorStop(1, lighterColor(fillcolor, 0.2));
this.fillStyle = lingrad;
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.arc(x + width - radius, y + radius, radius, -Math.PI / 2, Math.PI / 2, false);
this.lineTo(x + radius, y + height);
this.arc(x + radius, y + radius, radius, Math.PI / 2, 3 * Math.PI / 2, false);
this.closePath();
this.fill();
this.restore();
this.save();
this.fillStyle = "black";
this.textAlign = 'center';
var text_width = this.measureText(text).width;
var text_x = x + ((width) / 2);// - (text_width / 2);
this.fillText(text, text_x, y + (height - fontsize) + 3);
this.restore();
}
CanvasRenderingContext2D.prototype.DrawSelection = function (x, y, w, h, s, Plan) {
h -= 2 * Plan.zoom;
var fontheight = round(10 * Plan.zoom, 0);
this.textAlign = 'center';
this.font = (fontheight) + 'px FontAwesome';
this.fillStyle = 'lightgreen';
//this.fillText('\uf058', x + (w / 2), y + (h));
//this.fillText('\uF0A3', x + (w / 2), y + (h ));
this.arc(x + (w / 2), y + ((h + Plan.zoom) / 2), fontheight / 2.1, 0, 3 * Math.PI, false);
//this.rect(x, y, w, h);
this.fill();
this.beginPath();
//if (s)
// //this.fillStyle = '#18FF07';
// this.fillStyle = '#053A6B';
//else
// this.fillStyle = '#aaa';
this.fillStyle = 'green';
var fontheight = round(8 * Plan.zoom, 0);
this.font = (fontheight) + 'px FontAwesome';
this.fillText('\uf058', x + (w / 2), y + (h - 3 * Plan.zoom));
this.closePath();
}
CanvasRenderingContext2D.prototype.DrawSelectionBlock = function (x, y, width, height, s, Plan) {
height -= 2 * Plan.zoom;
var fill = '#B0C4DE';
//this.fillText('\uf058', x + (w / 2), y + (h));
//this.fillText('\uF0A3', x + (w / 2), y + (h ));
this.beginPath();
this.moveTo(x + 4, y);
this.lineTo(x + width - 4, y);
this.quadraticCurveTo(x + width, y, x + width, y + 4);
this.lineTo(x + width, y + height - 4);
this.quadraticCurveTo(x + width, y + height, x + width - 4, y + height);
this.lineTo(x + 4, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - 4);
this.lineTo(x, y + 4);
this.quadraticCurveTo(x, y, x + 4, y);
this.fillStyle = fill;
this.fill();
this.closePath();
}
CanvasRenderingContext2D.prototype.DrawSelectionDisabled = function (x, y, w, h, s, Plan) {
h -= 2 * Plan.zoom;
var fontheight = round(10 * Plan.zoom, 0);
this.textAlign = 'center';
this.font = (fontheight) + 'px FontAwesome';
this.fillStyle = 'red';
//this.fillText('\uf058', x + (w / 2), y + (h));
//this.fillText('\uF0A3', x + (w / 2), y + (h ));
this.arc(x + (w / 2), y + ((h + Plan.zoom) / 2), fontheight / 2.1, 0, 3 * Math.PI, false);
//this.rect(x, y, w, h);
this.fill();
this.beginPath();
//if (s)
// //this.fillStyle = '#18FF07';
// this.fillStyle = '#053A6B';
//else
// this.fillStyle = '#aaa';
this.fillStyle = 'green';
var fontheight = round(8 * Plan.zoom, 0);
this.font = (fontheight) + 'px FontAwesome';
this.fillText('\uf058', x + (w / 2), y + (h - 3 * Plan.zoom));
this.closePath();
}
CanvasRenderingContext2D.prototype.clearSelection = function (x, y, w, h) {
this.clearRect(x, y, w, h);
};
CanvasRenderingContext2D.prototype.DrawText = function (text, x, y, degrees, fontsize, Plan) {
this.lineWidth = 3;
this.textAlign = 'left';
if (degrees != 0) {
this.save();
var metrics = this.measureText(text);
var width = metrics.width
var x2 = 3.5 * (width / 5);
var y2 = fontsize;
this.translate(x + (x2), y + y2);
this.rotate(degrees * Math.PI / 180);
this.fillText(text, -x2 + (Plan.zoom * 5), y2 / 3);
this.restore();
}
else {
this.fillText(text, x + (fontsize / 3), y + (fontsize / 4) + fontsize);
}
}
CanvasRenderingContext2D.prototype.roundRect = function (text, x, y, width, height, radius, fill, fill2, stroke, degrees, status, zoom) {
degrees = degrees * Math.PI / 180;
var linewidth = 1;
if (status != 0) fill = 'black';
if (fill != "" && this.fillStyle != fill)
this.fillStyle = fill;
if (stroke == "") {
if (width > 16 && status != -1) {
if (width > 20)
if (status == 0 && text != "")
stroke = '#aaa';
else
stroke = '#777';
else
stroke = '#888';
this.lineWidth = 1 * zoom;
okstroke = true;
}
if (width <= 16 && status != -1) {
if (width <= 20)
if (status == 0 && text != "")
stroke = '#aaa';
else
stroke = '#777';
else
stroke = '#888';
this.lineWidth = 1 * zoom;
okstroke = true;
}
}
else {
//if (width > 20)
// linewidth = 2;
//else if (width > 16)
// linewidth = 2;
//else
linewidth = 1.5 * zoom;
}
x += 1 / 2;
y += 1; //this.lineWidth/2;
width -= 1;
height -= 2;//(this.lineWidth);
if (degrees != 0 && width > 0) {
var x2 = -width / 2;
var y2 = -height / 2;
this.save();
this.translate(x + width / 2, y + height / 2);
this.rotate(degrees);
if (height >= 10) {
if (stroke != "") {
this.beginPath();
this.moveTo(x2 + radius, y2);
this.lineTo(x2 + width - radius, y2);
this.quadraticCurveTo(x2 + width, y2, x2 + width, y2 + radius);
this.lineTo(x2 + width, y2 + height - radius);
this.quadraticCurveTo(x2 + width, y2 + height, x2 + width - radius, y2 + height);
this.lineTo(x2 + radius, y2 + height);
this.quadraticCurveTo(x2, y2 + height, x2, y2 + height - radius);
this.lineTo(x2, y2 + radius);
this.quadraticCurveTo(x2, y2, x2 + radius, y2);
this.fillStyle = stroke;
this.fill();
this.closePath();
x2 += linewidth;
y2 += linewidth;
width -= linewidth * 2;
height -= linewidth * 2;
}
this.beginPath();
this.moveTo(x2 + radius, y2);
this.lineTo(x2 + width - radius, y2);
this.quadraticCurveTo(x2 + width, y2, x2 + width, y2 + radius);
this.lineTo(x2 + width, y2 + height - radius);
this.quadraticCurveTo(x2 + width, y2 + height, x2 + width - radius, y2 + height);
this.lineTo(x2 + radius, y2 + height);
this.quadraticCurveTo(x2, y2 + height, x2, y2 + height - radius);
this.lineTo(x2, y2 + radius);
this.quadraticCurveTo(x2, y2, x2 + radius, y2);
//if ($.browser.msie || $.browser.chrome) {
if (fill != '' && fill != 'black') {
//this.fillStyle = fill;
//this.fill();
//var grd = this.createLinearGradient(x2, y2, x2, y2 + height);
//grd.addColorStop(0, fill);
//grd.addColorStop(1, fill2);
//this.fillStyle = grd;
this.fillStyle = fill;
this.fill();
}
//}
//else {
// this.fillStyle = fill;
// this.fill();
//}
this.closePath();
}
else {
if (stroke != "") {
this.fillStyle = stroke;
this.fillRect(x2, y2, width, height);
x2 += linewidth;
y2 += linewidth;
width -= linewidth * 2;
height -= linewidth * 2;
}
if (fill != '') {
this.fillStyle = fill;
this.fillRect(x2, y2, width, height);
}
else
this.rect(x2, y2, width, height);
}
this.restore();
}
else {
if (height >= 10) {
if (stroke != "") {
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
this.fillStyle = stroke;
this.fill();
this.closePath();
x += linewidth;
y += linewidth;
width -= linewidth * 2;
height -= linewidth * 2;
}
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
// if ($.browser.msie || $.browser.chrome) {
if (fill != '' && fill != 'black') {
//var grd = this.createLinearGradient(x, y, x, y + height);
//grd.addColorStop(0, fill);
//grd.addColorStop(1, fill2);
this.fillStyle = fill;
this.fill();
} //}
//else {
// this.fillStyle = fill;
// this.fill();
//}
this.closePath();
}
else {
if (width > 4) {
if (stroke != "") {
//this.beginPath();
this.fillStyle = stroke;
this.fillRect(x, y, width, height);
//this.closePath();
x += linewidth;
y += linewidth;
width -= linewidth * 2;
height -= linewidth * 2;
}
if (fill != '') {
//this.beginPath();
this.fillStyle = fill;
this.fillRect(x, y, width, height);
//this.closePath();
}
//else
// this.rect(x, y, width, height);
}
else {
if (fill != '') {
this.fillStyle = fill;
this.fillRect(x, y, width, height);
}
}
}
}
}
CanvasRenderingContext2D.prototype.roundRectGestion = function (x, y, height, radius, fill, stroke, status, degrees, text) {
if (status > 0) {
height /= 2;
}
if (degrees != 0 & height > 4) {
if (fill != '') {
if (this.fillStyle != fill)
this.fillStyle = fill;
var x2 = -height / 2;
var y2 = -height / 2;
this.save();
//this.translate(x + height / 2, y + height / 2);
this.translate(x, y);
this.rotate(degrees);
this.beginPath();
this.rect(x2, y2, height, height);
//this.rect(0,0, height, height);
this.fill();
//this.fillRect(x2, y2, height, height);
if (stroke != "") {
if (this.strokeStyle != stroke)
this.strokeStyle = stroke;
this.stroke();
}
this.closePath();
if (status == 0) {
if (text != '' && height > 14) {
var texth = planTextH;
this.font = texth + 'pt Arial';
this.fillStyle = '#000';
this.textAlign = 'center';
this.fillText(text, x2 + (height / 2), y2 + (height - 3.5));
}
}
this.restore();
}
}
else {
if (status > 0) {
x += height / 4;
y += height / 4;
}
this.beginPath();
this.rect(x - height / 2, y - height / 2, height, height);
if (fill != '') {
if (this.fillStyle != fill)
this.fillStyle = fill;
this.fill();
}
if (stroke != "") {
if (this.strokeStyle != stroke)
this.strokeStyle = stroke;
this.stroke();
}
this.closePath();
if (status == 0) {
if (text != '' && height > 14) {
var texth = planTextH;
this.font = texth + 'pt Arial';
this.fillStyle = '#000';
this.textAlign = 'center';
this.fillText(text, x, y);
}
}
}
}
CanvasRenderingContext2D.prototype.DrawStatus = function (x, y, width, height, zoom, status) {
Draw_texth = planStatusH;
if (status == -1) {
this.fillStyle = 'black';
Draw_text = "\uF00D";
}
else if (status == -2) {
this.fillStyle = "white";
Draw_text = "\uF05E";
}
else if (status == 99) {
this.fillStyle = 'black';
Draw_text = "\uF00C";
Draw_texth = round(7 * zoom, 0);
}
else if (status < 200) {
this.fillStyle = 'green';
Draw_text = "\uF00C";
}
else if (status < 300) {
this.fillStyle = 'yellow';
Draw_text = "\uf111";
}
else if (status == 370) {
Draw_texth = round(7 * zoom, 0);
this.fillStyle = 'chartreuse';
Draw_text = "\uF030";
}
else {
this.fillStyle = 'white';
Draw_text = "\uf02b";
}
this.font = Draw_texth + 'px FontAwesome';
this.textAlign = 'center';
//this.fillText(Draw_text, x + (width / 2), y + (height - (3 * zoom)));
this.fillText(Draw_text, x + (width / 2), y + (height - PlanTextDecal));
//if (planIsMoving == false && width > 8 && status >0) {
if (width > 5 && status > 0) {
if (width > 10)
this.strokeStyle = '#333';
else
this.strokeStyle = '#454545';
this.lineWidth = 1;
//this.strokeText(Draw_text, x + (width / 2) , y + (height - (3 * zoom)) + 1);
this.strokeText(Draw_text, x + (width / 2), y + (height - PlanTextDecal) + 1);
}
// sigle Euro sur dossier payé
if (width > 15 && status > 199 && status < 300) {
Draw_texth -= 6;
this.font = Draw_texth + 'px FontAwesome';
this.fillStyle = 'black';
this.fillText('\uf153', x + (width / 2) - 1, y + (height - PlanTextDecal));
//this.fillText('\uf153', x + (width / 2)-1, y + (height - (3 * zoom)) );
}
}
CanvasRenderingContext2D.prototype.roundRectOld = function (text, x, y, width, height, radius, fill, stroke, degrees) {
this.fillStyle = fill;
//if (height > 10)
// this.lineWidth = 2;
//else
// this.lineWidth = 1;
if (stroke == "") {
this.strokeStyle = 'black';
this.lineWidth = 1;
}
else {
this.strokeStyle = stroke;
this.lineWidth = 1.5 * Plan.zoom;
}
x += this.lineWidth / 2;
y += 1; //this.lineWidth/2;
width -= (this.lineWidth);
height -= 2;//(this.lineWidth);
if (degrees != 0 && height > 6) {
var x2 = -width / 2;
var y2 = -height / 2;
this.save();
this.beginPath();
this.translate(x + width / 2, y + height / 2);
this.rotate(degrees * Math.PI / 180);
if (height >= 16) {
this.moveTo(x2 + radius, y2);
this.lineTo(x2 + width - radius, y2);
this.quadraticCurveTo(x2 + width, y2, x2 + width, y2 + radius); ace
this.lineTo(x2 + width, y2 + height - radius);
this.quadraticCurveTo(x2 + width, y2 + height, x2 + width - radius, y2 + height);
this.lineTo(x2 + radius, y2 + height);
this.quadraticCurveTo(x2, y2 + height, x2, y2 + height - radius);
this.lineTo(x2, y2 + radius);
this.quadraticCurveTo(x2, y2, x2 + radius, y2);
}
else {
this.rect(x2, y2, width, height);
}
if (fill != '') {
// if(width>32 )
// {
// var grd = this.createLinearGradient( x, y, width, height);
// grd.addColorStop(0, '#8ED6FF');
// grd.addColorStop(1, '#004CB3');
// this.fillStyle = grd;
// this.fill();
// }
// else
// {
this.fill();
// }
}
if (width > 3)
this.stroke();
if (text != '' && height > 16) {
this.fillStyle = 'black';
this.textAlign = 'center';
this.fillText(text, x2 + (width / 2), y2 + (height - 3.5));
}
this.closePath();
this.restore();
}
else {
this.beginPath();
// this.fillStyle="blue";
// this.lineWidth = 1;
// this.strokeStyle = 'red';
if (height >= 16) {
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
if (fill != '') {
this.fill();
}
if (width > 3)
this.stroke();
}
else {
if (fill != '') {
this.fillRect(x, y, width, height);
}
else {
this.rect(x, y, width, height);
}
if (width > 3)
this.strokeRect(x, y, width, height);
}
//if (fill != '') {
// // if(width>25 )
// // {
// // var grd = this.createLinearGradient(x, y, x, y+height);
// // grd.addColorStop(0, lighterColor(fill,0.8) );
// // grd.addColorStop(1, fill);
// // this.fillStyle = grd;
// // }
// this.fill();
//}
//if (width > 3)
// this.stroke();
if (text != '' && height > 16) {
this.fillStyle = 'black';
this.fillText(text, x + (width / 2), y + height - 3.5);
}
this.closePath();
}
}
CanvasRenderingContext2D.prototype.roundRectMini3 = function (text, x, y, width, height, radius, fill, stroke, degrees, status, zoom) {
if (fill != "")
this.fillStyle = fill;
if (stroke == "") {
this.strokeStyle = "#777";
this.lineWidth = 0.5;
}
else {
this.strokeStyle = stroke;
this.lineWidth = round(2 * Plan.zoom, 1);
}
if (degrees != 0 && height > 6) {
var x2 = round(-width / 2, 0);
var y2 = round(-height / 2, 0);
this.save();
this.translate(x + x2, y + y2);
this.rotate(degrees);
this.beginPath();
if (fill != '')
this.fillRect(x2, y2, width, height);
else
this.rect(x2, y2, width, height);
if (stroke != '')
this.strokeRect(x2, y2, width, height);
this.closePath();
//var texth = round(10 * zoom, 0);
//this.font = texth + 'px FontAwesome';
//this.textAlign = 'center';
if (status != 0) {
if (status == -1) {
text = "\uF00D";
this.fillStyle = 'red';
}
else if (status == -2) {
text = "\uF05E";
this.fillStyle = "white";
}
else if (status == 99) {
text = "\uF00C";
this.fillStyle = 'black';
}
else if (status < 200) {
text = "\uF00C";
this.fillStyle = 'white';
}
else if (status < 300) {
text = "\uF058";
this.fillStyle = 'yellow';
}
else {
text = "\uF145";
this.fillStyle = 'white';
}
this.fillText(text, x2 + (width / 2), y2 + (height - (3 * zoom)));
}
this.restore();
}
else {
this.beginPath();
if (fill != '')
this.fillRect(x, y, width, height);
else
this.rect(x, y, width, height);
//this.fillRect(x, y, width, height);
if (stroke != '') {
this.strokeRect(x, y, width, height);
}
this.closePath();
if (status != 0) {
if (status == -1) {
text = "\uF00D";
this.fillStyle = 'red';
}
else if (status == -2) {
text = "\uF05E";
this.fillStyle = "white";
}
else if (status == 99) {
text = "\uF00C";
this.fillStyle = 'black';
}
else if (status < 200) {
text = "\uF00C";
this.fillStyle = 'white';
}
else if (status < 300) {
text = "\uF058";
this.fillStyle = 'yellow';
}
else {
text = "\uF145";
this.fillStyle = 'white';
}
this.fillText(text, x + (width / 2), y + (height - (3 * zoom)));
}
}
oldfillstyle = fill;
oldstrokestyle = stroke;
}
CanvasRenderingContext2D.prototype.ww = function (text, x, y, width, height, radius, fill, stroke, degrees, status, zoom) {
//if (oldfillstyle != fill && fill != "")
if (fill != "")
this.fillStyle = fill;
if (stroke == "") {
this.strokeStyle = "#777";
this.lineWidth = 0.5;
}
else {
this.strokeStyle = stroke;
this.lineWidth = round(2 * Plan.zoom, 1);
}
if (degrees != 0 && height > 6) {
var x2 = -width / 2;
var y2 = -height / 2;
this.save();
this.translate(x + x2, y + y2);
this.rotate(degrees);
this.beginPath();
this.moveTo(x2 + radius, y2);
this.lineTo(x2 + width - radius, y2);
this.quadraticCurveTo(x2 + width, y2, x2 + width, y2 + radius);
this.lineTo(x2 + width, y2 + height - radius);
this.quadraticCurveTo(x2 + width, y2 + height, x2 + width - radius, y2 + height);
this.lineTo(x2 + radius, y2 + height);
this.quadraticCurveTo(x2, y2 + height, x2, y2 + height - radius);
this.lineTo(x2, y2 + radius);
this.quadraticCurveTo(x2, y2, x2 + radius, y2);
if (fill != '')
this.fill();
this.stroke();
this.closePath();
if (status != 0) {
if (status == -1) {
text = "\uF00D";
this.fillStyle = 'red';
}
else if (status == -2) {
text = "\uF05E";
this.fillStyle = "white";
}
else if (status == 99) {
text = "\uF00C";
this.fillStyle = 'black';
}
else if (status < 200) {
text = "\uF00C";
this.fillStyle = 'white';
}
else if (status < 300) {
text = "\uF058";
this.fillStyle = 'yellow';
}
else {
text = "\uF145";
this.fillStyle = 'white';
}
this.fillText(text, x2 + (width / 2), y2 + (height - (3 * zoom)));
}
this.restore();
}
else {
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
if (fill != '') {
this.fill();
}
this.stroke();
this.closePath();
if (status != 0) {
if (status == -1) {
text = "\uF00D";
this.fillStyle = 'red';
}
else if (status == -2) {
text = "\uF05E";
this.fillStyle = "white";
}
else if (status == 99) {
text = "\uF00C";
this.fillStyle = 'black';
}
else if (status < 200) {
text = "\uF00C";
this.fillStyle = 'white';
}
else if (status < 300) {
text = "\uF058";
this.fillStyle = 'yellow';
}
else {
text = "\uF145";
this.fillStyle = 'white';
}
this.fillText(text, x + (width / 2), y + (height - (3 * zoom)));
}
}
oldfillstyle = fill;
oldstrokestyle = stroke;
}
CanvasRenderingContext2D.prototype.roundRectMini = function (text, x, y, width, height, radius, fill, stroke, degrees, status, zoom) {
if (oldfillstyle != fill)
this.fillStyle = fill;
this.beginPath();
this.rect(x, y, width, height);
if (fill != '') {
this.fill();
}
this.closePath();
oldfillstyle = fill;
}
CanvasRenderingContext2D.prototype.Infobulle = function (reference, reserve, text, x, y, color) {
var width = 50;
var height = 100;
var radius = 8;
this.font = '12pt bold Calibri';
var widthReference = this.measureText(reference).width;
this.font = '8pt Verdana';
var widthReserve = this.measureText(reserve).width;
this.textAlign = 'left';
width = widthReference + widthReserve + (radius * 2) + 20;
height = radius + 10 + 8;
if (width < 180) width = 180;
var widthTmp = 0;
for (var i = 0; i < text.length; i++) {
widthTmp = this.measureText(text[i]).width;
if (widthTmp > width)
width = widthTmp;
height += 14;
}
if (y + height + 10 > Plan.HEIGHT)
y -= height + 10;
else
y += 10;
if (x + width > Plan.WIDTH)
x -= (x + width) - Plan.WIDTH;
this.save();
this.shadowOffsetX = 10;
this.shadowOffsetY = 10;
this.shadowBlur = 10;
this.shadowColor = "#111";
this.lineWidth = 1;
this.strokeStyle = '#666';
this.beginPath();
this.moveTo(x + radius, y);
this.lineTo(x + width - radius, y);
this.quadraticCurveTo(x + width, y, x + width, y + radius);
this.lineTo(x + width, y + height - radius);
this.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
this.lineTo(x + radius, y + height);
this.quadraticCurveTo(x, y + height, x, y + height - radius);
this.lineTo(x, y + radius);
this.quadraticCurveTo(x, y, x + radius, y);
this.stroke();
var lingrad = this.createLinearGradient(x + width, y + height - 15, x, y + 15);
lingrad.addColorStop(0, "lightgreen");
//lingrad.addColorStop(0.4, "#888");
//lingrad.addColorStop(0.5, "#ddd");
lingrad.addColorStop(1, "white");
this.fillStyle = lingrad;
this.fill();
this.closePath();
this.restore();
this.save();
this.shadowOffsetX = -1;
this.shadowOffsetY = -1;
this.shadowBlur = 2;
this.shadowColor = "#fff";
this.font = '12pt bold Calibri';
this.fillStyle = 'black';
this.fillText(reference, x + radius, y + 12 + radius);
this.restore();
if (reserve != "") {
this.beginPath();
this.rect(x + (8 + widthReference + 20) - 2, y + radius - 2, (width - ((radius * 2) + widthReference + 20)) + 4, 11 + 4);
this.lineWidth = 2;
this.strokeStyle = color;
this.stroke();
this.closePath();
this.save();
this.fillStyle = '#000000';
this.textAlign = 'center';
this.font = '8pt Verdana';
this.fillText(reserve, x + (8 + widthReference + 20) + ((width - ((radius * 2) + widthReference + 20)) / 2) + 1, y + 9 + radius + 1);
this.restore();
}
this.fillStyle = '#000';
var y2 = y + 9 + radius + 18;
this.textAlign = 'left';
for (var i = 0; i < text.length; i++) {
this.fillText(text[i], x + radius, y2);
y2 += 14;
}
}