TimRef Posted December 7, 2021 Share Posted December 7, 2021 Hi, Suggestion: Add dedicated IP or hostname to the clinet and admin invoice.php page . That will save a lot of time. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted December 29, 2021 Share Posted December 29, 2021 On 12/7/2021 at 1:48 PM, TimRef said: Hi, Suggestion: Add dedicated IP or hostname to the clinet and admin invoice.php page . That will save a lot of time. Hello, Maybe we can manage a way, using a Hook file, interested in this? 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted December 31, 2021 Author Share Posted December 31, 2021 On 12/29/2021 at 8:25 PM, andrezzz said: Hello, Maybe we can manage a way, using a Hook file, interested in this? Thanks for your reply . do you have any plan ? 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 1, 2022 Share Posted January 1, 2022 (edited) On 12/31/2021 at 2:14 PM, TimRef said: Thanks for your reply . do you have any plan ? Check this out :D! <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.0 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); if ($dedicatedIP === '') return; Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . $dedicatedIP )); } }); It also have Language support, so that the client can understand what is that line. Edited January 1, 2022 by andrezzz 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted January 1, 2022 Share Posted January 1, 2022 56 minutes ago, andrezzz said: Check this out :D! <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.0 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); if ($dedicatedIP === '') return; Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . $dedicatedIP )); } }); It also have Language support, so that the client can understand what is that line. You need to check if invoiced item is hosting. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 1, 2022 Share Posted January 1, 2022 (edited) 33 minutes ago, pRieStaKos said: You need to check if invoiced item is hosting. Well, I thought like this: if you have an IP then it should appear, because many times there are services with an IP that are Other. Edited January 1, 2022 by andrezzz 0 Quote Link to comment Share on other sites More sharing options...
string Posted January 1, 2022 Share Posted January 1, 2022 (edited) Great work 🙂 pRieStaKos is right, the type should be checked. The problem is, for example, if the invoice line is about a domain and the domain ID matches with an ID in tblhosting, a wrong value will be inserted. And I have 2 general suggestions: Use type casting for integers. Some servers still uses old mysqlnd drivers, which returns everything as string, even if the column is a integer. However, because of the "if ($dedicatedIP === '') return;" check it doesn't matter in this case. I would trim the $dedicatedIP variable. While WHMCS automatically trims the IP field in newer versions, this was not the case in older versions and I think it is always a good idea to trim fields if it makes sense. And one never know what WHMCS admins do manually in the database. Whitespaces are conceivable. Edited January 1, 2022 by string 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 1, 2022 Share Posted January 1, 2022 31 minutes ago, string said: Great work 🙂 pRieStaKos is right, the type should be checked. The problem is, for example, if the invoice line is about a domain and the domain ID matches with an ID in tblhosting, a wrong value will be inserted. And I have 2 general suggestions: Use type casting for integers. Some servers still uses old mysqlnd drivers, which returns everything as string, even if the column is a integer. However, because of the "if ($dedicatedIP === '') return;" check it doesn't matter in this case. I would trim the $dedicatedIP variable. While WHMCS automatically trims the IP field in newer versions, this was not the case in older versions and I think it is always a good idea to trim fields if it makes sense. And one never know what WHMCS admins do manually in the database. Whitespaces are conceivable. You and @pRieStaKos are right, sorry. Thank you so much for your suggestions 😊! Check this newer version! In my case, I rather prefer choosing this type of Item. <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.1 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $typeOfItems = array('Hosting', 'Setup', 'PromoHosting', 'Upgrade'); $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; if (!in_array($invoiceItem->type, $invoiceItem)) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . trim($dedicatedIP) )); } }); 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 1, 2022 Author Share Posted January 1, 2022 1 hour ago, andrezzz said: You and @pRieStaKos are right, sorry. Thank you so much for your suggestions 😊! Check this newer version! In my case, I rather prefer choosing this type of Item. <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.1 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $typeOfItems = array('Hosting', 'Setup', 'PromoHosting', 'Upgrade'); $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; if (!in_array($invoiceItem->type, $invoiceItem)) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . trim($dedicatedIP) )); } }); Thanks all you guys , you are all so kind . thanks very very a lot . and also thanks for @pRieStaKos and @string 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 1, 2022 Author Share Posted January 1, 2022 1 hour ago, andrezzz said: You and @pRieStaKos are right, sorry. Thank you so much for your suggestions 😊! Check this newer version! In my case, I rather prefer choosing this type of Item. <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.1 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $typeOfItems = array('Hosting', 'Setup', 'PromoHosting', 'Upgrade'); $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; if (!in_array($invoiceItem->type, $invoiceItem)) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . trim($dedicatedIP) )); } }); I will test this in my page , and Need I do anything in the clientaraeinvoices.php ? 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 1, 2022 Share Posted January 1, 2022 Just now, TimRef said: I will test this in my page , and Need I do anything in the clientaraeinvoices.php ? Nothing to edit, just create a file in your Hooks folder (`/whmcspath/includes/hooks`). 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 Just now, andrezzz said: Nothing to edit, just create a file in your Hooks folder (`/whmcspath/includes/hooks`). Thanks after check , the page shows blank page ./clientarea.php?action=invoices maybe met some issues. 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 2, 2022 Share Posted January 2, 2022 2 minutes ago, TimRef said: Thanks after check , the page shows blank page ./clientarea.php?action=invoices maybe met some issues. Do you have Discord or Anydesk, so that I can help you further more? 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted January 2, 2022 Share Posted January 2, 2022 13 minutes ago, TimRef said: if (!in_array($invoiceItem->type, $invoiceItem)) return; Array is $typeOfItems. Not $invoiceItem 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 2, 2022 Share Posted January 2, 2022 (edited) 4 minutes ago, pRieStaKos said: Array is $typeOfItems. Not $invoiceItem Omg, I'm sleeping standing up, updated it. Update: I can't edit the message, so I will let it here. <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.1 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $typeOfItems = array('Hosting', 'Setup', 'PromoHosting', 'Upgrade'); $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; if (!in_array($invoiceItem->type, $typeOfItems)) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . trim($dedicatedIP) )); } }); Edited January 2, 2022 by andrezzz 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 5 minutes ago, pRieStaKos said: Array is $typeOfItems. Not $invoiceItem Thanks . I replaced all $invoiceItem to $typeOfItems . also shows blank page . in the phpmyadmin `tblerrorlog` , I found this error : file name : vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/ConfigurationController.php message: strpos(): Empty needle 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 5 minutes ago, andrezzz said: Omg, I'm sleeping standing up, updated it. Thanks for your help . 🤞 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted January 2, 2022 Share Posted January 2, 2022 1 minute ago, TimRef said: Thanks . I replaced all $invoiceItem to $typeOfItems . also shows blank page . in the phpmyadmin `tblerrorlog` , I found this error : file name : vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/ConfigurationController.php message: strpos(): Empty needle Go to Configuration and enable Display Errors to see what is wrong. 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 7 minutes ago, andrezzz said: Omg, I'm sleeping standing up, updated it. Update: I can't edit the message, so I will let it here. <?php /** * Invoice with Primary/Dedicated IP WHMCS Hook version 1.1 * * @package WHMCS * @copyright Andrezzz * @link https://www.andrezzz.pt * @author André Antunes <andreantunes@andrezzz.pt> */ if (!defined('WHMCS')) { exit(header('Location: https://www.andrezzz.pt')); } use WHMCS\Database\Capsule; add_hook('InvoiceCreation', 1, function($vars) { global $_LANG; $typeOfItems = array('Hosting', 'Setup', 'PromoHosting', 'Upgrade'); $invoiceItems = Capsule::table('tblinvoiceitems')->where('invoiceid', $vars['invoiceid'])->get(); foreach ($invoiceItems as $invoiceItem) { if ($invoiceItem->relid === 0) return; if (!in_array($invoiceItem->type, $typeOfItems)) return; $dedicatedIP = Capsule::table('tblhosting')->where('id', $invoiceItem->relid)->value('dedicatedip'); Capsule::table('tblinvoiceitems')->where('id', $invoiceItem->id)->update(array( 'description' => $invoiceItem->description . "\n" . $_LANG['primaryIP'] . ': ' . trim($dedicatedIP) )); } }); update to this , but still not working , also shows blank page . 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 1 minute ago, pRieStaKos said: Go to Configuration and enable Display Errors to see what is wrong. already enabled , but still shows blank . 0 Quote Link to comment Share on other sites More sharing options...
pRieStaKos Posted January 2, 2022 Share Posted January 2, 2022 2 minutes ago, TimRef said: already enabled , but still shows blank . Activity log will show the issue on smarty. Go to Admin Area and follow the smarty error 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 2, 2022 Share Posted January 2, 2022 8 minutes ago, TimRef said: Thanks . I replaced all $invoiceItem to $typeOfItems . also shows blank page . in the phpmyadmin `tblerrorlog` , I found this error : file name : vendor/whmcs/whmcs-foundation/lib/Admin/Setup/General/UriManagement/ConfigurationController.php message: strpos(): Empty needle That error, doesn't come from my Hook, do you have any other recent Hook? 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 Just now, pRieStaKos said: Activity log will show the issue on smarty. Go to Admin Area and follow the smarty error did't get any errors in admin area activty log . And I got this error in phpmyadmin #0 /home/wwwroot/my.xxx.com/vendor/whmcs/whmcs-foundation/lib/Invoice.php(0): WHMCS\Invoice->loadData() #1 /home/wwwroot/my.xxx.com/vendor/whmcs/whmcs-foundation/lib/Invoice.php(0): WHMCS\Invoice->getData() #2 /home/wwwroot/my.xxx.com/viewinvoice.php(0): WHMCS\Invoice->getModel() #3 {main} Message :Invalid invoice id provided Class : WHMCS\Exception\Module\NotServicable the attachment is for admin activity log . 0 Quote Link to comment Share on other sites More sharing options...
TimRef Posted January 2, 2022 Author Share Posted January 2, 2022 seems the hook page is Loaded , but not working . on page /clientarea.php?action=invoices . not showing anything . its a blank page . 0 Quote Link to comment Share on other sites More sharing options...
andrezzz Posted January 2, 2022 Share Posted January 2, 2022 3 minutes ago, TimRef said: did't get any errors in admin area activty log . And I got this error in phpmyadmin #0 /home/wwwroot/my.xxx.com/vendor/whmcs/whmcs-foundation/lib/Invoice.php(0): WHMCS\Invoice->loadData() #1 /home/wwwroot/my.xxx.com/vendor/whmcs/whmcs-foundation/lib/Invoice.php(0): WHMCS\Invoice->getData() #2 /home/wwwroot/my.xxx.com/viewinvoice.php(0): WHMCS\Invoice->getModel() #3 {main} Message :Invalid invoice id provided Class : WHMCS\Exception\Module\NotServicable the attachment is for admin activity log . Do you have this two enabled? -1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.