1b.app
Link copied -

Sort in shipping list template by value when reading from suborder array

Previously, they helped with the creation of a shipping list template through the suborder variable. https://crm-onebox.com/en/support/documents/10402-peremennaya-suborder-v-dokumen...
Everything is working! With a large number of shipments, you need to sort the table by a certain variable, for example, by transport company: TC {|$suborder.customOrder_transportnayakompaniya24|} . The default sorting is by subprocess number.
How to sort by a certain variable when reading from suborder array?
Shipping List Template: https://more-moto.crm-onebox.com/admin/shop/document/templates/37/control/
Shipment process for verification: https://more-moto.crm-onebox.com/admin/customorder/dostavka/5786/edit/
Original question is available on version: ru

Answers:


How to sort by a certain variable when reading from suborder array?

I don't think you can sort an array like this in HTML.
Here, except to refine it somehow directly in the document generation, where to set the sorting globally - but this is not very obvious ..
Do you need this purely for 1 PSU and 1 template?
06.09.2021, 17:52
Original comment available on version: ru

Found an example of a sorting solution for a multidimensional array using the usort() and array_multisort() functions
https://world-hello.ru/php/how-to-php/otsortirovat-mnogomernyj-massiv.html
In theory, you can read the array and output it back sorted by the desired value. But I can't figure it out.
All this is needed to create a list of orders for shipment. For the Shipment BP and the Shipping List template.
In theory, this is generally a typical task for each Crm user - to create a shipping list and there should be a proven solution on how to do this. Perhaps there is a simpler solution, such as exporting to a Google spreadsheet. But the option with an array is more convenient. And it is already ready, it remains to figure out the sorting and I hope everything :)
07.09.2021, 22:51
Original comment available on version: ru

Invented, it is possible even more simply and more conveniently without sorting. Display in the document template several tables in a row for each transport company.
When reading the array, make a filter by the value of the transport company {|$suborder.customOrder_transportnayakompaniya24|}.
If the value of TC=PEC, display only orders in the PEC in the table, If the value TC=CDEK, display in the following table, etc.
How can you make a filter?
08.09.2021, 07:45
Original comment available on version: ru


Found an example of a sorting solution for a multidimensional array using the usort() and array_multisort() functions
https://world-hello.ru/php/how-to-php/otsortirovat-mnogomernyj-massiv.html
In theory, you can read the array and output it back sorted by the desired value. But I can't figure it out.
All this is needed to create a list of orders for shipment. For the Shipment BP and the Shipping List template.
In theory, this is generally a typical task for each Crm user - to create a shipping list and there should be a proven solution on how to do this. Perhaps there is a simpler solution, such as exporting to a Google spreadsheet. But the option with an array is more convenient. And it is already ready, it remains to figure out the sorting and I hope everything :)

I know how to sort arrays on the web server side)
But you must understand that this must be done by some setting for the document template - by which additional field to sort the subprocesses. To do this, it will take about 4 hours.

Invented, it is possible even more simply and more conveniently without sorting. Display in the document template several tables in a row for each transport company.
When reading the array, make a filter by the value of the transport company {|$suborder.customOrder_transportnayakompaniya24|}.
If the value of TC=PEC, display only orders in the PEC in the table, If the value TC=CDEK, display in the following table, etc.
How can you make a filter?

It’s not particularly easy to do this on smarty, because these values \u200b\u200bwill not be constant and in different quantities.
Well, in general, you can if'at conditions on smarty - something might work out)
09.09.2021, 17:22
Original comment available on version: ru

Please join the conversation. If you have something to say - please write a comment. You will need a mobile phone and an SMS code for identification to enter. Log in and comment