cmc-sales/app/webroot/js/view_enquiry.js
2013-03-23 16:25:52 +11:00

79 lines
1.3 KiB
JavaScript
Executable file

$(function() {
$(".addJob").button('enable');
$(".addJob").click(function() {
$("#jobConfirm").dialog('open');
});
$( "#jobAddedDialog" ).dialog({
autoOpen: false,
modal: true,
buttons: {
Ok: function() {
$( this ).dialog( "close" );
}
},
close: function(event,ui) {
window.location.href = '/jobs';
}
});
$( "#jobConfirm" ).dialog({
autoOpen: false,
resizable: false,
height:140,
modal: true,
buttons: {
"Add new Job": function() {
addJob();
$( this ).dialog( "close" );
},
Cancel: function() {
$( this ).dialog( "close" );
}
}
});
$( "#jobsListDialog" ).dialog({
autoOpen: false,
resizable: false,
height:140,
modal: true
});
function addJob() {
var enquiryID = $(".addJob").attr("id");
$.post('/jobs/ajax_add/'+enquiryID, function(data) {
$( "#jobAddedDialog" ).dialog('open');
});
}
//Quote code below
$(".addQuote").click(function() {
window.location = '/documents/newDocument/quote/'+$( this ).attr('id');
});
$(".addInvoice").click(function() {
if($("#jobsListUL > li").length == 0) {
alert("Cant add an invoice yet! Add Invoice must be for a job. No Jobs exist for this Enquiry");
}
else {
$("#jobsListDialog").dialog('open');
}
});
});