3 replies [Last post]
japerry@drupal.org's picture
Offline
Bug FinderGetting busy with the Ubercode.Not Kulvik
Joined: 08/08/2007
Juice: 248
Was this information Helpful?

In e-commerce, when you clicked on an invoice it would change the workflow to 'Invoiced' -- this is a critical function for multiple employees working on orders.

I've changed the uc_orders module to add an 'Invoice Printed' workflow when you press 'Print invoice' -- I didn't like how ecommerce would not have a difference between view and print invoices.

Used the tips from this page:
http://www.ubercart.org/forum/ideas_and_suggestions/1589/update_order_st...

Around Line 2055 change:

  if ($op == 'print') {
    print $output;
    exit();
  }

To:

  if ($op == 'print') {
  if ($op == 'print') {
    $invoiced = FALSE; 
    $comments = uc_order_comments_load($order_id);   
    foreach($comments AS $comment ) {   
    if($comment->order_status == 'invoiced') {
    $invoiced = TRUE;
    }
   }
   if(!$invoiced) {
uc_order_comment_save($order_id, $uid, 'Invoice has been printed out','order','invoiced',false);
uc_order_update_status($order_id, 'invoiced');
   }
   print $output;
   exit();
  }
  }

Since you may print out the invoice multiple times, even after the workflow has been changed, this code is set so after you print the invoice once, can be printed over and over without constant notification.

You also need to add an 'invoiced' order status under store administration. I liked to label it 'Invoiced Printed'

japerry@drupal.org's picture
Offline
Bug FinderGetting busy with the Ubercode.Not Kulvik
Joined: 08/08/2007
Juice: 248
Re: Add 'invoiced' to workflow when printing an invoice

heh the newest version of ubercart still doesn't implement this.. oh well.

arielgold's picture
Offline
Joined: 02/14/2010
Juice: 63
Re: Re: Add 'invoiced' to workflow when printing an invoice

yes. this would be a nice feature that i think would merit getting rolled into ubercart

arielgold's picture
Offline
Joined: 02/14/2010
Juice: 63
Re: Re: Re: Add 'invoiced' to workflow when printing an invoice

Your code didn't work for me...here's code that works on drupal 6 / ubercart 2.2... this is in /sites/all/modules/ubercart/uc_order/uc_order.admin.inc
Is there a way to do this without hacking core? I know enough to know I'm not supposed to hack core, but that's about as far as my knowledge goes. =)

function uc_order_invoice($order, $op = 'view') {
  global $user;
  $output = uc_order_load_invoice($order, $op, variable_get('uc_cust_order_invoice_template', 'customer'));

  if ($op == 'print') {
    $invoiced = FALSE;
    $comments = uc_order_comments_load($order->order_id);
    if ($comments) {
      foreach($comments AS $comment ) {
        if($comment->order_status == 'Invoiced') {
          $invoiced = TRUE;
        }
      }
    }
   if(!$invoiced) {
     uc_order_comment_save($order->order_id, $user->uid,'-','order','Invoiced', false);
     uc_order_update_status($order->order_id, 'invoiced');
   }
   print $output;
   exit();
  }

  return $output;
}