Adding order number search to all Admin pages

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Adding order number search to all Admin pages

Post by AbleMods » Tue Jul 22, 2008 8:17 am

Introduction

This is a quick and dirty one, but oh will it make your day. I don't know about you, but I find myself jumping from order to order and it's always by order number. Well, there really isn't a way to get straight from one order to another by order number. You have to always go back to the main Dashboard and enter the order number there.

So I modified the Admin header navigation control to include an order number field. That way every single page on the Admin side has a box where you can type in any order number and jump straight to the order details page.

Code Changes

Normally I just post the changes to a file. In this case, the file is small so I'm going to post the entire file. That, and I have a dental appointment in 45 minutes :)

Edit the ~/Admin/UserControls/HeaderNavigation.ascx file and replace the entire contents with this code:

Code: Select all

<%@ Control Language="C#" ClassName="HeaderNavigation" EnableViewState="false" %>
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (Token.Instance.User == null || Token.Instance.User.IsAdmin == false)
        {
            AdminNavigationHeaderPanel.Visible = false;
        }
        else
        {
            OrdersLink.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            CatalogLink.Visible = (Token.Instance.User.IsInRole(Role.CatalogAdminRoles));
            OrderId.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
            ViewOrderButton.Visible = (Token.Instance.User.IsInRole(Role.OrderAdminRoles));
        }
    }

    protected void ViewOrderButton_Click(object sender, EventArgs e)
    {
        int tempOrderId = AlwaysConvert.ToInt(OrderId.Text);
        Order order = OrderDataSource.Load(tempOrderId);
        if (order != null)
        {
            Response.Redirect("~/Admin/Orders/ViewOrder.aspx?OrderId=" + tempOrderId.ToString());
        }
        else
        {
            CustomValidator invalidOrderId = new CustomValidator();
            invalidOrderId.ControlToValidate = "OrderId";
            invalidOrderId.ErrorMessage = "*";
            invalidOrderId.Text = "Order number is not valid";
            invalidOrderId.IsValid = false;
            AdminNavigationHeaderPanel.Controls.Add(invalidOrderId);
        }
    }

</script>
<asp:Panel ID="AdminNavigationHeaderPanel" runat="server" >
    <table>
    <tr>
        <td>
	    <asp:HyperLink ID="DashboardLink" runat="server" NavigateUrl="~/Admin/Default.aspx" CssClass="dashboard" Text="Dashboard"></asp:HyperLink>
	    <asp:HyperLink ID="OrdersLink" runat="server" NavigateUrl="~/Admin/Orders/Default.aspx" CssClass="orders" text="Orders"></asp:HyperLink>
	    <asp:HyperLink ID="CatalogLink" runat="server" NavigateUrl="~/Admin/Catalog/Browse.aspx" CssClass="catalog" Text="Catalog"></asp:HyperLink>
	    <asp:HyperLink ID="StoreLink" runat="server" NavigateUrl="~/Default.aspx" CssClass="stores" Text="Store"></asp:HyperLink>
	    <asp:HyperLink ID="LogoutLink" runat="server" NavigateUrl="~/Logout.aspx" CssClass="logout" Text="Logout"></asp:HyperLink>
	    </td> 
	    <td class="header" align="left" valign="bottom"><asp:Localize ID="ViewOrderNumberCaption" runat="server" Text="View Order:"></asp:Localize><br />
	    <asp:TextBox ID="OrderId" runat="server" Width="40px" ValidationGroup="OrderSummary"></asp:TextBox>
        <asp:Button ID="ViewOrderButton" runat="server" ValidationGroup="OrderSummary" OnClick="ViewOrderButton_Click" Text="Go" />
        </td>
	</tr> 
    </table>
</asp:Panel>
Save it.

Conclusion

You might notice the text color isn't right. Well, I hate CSS styles and CSS styles hate me. It's mutual and I'm ok with that. If you know how to make two stupid little words show the proper style color from the style sheet, please post it here. Others will be grateful and the score will become CSS 220, Joe 0 :wink:
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re: Adding order number search to all Admin pages

Post by Robbie@FireFold » Tue Jul 22, 2008 11:07 am

Marry me?

Haha. I love it.

My team is EPIC in CSS, but they are currently skinning our entire site. Once they move to the admin I can have them fix this up a little bit if you wish.
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Adding order number search to all Admin pages

Post by AbleMods » Tue Jul 22, 2008 2:16 pm

That would be awesome.

CSS and I haven't gotten along for some time. Part of the issue is I'm trying to learn the final lesson i.e. a 2,000+ line style sheet in AC7 when I really should be reading "CSS Styles for Dummies".
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

Robbie@FireFold
Commodore (COMO)
Commodore (COMO)
Posts: 433
Joined: Wed May 28, 2008 9:42 am
Location: Concord, NC
Contact:

Re: Adding order number search to all Admin pages

Post by Robbie@FireFold » Tue Jul 22, 2008 2:20 pm

Hopefully towards the end of the week I can have them work a little magic on your big magic.
Robbie Hodge
General Manager
Robbie@FireFold.com
http://www.FireFold.com

User avatar
AbleMods
Master Yoda
Master Yoda
Posts: 5170
Joined: Wed Sep 26, 2007 5:47 am
Location: Fort Myers, Florida USA

Re: Adding order number search to all Admin pages

Post by AbleMods » Tue Jul 22, 2008 2:28 pm

Robbie@FireFold wrote:Hopefully towards the end of the week I can have them work a little magic on your big magic.
Oh god there's so much I could add to that statement...but this is a public forum :wink:
Joe Payne
AbleCommerce Custom Programming and Modules http://www.AbleMods.com/
AbleCommerce Hosting http://www.AbleModsHosting.com/
Precise Fishing and Hunting Time Tables http://www.Solunar.com

mkeith1
Commander (CMDR)
Commander (CMDR)
Posts: 120
Joined: Wed Jul 25, 2007 12:46 pm
Contact:

Re: Adding order number search to all Admin pages

Post by mkeith1 » Thu Aug 27, 2009 9:41 am

can this mod be integrated into version 7.0.3. I used it with 7.0.2 and it worked great but then Able added a search capability to the header and i couldn't get the order search to mesh with it.

User avatar
mazhar
Master Yoda
Master Yoda
Posts: 5084
Joined: Wed Jul 09, 2008 8:21 am
Contact:

Re: Adding order number search to all Admin pages

Post by mazhar » Thu Aug 27, 2009 7:39 pm

Yes you can integrate it in 7.0.3

mkeith1
Commander (CMDR)
Commander (CMDR)
Posts: 120
Joined: Wed Jul 25, 2007 12:46 pm
Contact:

Re: Adding order number search to all Admin pages

Post by mkeith1 » Mon Aug 31, 2009 10:26 am

anyone care to share the code for this. The above code works for 7.02, but i had difficulty using it in 7.03.

Post Reply