File: /var/www/vhost/disk-apps/agile-selling-wpb/public/js/sizing.js
function createSizing() {
$('#createSizing').validator('update');
$("#createSizing").validator('update').on('submit', function (e) {
if (e.isDefaultPrevented()) {} else {
e.preventDefault();
var info = {
"name": $(" #createSizing input[name='name']").val(),
"abbreviation": $(" #createSizing input[name='abbreviation']").val(),
};
console.log(info);
swal(Lang.get("messagesClient.sizing_tag1"), {
buttons: {
cancel: "No",
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
$("#btn-create-sizing").prop("disabled", true);
$.ajax({
url: "/sizing/create",
type: "POST",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
if (r.r) {
swal(r.m, {
icon: "success",
buttons: {
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
console.log('creado');
$(location).attr('href', '/sizing');
}
});
} else {
swal("Error", r.m, "error");
$("#btn-create-sizing").prop("disabled", false);
}
},
error: function (e) {
swal("Error", Lang.get("messagesClient.sizing_tag2"), "error");
$("#btn-create-sizing").prop("disabled", false);
}
});
}
});
}
});
}
function clickEditSizing(value) {
_table = $("#example2").DataTable();
// index = _table.page();
// localStorage.setItem("productsTableIndex", index);
$(location).attr('href', '/sizing/edit/' + value);
}
function editSizing(id) {
$('#editSizing').validator('update');
$("#editSizing").validator('update').on('submit', function (e) {
if (e.isDefaultPrevented()) {} else {
e.preventDefault();
var info = {
"id": id,
"abbreviation": $(" #editSizing input[name='abbreviation']").val(),
"name": $(" #editSizing input[name='name']").val(),
};
console.log(info);
swal(Lang.get("messagesClient.sizing_tag4"), {
buttons: {
cancel: "No",
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
$("#btn-edit-sizing").prop("disabled", true);
$.ajax({
url: "/sizing/update",
type: "PUT",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
console.log(r);
if (r.r) {
swal(r.m, {
icon: "success",
buttons: {
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
console.log('creado');
// localStorage.setItem("setPageTable", true);
$(location).attr('href', '/sizing');
}
});
} else {
swal("Error", r.m, "error");
$("#btn-edit-sizing").prop("disabled", false);
}
},
error: function (e) {
swal("Error", Lang.get("messagesClient.sizing_tag3"), "error");
$("#btn-edit-sizing").prop("disabled", false);
}
});
}
});
}
});
}
/**Método para eliminar empresa desde la tabla de admins y en editar */
function clickDeleteSizing(id){
swal(Lang.get("messagesClient.sizing_tag5"), {
buttons: {
cancel: "No",
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
var info = {
"id": id
};
console.log(info);
$.ajax({
url: "/sizing/delete",
type: "POST",
contentType: 'application/json',
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
'Content-Type': 'application/json'
},
data: JSON.stringify(info),
success: function (r) {
console.log(r);
if (r.r) {
swal(r.m, {
icon: "success",
buttons: {
Ok: true,
}
}).then((val) => {
if (val == "Ok") {
$(location).attr('href', '/sizing');
}
});
} else {
swal("Error", Lang.get("messagesClient.sizing_tag6"), "error");
}
}, error: function(e){
swal("Error", Lang.get("messagesClient.sizing_tag6"), "error");
}
});
}
});
}
// function setPageTable(){
// localStorage.setItem("setPageTable", true);
// $(location).attr('href', '/companies');
// }