From fe738bd50be185447364d6a9ae90625f4ee0f2b9 Mon Sep 17 00:00:00 2001 From: ptruessel Date: Thu, 21 Nov 2024 13:06:18 +0100 Subject: [PATCH 1/4] Email design adjustments --- www/backend/core/com/invoices.cfc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/backend/core/com/invoices.cfc b/www/backend/core/com/invoices.cfc index a2adb7f..44495d6 100644 --- a/www/backend/core/com/invoices.cfc +++ b/www/backend/core/com/invoices.cfc @@ -1481,7 +1481,7 @@ component displayname="invoices" output="false" { #getTrans('titHello', local.customerData.language)# #local.invoicePerson#

#getTrans('msgThanksForPurchaseFindInvoice', local.customerData.language)#

#getTrans('txtDownloadInvoice', local.customerData.language)#

- #getTrans('btnDownloadInvoice', local.customerData.language)# + #getTrans('btnDownloadInvoice', local.customerData.language)#

#getTrans('txtRegards', local.customerData.language)#
#getTrans('txtYourTeam', local.customerData.language)#
@@ -1555,7 +1555,7 @@ component displayname="invoices" output="false" { echo(" #getTrans('titHello', local.customerData.language)# #local.invoicePerson#

#getTrans('txtPleasePayInvoice', local.customerData.language)#

- #getTrans('txtViewInvoice', local.customerData.language)# + #getTrans('txtViewInvoice', local.customerData.language)#

#getTrans('txtRegards', local.customerData.language)#
#getTrans('txtYourTeam', local.customerData.language)#
From d3394f1df1f5f72d0e74c3f5d2e69ebe29f1f7be Mon Sep 17 00:00:00 2001 From: ptruessel Date: Thu, 21 Nov 2024 13:06:36 +0100 Subject: [PATCH 2/4] Mapping refactor --- www/backend/core/com/mappings.cfc | 351 ++++++++++++++++++ .../core/handler/sysadmin/mappings.cfm | 181 ++------- 2 files changed, 379 insertions(+), 153 deletions(-) create mode 100644 www/backend/core/com/mappings.cfc diff --git a/www/backend/core/com/mappings.cfc b/www/backend/core/com/mappings.cfc new file mode 100644 index 0000000..0a96939 --- /dev/null +++ b/www/backend/core/com/mappings.cfc @@ -0,0 +1,351 @@ +component displayname="mappings" output="false" { + + + // #### FRONTEND MAPPINGS + + public struct function newFrontendMapping(required struct mappingData) { + + local.mappingData = evalDataFrontendMapping(arguments.mappingData); + local.frontendMapping = {}; + + // Check for existing mapping + local.mappingData.mapping = checkFrontendMapping(local.mappingData.mapping); + + queryExecute( + options = {datasource = application.datasource, result="local.newMapping"}, + params = { + mapping: {type: "varchar", value: local.mappingData.mapping}, + path: {type: "varchar", value: local.mappingData.path}, + metaTitle: {type: "nvarchar", value: local.mappingData.metaTitle}, + metaDescription: {type: "nvarchar", value: local.mappingData.metaDescription}, + metaHTML: {type: "nvarchar", value: local.mappingData.metaHTML}, + createdByApp: {type: "boolean", value: local.mappingData.createdByApp} + }, + sql = " + INSERT INTO frontend_mappings (strMapping, strPath, strMetatitle, strMetadescription, strhtmlcodes, blnCreatedByApp) + VALUES (:mapping, :path, :metaTitle, :metaDescription, :metaHTML, :createdByApp) + " + ) + + if (local.newMapping.recordCount) { + + local.frontendMapping['id'] = local.newMapping.generated_key; + local.frontendMapping['mapping'] = local.mappingData.mapping; + local.frontendMapping['path'] = local.mappingData.path; + local.frontendMapping['metaTitle'] = local.mappingData.metaTitle; + local.frontendMapping['metaDescription'] = local.mappingData.metaDescription; + local.frontendMapping['metaHTML'] = local.mappingData.metaHTML; + local.frontendMapping['createdByApp'] = local.mappingData.createdByApp; + + } + + return local.frontendMapping; + + + + } + + public struct function editFrontendMapping(required struct mappingData, required numeric mappingID) { + + local.mappingData = evalDataFrontendMapping(arguments.mappingData); + + // Check for existing mapping + local.mappingData.mapping = checkFrontendMapping(local.mappingData.mapping, arguments.mappingID); + + local.frontendMapping = {}; + + queryExecute( + options = {datasource = application.datasource, result="local.editMapping"}, + params = { + mappingID = {type: "numeric", value: arguments.mappingID}, + mapping: {type: "varchar", value: local.mappingData.mapping}, + path: {type: "varchar", value: local.mappingData.path}, + metaTitle: {type: "nvarchar", value: local.mappingData.metaTitle}, + metaDescription: {type: "nvarchar", value: local.mappingData.metaDescription}, + metaHTML: {type: "nvarchar", value: local.mappingData.metaHTML}, + createdByApp: {type: "boolean", value: local.mappingData.createdByApp} + }, + sql = " + UPDATE frontend_mappings + SET strMapping = :mapping, + strPath = :path, + strMetatitle = :metaTitle, + strMetadescription = :metaDescription, + strhtmlcodes = :metaHTML, + blnCreatedByApp = :createdByApp + WHERE intFrontendMappingsID = :mappingID + " + ) + + if (local.editMapping.recordCount) { + + local.frontendMapping['id'] = arguments.mappingID; + local.frontendMapping['mapping'] = local.mappingData.mapping; + local.frontendMapping['path'] = local.mappingData.path; + local.frontendMapping['metaTitle'] = local.mappingData.metaTitle; + local.frontendMapping['metaDescription'] = local.mappingData.metaDescription; + local.frontendMapping['metaHTML'] = local.mappingData.metaHTML; + local.frontendMapping['createdByApp'] = local.mappingData.createdByApp; + + } + + return local.frontendMapping; + + + } + + private struct function evalDataFrontendMapping(required struct mappingData) { + + local.mapping; + local.stringForUrlSlug; + local.path; + local.metaTitle; + local.metaDescription; + local.metaHTML; + local.createdByApp = false; + + if (structKeyExists(arguments.mappingData, "mapping") and len(trim(arguments.mappingData.mapping))) { + local.mapping = application.objGlobal.cleanUpText(arguments.mappingData.mapping, 255); + } + if (structKeyExists(arguments.mappingData, "path") and len(trim(arguments.mappingData.path))) { + local.path = application.objGlobal.cleanUpText(arguments.mappingData.path, 255); + } + if (structKeyExists(arguments.mappingData, "metaTitle") and len(trim(arguments.mappingData.metaTitle))) { + local.metaTitle = application.objGlobal.cleanUpText(arguments.mappingData.metaTitle, 255); + } + if (structKeyExists(arguments.mappingData, "metaDescription") and len(trim(arguments.mappingData.metaDescription))) { + local.metaDescription = application.objGlobal.cleanUpText(arguments.mappingData.metaDescription, 3000); + } + if (structKeyExists(arguments.mappingData, "metaHTML") and len(trim(arguments.mappingData.metaHTML))) { + local.metaHTML = application.objGlobal.cleanUpText(arguments.mappingData.metaHTML, 3000); + } + + // If stringForUrlSlug is specified, we generate the URL slug from it + if (structKeyExists(arguments.mappingData, "stringForUrlSlug") and len(trim(arguments.mappingData.stringForUrlSlug))) { + local.slash = len(trim(arguments.mappingData.mapping)) ? "/" : ""; + local.mapping = local.mapping & local.slash & application.objGlobal.beautifyString(arguments.mappingData.stringForUrlSlug); + } + if (structKeyExists(arguments.mappingData, "createdByApp") and isBoolean(arguments.mappingData.createdByApp)) { + local.createdByApp = arguments.mappingData.createdByApp; + } + + return local; + + } + + private string function checkFrontendMapping(required string mapping, numeric mappingID) { + + local.mapping = arguments.mapping; + local.whereStatement; + + if (structKeyExists(arguments, "mappingID")) { + local.whereStatement = "AND intFrontendMappingsID <> " & arguments.mappingID; + } + + local.qCheckMapping = queryExecute( + options = {datasource = application.datasource}, + params = { + mapping: {type: "varchar", value: local.mapping} + }, + sql = " + SELECT intFrontendMappingsID + FROM frontend_mappings + WHERE strMapping = :mapping + #local.whereStatement# + " + ) + + // Set an appendix to the mapping + if (local.qCheckMapping.recordCount) { + local.mapping = local.mapping & "-" & left(application.objGlobal.getUUID(), 6); + } + + return local.mapping; + + } + + public boolean function deleteFrontendMapping(required numeric mappingID) { + + try { + + queryExecute( + options = {datasource = application.datasource}, + params = { + mappingID: {type: "numeric", value: arguments.mappingID} + }, + sql = " + DELETE FROM frontend_mappings + WHERE intFrontendMappingsID = :mappingID + " + ) + + return true; + + } catch (any) { + + return false; + + } + + } + + + // #### CUSTOM MAPPINGS + + public struct function newCustomMapping(required struct mappingData) { + + local.mappingData = evalDataCustomMapping(arguments.mappingData); + local.customMapping = {}; + + // Check for existing mapping + local.mappingData.mapping = checkCustomMapping(local.mappingData.mapping); + + queryExecute( + options = {datasource = application.datasource, result="local.newMapping"}, + params = { + mapping: {type: "varchar", value: local.mappingData.mapping}, + path: {type: "varchar", value: local.mappingData.path}, + admin: {type: "boolean", value: local.mappingData.admin}, + superadmin: {type: "boolean", value: local.mappingData.superadmin}, + sysadmin: {type: "boolean", value: local.mappingData.sysadmin} + }, + sql = " + INSERT INTO custom_mappings (strMapping, strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin) + VALUES (:mapping, :path, :admin, :superadmin, :sysadmin) + " + ) + + if (local.newMapping.recordCount) { + + local.customMapping['id'] = local.newMapping.generated_key; + local.customMapping['mapping'] = local.mappingData.mapping; + local.customMapping['path'] = local.mappingData.path; + + } + + return local.customMapping; + + + } + + public struct function editCustomMapping(required struct mappingData, required numeric mappingID) { + + local.mappingData = evalDataCustomMapping(arguments.mappingData); + + // Check for existing mapping + local.mappingData.mapping = checkCustomMapping(local.mappingData.mapping, arguments.mappingID); + + local.customMapping = {}; + + queryExecute( + options = {datasource = application.datasource, result="local.editMapping"}, + params = { + mappingID: {type: "numeric", value: arguments.mappingID}, + mapping: {type: "varchar", value: local.mappingData.mapping}, + thispath: {type: "varchar", value: local.mappingData.path}, + admin: {type: "boolean", value: local.mappingData.admin}, + superadmin: {type: "boolean", value: local.mappingData.superadmin}, + sysadmin: {type: "boolean", value: local.mappingData.sysadmin} + }, + sql = " + UPDATE custom_mappings + SET strMapping = :mapping, + strPath = :thispath, + blnOnlyAdmin = :admin, + blnOnlySuperAdmin = :superadmin, + blnOnlySysAdmin = :sysadmin + WHERE intCustomMappingID = :mappingID + " + ) + + if (local.editMapping.recordCount) { + + local.customMapping['id'] = arguments.mappingID; + local.customMapping['mapping'] = local.mappingData.mapping; + local.customMapping['path'] = local.mappingData.path; + + } + + return local.customMapping; + + + } + + + private struct function evalDataCustomMapping(required struct mappingData) { + + local.mapping; + local.path; + + if (structKeyExists(arguments.mappingData, "mapping") and len(trim(arguments.mappingData.mapping))) { + local.mapping = application.objGlobal.cleanUpText(arguments.mappingData.mapping, 255); + } + if (structKeyExists(arguments.mappingData, "path") and len(trim(arguments.mappingData.path))) { + local.path = application.objGlobal.cleanUpText(arguments.mappingData.path, 255); + } + + local.admin = arguments.mappingData.admin eq "admin" ? 1 : 0; + local.superadmin = arguments.mappingData.admin eq "superadmin" ? 1 : 0; + local.sysadmin = arguments.mappingData.admin eq "sysadmin" ? 1 : 0; + + return local; + + } + + private string function checkCustomMapping(required string mapping, numeric mappingID) { + + local.mapping = arguments.mapping; + local.whereStatement; + + if (structKeyExists(arguments, "mappingID")) { + local.whereStatement = "AND intCustomMappingID <> " & arguments.mappingID; + } + + local.qCheckMapping = queryExecute( + options = {datasource = application.datasource}, + params = { + mapping: {type: "varchar", value: local.mapping} + }, + sql = " + SELECT intCustomMappingID + FROM custom_mappings + WHERE strMapping = :mapping + #local.whereStatement# + " + ) + + // Set an appendix to the mapping + if (local.qCheckMapping.recordCount) { + local.mapping = local.mapping & "-" & left(application.objGlobal.getUUID(), 6); + } + + return local.mapping; + + } + + public boolean function deleteCustomMapping(required numeric mappingID) { + + try { + + queryExecute( + options = {datasource = application.datasource}, + params = { + mappingID: {type: "numeric", value: arguments.mappingID} + }, + sql = " + DELETE FROM custom_mappings + WHERE intCustomMappingID = :mappingID + " + ) + + return true; + + } catch (any) { + + return false; + + } + + } + +} \ No newline at end of file diff --git a/www/backend/core/handler/sysadmin/mappings.cfm b/www/backend/core/handler/sysadmin/mappings.cfm index 735a9a6..5d668dc 100644 --- a/www/backend/core/handler/sysadmin/mappings.cfm +++ b/www/backend/core/handler/sysadmin/mappings.cfm @@ -1,40 +1,14 @@ -if (structKeyExists(form, "new_mapping")) { +objMapping = new backend.core.com.mappings(); - param name="form.mapping" default=""; - param name="form.path" default=""; - param name="form.admin" default=""; +if (structKeyExists(form, "new_mapping")) { - admin = 0; - superadmin = 0; - sysadmin = 0; + newCustomMapping = objMapping.newCustomMapping(form); - if (form.admin eq "admin") { - admin = 1; - } - if (form.admin eq "superadmin") { - superadmin = 1; + if (structIsEmpty(newCustomMapping)) { + getAltert('Something went wrong!', 'danger'); } - if (form.admin eq "sysadmin") { - sysadmin = 1; - } - - - queryExecute( - options = {datasource = application.datasource}, - params = { - mapping: {type: "varchar", value: form.mapping}, - path: {type: "varchar", value: form.path}, - admin: {type: "boolean", value: admin}, - superadmin: {type: "boolean", value: superadmin}, - sysadmin: {type: "boolean", value: sysadmin} - }, - sql = " - INSERT INTO custom_mappings (strMapping, strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin) - VALUES (:mapping, :path, :admin, :superadmin, :sysadmin) - " - ) location url="#application.mainURL#/sysadmin/mappings" addtoken="false"; @@ -45,56 +19,19 @@ if (structKeyExists(form, "edit_mapping")) { if (structKeyExists(form, "delete")) { - queryExecute( - options = {datasource = application.datasource}, - params = { - mappingID: {type: "numeric", value: form.edit_mapping} - }, - sql = " - DELETE FROM custom_mappings WHERE intCustomMappingID = :mappingID - " - ) + deleteCustomMapping = objMapping.deleteCustomMapping(form.edit_mapping); - } else { + if (!deleteCustomMapping) { + getAlert("Could not delete the mapping!", "danger"); + } - param name="form.mapping" default=""; - param name="form.path" default=""; - param name="form.admin" default=""; + } else { - admin = 0; - superadmin = 0; - sysadmin = 0; + editCustomMapping = objMapping.editCustomMapping(form, form.edit_mapping); - if (form.admin eq "admin") { - admin = 1; + if (structIsEmpty(editCustomMapping)) { + getAltert('Something went wrong!', 'danger'); } - if (form.admin eq "superadmin") { - superadmin = 1; - } - if (form.admin eq "sysadmin") { - sysadmin = 1; - } - - queryExecute( - options = {datasource = application.datasource}, - params = { - mappingID: {type: "numeric", value: form.edit_mapping}, - mapping: {type: "varchar", value: form.mapping}, - thispath: {type: "varchar", value: form.path}, - admin: {type: "boolean", value: admin}, - superadmin: {type: "boolean", value: superadmin}, - sysadmin: {type: "boolean", value: sysadmin} - }, - sql = " - UPDATE custom_mappings - SET strMapping = :mapping, - strPath = :thispath, - blnOnlyAdmin = :admin, - blnOnlySuperAdmin = :superadmin, - blnOnlySysAdmin = :sysadmin - WHERE intCustomMappingID = :mappingID - " - ) } @@ -105,32 +42,11 @@ if (structKeyExists(form, "edit_mapping")) { if (structKeyExists(form, "new_mapping_frontend")) { - param name="form.mapping" default=""; - param name="form.path" default=""; - param name="form.metatitle" default=""; - param name="form.metadescription" default=""; - param name="form.htmlcodes" default=""; - - local.mapping = application.objGlobal.cleanUpText(form.mapping, 255); - local.path = application.objGlobal.cleanUpText(form.path, 255); - local.metatitle = application.objGlobal.cleanUpText(form.metatitle, 255); - local.metadescription = application.objGlobal.cleanUpText(form.metadescription, 3000); - local.htmlcodes = left(replace(form.htmlcodes, "invalidTag", "meta", "all"), 3000); - - queryExecute( - options = {datasource = application.datasource}, - params = { - mapping: {type: "varchar", value: local.mapping}, - path: {type: "varchar", value: local.path}, - metatitle: {type: "nvarchar", value: local.metatitle}, - metadescription: {type: "nvarchar", value: local.metadescription}, - htmlcodes: {type: "nvarchar", value: local.htmlcodes} - }, - sql = " - INSERT INTO frontend_mappings (strMapping, strPath, strMetatitle, strMetadescription, strhtmlcodes) - VALUES (:mapping, :path, :metatitle, :metadescription, :htmlcodes) - " - ) + newFrontendMapping = objMapping.newFrontendMapping(form); + + if (structIsEmpty(newFrontendMapping)) { + getAltert('Something went wrong!', 'danger'); + } location url="#application.mainURL#/sysadmin/mappings##frontend" addtoken="false"; @@ -140,60 +56,19 @@ if (structKeyExists(form, "new_mapping_frontend")) { if(structKeyExists(form, "edit_mapping_frontend")) { if (structKeyExists(form, "delete")) { - queryExecute( - options = {datasource = application.datasource}, - params = { - mappingID: {type: "numeric", value: form.edit_mapping_frontend} - }, - sql = " - DELETE FROM frontend_mappings WHERE intFrontendMappingsID = :mappingID - " - ) - queryExecute( - options = {datasource = application.datasource}, - params = { - mappingID: {type: "numeric", value: form.edit_mapping_frontend} - }, - sql = " - DELETE FROM frontend_mappings_trans WHERE intFrontendMappingsID = :mappingID - " - ) + deleteFrontendMapping = objMapping.deleteFrontendMapping(form.edit_mapping_frontend); + + if (!deleteFrontendMapping) { + getAlert("Could not delete the mapping!", "danger"); + } } else { - param name="form.edit_mapping_frontend" default=""; - param name="form.mapping" default=""; - param name="form.path" default=""; - param name="form.metatitle" default=""; - param name="form.metadescription" default=""; - param name="form.htmlcodes" default=""; - - local.mapping = application.objGlobal.cleanUpText(form.mapping, 255); - local.path = application.objGlobal.cleanUpText(form.path, 255); - local.metatitle = application.objGlobal.cleanUpText(form.metatitle, 255); - local.metadescription = application.objGlobal.cleanUpText(form.metadescription, 3000); - local.htmlcodes = left(replace(form.htmlcodes, "invalidTag", "meta", "all"), 3000); - - queryExecute( - options = {datasource = application.datasource}, - params = { - mappingID: {type: "numeric", value: form.edit_mapping_frontend}, - mapping: {type: "varchar", value: local.mapping}, - path: {type: "varchar", value: local.path}, - metatitle: {type: "nvarchar", value: local.metatitle}, - metadescription: {type: "nvarchar", value: local.metadescription}, - htmlcodes: {type: "nvarchar", value: local.htmlcodes} - }, - sql = " - UPDATE frontend_mappings - SET strMapping = :mapping, - strPath = :path, - strMetatitle = :metatitle, - strMetadescription = :metadescription, - strhtmlcodes = :htmlcodes - WHERE intFrontendMappingsID = :mappingID - " - ) + editFrontendMapping = objMapping.editFrontendMapping(form, form.edit_mapping_frontend); + + if (structIsEmpty(editFrontendMapping)) { + getAltert('Something went wrong!', 'danger'); + } } From e098cbe26019682c2f422e3c628e80a755badeca Mon Sep 17 00:00:00 2001 From: ptruessel Date: Thu, 21 Nov 2024 13:06:54 +0100 Subject: [PATCH 3/4] Added CreatedByApp --- www/backend/core/com/sysadmin.cfc | 1 + 1 file changed, 1 insertion(+) diff --git a/www/backend/core/com/sysadmin.cfc b/www/backend/core/com/sysadmin.cfc index 8799f97..b6337a3 100644 --- a/www/backend/core/com/sysadmin.cfc +++ b/www/backend/core/com/sysadmin.cfc @@ -583,6 +583,7 @@ component displayname="sysadmin" output="false" { sql = " SELECT * FROM frontend_mappings + WHERE blnCreatedByApp = 0 " ); From b09ecd09be514af95ab589adddadfcb111640de4 Mon Sep 17 00:00:00 2001 From: ptruessel Date: Thu, 21 Nov 2024 17:17:28 +0100 Subject: [PATCH 4/4] Bugfix in plan bookings and added remove button for waiting plans --- www/backend/core/com/book.cfc | 18 ++++++++--- www/backend/core/com/cancel.cfc | 42 ++++++++++++++++++++++++++ www/backend/core/handler/book.cfm | 4 --- www/backend/core/handler/book_plan.cfm | 13 ++++++-- www/backend/core/handler/cancel.cfm | 35 ++++++++++++++++----- www/backend/core/views/plan_view.cfm | 7 ++++- 6 files changed, 99 insertions(+), 20 deletions(-) diff --git a/www/backend/core/com/book.cfc b/www/backend/core/com/book.cfc index 3e58c06..0254a4e 100644 --- a/www/backend/core/com/book.cfc +++ b/www/backend/core/com/book.cfc @@ -364,10 +364,10 @@ component displayname="book" output="false" { } - } else { - + // From yearly to monthly + } else if (local.currentProduct.recurring eq "yearly" and local.recurring eq "monthly") { - // Define the start date (a downgrade begins at the end of the current plan) + // Define the start date (it begins at the end of the current plan) local.startDate = dateFormat(local.currentProduct.endDate, "yyyy-mm-dd"); // Define the end date @@ -380,6 +380,13 @@ component displayname="book" output="false" { local.messageStruct['button'] = local.getTrans('btnYesDowngrade'); + // its the same plan they have clicked + } else { + + local.startDate = session.currentPlan.startDate; + local.endDate = session.currentPlan.endDate; + local.status = session.currentPlan.status; + } @@ -458,11 +465,13 @@ component displayname="book" output="false" { local.endDate = dateFormat(dateAdd("m", 1, local.startDate), "yyyy-mm-dd"); } else if (local.recurring eq "yearly") { local.endDate = dateFormat(dateAdd("yyyy", 1, local.startDate), "yyyy-mm-dd"); + } else { + // Set the end time to a date that will probably never be reached + local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd"); } local.status = "waiting"; - local.messageStruct['title'] = local.getTrans('titDowngrade'); local.messageStruct['message'] = local.getTrans('txtYouAreDowngrading') & " " & lsDateFormat(local.getTime.utc2local(utcDate=local.startDate)); local.messageStruct['button'] = local.getTrans('btnYesDowngrade'); @@ -523,7 +532,6 @@ component displayname="book" output="false" { // Change the plan or module } else { - // If the new status is waiting if (local.status eq "waiting") { diff --git a/www/backend/core/com/cancel.cfc b/www/backend/core/com/cancel.cfc index ff900c8..cda3181 100644 --- a/www/backend/core/com/cancel.cfc +++ b/www/backend/core/com/cancel.cfc @@ -28,6 +28,8 @@ component displayname="cancel" output="false" { " ) + + if (local.qCheck.recordCount or session.sysadmin) { variables.isAllowed = true; } else { @@ -179,4 +181,44 @@ component displayname="cancel" output="false" { } + // Cancel waiting plan + public struct function cancelWaitingPlan() { + + local.argsReturnValue = structNew(); + local.argsReturnValue['message'] = ""; + local.argsReturnValue['success'] = false; + + if (variables.isAllowed) { + + queryExecute ( + options = {datasource = application.datasource}, + params = { + customerID: {type: "numeric", value: variables.customerID}, + planID: {type: "numeric", value: variables.thisID} + }, + sql = " + + DELETE FROM bookings + WHERE intCustomerID = :customerID + AND intPlanID = :planID + AND strStatus = 'waiting' + + " + ) + + local.argsReturnValue['message'] = "OK"; + local.argsReturnValue['success'] = true; + + } else { + + local.argsReturnValue['message'] = application.objLanguage.getTrans('msgNoAccess'); + + } + + return local.argsReturnValue; + + + } + + } \ No newline at end of file diff --git a/www/backend/core/handler/book.cfm b/www/backend/core/handler/book.cfm index fbeb36b..4d06c2e 100644 --- a/www/backend/core/handler/book.cfm +++ b/www/backend/core/handler/book.cfm @@ -1,9 +1,5 @@ - // This file is used in order to book plans or modules. - // It handles the call to the payment service provider as well as the response. - // The call only works with the corresponding JSON string that is Base64 formatted (url.plan or url.module). - if (!structKeyExists(url, "plan") and !structKeyExists(url, "module")) { location url="#application.mainURL#" addtoken=false; } diff --git a/www/backend/core/handler/book_plan.cfm b/www/backend/core/handler/book_plan.cfm index 0997044..d36c16e 100644 --- a/www/backend/core/handler/book_plan.cfm +++ b/www/backend/core/handler/book_plan.cfm @@ -42,11 +42,20 @@ // Get more plan infos planDetails = objPlans.getPlanDetail(planID); + // Get plan group to compare with the current group + newPlanGroupID = planDetails.planGroupID; + oldPlanGroupID = session.currentPlan.planGroupID; + + // If the user has reached another plan group than the one already booked, they will be redirected to the plans in the backend + if (oldPlanGroupID gt 0) { + if (newPlanGroupID neq oldPlanGroupID) { + location url="#application.mainURL#/account-settings/plans" addtoken=false; + } + } + // First, get the booking details without a real booking checkBooking = objBook.checkBooking(customerID=session.customer_id, bookingData=planDetails, recurring=recurring, makeBooking=false, chargeInvoice=false); - local.payrexxFirst = false; - // If the amount to pay is less or equal zero, book right now and save the plan into the session if (structKeyExists(checkBooking, "amountToPay") and checkBooking.amountToPay lte 0) { diff --git a/www/backend/core/handler/cancel.cfm b/www/backend/core/handler/cancel.cfm index 6acb507..ca59eb9 100644 --- a/www/backend/core/handler/cancel.cfm +++ b/www/backend/core/handler/cancel.cfm @@ -24,16 +24,35 @@ if (structKeyExists(url, "plan")) { } else { - cancelPlan = new backend.core.com.cancel(session.customer_id, url.plan, 'plan').cancel(); + // Remove waiting plan + if (structKeyExists(url, "waitingPlan")) { - if (!cancelPlan.success) { - getAlert(cancelPlan.message, 'danger'); - logWrite("user", "error", "Plan could not be cancelled! [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#, Error: #cancelPlan.message#]"); - location url="#application.mainURL#/account-settings" addtoken="false"; - } + cancelWaitingPlan = new backend.core.com.cancel(session.customer_id, url.plan, 'plan').cancelWaitingPlan(); + + if (!cancelWaitingPlan.success) { + getAlert(cancelWaitingPlan.message, 'danger'); + logWrite("user", "warning", "Waiting plan could not be deleted! [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#]"); + location url="#application.mainURL#/account-settings/plans" addtoken="false"; + } - logWrite("user", "info", "Plan cancelled [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#]"); - getAlert('msgCanceledSuccessful', 'info'); + logWrite("user", "info", "Waiting plan deleted [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#]"); + + + // Cancel plan + } else { + + cancelPlan = new backend.core.com.cancel(session.customer_id, url.plan, 'plan').cancel(); + + if (!cancelPlan.success) { + getAlert(cancelPlan.message, 'danger'); + logWrite("user", "error", "Plan could not be cancelled! [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#, Error: #cancelPlan.message#]"); + location url="#application.mainURL#/account-settings" addtoken="false"; + } + + logWrite("user", "info", "Plan cancelled [PlanID: #url.plan#, CustomerID: #session.customer_id#, UserID: #session.user_id#]"); + getAlert('msgCanceledSuccessful', 'info'); + + } } diff --git a/www/backend/core/views/plan_view.cfm b/www/backend/core/views/plan_view.cfm index 7651060..127b1c0 100644 --- a/www/backend/core/views/plan_view.cfm +++ b/www/backend/core/views/plan_view.cfm @@ -42,7 +42,12 @@
#getTrans('txtNewPlanName')#:
-
#session.currentPlan.nextPlan.planName#
+
+
+
#session.currentPlan.nextPlan.planName#
+ +
+