Skip to content

Commit

Permalink
add order printing
Browse files Browse the repository at this point in the history
add order printing
  • Loading branch information
yushine committed Jan 2, 2025
1 parent d6007ac commit 989a8db
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions innopacks/panel/resources/views/orders/info.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
@foreach($next_statuses as $status)
<button class="btn btn-primary ms-2" @click="edit('{{ $status['status'] }}')">{{ $status['name'] }}</button>
@endforeach
<a class="btn btn-primary ms-2" href="{{ panel_route('orders.printing', $order) }}" target="_blank">{{ panel_trans('order.print') }}</a>
<el-dialog v-model="statusDialog" title="{{ __('panel/order.status') }}" width="500">
<div class="mb-2">{{ __('panel/order.comment') }}</div>
<textarea v-model="comment" class="form-control" placeholder="{{ __('panel/order.comment') }}"
Expand Down
103 changes: 103 additions & 0 deletions innopacks/panel/resources/views/orders/printing.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<!DOCTYPE html>
<html dir="{{ panel_locale_direction() }}" lang="{{ panel_locale_code() }}">
<head>
<meta charset="UTF-8"/>
<title>{{ config('app.name') }} {{ __("panel/order.ship_list") }}</title>
<link href="{{ mix('/build/panel/css/bootstrap.css') }}" rel="stylesheet">
<style media="print">
.printer {
display: none;
}
.btn {
display: none;
}
</style>
</head>

<body>
<div class="container">
<div id="print-button">
<p style="text-align: right;">
<button class="btn btn-primary right" type="button" onclick="window.print()"
class="printer">{{ __("panel/order.print") }}</button>
</p>
</div>

<div style="page-break-after: always;">
<h1 style="text-align: center;">{{ config('app.name') }} {{ __("panel/order.ship_list") }}</h1>
<table class="table">
<tbody>
<tr>
<td>
<b>{{ __("panel/order.shipping_customer_name") }}: </b> {{ $order['shipping_customer_name'] }}<br/>
<b>{{ __("panel/order.telephone") }}: </b> {{ $order['shipping_telephone'] }}<br/>
<b>{{ __("panel/order.email") }}: </b> {{ $order['email'] }}<br/>
<b>{{ __("panel/order.shipping_address") }}:
</b> {{ $order['shipping_customer_name'] . "(" . $order['shipping_telephone'] . ")". ' ', $order['shipping_address_1'] . ' ' . $order['shipping_address_2'] . ' ' . $order['shipping_city'] . ' ' . $order['shipping_zone'] . ' ' . $order['shipping_country'] }}
<br/>
</td>
<td style="width: 50%;">
<b>{{ __("panel/order.number") }}: </b> {{ $order['number'] }}<br/>
<b>{{ __("panel/order.created_at") }}: </b> {{ $order['created_at'] }}<br/>
</td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<thead>
<tr>
<td><b>{{ __("panel/order.index") }}</b></td>
<td><b>{{ __("panel/order.image") }}</b></td>
<td><b>{{ __("panel/order.product") }}</b></td>
<td><b>{{ __("panel/order.sku_code") }}</b></td>
<td class="text-right"><b>{{ __("panel/order.quantity") }}</b></td>
<td class="text-right"><b>{{ __("panel/order.unit_price") }}</b></td>
<td class="text-right"><b>{{ __("panel/order.total") }}</b></td>
</tr>
</thead>
<tbody>
@if ($order->items)
@foreach ($order->items as $product)
<tr>
<td>{{ $loop->iteration }}</td>
<td><img class="img-thumbnail" src="{{ $product['image'] }}" style="width: 30px;"></td>
<td>{{ $product['name'] }}</td>
<td>{{ $product['product_sku'] }}</td>
<td class="text-right">{{ $product['quantity'] }}</td>
<td class="text-right">{{ currency_format($product['price']) }}</td>
<td class="text-right">{{ currency_format($product['subtotal']) }}</td>
</tr>
@endforeach
@endif
</tbody>
</table>
<table class="table">
<thead style="border-top: 1px solid #ddd;">
@foreach ($order->fees as $total)
<tr>
<td colspan="6"></td>
<td><b>{{ $total->title }}</b>: {{ $total->value_format }}</td>
</tr>
@endforeach
<tr>
<td colspan="6"></td>
<td><b>{{ __("panel/order.total") }}</b>: {{ currency_format($order['total']) }}</td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="3">
<b>{{ $order['store_name'] }}</b> <br/>
<b>{{ __("panel/order.telephone") }}: </b> {{ $order['shipping_telephone'] }}<br/>
<b>{{ __("panel/order.email") }}: </b> {{ $order['email'] }}<br/>
<b>{{ __("panel/order.website") }}: </b> <a href="{{ config('app.url') }}">{{ config('app.url') }}</a></td>
</td>
</tr>
</tbody>
</table>
</div>

</div>
</body>
</html>
1 change: 1 addition & 0 deletions innopacks/panel/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
Route::post('/upload/files', [Controllers\UploadController::class, 'files'])->name('upload.files');

Route::resource('/orders', Controllers\OrderController::class);
Route::get('/orders/{order}/printing', [Controllers\OrderController::class, 'printing'])->name('orders.printing');
Route::put('/orders/{order}/status', [Controllers\OrderController::class, 'changeStatus'])->name('orders.change_status');

Route::resource('/order_returns', Controllers\OrderReturnController::class);
Expand Down
13 changes: 13 additions & 0 deletions innopacks/panel/src/Controllers/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,19 @@ public function form(Order $order): mixed
return inno_view('panel::orders.info', $data);
}

/**
* @param Order $order
* @return mixed
*/
public function printing(Order $order): mixed
{
$data = [
'order' => $order,
];

return inno_view('panel::orders.printing', $data);
}

/**
* @param Order $order
* @return RedirectResponse
Expand Down
5 changes: 5 additions & 0 deletions lang/en/panel/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@
'billing_address_2' => 'Billing Address 2',
'billing_zipcode' => 'Billing Zipcode',
'created_at' => 'Place At',
'index' => 'NO.',
'image' => 'Image',
'print' => 'Print',
'ship_list' => 'Ship List',
'website' => 'Website',
];
5 changes: 5 additions & 0 deletions lang/zh_cn/panel/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
'date_time' => '更新时间',
'email' => '电子邮件',
'history' => '状态历史',
'index' => '序号',
'image' => '图片',
'ip' => 'IP地址',
'locale' => '客户语言',
'number' => '订单号',
'order_info' => '订单信息',
'order_items' => '订单商品',
'paid' => '已付款',
'print' => '打印',
'product' => '商品',
'quantity' => '购买数量',
'ship_list' => '发货单',
'shipped' => '已发货',
'shipping_address' => '配送地址',
'shipping_address_1' => '收货地址1',
Expand All @@ -70,4 +74,5 @@
'unit_price' => '单价',
'unpaid' => '未付款',
'user_agent' => '浏览器',
'website' => '网站地址',
];

0 comments on commit 989a8db

Please sign in to comment.