File: /var/www/vhost/disk-apps/qas.sports-crowd.com/public/js/symbolicTicketsPrice.js
function createSymbolicTicketPrice() {
$("#createSymbolicTicket")
.validator("update")
.on("submit", function (e) {
e.preventDefault();
$("#btn-create-symbolic-ticket").prop("disabled", true);
var price = $("#createSymbolicTicket input[name='price']").val();
var comment = $(
"#createSymbolicTicket input[name='comment']"
).val();
var symbolic_ticket_id = $(
"#createSymbolicTicket input[name='symbolic_ticket_id']"
).val();
var info = {
price,
comment,
symbolic_ticket_id,
};
swal(Lang.get("messagesClient.symbolic_tickets.to_create"), {
buttons: {
cancel: "No",
Ok: true,
},
}).then((val) => {
if (val == "Ok") {
$.ajax({
url: "/symbolic_tickets_price/add",
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") {
$(location).attr(
"href",
"/symbolic_tickets"
);
}
});
} else {
swal("Error", r.m, "warning");
$("#btn-create-symbolic-ticket").prop(
"disabled",
false
);
}
},
error: function (e) {
swal(
"Error",
Lang.get("messagesClient.sucursal_tag4"),
"error"
);
$("#btn-create-symbolic-ticket").prop(
"disabled",
false
);
},
});
}
});
});
}
function clickEditSymbolicTicket(value) {
_table = $("#example2").DataTable();
index = _table.page();
localStorage.setItem("symbolicTicketsTableIndex", index);
$(location).attr("href", "/symbolic_tickets_price/" + value + "/edit");
}
function editSymbolicTicketPrice() {
$("#editSymbolicTicket")
.validator("update")
.on("submit", function (e) {
e.preventDefault();
var id = $("#editSymbolicTicket input[name='id']").val();
var price = $("#editSymbolicTicket input[name='price']").val();
var comment = $("#editSymbolicTicket input[name='comment']").val();
var info = {
id,
price,
comment,
};
swal(Lang.get("messagesClient.symbolic_tickets.to_update"), {
buttons: {
cancel: "No",
Ok: true,
},
}).then((val) => {
if (val == "Ok") {
$.ajax({
url: "/symbolic_tickets_price/" + id,
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) {
if (r.r) {
swal(r.m, {
icon: "success",
buttons: {
Ok: true,
},
}).then((val) => {
if (val == "Ok") {
localStorage.setItem(
"setPageTable",
true
);
$(location).attr(
"href",
"/symbolic_tickets"
);
}
});
}
},
error: function (e) {
swal(
"Error",
Lang.get("messagesClient.sucursal_tag6"),
"error"
);
$("#btn-edit-sucursal").prop("disabled", false);
},
});
}
});
});
}
function chkSymbolicTicket(id) {
var state = 0;
if ($("#Checkactive" + id).is(":checked")) {
state = 1;
}
var info = {
id,
state,
};
$.ajax({
url: "/symbolic_tickets_price/active",
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("Ok", r.m);
} else {
swal(
"Error",
Lang.get("messagesClient.symbolic_tickets.update_state"),
"error"
);
}
},
error: function (e) {
swal(
"Error",
Lang.get("messagesClient.symbolic_tickets.update_error"),
"error"
);
},
});
}