I need to add a button in list view that appears alongside each of the records that when clicked, takes the data from that records fields and creates an invoice with the same fields.
I think I can handle the creation of an invoice and all the fields fine, however I was wondering how do I create a button in list view, and how do I make sure it links with the record?
I’ve seen that, however I am trying to add this button to the AOS_Invoices Module not the Contacts module, and the Invoices module seems to be layer out differently and therefore does not have the function present that’s listen in that document.
I managed to do it!
I ended up using a process_record hook to add in the buttons and then use javascript to control the existing mass update function and it all works really well!
I then created a custom ‘view.list.php’ file to create add javascript to the links but only for the list view of that particular module.
In the file I used javascript as follows: when a user clicks on one of the buttons in the table row the checkbox in the given row is ticked, the status option is selected and the update function is ran. View the code below:
$(document).ready(function(){
$(".movetoenquiry-button").click(function(){
var checkboxes = $(this).parent().siblings().children();
checkboxes.prop("checked",!checkboxes.prop("checked"));
$("#mass_status").val(1);
return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
})
$(".movetojob-button").click(function(){
var checkboxes = $(this).parent().siblings().children();
checkboxes.prop("checked",!checkboxes.prop("checked"));
$("#mass_status").val(4);
return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
})
$(".cancel-button").click(function(){
var checkboxes = $(this).parent().siblings().children();
checkboxes.prop("checked",!checkboxes.prop("checked"));
$("#mass_status").val(10);
return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
})
$(".archive-button").click(function(){
var checkboxes = $(this).parent().siblings().children();
checkboxes.prop("checked",!checkboxes.prop("checked"));
$("#mass_status").val(9);
return sListView.send_mass_update("selected", "Please select at least 1 record to proceed.")
})
})