Save to file
1 |
/home/user/public_html/includes/hooks/hook_invoices_sbz.php |
the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
<?php if (!defined('WHMCS')) { die('This hook should not be run directly'); } use WHMCS\Service\Service; add_hook('ClientAreaPageInvoices', 1, function($vars) { $serviceData = Service::find($referral['id']); $nextDueDate = $serviceData->nextduedate; $GLOBALS['userid']=$vars[clientsdetails][userid]; $GLOBALS['language']=$vars[activeLocale][language]; function smarty_function_get_emdi_invoices($params, $smarty) { $vat = $params['vat']; $email = $params['email']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://emdi.sbzsystems.com/getDocsTo.php?user_id=XXXXX&vat='.$vat.'&email='.$email.'&key=XXXXXXXXXXXXXXXXXX'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $response = curl_exec($ch); if (curl_error($ch)) { die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch)); } curl_close($ch); $response =' </br> <div> <h1>'.Lang::trans('emdi_invoices').' <small>'.Lang::trans('emdi_invoice_title').'</small></h1> <table class="table table-list dataTable no-footer dtr-inline"> <tr> <td style="width: 12%">'.Lang::trans('invoicesdatecreated').'</td> <td style="width: 45%">'.Lang::trans('emdi_doc').'</td> <td style="width: 10%">'.Lang::trans('invoicesamount').'</td> <td>'.Lang::trans('emdi_issuer').'</td> </tr> </table> <div style="height:300px;overflow:auto;"> '.$response.' </div> </div> '; return $response; } }); ?> |
In the archive
1 |
/home/user/public_html/includes/hooks/hook_clients_sbz.php |
the code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
<?php if (!defined('WHMCS')) { die('This hook should not be run directly'); } function clientModuleLink($vars) { function filename_sanitizer($unsafeFilename){ // our list of "unsafe characters", add/remove characters if necessary $dangerousCharacters = array('"', "'", "&", "/", "\\", "?", "#"); // every forbidden character is replaced by an underscore $safe_filename = str_replace($dangerousCharacters, '', $unsafeFilename); return $safe_filename; } $customTab = ''; $lic_num=0; $lic_total=0; $not_permitted_version=0; $userid=$vars['userid'];//{$clientsdetails.userid}; //require "/home/freeextra/domains/freeextra.com/public_html/billing/configuration.php"; require "../configuration.php"; // Connects to your Database $link=mysqli_connect("$db_host", $db_username, $db_password) or die(mysqli_error($link)); mysqli_select_db($link,"$db_name") or die(mysqli_error($link)); //$query = "SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'"; $link->set_charset("utf8"); mysqli_query($link, $query); //LIST INVOICES $query = "SELECT tax_id,email FROM `tblclients` where id=".$vars['userid']; $data = mysqli_query($link,$query); $num_rows = mysqli_num_rows($data); if ($num_rows>0) { $vat=''; while($alldata = mysqli_fetch_array( $data )) { $vat=$alldata['tax_id']; $email =$alldata['email']; //echo '##'.$email.'##'; //break; } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://emdi.sbzsystems.com/getDocsTo.php?user_id=XXXXX&vat='.trim($vat).'&email='.trim($email).'&admin=1&key=XXXXXXXXXXXXXXXXXX'); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); $response = curl_exec($ch); if (curl_error($ch)) { die('Unable to connect: ' . curl_errno($ch) . ' - ' . curl_error($ch)); } curl_close($ch); if (trim($response)) { $customTab=$customTab. '<div id="invcs" style="height:200px;overflow:auto;">'. $response .'</div> <script> var objDiv = document.getElementById("invcs"); objDiv.scrollTop = objDiv.scrollHeight; </script> '; } } mysqli_close($link); return $customTab; } add_hook('AdminAreaClientSummaryPage', 1, 'clientModuleLink'); ?> |
Where XXXXX is the customer ID as listed in WHMCS and XXXXXXXXXXXXXXXXXX security code provided by SBZ.
In the archive
1 |
/home/user/public_html/templates/six/clientareainvoices.tpl |
add to the bottom
1 |
{get_emdi_invoices vat=$client.tax_id} |
example
1 2 3 4 5 6 7 8 |
... </tbody> </table> {get_emdi_invoices vat=$client.tax_id} <div class="text-center" id="tableLoading"> ... |
Finally we add to the end of the file
1 |
/home/user/public_html/lang/overrides/english.php |
the variables
1 2 3 4 |
$_LANG['emdi_invoices'] = "Invoices"; $_LANG['emdi_doc'] = "Document"; $_LANG['emdi_issuer'] = "Issuer"; $_LANG['emdi_invoice_title'] = "The documents that have been issued"; |
View invoices in WHMCS admin
Display the invoices in the WHMCS’ s client