Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

1 Neutral

About Tapeix

  • Rank
    Level 2 Member

Recent Profile Visitors

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

  1. The final code looks like this. <?php /** Check latefee status * 1 = no latefees to be applied, 0 = latefees to be applied * You can use the following message to display a custom message to clients with latefees enabled: * {if $latefeesoverride = 1}You are charged $10.00 administration costs{/if} * Made by brain! (ref. https://whmcs.community/topic/305334-access-smarty-gettemplatevars-in-mail-template/) */ use WHMCS\Database\Capsule; add_hook('EmailTplMergeFields', 1, function($vars) { $merge_fields = []; $merge_fields['latefeesoverride'] = "Latefeesoverride status"; return $merge_fields; }); add_hook('EmailPreSend', 1, function($vars) { $validtemplates = array("Invoice Payment Reminder","Invoice Payment Confirmation","First Invoice Overdue Notice","Second Invoice Overdue Notice","Third Invoice Overdue Notice"); if (in_array($vars["messagename"], $validtemplates)) { $merge_fields = $vars['mergefields']; $clientid = $merge_fields['client_id']; $overridelatefees = Capsule::table('tblclients')->where('id', $clientid)->value('latefeeoveride'); $merge_fields['latefeesoverride'] = $overridelatefees; return $merge_fields; } });
  2. Wow, Brian. That is very kind of you. Meanwhile, I've almost got it to work, but could figure it out how to process the following output. [{"latefeeoveride":0}] You have made the code much more clearer. I mean, look at my chunky code. 😄 Code: <?php use WHMCS\Database\Capsule; add_hook('EmailTplMergeFields', 1, function($vars) { $merge_fields = []; $merge_fields['latefeeoverides'] = "Latefeeoverides status"; return $merge_fields; }); add_hook('EmailPreSend', 1, function($vars) { $merge_fields = []; if (!array_key_exists('latefeeoverides', $vars['mergefields'])) { $result = Capsule::table('tblinvoices') ->select('latefeeoveride') ->join('tblclients', 'tblinvoices.userid', '=', 'tblclients.id') ->where("tblinvoices.id", $vars['relid']) ->get(); $merge_fields['latefeeoverides'] = $result; } else { $merge_fields['latefeeoverides'] = "abc"; } return $merge_fields; }); Moreover, I didn't know that $vars contained the client_id; I couldn't debug the mailoutput, so I decided to use a join instead. #doyourhomework I think I'll keep experimenting to better understand how things work, like this: $validtemplates = array("Invoice Payment Reminder","Invoice Payment Confirmation","First Invoice Overdue Notice","Second Invoice Overdue Notice","Third Invoice Overdue Notice"); But once again, thanks! I'll install your code within the next few minutes.
  3. Having me working with capsule for the first time is being a hard time. 😉 While this query works: SELECT latefeeoverides FROM tblinvoices WHERE tblinvoices.id = 8231611 JOIN tblclients ON tblclients.id=tblinvoices.userid This obvously doesn't because WHMCS didn't implement Laravel 1 on 1: Capsule::table('SELECT latefeeoverides FROM tblinvoices WHERE tblinvoices.id = ? JOIN tblclients ON tblclients.id=tblinvoices.userid', $vars['relid']); But unfortunately my attempt to rewrite the query to WHMCS standards doesn't work either: use WHMCS\Database\Capsule; add_hook('EmailPreSend', 1, function($vars) { $merge_fields = []; if (!array_key_exists('latefeeoverides', $vars['mergefields'])) { $merge_fields['latefeeoverides'] = Capsule::table('tblinvoices') ->select("latefeeoverides") ->join("tblclients ON tblclients.id=tblinvoices.userid") ->where("tblinvoices.id = ?", $vars['relid'] ); } return $merge_fields; }); # ADD MERGE FIELDS TO MAIL TEMPLATE add_hook('EmailTplMergeFields', 1, function($vars) { $merge_fields = []; $merge_fields['latefeeoverides'] = "Latefeeoverides status"; return $merge_fields; }); Even my attempt to use the deprecated select_query function didn't work: $table = "tblinvoices"; $fields = "latefeeoveride"; $where = array( "tblinvoices.id" => $vars['relid'], ); $sort = "id"; $sortorder = "ASC"; $limits = "1"; $join = "tblclients ON tblinvoices.userid=tblclients.id"; $result = select_query($table, $fields, $where,$sort,$sortorder,$limits, $join); while ($data = mysql_fetch_array($result)) { $merge_fields['latefeeoverides'] = $data['latefeeoveride']; } For now I'll take a break. 🙂
  4. Well I have been using the following code for years to redirect and it has been working well. {if $templatefile == 'homepage'} {if $loggedin} <html> <body> <script type="text/javascript"> window.location.replace("https://domaincom/clientarea.php"); </script> </body> </html> {/if} {/if} The code determines the current template, then checks if the user is logged in and then redirects the user to the page. It takes about 2 seconds to process.
  5. The following PHP code will display a message when latefee overide is enabled. GLOBAL $smarty; if ($smarty->getTemplateVars()['client']['latefeeoveride'] == 0) { print("show message"); } However, this code cannot be included within the mail templates. Instead, I have to rewrite the following syntax within the boundries of smarty. $smarty->getTemplateVars()['client']['latefeeoveride'] Can anyone help me with that? I'm looking forward to your suggestions.
  6. I'm looking for ModulesGarden lifetime licenses. If you have, for example, a lifetime license of the DNS Manager module and are not using it anymore; please let me know and I'm happy to take it over. Thanks!
  7. Well it surely works, but doesn't sync GSuite users automatically from the Reseller portal. Someone should definitely work on a better integration.
  8. Update: I think I can declare a variable by using this method. File: {ROOT}/newpage.php use WHMCS\Database\Capsule; $clientName = Capsule::table('tblclients')->where('id',$ca->getUserID())->value('firstname'); $ca->assign('clientname', $clientName); File: {ROOT}/templates/six/newpage.tpl <p>{$clientname}</p> However, no output is shown.
  9. Where you at? I have created a custom page by adding two files: > {ROOT}/newpage.php > {ROOT}/templates/six/newpage.tpl What do you want to achieve? I'd like to execute a SQL select query . The easiest way is to do that within the smarty tags from my .tpl page, as I can print those values directly. Since that mysql_query is depreciated, I have to use WHMCS\Database\Capsule. Unfortunately, it seems that Capsule is limited to .php files as I couldn't get it to work inside my .tpl file. Whenever I try to call PDO from inside the smarty tags, I receive the following error: "Error: Class 'Capsule' not found". What is your SQL query? $query_downloads = mysql_query(" SELECT B.id, B.title, B.description FROM tblproduct_downloads A JOIN tbldownloads B ON A.download_id = B.id WHERE B.title LIKE \"%SLA%\" "); What is your question? Well, I'd like to know how I can run this query and print the output in my .tpl file. I know how to write and process SQL queries, but not how I would share the variables between newpage.php and /templates/six/newpage.tpl. The "Interacting with the Database" article does not share similar examples. I hope someone can point me to the right direction. Thanks.
  10. Situation I currently have three DirectAdmin servers that are managing the DNS records of ~ 50 domains. I'd like to edit those DNS records from the customer area in WHMCS. To do so, I need a module that manages the DirectAdmin DNS records in WHMCS. Question I'm looking for a module that is capable of managing the DNS records in WHMCS by synchronising with DirectAdmin. I have found only one working module, better known as DNS Manager by ModulesGarden. This module unfortunately is pretty complicated (as DNS records are managed in "DNS Zones") and prior that above my budget. If anyone knows an alternative to DNS Manager by ModulesGarden that works with DirectAdmin, please let me know.
  11. I see. Unfortunately you'll have to write an API yourself that connects both worlds with each other; OR make use of the default WHMCS shopping cart which I do.
  12. I'd like to adjust the WHMCS Cron Job Activity e-mail template. Does someone know what hook I can use to apply some css styling? Some issues I'm currently experiencing: > Logo max-width is set to 100%, instead of, lets say, 300px, causing our logo to be spread very wide across the mail template; > Button "View Full Summary" not aligned properly; > WHMCS branding is added (I mean, why? We pay for an unbranded license and still see WHMCS branding in the Cron Job Activity e-mail)
  13. That's amazing Steven! I've added the URL if-then-else and tried it in our live environment. I can confirm it works. <?php add_hook('ClientAdd', 1, function($vars) { $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $client = \WHMCS\User\Client::find($vars['userid']); try { if ($client) { if (strpos($url, 'CNAMEdomain.com') !== false) { $client->groupid = 3; $client->save(); } else /** Default group **/ { $client->groupid = 1; $client->save(); } } } catch (Exception $e) { //TODO error handler } }); p.s. where did you learn that ClientAdd doesn't support a return? I couldn't find it in the documentation.
  14. That's a great idea @brian! I've tried to write a little hook by myself. Unfortunately I couldn't get it to work. Any thoughts? <?php add_hook('ClientAdd', 1, function($vars) { return array( 'create' => true, 'groupid' => 3, ); } ); The URL if statement would look something like this: $url = 'https://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; if (strpos($url,'CNAMEdomain') !== false) { }
  • 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