diff --git a/.vscode/launch.json b/.vscode/launch.json index b77f3b95..fcc80a75 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -53,7 +53,7 @@ "AYANOVA_FOLDER_USER_FILES": "c:\\temp\\RavenTestData\\userfiles", "AYANOVA_FOLDER_BACKUP_FILES": "c:\\temp\\RavenTestData\\backupfiles", "AYANOVA_FOLDER_TEMPORARY_SERVER_FILES": "c:\\temp\\RavenTestData\\tempfiles", - "AYANOVA_SERVER_TEST_MODE": "false", + "AYANOVA_SERVER_TEST_MODE": "true", "AYANOVA_SERVER_TEST_MODE_SEEDLEVEL": "small", "AYANOVA_SERVER_TEST_MODE_TZ_OFFSET": "-7", "AYANOVA_BACKUP_PG_DUMP_PATH": "C:\\data\\code\\postgres_13\\bin\\" diff --git a/server/AyaNova/biz/WorkOrderBiz.cs b/server/AyaNova/biz/WorkOrderBiz.cs index 03d34cbc..4e30437d 100644 --- a/server/AyaNova/biz/WorkOrderBiz.cs +++ b/server/AyaNova/biz/WorkOrderBiz.cs @@ -4764,21 +4764,24 @@ namespace AyaNova.Biz } //Scheduling conflict? - //TODO: Add global settings allow schedule conflicts setting check here (after implementing it) - if (proposedObj.UserId!=null && proposedObj.StartDate != null + if (!AyaNova.Util.ServerGlobalBizSettings.Cache.AllowScheduleConflicts + && proposedObj.UserId != null + && proposedObj.StartDate != null && proposedObj.StopDate != null && (isNew || (proposedObj.StartDate != currentObj.StartDate) || (proposedObj.StopDate != currentObj.StopDate) - || (proposedObj.UserId != currentObj.UserId) + || (proposedObj.UserId != currentObj.UserId) )) { - // ICollection Overlaps = await db.TaskTime.Where(a => a.UserId == UserId && a.StartDate <= time.EndDate && time.StartDate <= a.EndDate.Value).OrderBy(a => a).Select(a => a.StartDate).ToListAsync(); - // if (Overlaps.Any()) - // { - if(await ct.WorkOrderItemScheduledUser.AnyAsync(x=>x.Id!=proposedObj.Id && x.UserId==proposedObj.UserId && x.StartDate<= proposedObj.StopDate && proposedObj.StartDate <= x.StopDate )){ - AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("GlobalAllowScheduleConflicts")); - } + if (await ct.WorkOrderItemScheduledUser.AnyAsync(x => x.Id != proposedObj.Id + && x.UserId == proposedObj.UserId + && x.StartDate <= proposedObj.StopDate + && proposedObj.StartDate <= x.StopDate)) + { + AddError(ApiErrorCode.VALIDATION_FAILED, "StartDate", await Translate("ScheduleConflict")); + AddError(ApiErrorCode.VALIDATION_FAILED, "StopDate", await Translate("ScheduleConflict")); + } } diff --git a/server/AyaNova/models/GlobalBizSettings.cs b/server/AyaNova/models/GlobalBizSettings.cs index ab392cf3..60252d7f 100644 --- a/server/AyaNova/models/GlobalBizSettings.cs +++ b/server/AyaNova/models/GlobalBizSettings.cs @@ -40,6 +40,9 @@ namespace AyaNova.Models [Required] public TimeSpan WorkOrderCompleteByAge { get; set; } = TimeSpan.Zero;//was workorderclosebyage + public bool AllowScheduleConflicts { get; set; } + + //CUSTOMER ACCESS FEATURES AND SETTINGS public long? CustomerDefaultWorkOrderReportId { get; set; } diff --git a/server/AyaNova/resource/de.json b/server/AyaNova/resource/de.json index a23955ec..873e48db 100644 --- a/server/AyaNova/resource/de.json +++ b/server/AyaNova/resource/de.json @@ -2268,5 +2268,6 @@ "CustomerAccessWorkOrderReport":"Kundenversion Arbeitsauftragsbericht", "NoFeaturesAvailable":"Für Ihr Konto sind keine Funktionen aktiviert", "CustomerSignature":"Unterschrift des Kunden", - "TechSignature":"Unterschrift des Technikers" + "TechSignature":"Unterschrift des Technikers", + "ScheduleConflict":"Terminkonflikt" } \ No newline at end of file diff --git a/server/AyaNova/resource/en.json b/server/AyaNova/resource/en.json index beebdf01..ce878992 100644 --- a/server/AyaNova/resource/en.json +++ b/server/AyaNova/resource/en.json @@ -2268,7 +2268,8 @@ "CustomerAccessWorkOrderReport":"Customer work order report", "NoFeaturesAvailable":"No features are enabled for your account", "CustomerSignature":"Customer signature", - "TechSignature":"Technician signature" + "TechSignature":"Technician signature", + "ScheduleConflict":"Schedule conflict" } \ No newline at end of file diff --git a/server/AyaNova/resource/es.json b/server/AyaNova/resource/es.json index 6345b90f..5aee6d9a 100644 --- a/server/AyaNova/resource/es.json +++ b/server/AyaNova/resource/es.json @@ -2268,5 +2268,6 @@ "CustomerAccessWorkOrderReport":"Informe de orden de trabajo del cliente", "NoFeaturesAvailable":"No hay funciones habilitadas para su cuenta", "CustomerSignature":"Firma del cliente", - "TechSignature":"Firma del técnico" + "TechSignature":"Firma del técnico", + "ScheduleConflict":"Conflicto de horario" } \ No newline at end of file diff --git a/server/AyaNova/resource/fr.json b/server/AyaNova/resource/fr.json index b6415f6b..ef781002 100644 --- a/server/AyaNova/resource/fr.json +++ b/server/AyaNova/resource/fr.json @@ -2268,5 +2268,6 @@ "CustomerAccessWorkOrderReport":"Rapport de bon de travail client", "NoFeaturesAvailable":"Aucune fonctionnalité n'est activée pour votre compte", "CustomerSignature":"Signature du client", - "TechSignature":"Signature du technicien" + "TechSignature":"Signature du technicien", + "ScheduleConflict":"Conflit d'horaire" } \ No newline at end of file diff --git a/server/AyaNova/util/AySchema.cs b/server/AyaNova/util/AySchema.cs index d28d0240..fa3790f6 100644 --- a/server/AyaNova/util/AySchema.cs +++ b/server/AyaNova/util/AySchema.cs @@ -252,6 +252,7 @@ namespace AyaNova.Util await ExecQueryAsync("CREATE TABLE aglobalbizsettings (id INTEGER NOT NULL PRIMARY KEY, " + "searchcasesensitiveonly BOOL DEFAULT FALSE, " + "useinventory BOOL DEFAULT TRUE, " + + "allowscheduleconflicts BOOL DEFAULT FALSE, " + "workordercompletebyage INTERVAL NOT NULL DEFAULT '00:00:00', " + "workordertraveldefaultminutes INTEGER NOT NULL DEFAULT 0, " + "worklaborscheduledefaultminutes INTEGER NOT NULL DEFAULT 0, " @@ -527,7 +528,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); //Global tax code defaults await ExecQueryAsync("ALTER TABLE aglobalbizsettings ADD column taxpartpurchaseid BIGINT REFERENCES ataxcode, " + "ADD column taxpartsaleid BIGINT REFERENCES ataxcode, ADD column taxratesaleid BIGINT REFERENCES ataxcode"); - + //MEMO await ExecQueryAsync("CREATE TABLE amemo (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name TEXT NOT NULL, " + "notes TEXT, wiki TEXT, customfields TEXT, tags VARCHAR(255) ARRAY, " @@ -971,7 +972,7 @@ $BODY$ LANGUAGE PLPGSQL STABLE"); + "notes TEXT, roles INTEGER NOT NULL, atype INTEGER NOT NULL, template TEXT, style TEXT, jsprerender TEXT, jshelpers TEXT, rendertype INTEGER NOT NULL, " + "headertemplate TEXT, footertemplate TEXT, displayheaderfooter BOOL, paperformat INTEGER NOT NULL, landscape BOOL, marginoptionsbottom TEXT, " + "marginoptionsleft TEXT, marginoptionsright TEXT, marginoptionstop TEXT, pageranges TEXT, prefercsspagesize BOOL, printbackground BOOL, scale DECIMAL(8,5) )"); - + //Global customer default workorder report default await ExecQueryAsync("ALTER TABLE aglobalbizsettings ADD column customerdefaultworkorderreportid BIGINT REFERENCES areport(id) ");