|
|
|
@ -525,8 +525,8 @@ $('#demande-button').click(function () { |
|
|
|
type: "crêpe", |
|
|
|
amount: $('#demande-amount').val(), |
|
|
|
where: $('#demande-where').val(), |
|
|
|
supplement: $('#demande-supplement').val(), |
|
|
|
note: $('#demande-note').val() |
|
|
|
supplement: $('#demande-supp').val(), |
|
|
|
note: $('#demande-note').val(), |
|
|
|
}), |
|
|
|
contentType: "application/json; charset=utf-8", |
|
|
|
dataType: "json", |
|
|
|
@ -534,13 +534,61 @@ $('#demande-button').click(function () { |
|
|
|
success: function(data) { |
|
|
|
if(data.success) { |
|
|
|
$('#demande-form input').val(""); |
|
|
|
updateDemandes(); |
|
|
|
} else { |
|
|
|
alert(data.why); |
|
|
|
$('#error-message-demande').empty(); |
|
|
|
t = new TypeIt('#error-message-demande', { |
|
|
|
speed: 100, |
|
|
|
lifeLike: true |
|
|
|
}) |
|
|
|
.type(data.why) |
|
|
|
.go(); |
|
|
|
if(data.why.startsWith('Token expired') || data.why.startsWith('Not authen')) |
|
|
|
show_page("#login-page"); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
function updateDemandes() { |
|
|
|
$.ajax({ |
|
|
|
type: "POST", |
|
|
|
url: base_url + "get", |
|
|
|
data: JSON.stringify({ |
|
|
|
uid: localStorage.getItem('user'), |
|
|
|
token: localStorage.getItem('token'), |
|
|
|
type: "prank" |
|
|
|
|
|
|
|
}), |
|
|
|
contentType: "application/json; charset=utf-8", |
|
|
|
dataType: "json", |
|
|
|
|
|
|
|
success: function (data) { |
|
|
|
if(data.success) { |
|
|
|
$('#demande-list').html(''); |
|
|
|
let pd = data.prankData; |
|
|
|
for(const pd_uid in pd) { |
|
|
|
$('#demande-list').append(` |
|
|
|
<span id="${pd[pd_uid].prankUid}" class="prank"> |
|
|
|
<h2 class="prank-title">Demande de crêpe</h2> |
|
|
|
<div class="prank-amount">Quantité: ${pd[pd_uid].amount}</div> |
|
|
|
<div class="prank-supplement">Garniture: ${pd[pd_uid].supplement}</div> |
|
|
|
<div class="prank-where">Livraison: ${pd[pd_uid].where}</div> |
|
|
|
<div class="prank-note">Notes: ${pd[pd_uid].note}</div> |
|
|
|
<div class="prank-status">Statue: ${pd[pd_uid].state}</div> |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
`)
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
console.alert(data.why); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
function updateNextActivity() { |
|
|
|
$.ajax({ |
|
|
|
type: "POST", |
|
|
|
@ -604,6 +652,7 @@ $(window).on("load", function() { |
|
|
|
} |
|
|
|
|
|
|
|
updateNextActivity(); |
|
|
|
updateDemandes(); |
|
|
|
|
|
|
|
/* load timer */ |
|
|
|
window.setInterval(function() { |
|
|
|
|