Page 1 of 1

Change default number of days on dashboard order summary

Posted: Mon Oct 19, 2015 8:06 am
by compunerdy
Anyone know how to do this? I played with the code but could not get it to work. Having it default to today could make someone easily miss printing orders from the night before.

Re: Change default number of days on dashboard order summary

Posted: Tue Oct 20, 2015 4:26 am
by jguengerich
Not thoroughly tested, but I think the following works.
BTW: Yes, "DateRangeList" is misspelled "DateRageList"; if it bothers you enough you can correct the spelling while you're messing around in there anyway :).
In Admin\Dashboard\OrderSummary.aspx, add another item to the list and make it selected:

Code: Select all

                    <asp:DropDownList ID="DateRageList" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DateRageList_SelectedIndexChanged">
                        <asp:ListItem Text ="Today" Value="0" />
                        <asp:ListItem Text ="Yesterday & Today" Value="1" Selected="True" />
                        <asp:ListItem Text ="Last 7 Days" Value="7" />
                        <asp:ListItem Text ="Last 14 Days" Value="14" />
                        <asp:ListItem Text ="Last 30 Days" Value="30" />
                        <asp:ListItem Text ="Last 60 Days" Value="60" />
                        <asp:ListItem Text ="Last 90 Days" Value="90" />
                        <asp:ListItem Text ="Last 120 Days" Value="120" />
                    </asp:DropDownList>
In Admin\Dashboard\OrderSummary.aspx.cs, adjust the value of todayStart in Page_Load (rename it yesterdayStart if desired):

Code: Select all

            DateTime todayStart = new DateTime(localNow.Year, localNow.Month, localNow.Day, 0, 0, 0).AddDays(-1);
Also in Admin\Dashboard\OrderSummary.aspx.cs, there is a GetSelectedDateFilter method. It doesn't appear to be used anywhere, but just for completeness, you could add another item to the case statement and adjust the return values (original code jumps from returning 3 for case 14 to returning 5 for case 30, so in this example I added case 1 and adjusted the return values for case 7 and case 14):

Code: Select all

            switch (selectedRange)
            {
                case 0:
                    return 1;
                case 1:
                    return 2;
                case 7:
                    return 3;
                case 14:
                    return 4;
                case 30:
                    return 5;
                case 60:
                    return 6;
                case 90:
                    return 7;
                case 120:
                    return 8;
                default:
                    return 1;
            }

Re: Change default number of days on dashboard order summary

Posted: Tue Oct 20, 2015 5:36 am
by compunerdy
This worked perfectly, thanks. I just changed the 120 days option to be selected and then added this.

Code: Select all

).AddDays(-120);