Category Archives: DFFS

DFFS Package updated to v4.4.4.24

I have fixed a few bugs and added some new functionality. You find the compete change log here, and the updated files in the download section of the user manual.

Please note that I have made a lot of small changes to this version to clean up some old code. There are always chances for errors so please test this version before applying it in a production environment.

Post comments below, but use the form if you have questions or you think you have found a bug.

Best regards,
Alexander

Limit access to a NewForm / EditForm at specific times and weekdays

I got a request for a solution to limit access to a form for 30 minutes while a report was being made to ensure no records was added or modified.

This example code must be added to the specific form – in the Custom JS section. Change the from, to and weekdays to match the time and weekdays you want to limit access.

function limitAccessToForm(arg) {
    var disableStart = new Date();
    disableStart.setHours(arg.from.hour, arg.from.minute, 0); // hour, minute, second
    var disableEnd = new Date();
    disableEnd.setHours(arg.to.hour, arg.to.minute, 0); // hour, minute, second
    var disableStartFriendly = disableStart.toLocaleString();
    var disableEndFriendly = disableEnd.toLocaleString();
    var now = new Date();
    if (now > disableStart && now < disableEnd) {
        if (arg.weekdays.length > 0) {
            var pass = false;
            var today = now.getDay();
            jQuery.each(arg.weekdays, function (i, day) {
                if (today === day) {
                    pass = true;
                    return false;
                }
            });
            if (!pass) {
                // Not today
                return;
            }
        }
        jQuery("#part1").css("visibility", "hidden");
        spjs.dffs.alert({
            "title": "No access",
            "msg": "This form is disabled between " + disableStartFriendly + " and " + disableEndFriendly,
            "ok": function () {
                if(GetUrlKeyValue("IsDlg") === "1"){
                    window.frameElement.cancelPopUp();
                }else{
                    window.history.back();
                }
            }
        });
    }
}

// If you like to limit it to specific weekdays add them to the array weekdays (sunday = 0 and saturday = 6) - leave the array empty if you want it on all weekdays
limitAccessToForm({
    "from": {
        "hour": 13,
        "minute": 0
    },
    "to": {
        "hour": 13,
        "minute": 30
    },
    "weekdays": []
});

Post any comments below, or in the forum.

Alexander