Skip to content

Commit

Permalink
Merge pull request #556 from PAWECOGmbH/development
Browse files Browse the repository at this point in the history
Dev to Staging
  • Loading branch information
ptruessel authored Nov 20, 2024
2 parents 2cad34d + d346834 commit 9b5f9d9
Show file tree
Hide file tree
Showing 5 changed files with 246 additions and 159 deletions.
65 changes: 50 additions & 15 deletions www/backend/core/com/invoices.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -1459,13 +1459,8 @@ component displayname="invoices" output="false" {
// Build the link in order to download the pdf without login
local.dl_link = application.mainURL & "/account-settings/invoice/print?pdf=" & local.uuid;

// Get the invoicing email address
// Get the customer data
local.customerData = application.objCustomer.getCustomerData(local.customerID);
if (len(trim(local.customerData.billingEmail))) {
local.toEmail = local.customerData.billingEmail;
} else {
local.toEmail = local.customerData.email;
}

local.invoicePerson = "";
if (structKeyExists(local.invoiceData, "userID") and (local.invoiceData.userID) gt 0) {
Expand Down Expand Up @@ -1494,8 +1489,8 @@ component displayname="invoices" output="false" {
");
}

// Send activation link
mail to="#local.toEmail#" from="#application.fromEmail#" subject="#getTrans('titInvoiceReady', local.customerData.language)#" type="html" {
// Send invoice
mail to="#getInvoiceEmail(customerID=local.customerID)#" from="#application.fromEmail#" subject="#getTrans('titInvoiceReady', local.customerData.language)#" type="html" {
include template="/config.cfm";
include template="/frontend/core/mail_design.cfm";
}
Expand Down Expand Up @@ -1537,13 +1532,8 @@ component displayname="invoices" output="false" {

try {

// Get the invoicing email address
// Get the customer data
local.customerData = application.objCustomer.getCustomerData(local.customerID);
if (len(trim(local.customerData.billingEmail))) {
local.toEmail = local.customerData.billingEmail;
} else {
local.toEmail = local.customerData.email;
}

local.invoicePerson = "";
if (structKeyExists(local.invoiceData, "userID") and (local.invoiceData.userID) gt 0) {
Expand Down Expand Up @@ -1574,7 +1564,7 @@ component displayname="invoices" output="false" {
}

// Send activation link
mail to="#local.toEmail#" from="#application.fromEmail#" subject="#variables.mailTitle#" type="html" {
mail to="#getInvoiceEmail(customerID=local.customerID)#" from="#application.fromEmail#" subject="#variables.mailTitle#" type="html" {
include template="/config.cfm";
include template="/frontend/core/mail_design.cfm";
}
Expand Down Expand Up @@ -1654,7 +1644,52 @@ component displayname="invoices" output="false" {
}


public string function getInvoiceEmail(numeric userID, numeric customerID) {

local.userEmail;
local.customerEmail;
local.billingEmail;
local.invoiceEmail;

// Get data using the userID
if (structKeyExists(arguments, "userID") and arguments.userID gt 0) {

local.qUserData = application.objCustomer.getUserDataByID(arguments.userID);
local.userEmail = local.qUserData.strEmail;

// Get data using the customerID
} else if (structKeyExists(arguments, "customerID") and arguments.customerID gt 0) {

local.customerEmail = application.objCustomer.getCustomerData(arguments.customerID).email;
local.billingEmail = application.objCustomer.getCustomerData(arguments.customerID).billingEmail;
local.userEmail = application.objUser.getAllUsers(arguments.customerID).strEmail;

// Send back with error
} else {
return "Eighter the userID or the customerID must be passed in!";
}

// First, we check the billing address
if (application.objGlobal.checkEmail(local.billingEmail)) {
local.invoiceEmail = local.billingEmail;
return local.invoiceEmail;
}

//Second, check the customers email address
if (application.objGlobal.checkEmail(local.customerEmail)) {
local.invoiceEmail = local.customerEmail;
}

// If neighter the billing nor the customer email address is valid, return the users email address
if (!len(trim(local.billingEmail)) and !len(trim(local.customerEmail))) {

local.invoiceEmail = local.userEmail;

}

return local.invoiceEmail;

}



Expand Down
25 changes: 19 additions & 6 deletions www/backend/core/com/plans.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,21 @@ component displayname="plans" output="false" {


// Get plans using the groupID
public array function getPlans(required numeric planGroupID) {
public array function getPlans(numeric planGroupID) {

local.whereQuery;
local.planGroupID = 0;
if (structKeyExists(arguments, "planGroupID")) {
local.planGroupID = arguments.planGroupID;
local.whereQuery = "WHERE plans.intPlanGroupID = " & local.planGroupID;
}

local.getPlan = queryExecute (
options = {datasource = application.datasource},
params = {
languageID: {type: "numeric", value: variables.lngID},
currencyID: {type: "numeric", value: variables.currencyID},
planGroupID: {type: "numeric", value: arguments.planGroupID}
planGroupID: {type: "numeric", value: local.planGroupID}
},
sql = "
SELECT
Expand Down Expand Up @@ -306,7 +313,7 @@ component displayname="plans" output="false" {
LEFT JOIN currencies ON 1=1
AND plan_prices.intCurrencyID = currencies.intCurrencyID
WHERE plans.intPlanGroupID = :planGroupID
#local.whereQuery#
ORDER BY plans.intPrio
Expand Down Expand Up @@ -575,7 +582,7 @@ component displayname="plans" output="false" {
languageID: {type: "numeric", value: variables.lngID}
},
sql = "
SELECT blnCheckmark,
SELECT blnCheckmark, intPlanFeatureID, intPlansPlanFeatID,
(
IF
(
Expand Down Expand Up @@ -606,11 +613,14 @@ component displayname="plans" output="false" {
local.structFeatVal = structNew();
local.structFeatVal['value'] = '';
local.structFeatVal['checkmark'] = 0;
local.structFeatVal['id'] = 0;
local.structFeatVal['planFeatureID'] = 0;

if (local.qFeatValue.recordCount) {
local.structFeatVal['value'] = local.qFeatValue.strValue;
local.structFeatVal['checkmark'] = local.qFeatValue.blnCheckmark;

local.structFeatVal['id'] = local.qFeatValue.intPlansPlanFeatID;
local.structFeatVal['planFeatureID'] = local.qFeatValue.intPlanFeatureID;
}

return local.structFeatVal;
Expand All @@ -623,6 +633,7 @@ component displayname="plans" output="false" {

local.planStruct = structNew();
local.planStruct['planID'] = 0;
local.planStruct['planGroupID'] = 0;
local.planStruct['planName'] = "";
local.planStruct['status'] = '';
local.planStruct['maxUsers'] = 1;
Expand All @@ -648,7 +659,7 @@ component displayname="plans" output="false" {
SELECT bookings.intBookingID, bookings.strRecurring, bookings.intPlanID, bookings.strStatus,
DATE_FORMAT(bookings.dteStartDate, '%Y-%m-%e') as dteStartDate,
DATE_FORMAT(bookings.dteEndDate, '%Y-%m-%e') as dteEndDate,
plans.intMaxUsers, plans.blnFree,
plans.intMaxUsers, plans.blnFree, plans.intPlanGroupID,
(
IF
(
Expand Down Expand Up @@ -705,6 +716,7 @@ component displayname="plans" output="false" {
if (local.qCurrentPlan.currentrow eq 1) {

local.planStruct['planID'] = local.qCurrentPlan.intPlanID;
local.planStruct['planGroupID'] = local.qCurrentPlan.intPlanGroupID;
local.planStruct['planName'] = local.qCurrentPlan.strPlanName;
local.planStruct['status'] = local.qCurrentPlan.strStatus;
local.planStruct['maxUsers'] = local.qCurrentPlan.intMaxUsers;
Expand All @@ -723,6 +735,7 @@ component displayname="plans" output="false" {

// Append the second plan to the existing struct
local.nextPlan['planID'] = local.qCurrentPlan.intPlanID;
local.planStruct['planGroupID'] = local.qCurrentPlan.intPlanGroupID;
local.nextPlan['planName'] = local.qCurrentPlan.strPlanName;
local.nextPlan['maxUsers'] = local.qCurrentPlan.intMaxUsers;
local.nextPlan['startDate'] = dateFormat(local.qCurrentPlan.dteStartDate, 'yyyy-mm-dd');
Expand Down
29 changes: 29 additions & 0 deletions www/backend/core/handler/sysadmin/plans.cfm
Original file line number Diff line number Diff line change
Expand Up @@ -774,8 +774,12 @@ if (structKeyExists(form, "edit_features")) {
"
)
}
if (thisField eq "text") {
thisText = evaluate("text_#thisFeatureID#");
// Overwrite the text value
queryExecute(
options = {datasource = application.datasource},
params = {
Expand All @@ -790,6 +794,31 @@ if (structKeyExists(form, "edit_features")) {
AND intPlanFeatureID = :thisFeatureID
"
)
// If text value is empty in the default language, empty in other languages too
if (!len(thisText)) {
queryExecute(
options = {datasource = application.datasource},
params = {
planID: {type: "numeric", value: form.edit_features},
thisFeatureID: {type: "numeric", value: thisFeatureID}
},
sql = "
UPDATE plans_plan_features_trans
SET strValue = ''
WHERE intPlansPlanFeatID =
(
SELECT intPlansPlanFeatID
FROM plans_plan_features
WHERE intPlanFeatureID = :thisFeatureID
AND intPlanID = :planID
)
"
)
}
}
}
Expand Down
Loading

0 comments on commit 9b5f9d9

Please sign in to comment.