How to selectively mark as printed based on a certain status
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
How to selectively mark as printed based on a certain status
I got the orders to be marked as printed after printing but I have found this can be a issue sometimes. Is there a way to make it so that if the order is not a certain status then it does not get marked as printed. For instance if it is not order status of payment completed then do not mark as printed. The issue I have is sometimes I will reprint a invoice after it has been shipped and this will change the status from completed to packing list printed.
Re: Customizations in Gold
Edit Your Admin/Orders/Print/Invoices.aspx.cs file and locate following codecompunerdy wrote:I got the orders to be marked as printed after printing but I have found this can be a issue sometimes. Is there a way to make it so that if the order is not a certain status then it does not get marked as printed. For instance if it is not order status of payment completed then do not mark as printed. The issue I have is sometimes I will reprint a invoice after it has been shipped and this will change the status from completed to packing list printed.
Code: Select all
foreach (Order order in orders)
{
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
Code: Select all
foreach (Order order in orders)
{
if (order.OrderStatus != null && order.OrderStatus.Name != "YOUR PRINT ONLY STATUS NAME")
continue;
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
- jmestep
- AbleCommerce Angel
- Posts: 8164
- Joined: Sun Feb 29, 2004 8:04 pm
- Location: Dayton, OH
- Contact:
Re: Customizations in Gold
Mazhar, what version of Gold/browser are you using to get the above to work? I had to struggle with that also and when I print an invoice in R9 and R10, the Print_Click is never hit as long as the OnClientClick is present.
Judy Estep
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Web Developer
jestep@web2market.com
http://www.web2market.com
708-653-3100 x209
New search report plugin for business intelligence:
http://www.web2market.com/Search-Report ... -P154.aspx
Re: Customizations in Gold
I am using Gold R11 but I haven't tried the code. I just looked at the place where we trigger print event. In above change it will still open the print screen but it wouldn't trigger print event unless order status is of a specific name.
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: Customizations in Gold
This is not working for me. Here is my code..
I printed a invoice for a order with order status completed and it still was changed to packing list printed.
Code: Select all
protected void Print_Click(object sender, EventArgs e)
{
IList<int> selectedOrders = GetSelectedOrders();
if ((selectedOrders == null) || (selectedOrders.Count == 0))
return;
IList<Order> orders = GetOrders(selectedOrders.ToArray());
foreach (Order order in orders)
{
if (order.OrderStatus != null && order.OrderStatus.Name != "Payment Completed")
continue;
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
}
Re: Customizations in Gold
This is the issue with firefox browser with printing. When you call print using button OnClientClick event, the OnClick event never got fired. As a result the code inside Print_Click never executed.
To fix this issue, you can put the print function inside Print_Click and remove the OnClientClick from print button.
To do so open Admin/Orders/Print/Invoices.aspx
Locate
and replace with
Similarly, open Admin/Orders/Print/Invoices.aspx.cs
Locate
and replace with
To fix this issue, you can put the print function inside Print_Click and remove the OnClientClick from print button.
To do so open Admin/Orders/Print/Invoices.aspx
Locate
Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();" OnClick="Print_Click" />
Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClick="Print_Click" />
Locate
Code: Select all
protected void Print_Click(object sender, EventArgs e)
{
IList<int> selectedOrders = GetSelectedOrders();
if ((selectedOrders == null) || (selectedOrders.Count == 0))
return;
IList<Order> orders = GetOrders(selectedOrders.ToArray());
foreach (Order order in orders)
{
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
}
Code: Select all
protected void Print_Click(object sender, EventArgs e)
{
string scriptKey = "scriptKey";
if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), scriptKey))
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), scriptKey, "window.print();", true);
}
IList<int> selectedOrders = GetSelectedOrders();
if ((selectedOrders == null) || (selectedOrders.Count == 0))
return;
IList<Order> orders = GetOrders(selectedOrders.ToArray());
foreach (Order order in orders)
{
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
}
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: Customizations in Gold
I am confused here..
The original code to change the order status to "packing list printed" worked just fine for me. The problem was if I tried to reprint a order that was order status "completed" for example it would change the status to "packing list printed" which I did not want it to do. So I asked for code that would only change the status to "packing list printed" if the current order status was "payment completed" which I think Maz tried to give me but it did not work for me. Obviously the order status's I listed may not be standard ones but I am sure you get where I am going. If it matters I am using the Edge browser.
The original code to change the order status to "packing list printed" worked just fine for me. The problem was if I tried to reprint a order that was order status "completed" for example it would change the status to "packing list printed" which I did not want it to do. So I asked for code that would only change the status to "packing list printed" if the current order status was "payment completed" which I think Maz tried to give me but it did not work for me. Obviously the order status's I listed may not be standard ones but I am sure you get where I am going. If it matters I am using the Edge browser.
Re: Customizations in Gold
Original code wasn't working in Firefox browser because the Print_Click event wasn't firing. Now that the main issue is fixed, you can use part of code provided by Mazhar to get your desired results.
At Admin/Orders/Print/Invoices.aspx use the following code
and below code at Admin/Orders/Print/Invoices.aspx.cs
At Admin/Orders/Print/Invoices.aspx use the following code
Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClick="Print_Click" />
and below code at Admin/Orders/Print/Invoices.aspx.cs
Code: Select all
protected void Print_Click(object sender, EventArgs e)
{
string scriptKey = "scriptKey";
if (!Page.ClientScript.IsStartupScriptRegistered(Page.GetType(), scriptKey))
{
this.Page.ClientScript.RegisterStartupScript(this.GetType(), scriptKey, "window.print();", true);
}
IList<int> selectedOrders = GetSelectedOrders();
if ((selectedOrders == null) || (selectedOrders.Count == 0))
return;
IList<Order> orders = GetOrders(selectedOrders.ToArray());
foreach (Order order in orders)
{
if (order.OrderStatus != null && order.OrderStatus.Name != "Payment Completed")
continue;
EventsManager.Instance.RaiseOrderInvoicePrinted(null, new OrderEventArgs(order));
}
}
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: Customizations in Gold
This code below is what made it so orders where marked as printed.. using the code you posted above does not mark orders as printed.
mazhar wrote:Edit your Invoice.ascx.cs file and add following method to itWhen an order is printed the status needs to be updated to Order Printed. It was originally addressed at viewtopic.php?f=42&t=8681, but those modifications do not seem to work with Gold, no matter how many different ways we try them.Now find the following line of code in Invoices.ascx fileCode: Select all
protected void MarkPrinted_Click(object sender, EventArgs e) { IList<int> selectedOrders = GetSelectedOrders(); if ((selectedOrders == null) || (selectedOrders.Count == 0)) Response.Redirect("~/Admin/Orders/Default.aspx"); IList<Order> orders = GetOrders(selectedOrders.ToArray()); OrderStatus orderStatus = OrderStatusDataSource.Load(7); foreach (Order order in orders) order.UpdateOrderStatus(orderStatus); }
and make it look likeCode: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return false;" />
This change will change the order status with the print button.Code: Select all
<asp:Button ID="Print" runat="server" Text="Print" OnClientClick="window.print();return true;" OnClick="MarkPrinted_Click" />
Re: Customizations in Gold
Sorry if I'm jumping into the middle of this conversation, but I didn't know if you had seen that we have new triggers in Gold so you can change the order status automatically upon printing. Three new triggers are available for Order Invoice Printed, Packing List Printed, and Inventory Pull Sheet Printed.
Thank you for choosing AbleCommerce!
http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support
http://help.ablecommerce.com - product support
http://wiki.ablecommerce.com - developer support
- compunerdy
- Admiral (ADM)
- Posts: 1283
- Joined: Sun Nov 18, 2007 3:55 pm
Re: How to selectively mark as printed based on a certain status
Thanks to Katie I setup the built in trigger and then Nadeem's code worked for me.. Thanks!!!