Jump to content

Hook when "Create Add Funds Invoice"


Recommended Posts

Hi,

I created a function that when called via Hook renames the invoices that are created, this allows me to have my own name without using the IDs.

This function almost always works correctly, except in one case: when I enter the customer profile from the administrator area, and click on "Create Add Funds Invoice". In this case the function does not start.
What Hook should I use in this case? I am attaching my function and also the hooks I used to call it.

 

function DN_writeNUMproforma($vars) {

	$inv_id = $vars['invoiceid'];

	$invoicenum_db = Capsule::table('tblinvoices')->where('id', $inv_id)->value('invoicenum');

    if ($invoicenum_db == null) {

    	$proforma_num = 'FP-' . date('Y') . '-' . date('m') . $inv_id . rand(0,9);

		Capsule::table('tblinvoices')
	        ->where('id', $inv_id)
	        ->update(
	            [
	                'invoicenum' => $proforma_num,
	            ]
	        );
	}
}


// =========================================================================
// Hook
// =========================================================================

add_hook('InvoiceCreated',1,'DN_writeNUMproforma'); 
add_hook('InvoiceCreation',1,'DN_writeNUMproforma'); 
add_hook('InvoiceCreationPreEmail',1,'DN_writeNUMproforma'); 
add_hook('InvoiceCreationAdminArea', 1,'DN_writeNUMproforma');

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated