Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function addToDeliveryList(id) {
- $.post("func/addToDeliveryList.php", {
- id: id
- })
- .done(function(data) {
- if (data == 'ok') {
- $('#confirmedOrdersActions_' + id).html('<button type="button" style="width: 150px; border-radius:0px; cursor:default;" class="btn btn-success"><i class="fas fa-check"></i> <b>Aggiunto!</b></button>')
- setTimeout(function() {
- $('#confirmedOrdersRow_' + id).slideUp()
- }, 2000);
- var el = $('.deliveryList').find(".nav-link")
- $(el).effect('shake').delay(150).effect('shake')
- $('#deliveryListLabelButton').effect('shake').delay(150).effect('shake')
- }
- });
- }
- function removeFromDeliveryList(id) {
- $.post("func/removeFromDeliveryList.php", {
- id: id
- })
- .done(function(data) {
- if (data == 'ok') {
- $('#confirmedOrdersActions_' + id).html('<button type="button" style="width: 150px; border-radius:0px; cursor:default;" class="btn btn-danger"><i class="fas fa-check"></i> <b>Rimosso!</b></button>')
- setTimeout(function() {
- $('#confirmedOrdersRow_' + id).slideUp()
- }, 2000);
- }
- });
- }
- $(function() {
- var tmpArray = [];
- $('[id^="confirmedOrdersRow_"]').each(function(index) {
- var thisId = $(this).attr("id")
- var thisId = thisId.replace("confirmedOrdersRow_", "")
- var thisId = parseInt(thisId)
- tmpArray[thisId] = thisId
- })
- $('[id^="confirmedOrdersRow_"]').each(function(index, element) {
- var tmp = $(this).attr("id")
- var tmp = tmp.replace("confirmedOrdersRow_", "")
- window['confirmedOrdersRow_' + tmp] = $(this).detach()
- })
- var tmpArray2 = []
- var promises = [];
- $(tmpArray).each(function(index, element) {
- if (element) {
- promises.push($.post("func/checkIfInDeliveryList.php", {
- id: index
- })
- .done(function(data) {
- if (data != '') {
- tmpArray2[data] = index
- }
- }))
- }
- })
- $.when.apply($, promises).then(function() {
- $(tmpArray2).each(function(index, element) {
- $('#waitingOrdersContent').append(window['confirmedOrdersRow_' + element])
- })
- $(tmpArray).each(function(index, element) {
- var tmpIndex = tmpArray2.indexOf(element)
- if (tmpIndex > -1) tmpArray[element] = ''
- })
- $(tmpArray).each(function(index, element) {
- if (element) $('#waitingOrdersContent').append(window['confirmedOrdersRow_' + element])
- })
- recreateDeliveryList()
- })
- })
- function recreateDeliveryList() {
- deliveryListRecreated = []
- $('[id^="confirmedOrdersRow_"]').each(function(index) {
- var tmp = $(this).attr("id")
- var tmp = tmp.replace("confirmedOrdersRow_", "")
- deliveryListRecreated.push(tmp)
- })
- var deliveryListRecreatedJSON = JSON.stringify(deliveryListRecreated)
- $.post("func/recreateDeliveryList.php", {
- list: deliveryListRecreatedJSON
- })
- .done(function(data) {
- console.log("Delivery List saved.")
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement