-
Similar Content
-
By jerry.li
I created a hook to modify the due date of the invoice.
The whole code executes fine, but at the end I don't see any fields I update in the database.
Can anyone help me to see where the problem is.
Thanks for everyone's help
<?php use WHMCS\Database\Capsule; function hook_invoice_payment_terms($vars) { $pdo = Capsule::connection()->getPdo(); $pdo->beginTransaction(); // Setup $adminuser = "Jerry"; $responsetype = "json"; $customFieldName = 'Payment Terms'; $options=payment_terms_getoptions(); $defaultTerms=$options["DefaultPaymentTerm"]; $invoiceid = $vars['invoiceid']; $invoicesource =$vars['source'] ; $creatinguser = $vars['user'] ; // Get Invoice structure $command = "getinvoice"; $values["invoiceid"] = $invoiceid; $values["responsetype"] = $responsetype ; $getinvoice = localAPI($command,$values,$adminuser); //var_dump($getinvoice); //echo "<br/>"; logModuleCall( 'paymenmterms', $command, $values, $getinvoice); if ($getinvoice['result']=="success") { $values = null; unset($values); // Get customer details $command = "getclientsdetails"; $values["clientid"] = $getinvoice['userid']; $values["stats"] = false; $values["responsetype"] = $responsetype ; $getclientsdetails = localAPI($command,$values,$adminuser); logModuleCall( 'paymenmterms', $command, $values, $getclientsdetails); $sql = "SELECT DISTINCT SUBSTRING_INDEX(cv.value, '|', 1) FROM tblcustomfieldsvalues AS cv JOIN tblcustomfields AS cf ON cv.fieldid = cf.id WHERE cf.fieldname LIKE '".$customFieldName."' AND cv.relid = ".$getinvoice['userid']; $res = $pdo->query($sql); $numrows = $res->rowCount(); /* $sql = "SELECT DISTINCT SUBSTRING_INDEX(SUBSTRING_INDEX(cv.value, '|', 1), '|', -1) FROM tblcustomfieldsvalues AS cv JOIN tblcustomfields AS cf ON cv.fieldid = cf.id WHERE cf.fieldname LIKE '".$customFieldName."' AND cv.relid = ".$getinvoice['userid']; $result = mysql_query($sql); $numrows = mysql_num_rows($result); */ if ($numrows > 0) { // logModuleCall( 'paymenmterms', "GetCustomValue", $sql, $result); $TermDays = $res->fetchColumn($result); } else { $TermDays=$defaultTerms; } // Get Invoice Due Date $newInvoiceDate = time() + ($TermDays * 86400); $newInvoiceDate = date("Y-m-d", $newInvoiceDate); // Update invoice if not error //if ( !($errorOnTerms) ) { logActivity("Updating Invoice $invoiceid due date to $newInvoiceDate"); $command = "UpdateInvoice"; $values["invoiceid"] = $invoiceid; $values["duedate"] = $newInvoiceDate; $values["responsetype"] = $responsetype ; $values["notes"] = "Updating Invoice $invoiceid due date to $newInvoiceDate"; $updateinvoice = localAPI($command,$values,$adminuser); logModuleCall( 'paymenmterms', $command, $values, $updateinvoice); if ($updateinvoice['result']!="success") { // Error Updating Invoice logActivity("An Error Occurred while updating Invoice: ".$updateinvoice['result']); } Else { // Invoice Update Successful! // Get Invoice structure $values = array(); $command = "getinvoice"; $values["invoiceid"] = $invoiceid; $values["responsetype"] = $responsetype ; $getinvoice = localAPI($command,$values,$adminuser); //print_r($updateinvoice); //print_r($getinvoice); //exit; } // Cleanup $values = null; unset($values); } Else { // Error Getting Invoice logActivity("ERROR: Unable to retreive Invoice ID $invoiceid!"); } } function payment_terms_getoptions() { // Get configurable options $table = "tbladdonmodules"; $fields = "setting,value"; $where = array("module"=>"paymentterms"); $result = select_query($table,$fields,$where); $options = array(); while ($data = mysql_fetch_array($result)) { $option_name = $data['setting']; $options["$option_name"] = $data['value']; } return $options; } add_hook("InvoiceCreation",9999,"hook_invoice_payment_terms");
When I was debugging, after I tried update in the hook, I read out the invoice information, and it was the same as what I submitted for the update;
But in the end this information is not written to the mysql.
-
By LaneV
I can't seem to find a documented way to create an add funds invoice via the API. I can create regular invoices for services and charge them but I need to be able to create add funds invoices.
Has anyone been able to do this?
-
By otel
Hi
I've seen numerous treads on this community, and generally other forums across the net regarding showing the product description below the name of product in invoices and quotes.
I cannot find a setting nor any codes I can add in the TPL files.
Is there a module or code I can add so the description shows in the pdf of the invoice or quote?
-
By Marijo
Hello,
As some of you may know we in Croatia are obligated to have currency on HRK inside invoice, this makes stuff hard for me and my friend cause we're based on international marketplace and not only Croatia. Sadly we we're trying to come up with a solution and its been real pain in the ass trying to figure something out. As much as I know its not possible to use hooks inside php, so we have no idea how it would be possible to have currency exchange inside pdf that is being delivered by email. Really any help would be appreciated.
We tried looking up on older posts but haven't found a solution yet, so please help 2 guys out :D
-
By Balram
Hello,
i am trying to add bank transfer details but having some problem.
I am unable to add space after text below attaching screenshot for understanding.
My issue- https://prnt.sc/1x5pccy
i found one website using same theme without this problem - https://prnt.sc/1x5p7zo
here is how i have added details to whmcs admin area- https://prnt.sc/1x5pjhz
-
-
Recently Browsing 0 members
No registered users viewing this page.