Jump to content

Tapeix

Member
  • Posts

    148
  • Joined

  • Last visited

About Tapeix

Recent Profile Visitors

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

Tapeix's Achievements

Senior Member

Senior Member (3/3)

1

Reputation

  1. Ah, okay. I still find 149$ a year very expensive for managing ~ 100 domains. Do you offer small companies discount?
  2. 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; } });
  3. 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.
  4. 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. 🙂
  5. 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.
  6. 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.
  7. 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!
  8. Well it surely works, but doesn't sync GSuite users automatically from the Reseller portal. Someone should definitely work on a better integration.
  9. 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.
  10. 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.
  11. 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.
  12. 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.
  13. 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)
×
×
  • 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