Kian Posted June 26, 2020 Share Posted June 26, 2020 (edited) I've seen there's a feature request submitted 7 years ago about bulk auto recalculate. I know you can do that from phpMyAdmin or with a script but enough is enough. <? /** * Bulk Auto Recalculate Client Domain & Products/Services * * @writtenby Kian * */ use WHMCS\Database\Capsule; add_hook('AdminAreaHeaderOutput', 1, function($vars) { if ($vars['filename'] == 'clientssummary' AND $_GET['userid'] AND in_array($_GET['kata'], array('bulkAutoRecalculateP', 'bulkAutoRecalculateD'))) { $adminUsername = ''; // Optional for WHMCS 7.2 and later if ($_GET['kata'] == 'bulkAutoRecalculateP') { foreach(Capsule::table('tblhosting')->where('userid', '=', $_GET['userid'])->pluck('id') as $v) { localAPI('UpdateClientProduct', array('serviceid' => $v, 'autorecalc' => true), $adminUsername); } header('Location: clientssummary.php?userid=' . $_GET['userid']); die(); } elseif ($_GET['kata'] == 'bulkAutoRecalculateD') { foreach (Capsule::table('tbldomains')->where('userid', '=', $_GET['userid'])->pluck('id') as $v) { localAPI('UpdateClientDomain', array('domainid' => $v, 'autorecalc' => true), $adminUsername); } header('Location: clientssummary.php?userid=' . $_GET['userid']); die(); } } return <<<HTML <script> $(document).ready(function(){ $('[href*="affiliates.php?action=edit&id="], [href*="clientssummary.php?userid="][href*="&activateaffiliate=true&token="]').closest('li').after(('<li><a href="#" id="kata_BulkAutoRecalculate"><i class="fas fa-fw fa-sliders-h" style="width:16px;text-align:center;"></i> Bulk Auto Recalculate</a></li>')); $('#kata_BulkAutoRecalculate').on('click', function(e){ e.preventDefault(); $('#modalAjaxTitle').html('Bulk Auto Recalculate'); $('#modalAjaxBody').html('<div class="container col-md-12"><div class="row"><div class="col-md-6 text-center"><div class="panel panel-default"><div class="panel-body"><p><i class="fas fa-box fa-5x"></i></p><p><small>Auto Recalculate Customer\'s <strong>Products/Services</strong></small></p><p><a href="clientssummary.php?userid={$_GET['userid']}&kata=bulkAutoRecalculateP" class="btn btn-info btn-block">Recalculate Now »</a></p></div></div></div><div class="col-md-6 text-center"><div class="panel panel-default"><div class="panel-body"><p><i class="fas fa-globe fa-5x"></i></p><p><small>Auto Recalculate Customer\'s <strong>Domains</strong></small></p><p><a href="clientssummary.php?userid={$_GET['userid']}&kata=bulkAutoRecalculateD" class="btn btn-info btn-block">Recalculate Now »</a></p></div></div></div></div></div>'); $('#modalAjax .modal-submit').addClass('hidden'); $('#modalAjaxLoader').hide(); $('#modalAjax .modal-dialog').addClass('modal-lg'); $('#modalAjax').modal('show'); }) }) </script> HTML; }); Edited June 26, 2020 by Kian 7 Quote Link to comment Share on other sites More sharing options...
baymax Posted August 6, 2020 Share Posted August 6, 2020 Thanks a lot for this! I had to add php in the beginning though. <?php 0 Quote Link to comment Share on other sites More sharing options...
PatInt Posted September 16, 2020 Share Posted September 16, 2020 Hi there May I ask what is updated by this? I'm trying to simplify the process of updating due dates, invoices etc, and this sounds interesting. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted September 16, 2020 Author Share Posted September 16, 2020 1 minute ago, PatInt said: May I ask what is updated by this? Recurring amount. 1 minute ago, PatInt said: I'm trying to simplify the process of updating due dates, invoices etc, and this sounds interesting. Are you talking about overriding "Next Due Date" in bulk? 0 Quote Link to comment Share on other sites More sharing options...
PatInt Posted September 16, 2020 Share Posted September 16, 2020 Just now, Kian said: Recurring amount. Are you talking about overriding "Next Due Date" in bulk? Yes...I realise this is restricted to the current user though. Also the generate due invoices seems to miss anything over 1 month old, so just fishing around for solutions and handy tools as I'm new to WHMCS. 0 Quote Link to comment Share on other sites More sharing options...
baymax Posted September 17, 2020 Share Posted September 17, 2020 Technically, it didn't miss anything over 1 month old. If it doesn't generate the invoice(s), it means it's already been generated unless you deleted them manually. If that's not the case, try settings the next due date to a different date, save, and change it to the original expiry date, save again. Try generate due invoice again and see if that fixes the issue. 0 Quote Link to comment Share on other sites More sharing options...
persis Posted March 6, 2021 Share Posted March 6, 2021 Hi @Kian Many thanks for this useful hook. I test it with whmcs 8.1.3 and work great. could you please add this features to this hook? - work for all customers at once. -work automatic with whmcs cron. thank you in advance 0 Quote Link to comment Share on other sites More sharing options...
persis Posted July 10, 2021 Share Posted July 10, 2021 On 3/6/2021 at 2:04 PM, persis said: Hi @Kian Many thanks for this useful hook. I test it with whmcs 8.1.3 and work great. could you please add this features to this hook? - work for all customers at once. -work automatic with whmcs cron. thank you in advance <?php use WHMCS\Database\Capsule; add_hook('AfterCronJob', 1, function($vars) { $adminUsername = ''; // Optional for WHMCS 7.2 and later foreach(Capsule::table('tblhosting')->pluck('id') as $v) { localAPI('UpdateClientProduct', array('serviceid' => $v, 'autorecalc' => true), $adminUsername); } foreach (Capsule::table('tbldomains')->pluck('id') as $v) { localAPI('UpdateClientDomain', array('domainid' => $v, 'autorecalc' => true), $adminUsername); } }); 0 Quote Link to comment Share on other sites More sharing options...
Ardeshir Posted January 19, 2022 Share Posted January 19, 2022 (edited) On 7/10/2021 at 7:06 PM, persis said: <?php use WHMCS\Database\Capsule; add_hook('AfterCronJob', 1, function($vars) { $adminUsername = ''; // Optional for WHMCS 7.2 and later foreach(Capsule::table('tblhosting')->pluck('id') as $v) { localAPI('UpdateClientProduct', array('serviceid' => $v, 'autorecalc' => true), $adminUsername); } foreach (Capsule::table('tbldomains')->pluck('id') as $v) { localAPI('UpdateClientDomain', array('domainid' => $v, 'autorecalc' => true), $adminUsername); } }); Thanks, but it doesn't work as expected. Does it need any modification for whmcs 8.3.2 ? or I missed something 😞 Edited January 19, 2022 by Ardeshir 0 Quote Link to comment Share on other sites More sharing options...
Juanzo Posted January 25, 2023 Share Posted January 25, 2023 It seems the feature request shows a 404 now, not even a feature request for this now? The inflation is growing everywhere, but imagine living in Argentina where it's always 2 digits yearly. This module worked fine but not yet for PHP 8, hopefully there is a native feature for this, to mass update the pricing of all services to match the price configured at the product. 0 Quote Link to comment Share on other sites More sharing options...
Kian Posted January 25, 2023 Author Share Posted January 25, 2023 It shows a 404 because they deleted it leaving no trace 😄 Btw stop waiting and do it yourself. Sadly there's no other option. I recently managed to auto-update domains in line with changes in Registrars costs. Next week I'll add monthly updates for all prices based on inflation rate retreived from official statistical offices like Eurostat, Istat etc. It is well worth the effort since at the end of the day it lets you cover unnecessary financial loss. It puzzles me how this is still not part of WHMCS but it is what it is. After 10 years we are still waiting. The lesson here is: hire someone that can code it or do it youself 😐 1 Quote Link to comment Share on other sites More sharing options...
TheHostingHeroes Posted August 14, 2023 Share Posted August 14, 2023 (edited) Removed Edited August 14, 2023 by TheHostingHeroes . 0 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.