Forum Moderators: open
<script language="javascript">
$(function() {
$("#exists-form").hide();
$(".till_insert").click(function() {
var ref = $("input#ref").val();
var inn = $("input#in").val();
var out = $("input#out").val();
var detail = $("input#detail").val();
var dataString = 'ref='+ ref + '&inn=' + inn + '&out=' + out + '&detail=' + detail + '&till_insert1="true"';
$.ajax({
type: "POST",
url: "includes/process.php",
data: dataString,
dataType: "json",
cache: false,
success: function(response) {
//alert (JSON.stringify(response)); //Show JSON Alert
if (response.result === "success" ) {
$( "#till tbody" ).append( "<tr>" +
"<td>" + ref + "</td>" +
"<td>" + response.inn + "</td>" +
"<td>" + response.out + "</td>" +
"<td>" + detail + "</td>" +
"</tr>" );
$('#insert-form')[0].reset();
$("#balance").html("Balance: £" + response.balance);
$("#balance").removeClass('red orange green').addClass(response.colour);
$("#out").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_out").css({ "color": "#454545" });
$("#in").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_in").css({ "color": "#454545" });
}
else if (response.result === "exists") {
$("#exists-form").html("<div class=\"warning\">Reference already exists</div>");
$('#exists-form').dialog({
autoOpen: false,
draggable: false,
modal: true,
resizable: false,
title: "Warning",
buttons: {
"Yes": function() {
$(this).dialog('close');
var dataString = 'ref='+ ref + '&inn=' + inn + '&out=' + out + '&detail=' + detail + '&till_insert_exists="true"';
$.ajax({
type: 'POST',
url: 'includes/process.php',
data: dataString,
dataType: "json",
cache: false,
success: function(response) {
if (response.result === "success" ) {
$( "#till tbody" ).append( "<tr>" +
"<td>" + ref + "</td>" +
"<td>" + response.inn + "</td>" +
"<td>" + response.out + "</td>" +
"<td>" + detail + "</td>" +
"</tr>" );
$('#insert-form')[0].reset();
$("#balance").html("Balance: £" + response.balance);
$("#balance").removeClass('red orange green').addClass(response.colour);
$("#out").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_out").css({ "color": "#454545" });
$("#in").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_in").css({ "color": "#454545" });
}
}
});
},
"No": function() {
$(this).dialog('close');
}
}
});
$('#exists-form').dialog('open');
}
else if (response.result === "error") {
alert("There has been an error");
}
}
});
return false;
});
});
</script>
var successFn = function() {
$( "#till tbody" ).append( "<tr>" +
"<td>" + ref + "</td>" +
"<td>" + response.inn + "</td>" +
"<td>" + response.out + "</td>" +
"<td>" + detail + "</td>" +
"</tr>" );
$('#insert-form')[0].reset();
$("#balance").html("Balance: £" + response.balance);
$("#balance").removeClass('red orange green').addClass(response.colour);
$("#out").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_out").css({ "color": "#454545" });
$("#in").attr("disabled", "").css({ "border": "2px solid #D9D9D9" }),
$("#label_in").css({ "color": "#454545" });
}