mesut Posted July 3, 2018 Share Posted July 3, 2018 Hi All In Admin Area; How to disable redirect to created invoice when convert quote to invoice i want re-open on current page after convert quote ro invoice 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted July 10, 2018 Share Posted July 10, 2018 (edited) The redirect can't be disabled but you can get the job done using an action hook that brings you back to the original document like follows. <?php function somePrefix_InvoiceCreation($vars) { $quoteID = Capsule::table('tblinvoices')->where('id', $vars['invoiceid'])->where('notes', 'like', 'Re Quote #%')->first(['notes']); header('Location: quotes.php?action=manage&id=' . explode('#', $quoteID->notes)[1]); die(); } add_hook('InvoiceCreation', 1, 'somePrefix_InvoiceCreation'); You have to place this code in a new file under includes/hooks folder. You can name the file as you prefer. Lastly you should replace the two somePrefix_ in the code with something else to avoid function name collission (e.g. use your brand name). The code is pretty simple. InvoiceCreation hook point triggers the code every time you create an invoice from admin area. The code runs a query in database to detect if the current invoice "comes" from a quote (all quotes have "Re Quote #{QUOTE-ID}" string in name tblinvoices.notes column). If this string "Re Quote #" is found I extract the ID of the original quote exploding tblinvoices.notes by # and getting the second match (the part in red "Re Quote #{QUOTE-ID}"). Long story short now that we know that the invoice in question "comes" from a quote we can redirect you back to quote since we also know the ID. From now on when you press Convert to Invoice you'll stay on quote page. Edited July 10, 2018 by Kian 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.