salix/print/templates/reports/cmr/sql/data.sql

52 lines
1.5 KiB
MySQL
Raw Normal View History

2023-08-02 05:35:40 +00:00
SELECT c.id cmrFk,
2023-08-03 06:39:37 +00:00
t.id ticketFk,
2023-08-02 05:35:40 +00:00
c.truckPlate,
c.observations,
c.senderInstruccions,
c.paymentInstruccions,
c.specialAgreements,
c.created,
c.packagesList,
c.merchandiseDetail,
c.ead,
s.name carrierName,
2024-03-14 07:36:19 +00:00
s.nif carrierCif,
2023-08-02 05:35:40 +00:00
s.street carrierStreet,
s.postCode carrierPostCode,
s.city carrierCity,
2024-04-25 10:35:21 +00:00
cou.name carrierCountry,
2023-08-02 05:35:40 +00:00
s2.name senderName,
s2.street senderStreet,
s2.postCode senderPostCode,
s2.city senderCity,
2024-04-25 10:35:21 +00:00
cou2.name senderCountry,
2023-08-02 05:35:40 +00:00
a.street deliveryStreet,
a.id deliveryAddressFk,
a.postalCode deliveryPostalCode,
a.city deliveryCity,
a.nickname deliveryName,
a.phone deliveryPhone,
a.mobile deliveryMobile,
2024-04-25 10:35:21 +00:00
cou3.name deliveryCountry,
2023-08-02 05:35:40 +00:00
cl.phone clientPhone,
a2.street loadStreet,
a2.postalCode loadPostalCode,
a2.city loadCity,
2024-04-25 10:35:21 +00:00
cou4.name loadCountry,
2023-08-02 11:41:44 +00:00
co.stamp senderStamp,
s.stamp deliveryStamp
2023-08-02 05:35:40 +00:00
FROM cmr c
LEFT JOIN supplier s ON s.id = c.supplierFk
LEFT JOIN country cou ON cou.id = s.countryFk
LEFT JOIN company co ON co.id = c.companyFk
2024-05-03 15:37:36 +00:00
LEFT JOIN supplier s2 ON s2.id = c.companyFk
2023-08-02 05:35:40 +00:00
LEFT JOIN country cou2 ON cou2.id = s2.countryFk
LEFT JOIN `address` a ON a.id = c.addressToFk
LEFT JOIN province p ON p.id = a.provinceFk
LEFT JOIN country cou3 ON cou3.id = p.countryFk
LEFT JOIN client cl ON cl.id = a.clientFk
LEFT JOIN `address` a2 ON a2.id = c.addressFromFk
LEFT JOIN province p2 ON p2.id = a2.provinceFk
LEFT JOIN country cou4 ON cou4.id = p2.countryFk
2023-08-03 06:39:37 +00:00
LEFT JOIN ticket t ON t.cmrFk = c.id
2023-08-02 05:35:40 +00:00
WHERE c.id = ?