Hi,
Is there any way to generate a pdf invoice in edit view without saving the record to show in detail view and then clicking the pdf button??
I have made an html field that contains the print button and I have organised the invoices as a shopping-cart type experience with the next stage being encouraged and it’s therefore inconvenient to deliberately have to save the record and click print and then click edit again.
Thanks
Its possible with a bit of custom coding to do that. You basically need to add the button from the detail view to the editview and also copy over the JavaScript from the view.detail to the view.edit file that calls the the generate pdf action.
Thanks, it worked well, except if the data is changed in edit view and then I click ‘print pdf’ it doesn’t use the recently entered data, only data once it’s saved.
Any way around this?
Not really unless you use an Ajax call to automatically save the data when you click the ‘print pdf’ button. It would have to fire before the print pdf code did.
How would I initiate an ajax call?
I used this line from the save button, but of course it just loads a new page:
onclick=“var _form = document.getElementById(‘EditView’); _form.action.value=‘Save’; if(check_form(‘EditView’))SUGAR.ajaxUI.submitForm(_form);return false;”
This is not that simple I would look into using jquery for this.
Attach a JavaScript file to the metadata editview defs
within this file do something like :
$('#your_buttons_id').on('change', function() {
//Create varibles for all the fields
var name = $('#search_resource_name').val();
var type = $('#search_resource_type').val();
//attach them to the datastring
var dataString = '&name=' + name + '&type=' + type;
$.ajax({
type: "POST",
url: "index.php?module=AOS_Invoices&action=CustomSave",
data: dataString,
success: function(data) { // On success generate the tasks for the chart
// on success do something
}
});
});
You will also need to create a controller.php with a custom action to save the record received from the ajax call .
In fact the more I think about it the more I see it being a lot of work TBH. Probably not worth it mate.
Please share code with what and where need to change,
Thanks in advance
Gopal
I will take your advice and not bother.
Do you have any other suggestions then as to how I can achieve my aim?
I need the whole process of filling in the invoice form to be like a shopping cart where one finished one stage and moves on to the next without visiting any new module.
It’s great that now pdfs can be generated from within edit view, but what if they’ve started entering data from the 1st tab and have no reached the 4th and want to generate a quote…what is the simplest way of doing this and then moving on to the 5th tab? (Is there a way to make the pdf button ‘post’ save the invoice then switch to the quote tab with javascript and then generate the pdf all in one go?
Thanks
(Sorry if this is confusing)
I think what you are trying to do is beyond the scope of a forum post. It sounds like you are after some quite complicated modifications that will require a lot of custom coding.
My best advice is hire a developer to do it for you.
Is there no way I can utilise an after_save logic hook to generate and or email pdf?
Thanks