cocabean Posted January 17, 2011 Share Posted January 17, 2011 Hi, I have set this up but the email I think the trial mod sent is this; <style>body,td { font-family: verdana; font-size: 11px; font-weight: normal; } a { color: #0000ff; } </style> <p><a href="MY URL" target="_blank"><img src="MY URL" alt="" border="0" /></a></p> I put the email templates in the products category, am I meant to put it in general? Thanks 0 Quote Link to comment Share on other sites More sharing options...
cocabean Posted January 19, 2011 Share Posted January 19, 2011 OK I figured out this problem. Is there a way to put in the email an upgrade link so the user doesn't have to go through there account? 0 Quote Link to comment Share on other sites More sharing options...
pjs32 Posted June 11, 2011 Share Posted June 11, 2011 Hi, We are finding that the warning emails are being sent every day.ie. the client gets 4 First Notice Trial Ending emails,then on the 5th day they get a a second warning - this is then sent every day until the third warning etc. so should if ($regdate < $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate < $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate < $warndays3) { sendMessage("$warn3",$id); }elseif ($regdate < $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate < $warndays1) { sendMessage("$warn1",$id); } be changed to if ($regdate = $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate = $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate = $warndays3) { sendMessage("$warn3",$id); }elseif ($regdate = $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate = $warndays1) { sendMessage("$warn1",$id); } 0 Quote Link to comment Share on other sites More sharing options...
ExsysHost Posted June 16, 2011 Author Share Posted June 16, 2011 Open the file end_free_trials_hook.php and look at lines 28 to 33. I think you'll find your answer there. I'd still like an answer to my question please... can I just delete the lines that mention the second and third reminder without breaking stuff? Thanks Yes just delete the lines: elseif ($regdate = $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate = $warndays1) { sendMessage("$warn1",$id); } then set the warn days 3 line in the configuration portion. 0 Quote Link to comment Share on other sites More sharing options...
Si Posted July 11, 2011 Share Posted July 11, 2011 Just a quick check on this: It says in a few places, that the latest version is 1.4 However, no matter where I download it from, the file itself says it is 1.3 Is this an error in the file, or is there somewhere else I need to look to get 1.4 ? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 22, 2011 Share Posted July 22, 2011 Can I insert a 0 (zero) on each expiration date, just for testing it? I did that, and I deleted the lines related to the other trial products, leaving only the ones related to a single product, uploaded to the hooks folder, and it simply doesnt work. Do I also have to setup an exclusive cron task to this hook? 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 24, 2011 Share Posted July 24, 2011 It is working, but it is not sending any email, do I have to create the mail templates for this case manually? What about the amount of days? I can see that in the original the first warning comes like 13 days before, second 17, third 23... Do I just have to setup a completely free product and then use its ID on the script? 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 25, 2011 Share Posted July 25, 2011 thx for nothing. 0 Quote Link to comment Share on other sites More sharing options...
Si Posted July 25, 2011 Share Posted July 25, 2011 thx for nothing. hmmm maybe not the best way to win friends and influence people with your 3rd post on these forums. It was Sunday when you posted your questions and the provider of this mod appears to be in the USA. So it's probably only lunchtime on a Monday. Patience and a little reading of the previous posts may be the order of the day to help you. Chill. 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 26, 2011 Share Posted July 26, 2011 hmmm maybe not the best way to win friends and influence people with your 3rd post on these forums. It was Sunday when you posted your questions and the provider of this mod appears to be in the USA. So it's probably only lunchtime on a Monday. Patience and a little reading of the previous posts may be the order of the day to help you. Chill. I'm really sorry, really. I even created the mail templates, configured them in the script too, by replacing the lines, and it still doesnt work, and there is more, I must wait until midnight to test it................................. 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 26, 2011 Share Posted July 26, 2011 hmmm maybe not the best way to win friends and influence people with your 3rd post on these forums. It was Sunday when you posted your questions and the provider of this mod appears to be in the USA. So it's probably only lunchtime on a Monday. Patience and a little reading of the previous posts may be the order of the day to help you. Chill. ps: I already quadruple read the whole topic. not kidding..... 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 26, 2011 Share Posted July 26, 2011 hmmm maybe not the best way to win friends and influence people with your 3rd post on these forums. It was Sunday when you posted your questions and the provider of this mod appears to be in the USA. So it's probably only lunchtime on a Monday. Patience and a little reading of the previous posts may be the order of the day to help you. Chill. My first question was posted on friday. July 22. Was you able to put that extension to send the email templates? 0 Quote Link to comment Share on other sites More sharing options...
frank-sinatra Posted July 27, 2011 Share Posted July 27, 2011 Problem Solved. 0 Quote Link to comment Share on other sites More sharing options...
Juanzo Posted August 10, 2011 Share Posted August 10, 2011 Would you mind giving us a hand? We adapted the code to send 2 warnings instead of 3 because client would receive 9 emails in total (Client area details, order confirmation, invoice, account information, 3 warnings, a suspend and a termination email). Yet, the hook is sending the first warning for 3 consecutive days. Since I'm testing this before release it our public, would you mind taking a quick look? function end_free_trials_hook($args) { if (!function_exists("ModuleBuildParams")) require(ROOTDIR."/includes/modulefunctions.php"); $freetrials = array(); /* * Duplicate the free trials array for each trial product you want to offer */ $freetrials[0] = array( "pid" => "63", // product id "warndays1" => "9", // how many days before sending first warning "warndays2" => "15", // how many days before sending second warning "suspenddays" => "30", // how many days before suspending "terminatedays" => "40", // how many days before terminating "warn1" => "Trial Primer Aviso", // email template to send for first warning "warn2" => "Trial Segundo Aviso", // email template to send for second warning "suspend" => "Trial - Suspension", // email template to send when the trial period ends "terminate" => "Trial - Cancelado" // email template to send when customers data is deleted ); /* * Do not edit below this line * */ foreach ($freetrials as $key => $data) { $pid = $data["pid"]; $warn1 = $data["warn1"]; $warn2 = $data["warn2"]; $suspend = $data["suspend"]; $terminate = $data["terminate"]; $warndays1 = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["warndays1"],date("Y"))); $warndays2 = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["warndays2"],date("Y"))); $suspenddays = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["suspenddays"],date("Y"))); $terminatedays = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["terminatedays"],date("Y"))); $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; $result = full_query($query); while($rows = mysql_fetch_array($result)) { $id = $rows["id"]; $regdate = $rows["regdate"]; $module = $rows["servertype"]; if (!function_exists($module."_ConfigOptions")) require_once(ROOTDIR."/modules/servers/$module/$module.php"); if ($regdate < $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate < $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate < $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate < $warndays1) { sendMessage("$warn1",$id); } } } } add_hook("DailyCronJob",1,"end_free_trials_hook"); 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 10, 2011 Share Posted August 10, 2011 It looks like you are comparing strings instead of integers. Your dates should be integer values to compare them properly in your if statements. Replace the corresponding code with this and then try it. Also you may want to try "<=" for a comparison operator. As that will run the warnings on the date set rather than the next day. $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps $warndays2 = (int)$data["warndays2"]*86400; $suspenddays = (int)$data["suspenddays"]*86400; $terminatedays = (int)$data["terminatedays"]*86400; $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; $result = full_query($query); while($rows = mysql_fetch_array($result)) { $id = $rows["id"]; $regdate = time()-strtotime($rows["regdate"]); $module = $rows["servertype"]; 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 11, 2011 Share Posted August 11, 2011 To improve on what I said early and correct it. Here is the replacement part to the part above. The code originally posted sent an email every day to the user "warn1" until "warn2" is triggered which sent the "warn2" email every day until "suspend" is triggered which would send the "suspend" email every day until its finally terminated. The following only sends the emails within the specific day of the actions time frame and will not send out a gazillion emails (unless you run the cron more than once a day). $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps $warndays2 = (int)$data["warndays2"]*86400; $suspenddays = (int)$data["suspenddays"]*86400; $terminatedays = (int)$data["terminatedays"]*86400; $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; $result = full_query($query); while($rows = mysql_fetch_array($result)) { $id = $rows["id"]; $regdate = time()-strtotime("2011-07-28"); $withinTime = array($terminatedays-$regdate, $suspenddays-$regdate, $warndays2-$regdate, $warndays1-$regdate ); $module = $rows["servertype"]; if (!function_exists($module."_ConfigOptions")) require_once(ROOTDIR."/modules/servers/$module/$module.php"); if ($withinTime[0] <= 86400 && $withinTime[0] > 0) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($withinTime[1] <= 86400 && $withinTime[1] > 0) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn1",$id); } 0 Quote Link to comment Share on other sites More sharing options...
Juanzo Posted August 11, 2011 Share Posted August 11, 2011 Thanks for your help Jeremy, I'll try the code later and report back results! 0 Quote Link to comment Share on other sites More sharing options...
Si Posted August 12, 2011 Share Posted August 12, 2011 I'm finding this very difficult to follow to get set up. I just want to send 3 reminders as well. I'm giving 30 days free trials. 1st reminder 14 days before the 30th day. 2nd reminder 7 days before the 30th day. 3rd reminder 3 days before the 30th day Then the suspension email on the day. Then the termination email 7 days past the 30th day. You write in the code, we are to enter: "warndays1" => "14", // how many days before sending first warning So, as you can see I put 14. (as in 14 days for the first reminder). Is this not correct? Can you provide the code I need to achieve what I'm after please? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
ExsysHost Posted August 18, 2011 Author Share Posted August 18, 2011 The initial code is the best example possible, you are reversing the order, notice in the example it increase the days for each arning level starting with 2 days then 5 days then 12 days. I'm finding this very difficult to follow to get set up. I just want to send 3 reminders as well. I'm giving 30 days free trials. 1st reminder 14 days before the 30th day. 2nd reminder 7 days before the 30th day. 3rd reminder 3 days before the 30th day Then the suspension email on the day. Then the termination email 7 days past the 30th day. You write in the code, we are to enter: So, as you can see I put 14. (as in 14 days for the first reminder). Is this not correct? Can you provide the code I need to achieve what I'm after please? Thanks. 0 Quote Link to comment Share on other sites More sharing options...
ExsysHost Posted August 18, 2011 Author Share Posted August 18, 2011 I had already posted a fix to this: http://forum.whmcs.com/showpost.php?p=190371&postcount=29 Would you mind giving us a hand? We adapted the code to send 2 warnings instead of 3 because client would receive 9 emails in total (Client area details, order confirmation, invoice, account information, 3 warnings, a suspend and a termination email). Yet, the hook is sending the first warning for 3 consecutive days. Since I'm testing this before release it our public, would you mind taking a quick look? function end_free_trials_hook($args) { if (!function_exists("ModuleBuildParams")) require(ROOTDIR."/includes/modulefunctions.php"); $freetrials = array(); /* * Duplicate the free trials array for each trial product you want to offer */ $freetrials[0] = array( "pid" => "63", // product id "warndays1" => "9", // how many days before sending first warning "warndays2" => "15", // how many days before sending second warning "suspenddays" => "30", // how many days before suspending "terminatedays" => "40", // how many days before terminating "warn1" => "Trial Primer Aviso", // email template to send for first warning "warn2" => "Trial Segundo Aviso", // email template to send for second warning "suspend" => "Trial - Suspension", // email template to send when the trial period ends "terminate" => "Trial - Cancelado" // email template to send when customers data is deleted ); /* * Do not edit below this line * */ foreach ($freetrials as $key => $data) { $pid = $data["pid"]; $warn1 = $data["warn1"]; $warn2 = $data["warn2"]; $suspend = $data["suspend"]; $terminate = $data["terminate"]; $warndays1 = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["warndays1"],date("Y"))); $warndays2 = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["warndays2"],date("Y"))); $suspenddays = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["suspenddays"],date("Y"))); $terminatedays = date("Y-m-d",mktime(0,0,0,date("m"),date("d")-$data["terminatedays"],date("Y"))); $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; $result = full_query($query); while($rows = mysql_fetch_array($result)) { $id = $rows["id"]; $regdate = $rows["regdate"]; $module = $rows["servertype"]; if (!function_exists($module."_ConfigOptions")) require_once(ROOTDIR."/modules/servers/$module/$module.php"); if ($regdate < $terminatedays) { sendMessage("$terminate",$id); $sql = "insert into tblcancelrequests (date,relid,reason,type) VALUES (now(),".$id.",'Trial Account','Immediate')"; $rs = mysql_query($sql); }elseif ($regdate < $suspenddays) { sendMessage("$suspend",$id); ServerSuspendAccount($id); }elseif ($regdate < $warndays2) { sendMessage("$warn2",$id); }elseif ($regdate < $warndays1) { sendMessage("$warn1",$id); } } } } add_hook("DailyCronJob",1,"end_free_trials_hook"); It looks like you are comparing strings instead of integers. Your dates should be integer values to compare them properly in your if statements. Replace the corresponding code with this and then try it. Also you may want to try "<=" for a comparison operator. As that will run the warnings on the date set rather than the next day. $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps $warndays2 = (int)$data["warndays2"]*86400; $suspenddays = (int)$data["suspenddays"]*86400; $terminatedays = (int)$data["terminatedays"]*86400; $query = "SELECT tblhosting.id,tblhosting.regdate,tblproducts.servertype FROM tblhosting INNER JOIN tblproducts ON tblproducts.id=tblhosting.packageid WHERE packageid=".(int)$pid." AND regdate<'$warndays1' AND (domainstatus='Active' OR domainstatus='Suspended')"; $result = full_query($query); while($rows = mysql_fetch_array($result)) { $id = $rows["id"]; $regdate = time()-strtotime($rows["regdate"]); $module = $rows["servertype"]; 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 18, 2011 Share Posted August 18, 2011 I had already posted a fix to this:http://forum.whmcs.com/showpost.php?...1&postcount=29 Maybe a silly question, but why don't you simply update the community file that everyone downloads? 0 Quote Link to comment Share on other sites More sharing options...
Si Posted August 18, 2011 Share Posted August 18, 2011 The initial code is the best example possible, you are reversing the order, notice in the example it increase the days for each arning level starting with 2 days then 5 days then 12 days. OK, maybe it wasn't the best idea to try and explain it to you in the way that I did, so let me show you my code and see if you can tell me where I'm going wrong please. (Emails are all configured and the titles are correct). (P.S. I've been in the hosting business for 12 years and working with WHMCS for 5 years and coding and configuring many mods). I just find this 'jeremyhaber' guy is totally confusing the whole issue when your instructions in the download show this? "warndays1" => "9", // how many days before sending first warning then jeremyhaber writes $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps Which is correct? Anyway, here is what I have for one of my products: $freetrials[0] = array( "pid" => "190", // product id "warndays1" => "14", // how many days before sending first warning "warndays2" => "7", // how many days before sending second warning "warndays3" => "3", // how many days before sending third warning "suspenddays" => "1", // how many days before suspending "terminatedays" => "8", // how many days before terminating "warn1" => "First Notice Trial Ending", // email template to send for first warning "warn2" => "Second Notice Trial Ending", // email template to send for second warning "warn3" => "Final Notice Trial Ending", // email template to send for third warning "suspend" => "Trial Ended", // email template to send when the trial period ends "terminate" => "Trial Account Deleted" // email template to send when customers data is deleted ); It's a 30 day trial and I'm expecting the 1st warning on the 14th day The 2nd warning sent 7 days before it ends The 3rd warning sent 3 days before it ends and the 4th warning 1 day before it ends Then I expect the suspended account email to be suspended on the day it ends Then I expect the system to terminate/cancel it 8 days after. Is my code correct? If not....can you give me the correct code please? Thank you. 0 Quote Link to comment Share on other sites More sharing options...
jeremyhaber Posted August 18, 2011 Share Posted August 18, 2011 I'm finding this very difficult to follow to get set up. I just want to send 3 reminders as well. I'm giving 30 days free trials. 1st reminder 14 days before the 30th day. 2nd reminder 7 days before the 30th day. 3rd reminder 3 days before the 30th day Then the suspension email on the day. Then the termination email 7 days past the 30th day. You write in the code, we are to enter: So, as you can see I put 14. (as in 14 days for the first reminder). Is this not correct? Can you provide the code I need to achieve what I'm after please? Thanks. I've attached the modified version I did to this thread. To achieve this you need to do minor modifications. $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps $warndays2 = (int)$data["warndays2"]*86400; $suspenddays = (int)$data["suspenddays"]*86400; $terminatedays = (int)$data["terminatedays"]*86400; Should be: $warndays1 = (int)$data["warndays1"]*86400; // 86400 = 60*60*24 Which is one day in linux timestamps $warndays2 = (int)$data["warndays2"]*86400; $warndays3 = (int)$data["warndays3"]*86400; $suspenddays = (int)$data["suspenddays"]*86400; $terminatedays = (int)$data["terminatedays"]*86400; ------------------------------------------------------------------------------------ $withinTime = array($terminatedays-$regdate, $suspenddays-$regdate, $warndays2-$regdate, $warndays1-$regdate ); Should be: $withinTime = array($terminatedays-$regdate, $suspenddays-$regdate, $warndays3-$regdate, $warndays2-$regdate, $warndays1-$regdate ); ------------------------------------------------------------------------------------ }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn1",$id); } Should be: }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn3",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[4] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn1",$id); } Hope that helps end_free_trials_hook.zip 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 18, 2011 Share Posted August 18, 2011 @Si, the code posted in the community addon section doesn't work correctly. It sends emails based on registration date, but continuously does so everyday between each "warnday", which is what jeremyhaber attempted to fix. Unfortunately the code "jeremyhaber" originally posted doesn't send emails at all that I can tell - but I haven't tried his new updates in post #48. I will do that today as I hope you will and report back. (I would really like to get this worked out!) Si your code looks correct except I think: "suspenddays" => "1", // how many days before suspending "terminatedays" => "8", // how many days before terminating Needs to be changed to this: "suspenddays" => "31", // how many days before suspending "terminatedays" => "38", // how many days before terminating 0 Quote Link to comment Share on other sites More sharing options...
mgaccess Posted August 18, 2011 Share Posted August 18, 2011 @jeremyhaber, I assume this was a typo ($withinTime[3] <= 86400 && $withinTime[2] )? }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn3",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[4] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn1",$id); } and should be changed to this: }elseif ($withinTime[2] <= 86400 && $withinTime[2] > 0) { sendMessage("$warn3",$id); }elseif ($withinTime[3] <= 86400 && $withinTime[3] > 0) { sendMessage("$warn2",$id); }elseif ($withinTime[4] <= 86400 && $withinTime[4] > 0) { sendMessage("$warn1",$id); 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.