init
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/** @var \Esun\LegacyOrder\Block\Adminhtml\Customer\Edit\Tab\LegacyOrders $block */
|
||||
$orders = $block->getLegacyOrders();
|
||||
?>
|
||||
<div class="admin__page-section">
|
||||
<div class="admin__page-section-title">
|
||||
<span class="title"><?= $block->escapeHtml(__('Legacy Orders')) ?></span>
|
||||
</div>
|
||||
<div class="admin__page-section-content">
|
||||
<?php if (!$orders): ?>
|
||||
<div class="message message-info info">
|
||||
<div><?= $block->escapeHtml(__('No legacy orders are linked to this customer.')) ?></div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="admin__data-grid-wrap">
|
||||
<table class="data-grid">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Legacy Order #')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Order Date')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Order Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Payment Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Shipping Status')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Grand Total')) ?></th>
|
||||
<th class="data-grid-th"><?= $block->escapeHtml(__('Action')) ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($orders as $order): ?>
|
||||
<tr class="data-row">
|
||||
<td><a href="<?= $block->escapeUrl($block->getLegacyOrderUrl((int)$order['legacy_order_id'])) ?>"><?= $block->escapeHtml($order['source_order_number']) ?></a></td>
|
||||
<td><?= $block->escapeHtml($order['ordered_at'] ?: '-') ?></td>
|
||||
<td><?= $block->escapeHtml($order['order_status'] ?: '-') ?></td>
|
||||
<td><?= $block->escapeHtml($order['payment_status'] ?: '-') ?></td>
|
||||
<td><?= $block->escapeHtml($order['shipping_status'] ?: '-') ?></td>
|
||||
<td><?= $block->escapeHtml(($order['currency'] ?: '') . ' ' . $order['grand_total']) ?></td>
|
||||
<td><a href="<?= $block->escapeUrl($block->getLegacyOrderUrl((int)$order['legacy_order_id'])) ?>"><?= $block->escapeHtml(__('View')) ?></a></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?php /** @var \Esun\LegacyOrder\Block\Adminhtml\Import\Form $block */ ?>
|
||||
<div class="admin__fieldset-wrapper-content"><form action="<?= $block->escapeUrl($block->getUrl('esun_legacy_order/import/validate')) ?>" method="post" enctype="multipart/form-data"><input name="form_key" type="hidden" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/><fieldset class="admin__fieldset"><div class="admin__field required"><label class="admin__field-label"><span><?= $block->escapeHtml(__('CSV File')) ?></span></label><div class="admin__field-control"><input class="admin__control-file" type="file" name="csv_file" accept=".csv" required/></div></div><div class="admin__field required"><label class="admin__field-label"><span><?= $block->escapeHtml(__('Source Code')) ?></span></label><div class="admin__field-control"><input class="admin__control-text" name="source_code" value="old_us_site" required/><div class="note"><?= $block->escapeHtml(__('Used with the legacy order number as the unique key.')) ?></div></div></div><div class="admin__field required"><label class="admin__field-label"><span><?= $block->escapeHtml(__('Target Website')) ?></span></label><div class="admin__field-control"><select class="admin__control-select" name="website_id" required><?php foreach($block->getWebsites() as $w): ?><option value="<?= $block->escapeHtmlAttr($w['value']) ?>"><?= $block->escapeHtml($w['label']) ?></option><?php endforeach; ?></select></div></div><div class="admin__field required"><label class="admin__field-label"><span><?= $block->escapeHtml(__('Currency')) ?></span></label><div class="admin__field-control"><input class="admin__control-text" name="currency" value="USD" maxlength="3" required/></div></div><div class="admin__actions"><button class="action-primary" type="submit"><span><?= $block->escapeHtml(__('Check Data')) ?></span></button></div></fieldset></form><?php if($block->hasValidatedFile()): ?><form action="<?= $block->escapeUrl($block->getUrl('esun_legacy_order/import/run')) ?>" method="post"><input name="form_key" type="hidden" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/><button class="action-primary" type="submit"><span><?= $block->escapeHtml(__('Import Validated File')) ?></span></button></form><?php endif; ?></div>
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php /** @var \Esun\LegacyOrder\Block\Adminhtml\Order\View $block */ $o=$block->getOrder();$isModal=(bool)$block->getData('modal'); ?>
|
||||
<?php if(!$o): ?><div class="message error"><?= $block->escapeHtml(__('Legacy order not found.')) ?></div><?php else: $ship=$block->decode($o['shipping_address']);$bill=$block->decode($o['billing_address']);$items=$block->getItems();$money=static fn($value):string=>number_format((float)$value,2,'.',',');$discount=abs((float)($o['discount_amount']??0));$coupon=trim((string)($o['coupon']??''));$hasDiscount=$discount>0.0001||$coupon!== ''; ?>
|
||||
<?php if(!$isModal): ?><div class="page-main-actions"><a class="action-default" href="<?= $block->escapeUrl($block->getUrl('esun_legacy_order/order/index')) ?>"><?= $block->escapeHtml(__('Back')) ?></a></div><?php endif; ?>
|
||||
<div class="admin__page-section legacy-order-summary">
|
||||
<div class="legacy-order-summary__header"><div><span><?= $block->escapeHtml(__('Historical record')) ?></span><h2><?= $block->escapeHtml(__('Legacy Order #%1',$o['source_order_number'])) ?></h2></div><div class="legacy-order-summary__total"><span><?= $block->escapeHtml(__('Grand Total')) ?></span><strong><?= $block->escapeHtml($o['currency'].' '.$money($o['grand_total'])) ?></strong></div></div>
|
||||
<div class="legacy-order-summary__grid">
|
||||
<div><span><?= $block->escapeHtml(__('Customer Email')) ?></span><strong><?= $block->escapeHtml($o['customer_email']) ?></strong></div>
|
||||
<div><span><?= $block->escapeHtml(__('Customer Link')) ?></span><strong class="legacy-order-summary__link-status"><?= $block->escapeHtml(ucfirst((string)$o['link_status'])) ?><?= $o['customer_id']?' (#'.(int)$o['customer_id'].')':'' ?></strong></div>
|
||||
<div><span><?= $block->escapeHtml(__('Order Date')) ?></span><strong><?= $block->escapeHtml($o['ordered_at']?:'-') ?></strong></div>
|
||||
<div><span><?= $block->escapeHtml(__('Website ID')) ?></span><strong><?= (int)$o['website_id'] ?></strong></div>
|
||||
</div>
|
||||
<div class="legacy-order-summary__statuses"><?php foreach([[__('Payment Status'),$o['payment_status']],[__('Order Status'),$o['order_status']],[__('Shipping Status'),$o['shipping_status']]] as$status): ?><div><span><?= $block->escapeHtml($status[0]) ?></span><strong><?= $block->escapeHtml($status[1]?:'-') ?></strong></div><?php endforeach; ?></div>
|
||||
</div>
|
||||
<?php if(!$isModal): ?><div class="admin__page-section legacy-order-panel legacy-order-customer-link"><div class="admin__page-section-title"><span class="title"><?= $block->escapeHtml(__('Customer Link')) ?></span></div><div class="legacy-order-customer-link__actions"><form class="legacy-order-customer-link__form" method="post" action="<?= $block->escapeUrl($block->getUrl('esun_legacy_order/order/link')) ?>"><input type="hidden" name="form_key" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/><input type="hidden" name="id" value="<?= (int)$o['legacy_order_id'] ?>"/><div><label for="legacy-customer-link"><?= $block->escapeHtml(__('Customer ID or Email')) ?></label><input id="legacy-customer-link" class="admin__control-text" type="text" name="customer" placeholder="<?= $block->escapeHtmlAttr(__('Customer ID or email in Website ID %1',$o['website_id'])) ?>" required/></div><button class="action-primary" type="submit"><?= $block->escapeHtml(__('Link Customer')) ?></button></form><?php if($o['customer_id']): ?><form method="post" action="<?= $block->escapeUrl($block->getUrl('esun_legacy_order/order/unlink')) ?>"><input type="hidden" name="form_key" value="<?= $block->escapeHtmlAttr($block->getFormKey()) ?>"/><input type="hidden" name="id" value="<?= (int)$o['legacy_order_id'] ?>"/><button class="action-secondary" type="submit" onclick="return confirm('<?= $block->escapeJs(__('Remove this customer link?')) ?>')"><?= $block->escapeHtml(__('Unlink Customer')) ?></button></form><?php endif; ?></div></div><?php endif; ?>
|
||||
<div class="admin__page-section legacy-order-panel legacy-order-items"><div class="admin__page-section-title"><span class="title"><?= $block->escapeHtml(__('Items')) ?></span><span class="legacy-order-items__count"><?= count($items) ?></span></div><div class="legacy-order-items__table"><table class="data-table admin__table-primary"><thead><tr><th>SKU</th><th><?= $block->escapeHtml(__('Price')) ?></th><th><?= $block->escapeHtml(__('Qty')) ?></th><th><?= $block->escapeHtml(__('Subtotal')) ?></th></tr></thead><tbody><?php foreach($items as$i): ?><tr><td><strong><?= $block->escapeHtml($i['sku']) ?></strong></td><td><?= $block->escapeHtml($o['currency'].' '.$money($i['price'])) ?></td><td><span class="legacy-order-items__qty"><?= (int)round((float)$i['qty']) ?></span></td><td><strong><?= $block->escapeHtml($o['currency'].' '.$money($i['row_total'])) ?></strong></td></tr><?php endforeach; ?></tbody></table></div></div>
|
||||
<div class="admin__page-section legacy-order-panel legacy-order-totals"><div class="admin__page-section-title"><span class="title"><?= $block->escapeHtml(__('Order Totals')) ?></span></div><table class="admin__table-secondary"><tr><th><?= $block->escapeHtml(__('Product Subtotal')) ?></th><td><?= $block->escapeHtml($o['currency'].' '.$money($o['product_total'])) ?></td></tr><?php if($hasDiscount): ?><tr class="legacy-order-totals__discount"><th><?= $block->escapeHtml(__('Discount')) ?><?php if($coupon!==''): ?> <small><?= $block->escapeHtml(__('Coupon: %1',$coupon)) ?></small><?php endif; ?></th><td>-<?= $block->escapeHtml($o['currency'].' '.$money($discount)) ?></td></tr><?php endif; ?><?php if((float)$o['shipping_amount']!==0.0): ?><tr><th><?= $block->escapeHtml(__('Shipping')) ?></th><td><?= $block->escapeHtml($o['currency'].' '.$money($o['shipping_amount'])) ?></td></tr><?php endif; ?><?php if((float)$o['tax_amount']!==0.0): ?><tr><th><?= $block->escapeHtml(__('Tax')) ?></th><td><?= $block->escapeHtml($o['currency'].' '.$money($o['tax_amount'])) ?></td></tr><?php endif; ?><?php if((float)$o['fee_amount']!==0.0): ?><tr><th><?= $block->escapeHtml(__('Fee')) ?></th><td><?= $block->escapeHtml($o['currency'].' '.$money($o['fee_amount'])) ?></td></tr><?php endif; ?><tr class="legacy-order-totals__grand"><th><?= $block->escapeHtml(__('Grand Total')) ?></th><td><?= $block->escapeHtml($o['currency'].' '.$money($o['grand_total'])) ?></td></tr></table></div>
|
||||
<div class="admin__page-section legacy-order-information">
|
||||
<div class="admin__page-section-title"><span class="title"><?= $block->escapeHtml(__('Order Information')) ?></span></div>
|
||||
<div class="legacy-order-information__grid">
|
||||
<?php foreach([[__('Shipping Address'),$ship],[__('Billing Address'),$bill]] as$addressBlock): $label=$addressBlock[0];$a=$addressBlock[1]; ?>
|
||||
<section class="legacy-order-information__card">
|
||||
<h3><?= $block->escapeHtml($label) ?></h3>
|
||||
<address><?= /* @noEscape */ nl2br($block->escapeHtml(implode("\n",array_filter([$a['name']??'',trim(($a['street']??'').' '.($a['unit']??'')),trim(($a['city']??'').' '.($a['region']??'').' '.($a['postcode']??'')),$a['country']??'',$a['telephone']??''])))) ?></address>
|
||||
</section>
|
||||
<?php endforeach; ?>
|
||||
<section class="legacy-order-information__card">
|
||||
<h3><?= $block->escapeHtml(__('Shipping Method')) ?></h3>
|
||||
<p><?= $block->escapeHtml($o['shipping_method']?:'-') ?></p>
|
||||
<?php if(!empty($o['carrier'])): ?><small><?= $block->escapeHtml(__('Carrier: %1',$o['carrier'])) ?></small><?php endif; ?>
|
||||
<?php if(!empty($o['tracking_number'])): ?><small><?= $block->escapeHtml(__('Tracking Number: %1',$o['tracking_number'])) ?></small><?php endif; ?>
|
||||
</section>
|
||||
<section class="legacy-order-information__card">
|
||||
<h3><?= $block->escapeHtml(__('Payment Method')) ?></h3>
|
||||
<p><?= $block->escapeHtml($o['payment_method']?:'-') ?></p>
|
||||
<?php if(!empty($o['payment_transaction_id'])): ?><small><?= $block->escapeHtml(__('Transaction: %1',$o['payment_transaction_id'])) ?></small><?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
Reference in New Issue
Block a user