Skip to content

Commit 0138d5f

Browse files
authored
Merge pull request #675 from PAWECOGmbH/development
Dev to staging
2 parents 1c53524 + 6eb7d72 commit 0138d5f

33 files changed

+810
-554
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SET NAMES utf8mb4;
2+
SET FOREIGN_KEY_CHECKS = 0;
3+
4+
ALTER TABLE `modules`
5+
ADD COLUMN `intDurationDays` int NULL DEFAULT 0 AFTER `intNumTestDays`;
6+
7+
SET FOREIGN_KEY_CHECKS = 1;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SET NAMES utf8mb4;
2+
SET FOREIGN_KEY_CHECKS = 0;
3+
4+
INSERT INTO system_mappings (strMapping, strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin)
5+
VALUES
6+
('sysadmin/mapping/edit', 'backend/core/views/sysadmin/mapping_edit.cfm', 0, 0, 1);
7+
8+
SET FOREIGN_KEY_CHECKS = 1;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SET NAMES utf8mb4;
2+
SET FOREIGN_KEY_CHECKS = 0;
3+
4+
INSERT INTO system_settings (strSettingVariable, strDefaultValue, strDescription)
5+
VALUES
6+
('settingMailNewRegistrations', '1', 'Would you like to be notified about new registrations by email?');
7+
8+
SET FOREIGN_KEY_CHECKS = 1;

config/db/dev/create-modules.sql

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,20 @@ CREATE TABLE `modules` (
6666
`strPicture` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
6767
`blnBookable` tinyint NOT NULL,
6868
`intNumTestDays` int NOT NULL,
69+
`intDurationDays` int NOT NULL DEFAULT 0,
6970
`strSettingPath` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
7071
`blnFree` tinyint NULL DEFAULT 0,
72+
`strRedirectPath` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
7173
`intPrio` int NOT NULL,
7274
PRIMARY KEY (`intModuleID`) USING BTREE
7375
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci ROW_FORMAT = DYNAMIC;
7476

7577
-- ----------------------------
7678
-- Records of modules
7779
-- ----------------------------
78-
INSERT INTO `modules` VALUES (1, 'Free Todo list app', 'Let your tasks be done', '<p>With this small but powerful tool for task management, you always have all your tasks under control. Simply click on \"Activate\" and get started :-)<br></p>', 1, 'todo', '', 1, 0, 'backend/modules/todo/settings', 1, 1);
79-
INSERT INTO `modules` VALUES (2, 'Easy ERP', 'Manage your contacts using Easy CRM', '<p>Manage your contacts easily with Easy ERP. Many features are included here, such as:<br><br>- Create and manage contacts<br>- Customer history<br>- Acquisition<br>- Appointment management<br>- and much more...<br></p>', 1, 'easyerp', '', 1, 30, 'backend/modules/easyerp/settings', 0, 2);
80-
INSERT INTO `modules` VALUES (3, 'MailChimp API', 'Automatically transfer your customers to MailChimp', '<p>With the newsletter marketing tool MailChimp, you serve all your customers with a newsletter. Connect your account with MailChimp and let this module take care of the synchronisation.</p>', 1, 'mailchimp', '', 1, 10, 'backend/modules/mailchimp/settings', 0, 3);
80+
INSERT INTO `modules` VALUES (1, 'Free Todo list app', 'Let your tasks be done', '<p>With this small but powerful tool for task management, you always have all your tasks under control. Simply click on \"Activate\" and get started :-)<br></p>', 1, 'todo', '', 1, 0, 0, 'backend/modules/todo/settings', 1, '', 1);
81+
INSERT INTO `modules` VALUES (2, 'Easy ERP', 'Manage your contacts using Easy CRM', '<p>Manage your contacts easily with Easy ERP. Many features are included here, such as:<br><br>- Create and manage contacts<br>- Customer history<br>- Acquisition<br>- Appointment management<br>- and much more...<br></p>', 1, 'easyerp', '', 1, 30, 0, 'backend/modules/easyerp/settings', 0, '', 2);
82+
INSERT INTO `modules` VALUES (3, 'MailChimp API', 'Automatically transfer your customers to MailChimp', '<p>With the newsletter marketing tool MailChimp, you serve all your customers with a newsletter. Connect your account with MailChimp and let this module take care of the synchronisation.</p>', 1, 'mailchimp', '', 1, 10, 0, 'backend/modules/mailchimp/settings', 0, '', 3);
8183

8284

8385
-- ----------------------------

config/db/dev/create-plans.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ CREATE TABLE `plans` (
106106
`strDescription` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL,
107107
`strButtonName` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
108108
`strBookingLink` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
109+
`strRedirectPath` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL,
109110
`blnRecommended` tinyint NULL DEFAULT 0,
110111
`intMaxUsers` int NULL DEFAULT NULL,
111112
`intNumTestDays` int NULL DEFAULT 0,
@@ -121,10 +122,10 @@ CREATE TABLE `plans` (
121122
-- ----------------------------
122123
-- Records of plans
123124
-- ----------------------------
124-
INSERT INTO `plans` VALUES (1, 1, 'Free', '3 users + 0 guests\r\nBest for small, personal projects', '<ul><li>1 project</li><li>3 users</li><li>60 task limit</li></ul>', 'Try free', '', 0, 3, 0, 0, 1, 0, 1);
125-
INSERT INTO `plans` VALUES (2, 1, 'Standard', 'Up to 10 users\r\nFor teams that need planning and collaboration features.', '<p><strong>Try free for 30 days. Cancel anytime.</strong></p><ul><li>Unlimited projects</li><li>Unlimited tasks</li><li>Add users as needed</li><li>Collaboration and planning features</li></ul>', 'Try standard', '', 1, 10, 30, 0, 0, 0, 2);
126-
INSERT INTO `plans` VALUES (3, 1, 'Advanced', 'Up to 30 users\r\nFor teams that need planning and collaboration, + tracking workloads by hours, and advanced project reporting. ', '<p><strong>Including all from Basic plan and:</strong></p><ul><li>Advanced reporting</li><li>Track workloads by hours</li></ul><ul></ul>', 'Try advanced', '', 0, 30, 30, 0, 0, 0, 3);
127-
INSERT INTO `plans` VALUES (4, 1, 'Enterprise', 'Bis business for large companies.\r\nUp to 500 users or more - pleas ask for offer', '<ul><li>Unlimited projects</li><li>Unlimited tasks</li><li>Add users as needed no limits</li><li>and much more<br></li></ul>', 'Contact', 'contact/enterprise', 0, 0, 30, 0, 0, 0, 4);
125+
INSERT INTO `plans` VALUES (1, 1, 'Free', '3 users + 0 guests\r\nBest for small, personal projects', '<ul><li>1 project</li><li>3 users</li><li>60 task limit</li></ul>', 'Try free', '', '', 0, 3, 0, 0, 1, 0, 1);
126+
INSERT INTO `plans` VALUES (2, 1, 'Standard', 'Up to 10 users\r\nFor teams that need planning and collaboration features.', '<p><strong>Try free for 30 days. Cancel anytime.</strong></p><ul><li>Unlimited projects</li><li>Unlimited tasks</li><li>Add users as needed</li><li>Collaboration and planning features</li></ul>', 'Try standard', '', '', 1, 10, 30, 0, 0, 0, 2);
127+
INSERT INTO `plans` VALUES (3, 1, 'Advanced', 'Up to 30 users\r\nFor teams that need planning and collaboration, + tracking workloads by hours, and advanced project reporting. ', '<p><strong>Including all from Basic plan and:</strong></p><ul><li>Advanced reporting</li><li>Track workloads by hours</li></ul><ul></ul>', 'Try advanced', '', '', 0, 30, 30, 0, 0, 0, 3);
128+
INSERT INTO `plans` VALUES (4, 1, 'Enterprise', 'Bis business for large companies.\r\nUp to 500 users or more - pleas ask for offer', '<ul><li>Unlimited projects</li><li>Unlimited tasks</li><li>Add users as needed no limits</li><li>and much more<br></li></ul>', 'Contact', 'contact/enterprise', '', 0, 0, 30, 0, 0, 0, 4);
128129

129130
-- ----------------------------
130131
-- Table structure for plans_trans

www/Application.cfc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
5656
application.objNotifications = new backend.core.com.notifications();
5757
application.objSysadmin = new backend.core.com.sysadmin();
5858
application.objMeta = new backend.core.com.meta();
59+
application.objModules = new backend.core.com.modules();
5960
application.objCoreUtil = new frontend.core.com.coreutility();
6061

6162
// Save all choosable languages into a list
@@ -119,11 +120,11 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
119120

120121
// For local development only,
121122
// automatically reinitialize the application without using the reinit URL parameter
122-
/* if (variables.environment eq "dev") {
123+
if (variables.environment eq "dev") {
123124
structClear(APPLICATION);
124125
onApplicationStart();
125126
application.langStruct = application.objLanguage.initLanguages();
126-
} */
127+
}
127128

128129
// Check if the user is logged in as a sysadmin
129130
if (structKeyExists(session, "sysadmin") and session.sysadmin) {
@@ -174,6 +175,7 @@ component displayname="Application" output="false" extends="backend.myapp.ownApp
174175

175176

176177
public boolean function onRequest(required string TargetPage) {
178+
177179
// Create SEF URL
178180
thiscontent = application.objGlobal.getSEF(replace(cgi.path_info,'/','','one'));
179181

www/backend/core/com/book.cfc

Lines changed: 33 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ component displayname="book" output="false" {
8686

8787
local.modulesIncluded = arrayNew(1);
8888

89-
local.objPrices = new backend.core.com.prices(vat=bookingData.vat, vat_type=bookingData.vatType, isnet=bookingData.isNet);
89+
local.objPrices = new backend.core.com.prices(vat=local.bookingData.vat, vat_type=local.bookingData.vatType, isnet=local.bookingData.isNet);
9090

9191

9292
if (structKeyExists(local.bookingData, "currencyID") and isNumeric(local.bookingData.currencyID)) {
@@ -183,11 +183,11 @@ component displayname="book" output="false" {
183183
// Is it a free product?
184184
if (local.bookingData.itsFree) {
185185

186-
local.recurring = "onetime";
187-
local.status = "free";
186+
local.recurring = "onetime";
187+
local.status = "free";
188188

189-
// Set the end time to a date that will probably never be reached
190-
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
189+
// Set the end time to a date that will probably never be reached
190+
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
191191

192192
} else {
193193

@@ -199,13 +199,22 @@ component displayname="book" output="false" {
199199
local.endDate = dateFormat(dateAdd("yyyy", 1, local.startDate), "yyyy-mm-dd");
200200
local.priceBeforeVat = local.bookingData.priceYearly;
201201
} else if (local.recurring eq "onetime") {
202-
// Set the end time to a date that will probably never be reached
203-
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
204-
if (structKeyExists(local.bookingData, "priceOnetime")) {
205-
local.priceBeforeVat = local.bookingData.priceOnetime;
202+
203+
// If its a limited product (only modules)
204+
if (structKeyExists(local.bookingData, "durationDays") and local.bookingData.durationDays gt 0) {
205+
206+
// Define the end date
207+
local.endDate = dateFormat(dateAdd("d", local.bookingData.durationDays, local.startDate), "yyyy-mm-dd");
208+
206209
} else {
207-
local.priceBeforeVat = 0;
210+
211+
// Set the end time to a date that will probably never be reached
212+
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
213+
208214
}
215+
216+
local.priceBeforeVat = local.bookingData.priceOnetime ?: 0;
217+
209218
}
210219

211220
local.amountToPay = local.objPrices.getPriceData(local.priceBeforeVat).priceAfterVAT;
@@ -276,13 +285,22 @@ component displayname="book" output="false" {
276285
local.endDate = dateFormat(dateAdd("yyyy", 1, local.startDate), "yyyy-mm-dd");
277286
local.priceBeforeVat = local.bookingData.priceYearly;
278287
} else if (local.recurring eq "onetime") {
279-
// Set the end time to a date that will probably never be reached
280-
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
281-
if (structKeyExists(local.bookingData, "priceOnetime")) {
282-
local.priceBeforeVat = local.bookingData.priceOnetime;
288+
289+
// If its a limited product (only modules)
290+
if (structKeyExists(local.bookingData, "durationDays") and local.bookingData.durationDays gt 0) {
291+
292+
// Define the end date
293+
local.endDate = dateFormat(dateAdd("d", local.bookingData.durationDays, local.startDate), "yyyy-mm-dd");
294+
283295
} else {
284-
local.priceBeforeVat = 0;
296+
297+
// Set the end time to a date that will probably never be reached
298+
local.endDate = dateFormat(createDate(3000, 1, 1), "yyyy-mm-dd");
299+
285300
}
301+
302+
local.priceBeforeVat = local.bookingData.priceOnetime ?: 0;
303+
286304
}
287305

288306
local.amountToPay = local.objPrices.getPriceData(local.priceBeforeVat).priceAfterVAT;
@@ -391,7 +409,6 @@ component displayname="book" output="false" {
391409
}
392410

393411

394-
395412
} else {
396413

397414

www/backend/core/com/cancel.cfc

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,25 +104,36 @@ component displayname="cancel" output="false" {
104104

105105
}
106106

107-
// Delete module (only possible via SysAdmin)
107+
// Withdraw module (only possible via SysAdmin)
108108
public boolean function delete(required numeric bookingID, required numeric moduleID, required numeric customerID) {
109109

110+
// First, set intBookingID in invoices to 0
110111
queryExecute(
111112
options = {datasource = application.datasource},
112113
params = {
113114
bookingID: {type: "numeric", value: arguments.bookingID},
114-
moduleID: {type: "numeric", value: arguments.moduleID},
115115
customerID: {type: "numeric", value: arguments.customerID}
116116
},
117117
sql = "
118+
UPDATE invoices
119+
SET intBookingID = 0
120+
WHERE intBookingID = :bookingID
121+
AND intCustomerID = :customerID
122+
"
123+
)
118124

125+
// Then delete the booking
126+
queryExecute(
127+
options = {datasource = application.datasource},
128+
params = {
129+
bookingID: {type: "numeric", value: arguments.bookingID},
130+
moduleID: {type: "numeric", value: arguments.moduleID},
131+
customerID: {type: "numeric", value: arguments.customerID}
132+
},
133+
sql = "
119134
DELETE FROM bookings
120135
WHERE intCustomerID = :customerID
121-
AND intModuleID = :moduleID;
122-
123-
DELETE FROM invoices
124-
WHERE intBookingID = :bookingID;
125-
136+
AND intModuleID = :moduleID
126137
"
127138
)
128139

www/backend/core/com/global.cfc

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ component displayname="globalFunctions" output="false" {
3030
strMapping: {type: "nvarchar", value: local.sefString}
3131
},
3232
sql = "
33-
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend
33+
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend, 0 as intModuleID
3434
FROM system_mappings
3535
WHERE strMapping = :strMapping
3636
UNION
37-
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend
37+
SELECT strPath, blnOnlyAdmin, blnOnlySuperAdmin, blnOnlySysAdmin, 0 as itsFrontend, intModuleID
3838
FROM custom_mappings
3939
WHERE strMapping = :strMapping
4040
UNION
41-
SELECT strPath, 0, 0, 0, 1 as itsFrontend
41+
SELECT strPath, 0, 0, 0, 1 as itsFrontend, 0 as intModuleID
4242
FROM frontend_mappings
4343
WHERE strMapping = :strMapping
4444
UNION
@@ -47,14 +47,37 @@ component displayname="globalFunctions" output="false" {
4747
SELECT strPath
4848
FROM frontend_mappings
4949
WHERE intFrontendMappingsID = frontend_mappings_trans.intFrontendMappingsID
50-
) as strPath, 0, 0, 0, 1 as itsFrontend
50+
) as strPath, 0, 0, 0, 1 as itsFrontend, 0 as intModuleID
5151
FROM frontend_mappings_trans
5252
WHERE strMapping = :strMapping
5353
LIMIT 1
5454
"
5555
)
5656

5757
if (local.qCheckSEF.recordCount) {
58+
59+
// Check if the path is coming from a module
60+
if (local.qCheckSEF.intModuleID gt 0 and structKeyExists(session, "customer_id") and session.customer_id gt 0) {
61+
62+
// We have to check if the module is active for the current customer
63+
local.moduleStatus = application.objModules.getModuleStatus(session.customer_id, local.qCheckSEF.intModuleID);
64+
65+
// Overwrite the flag 'noaccess' generally to true (if its not a SysAdmin)
66+
if (!session.sysadmin) {
67+
local.returnStruct['noaccess'] = true;
68+
}
69+
70+
// If the module is active, we can set 'noaccess' to false
71+
if (isStruct(local.moduleStatus) and !structIsEmpty(local.moduleStatus)) {
72+
if (structKeyExists(local.moduleStatus, "status")) {
73+
if (local.moduleStatus.status eq "free" or local.moduleStatus.status eq "test" or local.moduleStatus.status eq "active") {
74+
local.returnStruct['noaccess'] = false;
75+
}
76+
}
77+
}
78+
79+
}
80+
5881
if (local.qCheckSEF.itsFrontend) {
5982
local.returnStruct['thisPath'] = "frontend/" & application.activeTheme & "/" & local.qCheckSEF.strPath;
6083
} else {

www/backend/core/com/mappings.cfc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ component displayname="mappings" output="false" {
116116
if (structKeyExists(arguments.mappingData, "metaDescription") and len(trim(arguments.mappingData.metaDescription))) {
117117
local.metaDescription = application.objGlobal.cleanUpText(arguments.mappingData.metaDescription, 3000);
118118
}
119-
if (structKeyExists(arguments.mappingData, "metaHTML") and len(trim(arguments.mappingData.metaHTML))) {
120-
local.metaHTML = application.objGlobal.cleanUpText(arguments.mappingData.metaHTML, 3000);
119+
if (structKeyExists(arguments.mappingData, "htmlcodes") and len(trim(arguments.mappingData.htmlcodes))) {
120+
local.metaHTML = arguments.mappingData.htmlcodes;
121121
}
122122

123123
// If stringForUrlSlug is specified, we generate the URL slug from it

0 commit comments

Comments
 (0)