Print multiple orders together at once

In this example we will see how to realize a print that allows to join multiple orders together using the document object.

Script Group

Program

Event

Action


table_rows = database.getsql("SELECT gguid FROM orders WHERE eli=0")

We begin to extrapolate what orders we are going to print. In this case we say that we will take them all. Obviously it is better to insert a filter system as per date or customer.

To make the prints, however, we will only need the gguid of each order

rows = table_rows.getrows()

print = nil

for i = 1,table_rows.countrows() do

if print == nil then

print = database.createdocument("gguidprint", "orders",rows[i].getvalue("gguid"))

else

print2 = database.createdocument("gguidprint", "orders",rows[i].getvalue("gguid"))

print.adddocument(print2)

end

end

if print != nil then

print.show()

end

Let's start by turning all the rows in the table. We created an empty print object because we need to create a first document that collects all the others.

After setting the print object, all other orders will be appended to this.

At the end if at least one print is present we will proceed to show it.