Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Restricting the Date to Today or Earlier on the Add Payments and Add Credits pages

  1. Click on the on Setup tab

  2. Click Page Extensions

  3. Click the Add button

  4. Enter the following information:
    Name - as listed below
    Page - as listed below
    Script - (see below)

    --paste in code from below as needed

  5. Click Save

Name: Force Date on Add Credit
Page: statementdetailscredittransactions/add

Code Block
languagejs
function BillCreditDateCheck() {
    var de = document.getElementById("Date");
    var d = de.value.split("/");
    var now = new Date();
    if (d[2] > now.getFullYear())
    {
        return false;
    }
    if (d[2] == now.getFullYear())
    {
        if (d[1] > (now.getMonth() + 1))
        {
            return false;
        }
        if (d[1] == (now.getMonth() + 1))
        {
            if (d[0] > now.getDate())
            {
                return false;
            }
        }
    }
}

function BillCreditDateCheckOnClick(e)
{
    if (BillCreditDateCheck() == false)
    {
        setTimeout("alert('The Date must be less than or equal to today.');", 50);
        return false;
    }

    return this.oldOnClick(e);
}

var theCrumb = document.getElementById('crumb');
var loggedInUser = theCrumb.getElementsByTagName('a')[0].innerHTML;

if (loggedInUser != "rrichardson" && loggedInUser != "obechu" && loggedInUser != "nboirard"
&& loggedInUser != "bwaasdorp" && loggedInUser != "yjadhav")
{
    document.getElementById("Date").readOnly = true;
    document.getElementById("Datectlpopup").style.display = 'none';
}
else
{
    var sb = document.getElementById("SaveButton");
    if (sb != null)
    {
        sb.oldOnClick = sb.onclick;
        sb.onclick = BillCreditDateCheckOnClick;
    }
    var snb = document.getElementById("SaveNewButton");
    if (snb != null)
    {
        snb.oldOnClick = snb.onclick;
        snb.onclick = BillCreditDateCheckOnClick;
    }
}


Name: Force Date on Add Payment
Page: payment/addpayment

Code Block
languagejs
function BillPaymentDateCheck() {

    var de = document.getElementById("Date");
    var d = de.value.split("/");
    var now = new Date();

    if (d[2] > now.getFullYear())
    {
        return false;
    }

    if (d[2] == now.getFullYear())
    {
        if (d[1] > (now.getMonth() + 1))
        {
            return false;
        }

        if (d[1] == (now.getMonth() + 1))
        {
            if (d[0] > now.getDate())
            {
                return false;
            }
        }
    }
}

function BillPaymentDateCheckOnClick(e)
{
    if (BillPaymentDateCheck() == false)
    {
        setTimeout("alert('The Date must be less than or equal to today.');", 50);
        return false;
    }

    return this.oldOnClick(e);
}

var theCrumb = document.getElementById('crumb');
var loggedInUser = theCrumb.getElementsByTagName('a')[0].innerHTML;

if (loggedInUser != "rrichardson" && loggedInUser != "obechu" && loggedInUser != "nboirard"
&& loggedInUser != "bwaasdorp" && loggedInUser != "yjadhav")
{
    document.getElementById("Date").readOnly = true;
    document.getElementById("Datectlpopup").style.display = 'none';
}
else
{
    var sb = document.getElementById("SaveButton");
    if (sb != null)
    {
        sb.oldOnClick = sb.onclick;
        sb.onclick = BillPaymentDateCheckOnClick;
    }
    var snb = document.getElementById("SaveNewButton");
    if (snb != null)
    {
        snb.oldOnClick = snb.onclick;
        snb.onclick = BillPaymentDateCheckOnClick;
    }
}