Add User ID To Invoice Template

Discussion in 'Templates customization' started by relapse, Oct 8, 2018.

  1. relapse

    relapse Member

    Joined:
    Jun 15, 2010
    Messages:
    133
    I have the correct code snippet for customizing the invoice template, but am unsure on how to implement this specific item (user id).

    Here is the code with other customization snippets, in red, in site.php:

    Code:
    Am_Di::getInstance()->hook->add(Am_Event::PDF_INVOICE_COL_RIGHT, function (Am_Event $e) {
        $payment = $e->getPayment();
        $inv = $payment->getInvoice();
        $col = $e->getCol();
    
        //$col->add("PO# {$inv->purchase_order}");
        //$col->moveBefore('date', 'invoiceNumber');
        //$col->prepend('Reçu de transaction'); //prepend line
        //print_rre($user);
    
        $col->remove('name');
        $col->remove('email');
        $col->remove('address');
        $col->remove('city');
        $col->remove('country');
    
        $col->add('Date: ' . amDate($payment->dattm), 'date');  <<<<<THIS ONE
        $col->add('Invoice Number: ' . $payment->invoice_id, 'invoiceNumber'); <<<<<AND THIS ONE
       
        if($inv->paysys_id == "offline"){
            $col->add('Payment Method: PURCHASE ORDER');
        } elseif($inv->paysys_id == "authorize-cim"){
            $col->add('Payment Method: CREDIT CARD');
        } else {
            $col->add('Payment Method: ' . strtoupper($inv->paysys_id));
        }
    
    
        if($inv->paysys_id == "offline"){
            $col->add("P.O. Number: {$inv->purchase_order}");
        }
    
    });

    I would like to add the user id to the right column, below the PO# as shown in the attached image:

    https://imgur.com/a/UCZpEpw

    [​IMG]

    If anyone could help with the right line of php, I would be grateful.

    Thanks,

    Roger
  2. caesar

    caesar aMember Pro Developer Staff Member

    Joined:
    Oct 16, 2009
    Messages:
    2,295
    Hello Roger,

    Please add the following code in the end of your function that handle
    PDF_INVOICE_COL_RIGHT event in site.php:

    PHP:
    $col->add("User ID: {$inv->user_id}");
    Best Regards.
  3. relapse

    relapse Member

    Joined:
    Jun 15, 2010
    Messages:
    133
    Thanks Caesar!
    caesar likes this.

Share This Page