Skip to content

Commit 5cf050f

Browse files
authored
Merge pull request #666 from PAWECOGmbH/staging
Staging to Production
2 parents 9ae3fb8 + 1c53524 commit 5cf050f

5 files changed

Lines changed: 106 additions & 11 deletions

File tree

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
SET NAMES utf8mb4;
2+
SET FOREIGN_KEY_CHECKS = 0;
3+
4+
INSERT INTO system_translations (strVariable, strStringDE, strStringEN)
5+
VALUES
6+
('titTestPhaseExpired', 'Ihre Testphase ist abgelaufen', 'Your test phase has expired'),
7+
('msgModuleExpiredPurchase', 'Ihr Modul <b>@modulname@</b> ist leider abgelaufen. Bitte erwerben Sie es jetzt, um weiterzuarbeiten. Vielen Dank!', 'Your <b>@modulname@</b> module has unfortunately expired. Please purchase it now to continue working. Thank you!'),
8+
('msgPlanExpiredPurchase', 'Ihr Plan <b>@modulname@</b> ist leider abgelaufen. Bitte erwerben Sie ihn jetzt, um weiterzuarbeiten. Vielen Dank!', 'Your <b>@planname@</b> plan has unfortunately expired. Please purchase it now to continue working. Thank you!')
9+
;
10+
11+
SET FOREIGN_KEY_CHECKS = 1;

www/Application.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
119119

120120
// For local development only,
121121
// automatically reinitialize the application without using the reinit URL parameter
122-
if (variables.environment eq "dev") {
122+
/* if (variables.environment eq "dev") {
123123
structClear(APPLICATION);
124124
onApplicationStart();
125125
application.langStruct = application.objLanguage.initLanguages();
126-
}
126+
} */
127127

128128
// Check if the user is logged in as a sysadmin
129129
if (structKeyExists(session, "sysadmin") and session.sysadmin) {

www/backend/core/com/book.cfc

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,9 +928,9 @@ component displayname="book" output="false" {
928928

929929
// Make log
930930
if (local.moduleID gt 0) {
931-
application.objLog.logWrite("user", "info", "A module has been updated [CustomerID: #local.customerID#, ModuleID: #local.moduleID#, Recurring: #local.recurring#, Status: #local.status#]");
931+
application.objLog.logWrite("scheduletask", "info", "A booking for a module has been updated [CustomerID: #local.customerID#, ModuleID: #local.moduleID#, Recurring: #local.recurring#, Status: #local.status#]");
932932
} else {
933-
application.objLog.logWrite("user", "info", "A plan has been updated [CustomerID: #local.customerID#, PlanID: #local.planID#, Recurring: #local.recurring#, Status: #local.status#]");
933+
application.objLog.logWrite("scheduletask", "info", "A booking for a plan has been updated [CustomerID: #local.customerID#, PlanID: #local.planID#, Recurring: #local.recurring#, Status: #local.status#]");
934934
}
935935

936936
return local.qBooking.intBookingID;
@@ -1023,5 +1023,85 @@ component displayname="book" output="false" {
10231023
}
10241024

10251025

1026+
// Send an email to the customer after a module or plan has expired
1027+
public void function sendExpiredEmail(required numeric customerID, numeric moduleID=0, numeric planID=0) {
1028+
1029+
local.getTrans = application.objLanguage.getTrans;
1030+
1031+
// Get customer data
1032+
local.qCustomer = queryExecute (
1033+
options = {datasource = application.datasource},
1034+
params = {
1035+
customerID: {type: "numeric", value: arguments.customerID}
1036+
},
1037+
sql = "
1038+
SELECT strEmail, strFirstName, strLastName, strLanguage
1039+
FROM users
1040+
WHERE intCustomerID = :customerID
1041+
AND blnSuperAdmin = 1
1042+
AND blnActive = 1
1043+
"
1044+
)
1045+
1046+
if (local.qCustomer.recordCount) {
1047+
1048+
// Expired email for a module
1049+
if (arguments.moduleID gt 0) {
1050+
1051+
local.objModule = new backend.core.com.modules(language=local.qCustomer.strLanguage);
1052+
local.moduleData = local.objModule.getModuleData(arguments.moduleID);
1053+
local.moduleName = local.moduleData.name;
1054+
1055+
variables.mailTitle = local.getTrans('titTestPhaseExpired', local.qCustomer.strLanguage) & ": " & local.moduleName;
1056+
local.mailText = replace(getTrans('msgModuleExpiredPurchase', local.qCustomer.strLanguage), '@modulname@', local.moduleName);
1057+
local.logText = "Expiration email for the module has been sent to the customer";
1058+
1059+
}
1060+
1061+
// Expired email for a plan
1062+
else if (arguments.planID gt 0) {
1063+
1064+
local.objPlan = new backend.core.com.plans(language=local.qCustomer.strLanguage);
1065+
local.planData = local.objPlan.getPlanDetail(arguments.planID);
1066+
local.planName = local.planData.planName;
1067+
1068+
variables.mailTitle = local.getTrans('titTestPhaseExpired', local.qCustomer.strLanguage) & ": " & local.planName;
1069+
local.mailText = replace(getTrans('msgPlanExpiredPurchase', local.qCustomer.strLanguage), '@planname@', local.planName);
1070+
local.logText = "Expiration email for the plan has been sent to the customer";
1071+
1072+
}
1073+
1074+
}
1075+
1076+
variables.mailType = "html";
1077+
1078+
cfsavecontent (variable = "variables.mailContent") {
1079+
echo("
1080+
#getTrans('titHello', local.qCustomer.strLanguage)# #local.qCustomer.strFirstName# #local.qCustomer.strLastName#<br><br>
1081+
#local.mailText#<br><br>
1082+
<a class='mail-btn' href='#application.mainURL#/login' target='_blank'>Login</a>
1083+
<br><br>
1084+
#getTrans('txtRegards', local.qCustomer.strLanguage)#<br>
1085+
#getTrans('txtYourTeam', local.qCustomer.strLanguage)#<br>
1086+
#application.appOwner#
1087+
");
1088+
}
1089+
1090+
// Send email
1091+
loop query=local.qCustomer {
1092+
1093+
mail to="#local.qCustomer.strEmail#" from="#application.fromEmail#" subject="#variables.mailTitle#" type="html" {
1094+
include template="/config.cfm";
1095+
include template="/frontend/core/mail_design.cfm";
1096+
}
1097+
1098+
// Make Log
1099+
application.objLog.logWrite("scheduletask", "info", local.logText & " [CustomerID: #arguments.customerID#, Email: #local.qCustomer.strEmail#, ModuleID: #arguments.moduleID#, PlanID: #arguments.planID#]");
1100+
1101+
}
1102+
1103+
}
1104+
1105+
10261106

10271107
}

www/frontend/core/scheduletasks/subscriptions.cfm

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -554,24 +554,28 @@ if (url.pass eq variables.schedulePassword) {
554554
}
555555
556556
557-
// Set expired plans or modules to "expired"
558-
} else if (dateFormat(qRenewBookings.dteEndDate, "yyyy-mm-dd") lt dateFormat(now(), "yyyy-mm-dd")) {
557+
// Set expired test phases to "expired" if its not already done
558+
} else if (dateFormat(qRenewBookings.dteEndDate, "yyyy-mm-dd") lt dateFormat(now(), "yyyy-mm-dd") and qRenewBookings.strStatus eq "test") {
559559
560560
// Update booking table
561561
updateStruct = structNew();
562562
updateStruct['bookingID'] = qRenewBookings.intBookingID;
563563
updateStruct['status'] = "expired";
564564
565-
updateBooking = objBook.updateBooking(updateStruct);
566-
567-
// Make log
568-
objLogs.logWrite("scheduletask", "info", "A plan or module has been set to expired [BookingID: CustomerID: #qRenewBookings.intBookingID#, #qRenewBookings.intCustomerID#]");
565+
objBook.updateBooking(updateStruct);
569566
570567
// Update scheduletasks
571568
if (qRenewBookings.intModuleID gt 0) {
572569
objModules.distributeScheduler(moduleID=qRenewBookings.intModuleID, customerID=qRenewBookings.intCustomerID, status='expired');
573570
}
574571
572+
// Send expired email to customer
573+
local.moduleID = len(qRenewBookings.intModuleID) ? qRenewBookings.intModuleID : 0;
574+
local.planID = len(qRenewBookings.intPlanID) ? qRenewBookings.intPlanID : 0;
575+
576+
objBook.sendExpiredEmail(qRenewBookings.intCustomerID, local.moduleID, local.planID);
577+
578+
575579
}
576580
577581
}

www/frontend/core/scheduletasks/tasks.cfm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ if (url.pass eq variables.schedulePassword) {
119119
120120
lastRunSuccessful = false;
121121
122-
// Stop schedulecontrol
122+
// Set the last run to the current time and 'runnning' to false
123123
application.objSysadmin.stopScheduleControl(url.task);
124124
125125
// Make log

0 commit comments

Comments
 (0)