I've created a separate menu entry for our purpose on commerce_billy_pdf (currently as custom extension):


$items['admin/commerce/orders/%commerce_order/pdf-invoice'] = array(
    'title' => 'Invoice (PDF)',
    'page callback' => 'commerce_billy_pdf',
    'page arguments' => array(3),
    'access callback' => 'commerce_billy_pdf_view_access',
    'access arguments' => array(3),
    'type' => MENU_LOCAL_TASK,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'commerce_billy_pdf.module',
    'file path' => drupal_get_path('module', 'commerce_billy_pdf') . '/',
  );

If you like it, that would be a nice upgrade for commerce_billy_pdf to easier access the pdf invoice by default. I'm sorry that I have not created a patch directly, but my current environment does not allow that ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anybody’s picture

On the clients (user) order page something like this could make sense, but perhaps it is too hard coded or should have a separate permission "Access Invoice PDF download link":

$items['user/%user/orders/%commerce_order/pdf-invoice'] = array(
    'title' => 'Invoice (PDF)',
    'page callback' => 'commerce_billy_pdf',
    'page arguments' => array(3),
    'access callback' => 'commerce_billy_pdf_view_access',
    'access arguments' => array(3),
    'type' => MENU_LOCAL_ACTION,
    'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
    'weight' => 10,
    'file' => 'commerce_billy_pdf.module',
    'file path' => drupal_get_path('module', 'commerce_billy_pdf') . '/',
  );

But that snippet doesn't work yet. What's your opinion in general about this?

fonant’s picture

I also added a menu tab to the order page for administrators to easily view/download the invoice. Your menu code is a bit more robust than mine, so I've borrowed it!

Adds an "Invoice (PDF)" tab to orders that have invoices. The tab doesn't appear for orders that don't have invoices.

Now I wonder if we need to display invoices for orders that are in other states, such as "Processing" and "Completed" too, or whether it's safer to store the PDF files somewhere else...

TheoRichel’s picture

Issue summary: View changes

This is very useful......if only I knew where I should paste this piece of code. Please help!

fonant’s picture

@ThoeRichel - Ideally you need to create a custom module to contain this code in a function that implements hook_menu(). But so long as you're careful with future updates, you can paste it into the function commerce_billy_pdf_menu() in commerce_billy_pdf.module. It should be clear where it goes with the other menu item definitions.

TheoRichel’s picture

Thanks very much!

lsolesen’s picture

@Anybody Are you up for creating a patch for Commerce Billy as this seems as a clever idea?

discipolo’s picture

Status: Active » Needs review
FileSize
1009 bytes
discipolo’s picture

FileSize
1.35 KB
lsolesen’s picture

This works for me. Only question is whether we need to do a clear cache to get it to show right away?

Anybody’s picture

Well the clear cache is not required I think. It's only required if you patch the module which is already installed. On fresh install Drupal clears the menu cache after enabling a new module.

So I think you could add this to the next .dev version?

lsolesen’s picture

Though, it might also be useful to have this tab on: user/5703/orders/21 so the user can access the pdf when logged into the system?

lsolesen’s picture

Status: Needs review » Needs work

Actually, this menu item is created in the wrong module. Should be in commerce_billy_pdf instead.

mglaman’s picture

Status: Needs work » Needs review
FileSize
1.2 KB

Re-roll with menu path in proper module.

doxigo’s picture

Okay thank you guys for the patches, I used mglaman patch to add the Invoice Tab, but how about a tab or button for the user? so he can access the invoice while viewing his order?

fugazi’s picture

#14 I also find a good thing. So the customer can download the bill itself.

mglaman’s picture

That's outside of the scope of the patch, would need to investigate commerce_billy_pdf_view_access(), which takes a commerce order as the access argument (as far as I can tell.)

First step would to get this fixed, then rework invoice permissions.

Joe Huggans’s picture

I am unable to view the invoice, I get an Access Denied message when navigating to the url order/1234/pdf-invoice, even when using admin role

mglaman’s picture

joeuk, the patch in #13 doesn't support that - only from the admin.

Joe Huggans’s picture

Hi mglaman, yes I am using admin user but I still get Access Denied.

Joe Huggans’s picture

However I did only create separate module, I will try patch later and report back... But even still it should not be behaving like this

Joe Huggans’s picture

Where should the tab be showing up to download the PDF invoice for the order, because I again don't see anything.

Also I am getting access denied message when navigating to www.mysite.com/invoice-pdf/[order-number]

silkogelman’s picture

Status: Needs review » Reviewed & tested by the community

Results patch #13:

  • 'invoice (pdf)' appears under operations in the list of orders at the admin/commerce/orders
  • 'Invoice (pdf)' appears as a tab on the order itself

Both appear only if the order has status 'invoiced'

I also tested in combination with multiple order statuses that have PDF download permission #2108335: Allow PDFs to be downloaded from other order states than invoiced.
Result is perfect: the 'invoice (pdf)' only appears for orders that have statusses that have 'PDF download permission'.

Tested & works with

  • user1
  • users that are given 'administrator' permissions

Untested:

  • users that are given permission to view/administer all orders

If #16 is correct, than this current issue seems to be fixed and we can create the ability for customers to download their order as PDF in another issue.

Anonymous’s picture

+1

klausi’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks!

  • klausi committed 94c8dae on 7.x-1.x authored by mglaman
    Issue #2107513 by discipolo, mglaman: Add an Invoice PDF Tab in Order...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.