switched csv export to excel export
This commit is contained in:
@@ -60,8 +60,8 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
$orderItems[$item['orderId']] = [];
|
||||
}
|
||||
|
||||
$article = array_search($item['articleId'], array_column($articles, 'id'));
|
||||
$articlePacket = array_search($item['articlePacketId'], array_column($articlePackets, 'id'));
|
||||
$article = $item['articleId'] ? array_search($item['articleId'], array_column($articles, 'id')) : null;
|
||||
$articlePacket = $item['articlePacketId'] ? array_search($item['articlePacketId'], array_column($articlePackets, 'id')) : null;
|
||||
|
||||
$orderItems[$item['orderId']][] = [
|
||||
'id' => $item['id'],
|
||||
@@ -147,18 +147,26 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
}
|
||||
|
||||
$ordersItems = $this->getAllOrderItemsPerOrder();
|
||||
$rows = [];
|
||||
|
||||
// Create CSV with these Headers: Adressnummer, Name, Straße, Postleitzahl, Ort, Land, Anschriftenzusatz 1
|
||||
$csv = "Adressnummer,Name,Straße,Postleitzahl,Ort,Land,Anschriftenzusatz 1,Produkte\n";
|
||||
foreach ($orders as $order) {
|
||||
$orderItems = $ordersItems[$order['id']];
|
||||
$orderItemsStr = join(' : ', array_map(function($item) {
|
||||
$orderItemsStr = join('; ', array_map(function($item) {
|
||||
$articleTitle = $item['articleTitle'] ?? $item['articlePacketTitle'];
|
||||
$quantity = $item['quantity'];
|
||||
return "$quantity x $articleTitle";
|
||||
}, $orderItems));
|
||||
|
||||
$csv .= '23000539,' . $order['deliveryAddressName'] . ',' . $order['deliveryAddressLine'] . ',' . $order['deliveryAddressPLZ'] . ',' . $order['deliveryAddressCity'] . ',AT,,'. $orderItemsStr . "\n";
|
||||
$rows[] = [
|
||||
'AddressNumber' => '23000539',
|
||||
'Name' => $order['deliveryAddressName'],
|
||||
'Straße' => $order['deliveryAddressLine'],
|
||||
'Postleitzahl' => $order['deliveryAddressPLZ'],
|
||||
'Ort' => $order['deliveryAddressCity'],
|
||||
'Land' => 'AT',
|
||||
'Anschriftenzusatz 1' => '',
|
||||
'Produkte' => $orderItemsStr
|
||||
];
|
||||
|
||||
WarehouseHistoryModel::create([
|
||||
'table' => 'WarehouseEShopOrder',
|
||||
@@ -173,10 +181,9 @@ class WarehouseEShopOrderController extends TTCrud {
|
||||
|
||||
$order['status'] = 'accepted';
|
||||
WarehouseEShopOrderModel::update($order);
|
||||
|
||||
}
|
||||
|
||||
die($csv);
|
||||
self::returnJson($rows);
|
||||
}
|
||||
|
||||
protected function beforeUpdate($postData): bool {
|
||||
|
||||
Reference in New Issue
Block a user