/** * Created by fab on 30/12/17. */ function getPrice(priceWithTax, taxRate) { return parseFloat(parseFloat(priceWithTax) / (taxRate + 1)).toFixed(2); } function getPriceWithTax(priceWithoutTax, taxRate) { return parseFloat(parseFloat(priceWithoutTax) * (taxRate + 1)).toFixed(2); } function formatPrice(price) { return Number(price).toFixed(2).replace('.', ',') + ' €'; } function log(msg) { try { console.log(msg); } catch (e) { } } //Convertit un formulaire ou un objet en JSON (utilisé pour l'envoie de donnée en ajax) $.fn.serializeObject = function () { var o = {}; var a = this.serializeArray(); $.each(a, function () { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; function getDateFormatted(date) { var _d = date.getDate(), d = _d > 9 ? _d : '0' + _d, _m = date.getMonth() + 1, m = _m > 9 ? _m : '0' + _m, formatted = date.getFullYear() + '-' + m + '-' + d; return formatted; } //Affiche une alert au click sur un bouton submit lorsqu'un utilisateur admin tente de modifer un établissement function userNotAllowToEdit() { alert('Vous n\'êtes pas autorisé à effectuer cette action'); return false; }