Page 1 of 1

Adding fields to invoices

Posted: Mon Jun 30, 2008 10:25 pm
by Brewhaus
Due to the way that we process orders in our warehouse, it is currently a hassle using the stock AC invoice as a couple of fields that we use are not listed- specifically the customer's phone number, selected shipping method, and payment method (payment method name is sufficient, although for the customer's own use it may be helpful to add the last four digits of their card number). I have looked at the files, but cannot follow deep enough to see where I can add these three fields to the invoice that we print.

Is there a simple way that we can do this? The best is likely to add the payment information to the 'Bill To' section, and the phone number and shipping method to the 'Ship To' section.

Re: Adding fields to invoices

Posted: Tue Jul 01, 2008 4:48 pm
by jmestep
Here was a fix on the phone number and others might be similar:
viewtopic.php?f=42&t=7476

Re: Adding fields to invoices

Posted: Tue Jul 01, 2008 8:20 pm
by Brewhaus
That works great (I manipulated it to put the phone number in the same box as the billing address, immediately below the address). I do hit a problem pulling the shipping method and payment method because they come from different tables. How can I change the table that we are pulling pieces of information from?

Re: Adding fields to invoices

Posted: Tue Jul 01, 2008 10:54 pm
by compunerdy

Re: Adding fields to invoices

Posted: Wed Jul 02, 2008 9:26 pm
by Brewhaus
I am afraid that I am still at a bit of a loss. I simply want to pull the payment method (which is in one table) and the shipping method (in another table, of course) to put onto the invoice so that we can use it for both pulling orders and printing a new copy to include for the customer. I do like the current invoice layout, so I do not want to alter that as substantially as you have.

I guess where I get lost is in trying to pull the data from different tables.

Re: Adding fields to invoices

Posted: Thu Jul 03, 2008 8:31 am
by jmestep
You might want to check with mazhar. I paid him for a snippet of code that puts the CC number on the invoice since I didn't have time to figure it all out. His price was reasonable and his code gives me a pattern for other things.

Re: Adding fields to invoices

Posted: Thu Jul 03, 2008 9:46 am
by heinscott
One way to accomplish this would be to create some kind of data structure, like a DataTable, and manually created all the columns you will need (Order#, Shipmethod, etc) and then loop through the order collection, and manually find the shipmethod and paymethod of each order, and, along with the order data, add that info as a new row in the DataTable.
Here is an example of one I had to do...

List<ProductInventoryDetail> l = ProductInventoryDataSource.GetLowProductInventory();
DataTable dt = new DataTable();
dt.Columns.Add("ProductId", typeof(int));
dt.Columns.Add("Name", typeof(String));
dt.Columns.Add("ProductVariantId", typeof(int));
dt.Columns.Add("VariantName", typeof(String));
dt.Columns.Add("InStock", typeof(int));
dt.Columns.Add("InStockWarningLevel", typeof(int));
dt.Columns.Add("ManName", typeof(String));
dt.Columns.Add("Sku", typeof(String));
dt.Columns.Add("LastOrdered", typeof(DateTime));
foreach (ProductInventoryDetail p in l)
{
//Put the logic here for getting additional information.
//Then add the data

dt.Rows.Add(new Object[] { p.ProductId, p.Name, p.ProductVariantId, p.VariantName, p.InStock, p.InStockWarningLevel, ManName, p1.Sku, LastOrdered });

}
InventoryGrid.DataSource = dt;
InventoryGrid.DataBind();

The items in red were ones that were not included in the object list, and hence required the extra work.

Hope this is helpful.

Scott

Re: Adding fields to invoices

Posted: Thu Jul 03, 2008 10:12 am
by m_plugables
jmestep wrote:You might want to check with mazhar. I paid him for a snippet of code that puts the CC number on the invoice since I didn't have time to figure it all out. His price was reasonable and his code gives me a pattern for other things.
Judy you own that code. You can post it if you like.

Re: Adding fields to invoices

Posted: Thu Jul 03, 2008 11:34 am
by jmestep
I'm not to post something I paid for!!!!!!!!!!!!!!! :D

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 9:44 am
by Brewhaus
Mazhar- I would be happy to pay for my own coding (cost dependent, of course). I imagine that it would be pretty straight forward- I just want to add the payment method to the Bill To window, and the shipping method to the Ship To window.

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 10:50 am
by compunerdy
This will give you all the info you asked for.

Code: Select all

<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Invoices" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>
<%@ Register Src="../../UserControls/OrderItemDetail.ascx" TagName="OrderItemDetail" TagPrefix="uc" %>

<script runat="server">
    private List<string> orderNumbers;
    protected int OrderCount = 0;
    
    private List<int> GetSelectedOrders()
    {
        //CHECK FOR QUERYSTRING PARAMETERS
        List<int> selectedOrders = new List<int>();
        string orderIdList = Request.QueryString["orders"];
        if (!string.IsNullOrEmpty(orderIdList))
        {
            string[] numberTokens = orderIdList.Split(",".ToCharArray());
            foreach (string numberToken in numberTokens)
            {
                int temp = AlwaysConvert.ToInt(numberToken);
                if (temp > 0) selectedOrders.Add(temp);
            }
        }
        return selectedOrders;
    }

    private string GetOrderNumbers(List<int> orders)
    {
        if (orderNumbers == null)
        {
            orderNumbers = new List<string>();
            foreach (int orderId in orders)
            {
                orderNumbers.Add(orderId.ToString());
            }
        }
        if (orderNumbers.Count == 0) return string.Empty;
        return string.Join(", ", orderNumbers.ToArray());
    }

    /// <summary>
    /// Gets a collection of orders from a list of order ids.
    /// </summary>
    /// <param name="orderIds">The orderIds to load.</param>
    /// <returns>A collection of orders from the list of ids.</returns>
    protected OrderCollection GetOrders(params int[] orderIds)
    {
        OrderCollection orders = new OrderCollection();
        orderNumbers = new List<string>();
        foreach (int orderId in orderIds)
        {
            Order order = OrderDataSource.Load(orderId);

			if (order != null)
            {
                orderNumbers.Add(order.OrderId.ToString());
                orders.Add(order);
            }
        }
        OrderCount = orders.Count;
        return orders;
    }

//BH080405 Create a new collection for Payments to access payment reference
    protected PaymentCollection GetPayments(int orderId)
    {
		Order order = OrderDataSource.Load(orderId);
        return order.Payments;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        List<int> selectedOrders = GetSelectedOrders();
        if ((selectedOrders == null) || (selectedOrders.Count == 0)) Response.Redirect("~/Admin/Orders/Default.aspx");
        OrderRepeater.DataSource = GetOrders(selectedOrders.ToArray());
        OrderRepeater.DataBind();
        OrderList.Text = GetOrderNumbers(selectedOrders);
    }

    protected OrderItemCollection GetProducts(object dataItem)
    {
        Order order = (Order)dataItem;
        OrderItemCollection products = new OrderItemCollection();
        foreach (OrderItem item in order.Items)
        {
            if (item.OrderItemType == OrderItemType.Product)
            {
                products.Add(item);
            }
        }
        products.Sort("Name");
        return products;
    }

    protected string GetBillToAddress(object dataItem)
    {
        return ((Order)dataItem).FormatAddress(true);
    }

    protected string GetShipToAddress(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> addressList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipTo = shipment.FormatToAddress();
            if (!addressList.Contains(shipTo)) addressList.Add(shipTo);
        }
        if (addressList.Count == 0) return "n/a";
        return string.Join("<hr />", addressList.ToArray());
    }
	
//BH080406  LOAD SHIPMETHOD NAME TO SHIPMENT
	protected string GetShippingMethod(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> shipmethodList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipmethod = shipment.ShipMethodName;
			shipmethodList.Add(shipmethod);
        }
        return string.Join("<hr/>", shipmethodList.ToArray());
    }
//////

//BH080406  LOAD SHIPMESSAGE TO SHIPMENT
	protected string GetShipMessage(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> shipmethodList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipmethod = shipment.ShipMessage;
			shipmethodList.Add(shipmethod);
        }
        return string.Join("<hr/>", shipmethodList.ToArray());
    }
//////


    protected LSDecimal GetTotal(object dataItem, params OrderItemType[] orderItems)
    {
        return ((Order)dataItem).Items.TotalPrice(orderItems);
    }

    protected LSDecimal GetTotalPayments(object dataItem)
    {
        return ((Order)dataItem).Payments.Total(true);
    }
    
    protected LSDecimal GetBalance(object dataItem)
    {
        return GetTotal(dataItem) - GetTotalPayments(dataItem);
    }
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="pageHeader noPrint">
        <div class="caption">
            <h1><asp:Localize ID="Caption" runat="server" Text="Invoices"></asp:Localize></h1>
        </div>
        <div class="content">
            <h2><asp:Localize ID="OrderListLabel" runat="server" Text="Includes Order Numbers:"></asp:Localize></h2>
            <asp:Label ID="OrderList" runat="server" Text=""></asp:Label><br />
            <p><asp:Localize ID="PrintInstructions" runat="server" Text="This document includes a printable stylesheet.  If you are using a modern browser (such as IE7, FF2, or Opera 7) this page will print with appropriate styles and page breaks if needed.  Website headers, footers, and this message will not be printed."></asp:Localize></p>
        </div>
    </div>
    <div class="noPrint">
        <asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
        <asp:Button ID="Back" runat="server" Text="Back" OnClientClick="window.history.go(-1);return false;" />
    </div>
    <asp:Repeater ID="OrderRepeater" runat="server">
        <ItemTemplate>
            <table align="center" class="form<%# (Container.ItemIndex < (OrderCount - 1)) ? " breakAfter" : string.Empty %>" cellpadding="0" cellspacing="0" border="1">
                <tr>
                    <td colspan="4" valign="middle">
                        <div style="float:left">
                            <br />
							<span class="inlineCaption" style="font-size:150%;"><%#Token.Instance.Store.Name%></span>
							<br />
                            <%# Token.Instance.Store.DefaultWarehouse.FormatAddress(true) %>
                        </div>
                        <div style="float:right">
                            <h1 class="invoice">INVOICE</h1>
                            <asp:Label ID="OrderNumberLabel" runat="server" Text="Order Number:" SkinID="FieldHeader"></asp:Label>
                            <asp:Label ID="OrderNumber" runat="server" Text='<%# Eval("OrderId") %>'></asp:Label><br />
                            <asp:Label ID="OrderDateLabel" runat="server" Text="Order Date:" SkinID="FieldHeader"></asp:Label>
                            <asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}") %>'></asp:Label><br />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td style="width:10px;text-align:center;font-weight:bold" valign="top">
                        S O L D &nbsp; T O
                    </td>
                    <td valign="middle" width="50%">
                        <%# GetBillToAddress(Container.DataItem) %><br>
<asp:Label ID="Label1" runat="server" Text="Billing Phone:"></asp:Label><%# Eval("BillToPhone") %><br>


<asp:formview 
                            	runat="server"
                                HorizontalAlign="left" 
                                id="paymentref_fv" 
                                DataSource='<%#GetPayments(Convert.ToInt32(Eval("OrderId")))%>' 
                      >
                            	<ItemTemplate>
					Payment method:
                                    <asp:Label ID="PaymentMethodName" runat="server" Text='<%#Eval("PaymentMethodName")%>'></asp:Label>
					                <asp:Label ID="ReferenceNumber" runat="server" Text='<%#Eval("ReferenceNumber")%>'></asp:Label> 
				</ItemTemplate>	
		                    </asp:formview>





                    </td>

                    <td style="width:10px;text-align:center;font-weight:bold" valign="top">
                        S H I P &nbsp; T O
                    </td>
                    <td valign="middle" width="50%">
                        <%# GetShipToAddress(Container.DataItem) %><br>Ship method:<%# GetShippingMethod(Container.DataItem) %>
                    </td>
                </tr>

                <tr>
                    <td colspan="4" class="dataSheet">
                        <asp:GridView ID="OrderItems" runat="server" ShowHeader="true"
                            AutoGenerateColumns="false" CellPadding=0 CellSpacing=0 GridLines="none" 
                            Width="100%" DataSource='<%#GetProducts(Container.DataItem)%>' CssClass="dataSheet">
                            <Columns>
                                <asp:BoundField DataField="Quantity" HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" />
                                <asp:BoundField DataField="Sku" HeaderText="Sku" ItemStyle-HorizontalAlign="Center" />
                                <asp:TemplateField HeaderText="Item">
                                    <ItemTemplate>
                                        <uc:OrderItemDetail ID="OrderItemDetail1" runat="server" OrderItem='<%#(OrderItem)Container.DataItem%>' ShowAssets="False" LinkProducts="False" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Price">
                                    <ItemStyle HorizontalAlign="right" width="80px" />
                                    <ItemTemplate>
                                        <asp:Label ID="Price" runat="server" Text='<%#Eval("ExtendedPrice", "{0:lc}")%>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <table width="100%" cellpadding="0" cellspacing="0" class="dataSheet">
                            <tr>
                                <th align="right">
                                    <asp:Label ID="SubtotalLabel" runat="server" Text="Subtotal:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Product)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
                                    <asp:Label ID="ShippingTotalLabel" runat="server" Text="Shipping:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Shipping, OrderItemType.Handling)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
                                    <asp:Label ID="TaxTotalLabel" runat="server" Text="Tax:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Tax)) %>
                                </td>
                            </tr>
                            <tr id="trOther" runat="server" visible='<%# GetTotal(Container.DataItem, OrderItemType.Charge, OrderItemType.Coupon, OrderItemType.Credit, OrderItemType.Discount, OrderItemType.GiftCertificate, OrderItemType.GiftWrap) > 0 %>'>
                                <th align="right">
                                    <asp:Label ID="OtherTotalLabel" runat="server" Text="Other:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Charge, OrderItemType.Coupon, OrderItemType.Credit, OrderItemType.Discount, OrderItemType.GiftCertificate, OrderItemType.GiftWrap)) %>
                                </td>
                            </tr>
                            <tr class="totalRow">
                                <th align="right">
                                    <asp:Label ID="TotalLabel" runat="server" Text="Total:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem)) %>
                                </td>
                            </tr>
                            <%--
                            <tr>
                                <th align="right">
                                    <asp:Label ID="PaymentsLabel" runat="server" Text="Payments:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotalPayments(Container.DataItem)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
                                    <asp:Label ID="BalanceLabel" runat="server" Text="Balance:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetBalance(Container.DataItem)) %>
                                </td>
                            </tr>
                            --%>
                        </table>
                    </td>
                </tr>
            </table>
        </ItemTemplate>
    </asp:Repeater>
</asp:Content>

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 12:40 pm
by Brewhaus
That is fantastic- thank you! :D

I wonder if there is a realistic way to add comments to the invoice, so that those pulling orders will see them (not that they pay attention half the time). Our other site automatically shows comments on the invoice, however, it does not allow for the updated commenting / addition of comments that AC does. This is a nice feature in AC, but will it make it difficult to show at least the original comment by the customer (for example, if they have special shipping instructions) on the invoice?

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 1:40 pm
by compunerdy
I have a place for the customer to add comments during checkout which are then displayed on the invoice. So yes it is possible but takes a bit of code changing to work.

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 1:52 pm
by Brewhaus
I have a comments box at the checkout. Is it simply a matter of pulling this information (if any is submitted) and putting it onto the invoice, similar to how the phone number, etc., are pulled (ie. from the SQL tables)?

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 2:07 pm
by compunerdy
Try adding this where you want it. That is if you used the shipmessage as I did for the comments box.

Code: Select all

<tr>
                    <td colspan="4" valign="middle" >
                    <asp:Label ID="GetShipMessageLabel" runat="server" Text="Ship Message: " SkinID="FieldHeader"></asp:Label>
                        <%# GetShipMessage(Container.DataItem) %>
                    </td>
                </tr>

Re: Adding fields to invoices

Posted: Fri Jul 04, 2008 8:40 pm
by cerami2

Code: Select all

try this flavor I moved a few things around



<%@ Page Language="C#" MasterPageFile="~/Admin/Admin.master" Title="Invoices" Inherits="CommerceBuilder.Web.UI.AbleCommerceAdminPage" %>
<%@ Register Src="../../UserControls/OrderItemDetail.ascx" TagName="OrderItemDetail" TagPrefix="uc" %>

<script runat="server">
    private List<string> orderNumbers;
    protected int OrderCount = 0;
    
    private List<int> GetSelectedOrders()
    {
        //CHECK FOR QUERYSTRING PARAMETERS
        List<int> selectedOrders = new List<int>();
        string orderIdList = Request.QueryString["orders"];
        if (!string.IsNullOrEmpty(orderIdList))
        {
            string[] numberTokens = orderIdList.Split(",".ToCharArray());
            foreach (string numberToken in numberTokens)
            {
                int temp = AlwaysConvert.ToInt(numberToken);
                if (temp > 0) selectedOrders.Add(temp);
            }
        }
        return selectedOrders;
    }

    private string GetOrderNumbers(List<int> orders)
    {
        if (orderNumbers == null)
        {
            orderNumbers = new List<string>();
            foreach (int orderId in orders)
            {
                orderNumbers.Add(orderId.ToString());
            }
        }
        if (orderNumbers.Count == 0) return string.Empty;
        return string.Join(", ", orderNumbers.ToArray());
    }

    /// <summary>
    /// Gets a collection of orders from a list of order ids.
    /// </summary>
    /// <param name="orderIds">The orderIds to load.</param>
    /// <returns>A collection of orders from the list of ids.</returns>
    protected OrderCollection GetOrders(params int[] orderIds)
    {
        OrderCollection orders = new OrderCollection();
        orderNumbers = new List<string>();
        foreach (int orderId in orderIds)
        {
            Order order = OrderDataSource.Load(orderId);

         if (order != null)
            {
                orderNumbers.Add(order.OrderId.ToString());
                orders.Add(order);
            }
        }
        OrderCount = orders.Count;
        return orders;
    }

//BH080405 Create a new collection for Payments to access payment reference
    protected PaymentCollection GetPayments(int orderId)
    {
      Order order = OrderDataSource.Load(orderId);
        return order.Payments;
    }
    
    protected void Page_Load(object sender, EventArgs e)
    {
        List<int> selectedOrders = GetSelectedOrders();
        if ((selectedOrders == null) || (selectedOrders.Count == 0)) Response.Redirect("~/Admin/Orders/Default.aspx");
        OrderRepeater.DataSource = GetOrders(selectedOrders.ToArray());
        OrderRepeater.DataBind();
        OrderList.Text = GetOrderNumbers(selectedOrders);
    }

    protected OrderItemCollection GetProducts(object dataItem)
    {
        Order order = (Order)dataItem;
        OrderItemCollection products = new OrderItemCollection();
        foreach (OrderItem item in order.Items)
        {
            if (item.OrderItemType == OrderItemType.Product)
            {
                products.Add(item);
            }
        }
        products.Sort("Name");
        return products;
    }

    protected string GetBillToAddress(object dataItem)
    {
        return ((Order)dataItem).FormatAddress(true);
    }

    protected string GetShipToAddress(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> addressList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipTo = shipment.FormatToAddress();
            if (!addressList.Contains(shipTo)) addressList.Add(shipTo);
        }
        if (addressList.Count == 0) return "n/a";
        return string.Join("<hr />", addressList.ToArray());
    }
   
//BH080406  LOAD SHIPMETHOD NAME TO SHIPMENT
   protected string GetShippingMethod(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> shipmethodList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipmethod = shipment.ShipMethodName;
         shipmethodList.Add(shipmethod);
        }
        return string.Join("<hr/>", shipmethodList.ToArray());
    }
//////

//BH080406  LOAD SHIPMESSAGE TO SHIPMENT
   protected string GetShipMessage(object dataItem)
    {
        Order order = (Order)dataItem;
        List<string> shipmethodList = new List<string>();
        foreach (OrderShipment shipment in order.Shipments)
        {
            string shipmethod = shipment.ShipMessage;
         shipmethodList.Add(shipmethod);
        }
        return string.Join("<hr/>", shipmethodList.ToArray());
    }
//////


    protected LSDecimal GetTotal(object dataItem, params OrderItemType[] orderItems)
    {
        return ((Order)dataItem).Items.TotalPrice(orderItems);
    }

    protected LSDecimal GetTotalPayments(object dataItem)
    {
        return ((Order)dataItem).Payments.Total(true);
    }
    
    protected LSDecimal GetBalance(object dataItem)
    {
        return GetTotal(dataItem) - GetTotalPayments(dataItem);
    }
    
</script>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
    <div class="pageHeader noPrint">
        <div class="caption">
            <h1><asp:Localize ID="Caption" runat="server" Text="Invoices"></asp:Localize></h1>
        </div>
        <div class="content">
            <h2><asp:Localize ID="OrderListLabel" runat="server" Text="Includes Order Numbers:"></asp:Localize></h2>
            <asp:Label ID="OrderList" runat="server" Text=""></asp:Label><br />
            <p><asp:Localize ID="PrintInstructions" runat="server" Text="This document includes a printable stylesheet.  If you are using a modern browser (such as IE7, FF2, or Opera 7) this page will print with appropriate styles and page breaks if needed.  Website headers, footers, and this message will not be printed."></asp:Localize></p>
        </div>
    </div>
    <div class="noPrint">
        <asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
        <asp:Button ID="Back" runat="server" Text="Back" OnClientClick="window.history.go(-1);return false;" />
    </div>
    <asp:Repeater ID="OrderRepeater" runat="server">
        <ItemTemplate>
            <table width="454" border="1" align="center" cellpadding="0" cellspacing="0" class="form<%# (Container.ItemIndex < (OrderCount - 1)) ? " breakAfter" : string.Empty %>">
<tr>
                    <td colspan="4" valign="top">
                        <div style="float:left">
                          <div align="left"><span class="inlineCaption" style="font-size:150%;"><%#Token.Instance.Store.Name%></span>
                            <br />
                            <%# Token.Instance.Store.DefaultWarehouse.FormatAddress(true) %></div>
                        </div>
                        <div style="float:right">
                            <h1 class="invoice">INVOICE</h1>
                            <asp:Label ID="OrderNumberLabel" runat="server" Text="Order Number:" SkinID="FieldHeader"></asp:Label>
                            <asp:Label ID="OrderNumber" runat="server" Text='<%# Eval("OrderId") %>'></asp:Label><br />
                            <asp:Label ID="OrderDateLabel" runat="server" Text="Order Date:" SkinID="FieldHeader"></asp:Label>
                            <asp:Label ID="OrderDate" runat="server" Text='<%# Eval("OrderDate", "{0:g}") %>'></asp:Label><br />
                        </div>                    </td>
                </tr>
                <tr>
                    <td width="10" valign="top" bgcolor="#FFFFFF" style="width:10px;text-align:center;font-weight:normal">
                        S O L D &nbsp; T O </td>
<td width="173" valign="top">
                        <p><%# GetBillToAddress(Container.DataItem) %><br>
            </p>
<p>
                    <asp:Label ID="Label1" runat="server" Text="Billing Phone:"></asp:Label>
                            <strong><%# Eval("BillToPhone") %></strong><br>
                                                </p>
<asp:formview 
                               runat="server"
                                HorizontalAlign="left" 
                                id="paymentref_fv" 
                                DataSource='<%#GetPayments(Convert.ToInt32(Eval("OrderId")))%>' 
                      >
                               <ItemTemplate>
               Payment method:
                                    <asp:Label ID="PaymentMethodName" runat="server" Text='<%#Eval("PaymentMethodName")%>'></asp:Label>
                               <asp:Label ID="ReferenceNumber" runat="server" Text='<%#Eval("ReferenceNumber")%>'></asp:Label> 
            </ItemTemplate>   
                          </asp:formview>                    </td>

              <td width="10" valign="top" bgcolor="#FFFFFF" style="width:10px;text-align:center;font-weight:normal">
                <div align="left"><font color="#000000">S H I P &nbsp; T O</font>                  </div></td>
<td width="237" valign="top">
<p><%# GetShipToAddress(Container.DataItem) %><br>
                        </p>
                        <p>&nbsp;</p>
            <p><strong>Ship Method</strong>:&nbsp;<strong><font color="#FF0000" size="4"> <%# GetShippingMethod(Container.DataItem) %></font></strong> </p></td>
              </tr>
                <tr>
                  <td colspan="4" valign="top" style="width:10px;text-align:center;font-weight:bold"><%-- BH080406 ADD ROW FOR SHIPPING METHOD AND SHIP MESSAGE --%>                
                <tr>
                    <td colspan="4" valign="middle" >
                    <asp:Label ID="GetShipMessageLabel" runat="server" Text="Ship Message: " SkinID="FieldHeader"></asp:Label>
                        <%# GetShipMessage(Container.DataItem) %>                    </td>
                </tr>
<%-- BH080406 ADD ROW FOR SHIPPING METHOD AND SHIP MESSAGE --%>&nbsp;</td>
                </tr>

                <tr>
                    <td colspan="5" class="dataSheet">
                        <asp:GridView ID="OrderItems" runat="server" ShowHeader="true"
                            AutoGenerateColumns="false" CellPadding=0 CellSpacing=0 GridLines="none" 
                            Width="100%" DataSource='<%#GetProducts(Container.DataItem)%>' CssClass="dataSheet">
                            <Columns>


<asp:TemplateField HeaderText="Pulled" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                          <ItemTemplate>
                                 [&nbsp;&nbsp;&nbsp;]
                          </ItemTemplate>
                      </asp:TemplateField> 



                                <asp:BoundField DataField="Quantity" HeaderText="Quantity" ItemStyle-HorizontalAlign="Center" />
                                <asp:BoundField DataField="Sku" HeaderText="Sku" ItemStyle-HorizontalAlign="Center" />
                                <asp:TemplateField HeaderText="Item">
                                    <ItemTemplate>
                                        <uc:OrderItemDetail ID="OrderItemDetail1" runat="server" OrderItem='<%#(OrderItem)Container.DataItem%>' ShowAssets="False" LinkProducts="False" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Price">
                                    <ItemStyle HorizontalAlign="right" width="80px" />
                                    <ItemTemplate>
                                        <asp:Label ID="Price" runat="server" Text='<%#Eval("ExtendedPrice", "{0:lc}")%>'></asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                        <table width="100%" cellpadding="0" cellspacing="0" class="dataSheet">
                            <tr>
                                <th align="right">
                                    <asp:Label ID="SubtotalLabel" runat="server" Text="Subtotal:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Product)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
            
                                    <asp:Label ID="ShippingTotalLabel" runat="server" Text="Shipping:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Shipping, OrderItemType.Handling)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
                                    <asp:Label ID="TaxTotalLabel" runat="server" Text="Tax:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Tax)) %>
                                </td>
                            </tr>
                          <tr id="trOther" runat="server" > 
                                <th align="right">
                                    <asp:Label ID="OtherTotalLabel" runat="server" Text="Discounts & Other:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem, OrderItemType.Charge, OrderItemType.Coupon, OrderItemType.Credit, OrderItemType.Discount, OrderItemType.GiftCertificate, OrderItemType.GiftWrap)) %>
                                </td>
                            </tr>
                            <tr class="totalRow">
                                <th align="right">
                                    <asp:Label ID="TotalLabel" runat="server" Text="Total:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotal(Container.DataItem)) %>
                                </td>
                            </tr>
                            
                            
                            <%--
                            <tr>
                                <th align="right">
                                    <asp:Label ID="PaymentsLabel" runat="server" Text="Payments:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetTotalPayments(Container.DataItem)) %>
                                </td>
                            </tr>
                            <tr>
                                <th align="right">
                                    <asp:Label ID="BalanceLabel" runat="server" Text="Balance:" />
                                </th>
                                <td align="right" width="80px">
                                    <%# string.Format("{0:lc}", GetBalance(Container.DataItem)) %>
                                </td>
                            </tr>
                            --%>
                            
                        </table>
                    </td>
                </tr>
            </table>
      </ItemTemplate>
    </asp:Repeater>         

</asp:Content>


Re: Adding fields to invoices

Posted: Sat Jul 05, 2008 5:05 pm
by Brewhaus
Thanks for the options! :)

Re: Adding fields to invoices

Posted: Wed Aug 06, 2008 9:44 pm
by cerami2
I just added the text for discount & other so it would showup and it does show the discount now when there is one


Thanks
Joe