Create/Add a note to order history when Invoice Printed
-
- Lieutenant (LT)
- Posts: 77
- Joined: Mon Apr 19, 2010 4:52 pm
Create/Add a note to order history when Invoice Printed
Anyone have the code to add a note (private) to the order history when an invoice is printed?
Bottom line is that our coordination would be enhanced if we could look in the history/notes and see that one of us had already printed the invoice.
Seems that capturing that when it is actually printed (admin user hits the print button instead of the back button) there is no current way to get control. Maybe there is...
I'd even be semi-satisfied if we could just know when the order's invoice was displayed for printing.
Bottom line is that our coordination would be enhanced if we could look in the history/notes and see that one of us had already printed the invoice.
Seems that capturing that when it is actually printed (admin user hits the print button instead of the back button) there is no current way to get control. Maybe there is...
I'd even be semi-satisfied if we could just know when the order's invoice was displayed for printing.
Re: Create/Add a note to order history when Invoice Printed
Have a look at this
viewtopic.php?f=42&t=9146
viewtopic.php?f=42&t=9146
-
- Lieutenant (LT)
- Posts: 77
- Joined: Mon Apr 19, 2010 4:52 pm
Re: Create/Add a note to order history when Invoice Printed
mazhar
Perhaps I wasn't clear. The thread you referred me to is for the situation where they want the existing notes to be added to the invoice displayed and printed.
I am seeking the opposite...When an admin prints a customer invoice I want to add a private note to the history that shows when/who printed that invoice.
So, when the administrator prints the invoice I want to add a note that would appear in the Order History and Notes as something like this:
8/2/2010 1:00:02 PM admin@ourstore.com The invoice has been printed.
Perhaps I wasn't clear. The thread you referred me to is for the situation where they want the existing notes to be added to the invoice displayed and printed.
I am seeking the opposite...When an admin prints a customer invoice I want to add a private note to the history that shows when/who printed that invoice.
So, when the administrator prints the invoice I want to add a note that would appear in the Order History and Notes as something like this:
8/2/2010 1:00:02 PM admin@ourstore.com The invoice has been printed.
Re: Create/Add a note to order history when Invoice Printed
You can try following trick. Edit your Admin/Orders/Print/Invoices.aspx file and locate following code line
and update it as
Now edit Admin/Orders/Print/Invoices.aspx.cs file and add following code just above the last closing curly brace.
save the changes and try print invoice for some test order then see its not section for private note
Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" OnClick="Print_Click" />
Code: Select all
protected void Print_Click(Object sender,EventArgs e)
{
List<int> selectedOrders = GetSelectedOrders();
foreach (int orderId in selectedOrders)
{
Order order = OrderDataSource.Load(orderId);
OrderNote note = new OrderNote();
note.Comment = string.Format("Invoice Printed By {0}", Token.Instance.User.UserName);
note.CreatedDate = LocaleHelper.LocalNow;
note.NoteType = NoteType.Private;
order.Notes.Add(note);
order.Save();
}
}
-
- Lieutenant (LT)
- Posts: 77
- Joined: Mon Apr 19, 2010 4:52 pm
Re: Create/Add a note to order history when Invoice Printed
Hmm, it doesn't seem to be running both scripts (the actual print, caused by the OnClientClick, and the "Print_Click" script.
I can tell the "Print_Click" is correctly in the .cs because I can take the following line and add it to the Admin/Orders/Print/Invoices.aspx file and cause the note to be added:
Why isn't the OnClick="Print_Click and OnClientClick="window.print();return false;" not both running when the button is clicked? DId we miss something obvious?
I can tell the "Print_Click" is correctly in the .cs because I can take the following line and add it to the Admin/Orders/Print/Invoices.aspx file and cause the note to be added:
Code: Select all
<asp:Button ID="Print1" runat="server" Text="Print1" OnClick="Print_Click" />
Re: Create/Add a note to order history when Invoice Printed
try updating this part
to
Code: Select all
OnClientClick="window.print();return false;"
Code: Select all
OnClientClick="window.print();"
-
- Lieutenant (LT)
- Posts: 77
- Joined: Mon Apr 19, 2010 4:52 pm
Re: Create/Add a note to order history when Invoice Printed
Done and works exactly as needed.