Jump to content


Regular Collector
  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About cjsmith87

  • Rank
    Junior Member

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hey, thanks for the reply, this is what i tried, I have just tried it again to be sure but the widget doesnt show up. I am thinking it is to do with this line of code: $codeToUse = App::getFromRequest('codeToUse'); It works when it is in the hooks.php file but not when it is in its own class. Please see the code below for the use statements i include: namespace WHMCS\Module\Addon\fourmatrix\Widgets; use APP; use WHMCS\Session; use WHMCS\Database\Capsule; use WHMCS\Service\Service; use WHMCS\Module\AbstractWidget; use WHMCS\Module\Addon\fourmatrix\Tools; class AccessCodeWidget extends \WHMCS\Module\AbstractWidget
  2. When an anonymous ticket is posted, then assigned by admin to a client, it shows as being from the main contact on the account, even if it not. There doesnt seem to be a way to link a ticket to a client contact once it has been posted? Only the client. Ideally it should allow a contact from the selected client to link to and if no contact is selected, it should show the original name and email that posted the ticket. I can override a lot of this using the client side templates but cant change anything on the admin side as the tickets isnt fully themed. Any ideas anyone?
  3. Sorry, I cant seem to edit my post so commenting again to add a bit more detail to the last code sample: class AccessCodeWidget extends \WHMCS\Module\AbstractWidget { protected $title = 'Generate Access Code'; protected $description = ''; protected $weight = 150; protected $columns = 1; protected $cache = false; protected $cacheExpiry = 120; protected $requiredPermission = ''; public function getData() { return array(); } public function generateOutput($data) { $codeToUse = App::getFromRequest('codeToUse'); $codeToSet = ''; if ($codeToUse!=''){ $fullCode = base64_encode(Tools::encrypt(str_replace('-','',$codeToUse))); $codeToSet = substr($fullCode,0,3) . '-' . substr($fullCode,3,3) . '-' . substr($fullCode,6,3); } return <<<EOF <br> <div class="container-fluid"> <div class="row"> <div class="col-xs-12"> <div class="form-group"> <div class="input-group"> <input id="codeToCheck" type="text" class="form-control" placeholder="Enter 9 Digit Code..." value={$codeToUse}> <span id="generateCode" class="input-group-btn"><button class="btn btn-info" type="button">Generate</button></span> </div> <br> <div class="input-group"> <input id="validationCode" type="text" class="form-control" placeholder="___-___-___" value="{$codeToSet}" readonly> <span id="copyCode" class="input-group-btn"><button class="btn btn-info" type="button">Copy</button></span> </div> </div> </div> </div> </div> <script> $(document).ready(function() { $('#generateCode').click(function() { refreshWidget('AccessCodeWidget', 'codeToUse=' + $('#codeToCheck').val()); }); $('#copyCode').click(function() { var copyText = document.getElementById("validationCode"); copyText.select(); document.execCommand("copy"); }); }); </script> EOF; } }
  4. Because of the way WHMCS sends all Ticket Emails to main Client even if logged by a Contact, we disable the standard emails and send our own using hooks and PHPMailer so that we can only send them to the contact if one is defined. Is there a better way to achieve this? It seems a bit hacky! add_hook('TicketClose', 1, function($vars) { Tools::sendTicketEmail($vars,'closed'); }); function sendTicketEmail($vars, $type) { // Get the required data $headertt = file_get_contents('<Removed>/headerCustom.tpl'); $footertt = file_get_contents('<Removed>/footerCustom.tpl'); $ticket_details = Capsule::table('tbltickets')->where('id', $vars['ticketid'])->first(); $department_details = Capsule::table('tblticketdepartments')->where('id', $ticket_details->did)->first(); $emailsURL = '<Removed>/viewticket.php?tid=' . $ticket_details->tid .'&c=' . $ticket_details->c; $headertt = str_replace('{$emailsURL}', $emailsURL , $headertt); // Create a new PHPMailer object $mail = new PHPMailer(TRUE); // Set TRUE to enable exceptions $mail->IsSMTP(); // Set mailer to use SMTP $mail->Host = 'smtp.office365.com'; // Specify main and backup server $mail->Port = 587; // Set the SMTP port ... The second problem i am having with this is when i am calling it from my modules Hooks.php, My SendTicketEmail function wont work unless it is in the hooks.php file. I have tried adding it to my tools class, which has other methods in it that call fine, but it cant seem to find the PHPMailer class? I have tried lots of requires... statements but cant seem to get it right. What do i need to do to get a custom class access the standard WHMCS classes that seem to be available to Hooks.php?
  5. I am probably missing something obvious here but where should i put the code for an admin Widget for my Addon Module? I want it to live inside my module, not the widgets folder. Is this possible? At the moment it is in my hooks.php like this: add_hook('AdminHomeWidgets', 1, function() { return new AccessCodeWidget(); }); then the class is above. I was trying to put the class into a separate file so that my hooks.php isnt full of loads of code. I tried putting it in its own file AccessCodeWidget.php in the lib folder but then $codeToUse = App::getFromRequest('codeToUse'); Stopped working, even if is put Using App; in the file and set the namespace to be that of my module?
  6. Hi, We have a "Web Connector" addon to one of our product that needs to be an addon, not a configuration option, as we need it to have its own licence key and to be active as soon as we accept the order. I know this isnt possible within WHMCS so i am trying to use hooks to override what gets created. So far I have worked out i can override the price in the basket using the following: add_hook('OrderAddonPricingOverride', 1, function($vars) { $return = []; if (!array_key_exists('proddata', $vars)) { /** * This is an addon only purchase for existing service */ $serviceData = Service::find($vars['serviceid']); if ($serviceData && $vars['addonid'] == 3 && $serviceData->packageId == 2) { } } return $return; }); Inside the IF I will need to use the $serviceData to calculate the new price from the next due date of the service. I dont think i can set the next due date here as it seems to only accept recurring and setup. Another option I have looked at is: add_hook('CartTotalAdjustment', 1, function($vars) { $cart_adjustments = array(); if (sizeof($vars['products']) > 0) { } elseif (array_key_exists('addons',$vars)) { $serviceData = Service::find($vars['addons'][0]['productid']); print($serviceData->nextduedate); $cart_adjustments = [ "description" => "Partial Subscription", "amount" => "-18.00", "taxed" => false, ]; } return $cart_adjustments; }); to deduct the relevant amount from the order, which is great because it also shows on the invoice. The only problem with this is that the invoice has the wrong dates on the product line e.g. Addon (######) - <Product Name> (02/04/2019 - 01/04/2020) * Also, the next due date is wrong as it runs for a year from the date it is created where as I want it to finish on the same date as the main service. I think I can use: add_hook('AfterShoppingCartCheckout', 1, function($vars) { print_r($vars); }); to update the values directly in the database but is this the best way to do it? It seems like a bit of a hack for something that you would expect to be built into a billing system
  7. Hi, I am new to WHMCS and I am trying to import my clients from our spreadsheet, I am using the API via a .net win forms app i have created. I think i have managed to get the customers/clients imported, i am just struggling with importing the Products for them. I can see AddOrder on the API but I cannot see how to set the date. I need to import all the current orders with their start and end dates. The documentation at https://developers.whmcs.com/api-reference/addorder/ does not show any dates, can it be set as part of the billingcycle or configoptions arrays? There is no documentation on how to find out what should be in these 2 arrays. Any help would be much appreciated! Thanks
  8. Welcome to WHMCS.Community cjsmith87! We're glad you're here please take some time to familiarise yourself with the Community Rules & Guidelines and take a moment to introduce yourself to other WHMCS.Community members in the Introduce Yourself Board.

  • 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