This commit is contained in:
2026-03-28 11:33:56 +01:00
parent 412e235512
commit aa8e21862d
132 changed files with 24381 additions and 10882 deletions

View File

@@ -0,0 +1,521 @@
<style type="text/css">
.attr-copy-btn {
display: inline-block;
padding: 1px 5px;
font-size: 11px;
line-height: 1.5;
background: transparent;
border: 1px solid #d0d0d0;
border-radius: 3px;
color: #999;
cursor: pointer;
vertical-align: middle;
margin-left: 4px;
transition: background .12s, color .12s, border-color .12s;
}
.attr-copy-btn:hover {
background: #f4f4f4;
border-color: #aaa;
color: #555;
}
.attr-copy-btn--copied {
background: #d4edda !important;
border-color: #28a745 !important;
color: #28a745 !important;
}
</style>
<script type="text/javascript">
(function() {
var orderId = <?= (int)($this->order_id ?? 0);?>;
var currentTrustmateState = <?= ((int)($this->trustmate_send ?? 0) === 1) ? 'true' : 'false';?>;
$(function() {
var btn = $('#integrationsDropdownBtn');
var menu = $('#integrationsDropdownMenu');
btn.wrap('<div class="dropdown d-inline-block pull-right"></div>');
menu.appendTo(btn.parent());
btn.on('click', function(e) {
e.preventDefault();
e.stopPropagation();
menu.toggleClass('show');
});
$(document).on('click', function(e) {
if (!btn.is(e.target) && !menu.is(e.target) && menu.has(e.target).length === 0) {
menu.removeClass('show');
}
});
});
$(function() {
var timer = '';
$('#notes').keyup(function() {
var textarea = $(this);
clearTimeout(timer);
timer = setTimeout(function() {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/notes_save/',
data: {
order_id: orderId,
notes: textarea.val()
}
});
}, 500);
});
$('body').on('click', '.btn-send-order-to-apilo', function(e) {
e.preventDefault();
var href = $(this).attr('href');
$.alert({
title: 'Potwierdź',
content: 'Czy na pewno chcesz wysłać zamówienie do apilo.com?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
});
});
$('body').on('click', '.set_order_as_unpaid', function() {
var href = $(this).attr('href');
$.alert({
title: 'Pytanie',
content: 'Zmienić zamówienie na nieopłacone?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.set_order_as_paid', function() {
var href = $(this).attr('href');
$.alert({
title: 'Pytanie',
content: 'Zmienić zamówienie na opłacone?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
confirm2: {
text: 'Tak (wyślij mail)',
btnClass: 'btn-primary',
keys: ['enter'],
action: function() {
document.location.href = href + '&send_mail=1';
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.order_status_change_email', function() {
$.alert({
title: 'Pytanie',
content: 'Na pewno chcesz wysłać mail o zmianie statusu?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
order_status_change(orderId, $('#order-status').val(), true);
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.resend_order_confirmation_email button', function() {
$.alert({
title: 'Pytanie',
content: 'Na pewno chcesz wysłać mail o złożonym zamówieniu?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/order_resend_confirmation_email/',
data: {
order_id: orderId
},
beforeSend: function() {
$('#overlay').show();
},
success: function(response) {
$('#overlay').hide();
var data = jQuery.parseJSON(response);
if (data.result === true) {
return $.alert({
title: 'Informacja',
content: 'Wiadomość została wysłana',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if (data.result === false) {
return $.alert({
title: 'Błąd',
content: 'Podczas wysyłania wiadomości wystąpił błąd',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-exclamation',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
}
});
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.order_status_change', function() {
order_status_change(orderId, $('#order-status').val(), false);
return false;
});
function order_status_change(order_id, status, email) {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/order_status_change/',
data: {
order_id: order_id,
status: status,
email: email
},
beforeSend: function() {
$('#overlay').show();
},
success: function(response) {
$('#overlay').hide();
var data = jQuery.parseJSON(response);
if (data.email === true) {
return $.alert({
title: 'Informacja',
content: 'Wiadomość o zmiane statusu została wysłana',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if (data.email === false) {
return $.alert({
title: 'Błąd',
content: 'Podczas wysyłania wiadomości wystąpił błąd',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-exclamation',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if (data.result == true) {
return $.alert({
title: 'Informacja',
content: 'Status zamówienia został zmieniony',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
}
});
}
$(function() {
function fallbackCopy(text) {
var $tmp = $('<textarea>').css({position: 'fixed', top: 0, left: 0, opacity: 0}).val(text);
$('body').append($tmp);
$tmp[0].select();
try { document.execCommand('copy'); } catch (e) {}
$tmp.remove();
}
$('.atributes').each(function() {
var $div = $(this);
var html = $.trim($div.html());
if (!html) { return; }
var parts = html.split(/<br\s*\/?>/i);
var newParts = [];
for (var i = 0; i < parts.length; i++) {
var part = $.trim(parts[i]);
if (!part) { continue; }
var match = part.match(/^(<b>[^<]*<\/b>\s*:\s*)(.+)$/);
if (match) {
var labelHtml = match[1];
var value = $.trim(match[2]);
var escapedValue = $('<div>').text(value).html();
part = labelHtml + escapedValue
+ ' <button type="button" class="js-attr-copy-btn attr-copy-btn" data-value="'
+ escapedValue + '" title="Kopiuj: ' + escapedValue + '">'
+ '<i class="fa fa-copy"></i></button>';
}
newParts.push(part);
}
$div.html(newParts.join('<br>'));
});
$(document).on('click', '.js-attr-copy-btn', function() {
var $btn = $(this);
var value = String($btn.data('value'));
function showCopied() {
$btn.addClass('attr-copy-btn--copied');
$btn.find('i').removeClass('fa-copy').addClass('fa-check');
setTimeout(function() {
$btn.removeClass('attr-copy-btn--copied');
$btn.find('i').removeClass('fa-check').addClass('fa-copy');
}, 1500);
}
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(value).then(showCopied, function() {
fallbackCopy(value);
showCopied();
});
} else {
fallbackCopy(value);
showCopied();
}
});
});
$('body').on('click', '.btn-toggle-trustmate', function(e) {
e.preventDefault();
$.alert({
title: 'Potwierdź',
content: currentTrustmateState
? 'Czy na pewno chcesz odznaczyć zamówienie jako wysłane do trustmate.io?'
: 'Czy na pewno chcesz zaznaczyć zamówienie jako wysłane do trustmate.io?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/toggle_trustmate_send/',
data: {
order_id: orderId
},
beforeSend: function() {
$('#overlay').show();
},
success: function(response) {
$('#overlay').hide();
var data = jQuery.parseJSON(response);
if (data.result === true) {
location.reload();
}
}
});
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
});
})();
</script>

View File

@@ -1,8 +1,37 @@
<?
global $db;
ob_start();
$orderId = (int)($this -> order['id'] ?? 0);
?>
<div class="details order-details">
<div class="site-title">Szczegóły zamówienia: <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?></div>
<script>document.title = 'Zamówienie <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?> - shopPro';</script>
<div class="od-actions mb15">
<a href="/admin/shop_order/list/" class="btn btn-dark btn-sm">
<i class="fa fa-reply"></i> <span class="od-actions-label">Wstecz</span>
</a>
<a href="/admin/shop_order/order_edit/order_id=<?= $orderId;?>" class="btn btn-danger btn-sm">
<i class="fa fa-pencil"></i> <span class="od-actions-label">Edytuj</span>
</a>
<? if ( $this -> prev_order_id ):?>
<a href="/admin/shop_order/order_details/order_id=<?= (int)$this -> prev_order_id;?>" class="btn btn-success btn-sm">
<i class="fa fa-arrow-left"></i> <span class="od-actions-label">Poprzednie</span>
</a>
<? endif;?>
<? if ( $this -> next_order_id ):?>
<a href="/admin/shop_order/order_details/order_id=<?= (int)$this -> next_order_id;?>" class="btn btn-success btn-sm">
<i class="fa fa-arrow-right"></i> <span class="od-actions-label">Następne</span>
</a>
<? endif;?>
<button id="integrationsDropdownBtn" type="button" class="btn btn-primary btn-sm pull-right">
<i class="fa fa-ellipsis-v"></i>
</button>
</div>
<div class="details order-details panel">
<div class="panel-body">
<div class="row">
<div class="col-lg-8">
<div class="row">
@@ -45,7 +74,7 @@ ob_start();
<div class="panel-body">
<div>Kwota zamówienia <b><?= $this -> order[ 'summary' ];?> zł</b></div>
<? if ( $this -> coupon ):?>
<div>Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon -> name;?> - <?= $this -> coupon -> amount;?> <?= $this -> coupon -> type == 1 ? '%' : 'zł';?></span></div>
<div>Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon['name'];?> - <?= $this -> coupon['amount'];?> <?= $this -> coupon['type'] == 1 ? '%' : 'zł';?></span></div>
<? endif;?>
<br>
<div><?= strip_tags( $this -> order[ 'transport' ] );?>: <b><?= $this -> order[ 'transport_cost' ];?> zł</b></div>
@@ -61,17 +90,30 @@ ob_start();
<div>
<b><?= $this -> order[ 'payment_method' ];?> </b>
</div>
<? if ( !empty($this -> order['apilo_order_id']) ):?>
<br/>
<div>
<i class="fa fa-cloud"></i> Apilo: <b style="color: #27ae60;">tak</b>
&mdash; ID: <b id="order-apilo-id"><?= htmlspecialchars((string)$this -> order['apilo_order_id'], ENT_QUOTES, 'UTF-8');?></b>
<i class="fa fa-copy" onclick="copyToClipboard( 'order-apilo-id' ); return false;"></i>
</div>
<? else:?>
<br/>
<div>
<i class="fa fa-cloud"></i> Apilo: <b style="color: #c0392b;">nie</b>
</div>
<? endif;?>
</div>
</div>
<div class="paid-status panel">
<div class="panel-body">
<? if ( $this -> order['paid'] ):?>
<a href="/admin/shop_order/set_order_as_unpaid/order_id=<?= $this -> order['id'];?>" class="set_order_as_unpaid">
<a href="/admin/shop_order/set_order_as_unpaid/order_id=<?= $orderId;?>" class="set_order_as_unpaid">
<span><i class="fa fa-dollar"></i></span>
<b>Oznacz zamówienie jako nieopłacone</b>
</a>
<? else:?>
<a href="/admin/shop_order/set_order_as_paid/order_id=<?= $this -> order['id'];?>" class="set_order_as_paid">
<a href="/admin/shop_order/set_order_as_paid/order_id=<?= $orderId;?>" class="set_order_as_paid">
<span class="danger"><i class="fa fa-dollar"></i></span>
<b>Oznacz zamówienie jako opłacone</b>
</a>
@@ -100,7 +142,7 @@ ob_start();
<button class="btn btn-success order_status_change">zmień status</button>
</div>
<div class="col-12 order-history">
<? if ( \S::is_array_fix( $this -> order['statuses'] ) ): foreach ( $this -> order['statuses'] as $status ):?>
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> order['statuses'] ) ): foreach ( $this -> order['statuses'] as $status ):?>
<div><b><?= date( 'Y-m-d H:i', strtotime( $status['date'] ) );?></b>: <?= $this -> order_statuses[$status['status_id']];?> <? if ( $status['mail'] ):?><i class="fa fa-envelope-o"></i><? endif;?></div>
<? endforeach; endif;?>
</div>
@@ -132,7 +174,7 @@ ob_start();
<tbody>
<? if ( is_array( $this -> order[ 'products' ] ) ): foreach ( $this -> order[ 'products' ] as $product ):?>
<?
if ( $id = \admin\factory\ShopProduct::get_product_parent_id( $product['product_id'] ) )
if ( $id = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->getParentId( $product['product_id'] ) )
$product_id = $id;
else
$product_id = $product['product_id'];
@@ -140,11 +182,11 @@ ob_start();
<tr class="order-product-details">
<td class="product-image">
<? if ( $product['product_id'] ):?>
<img src="<?= \shop\Product::getProductImg( (int)$product_id );?>">
<img src="<?= ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->getProductImg( (int)$product_id );?>">
<? endif;?>
</td>
<td>
<a href="<?= \shop\Product::getProductUrl( (int)$product_id );?>" target="_blank"><?= $product[ 'name' ];?></a>
<a href="<?= ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->getProductUrl( (int)$product_id );?>" target="_blank"><?= $product[ 'name' ];?></a>
<br />
<div class="atributes">
<?= $product[ 'attributes' ];?>
@@ -155,11 +197,15 @@ ob_start();
<div class="product-message">
<?= $product[ 'message' ] != '' ? '<strong>Wiadomość:</strong> ' . $product['message'] : '';?>
</div>
<div class="od-mobile-price-line">
<? $effective = ((float)$product['price_brutto_promo'] > 0 && (float)$product['price_brutto_promo'] < (float)$product['price_brutto']) ? (float)$product['price_brutto_promo'] : (float)$product['price_brutto'];?>
<?= (int)$product['quantity'];?> &times; <?= \Shared\Helpers\Helpers::decimal( $effective );?> = <?= \Shared\Helpers\Helpers::decimal( $effective * $product['quantity'] );?> zł
</div>
</td>
<td class="tab-center"><?= $product[ 'quantity' ];?></td>
<td class="tab-right"><?= \S::decimal( $product[ 'price_brutto' ] );?> zł</td>
<td class="tab-right"><?= \S::decimal( $product[ 'price_brutto_promo' ] );?> zł</td>
<td class="tab-right"><?= \S::decimal( $product[ 'price_brutto_promo' ] * $product[ 'quantity' ] );?> zł</td>
<td class="tab-right"><?= \Shared\Helpers\Helpers::decimal( $product[ 'price_brutto' ] );?> zł</td>
<td class="tab-right"><?= \Shared\Helpers\Helpers::decimal( $effective );?> zł</td>
<td class="tab-right"><?= \Shared\Helpers\Helpers::decimal( $effective * $product[ 'quantity' ] );?> zł</td>
</tr>
<? endforeach; endif;?>
</tbody>
@@ -177,59 +223,11 @@ ob_start();
</form>
</div>
</div>
</div>
</div>
<?
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> id = 'order-details';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Szczegóły zamówienia: ' . $this -> order[ 'number' ];
$grid -> buttons = [
[
'label' => 'Wstecz',
'url' => '/admin/shop_order/view_list/',
'icon' => 'fa-reply',
'class' => 'btn btn-dark btn-sm mr5'
], [
'label' => 'Edytuj zamówienie',
'url' => '/admin/shop_order/order_edit/order_id=' . $this -> order['id'],
'icon' => 'fa-pencil',
'class' => 'btn btn-danger btn-sm mr5 ml5'
]
];
if ( $this -> prev_order_id )
{
$grid -> buttons[] = [
'label' => 'Poprzednie zamówienie',
'url' => '/admin/shop_order/order_details/order_id=' . $this -> prev_order_id,
'icon' => 'fa-arrow-left',
'class' => 'btn btn-success btn-sm mr5 ml5'
];
}
if ( $this -> next_order_id )
{
$grid -> buttons[] = [
'label' => 'Następne zamówienie',
'url' => '/admin/shop_order/order_details/order_id=' . $this -> next_order_id,
'icon' => 'fa-arrow-right',
'class' => 'btn btn-success btn-sm mr5 ml5'
];
}
$grid -> buttons[] = [
'label' => '',
'url' => '#',
'icon' => 'fa-ellipsis-v',
'class' => 'btn btn-primary',
'id' => 'integrationsDropdownBtn'
];
$grid -> default_buttons = false;
$grid -> external_code = $out;
echo $grid -> draw();
?>
<div class="dropdown-menu dropdown-menu-right" id="integrationsDropdownMenu">
<a class="dropdown-item btn-send-order-to-apilo" href="/admin/shop_order/send_order_to_apilo/order_id=<?= $this -> order['id'];?>">
<a class="dropdown-item btn-send-order-to-apilo" href="/admin/shop_order/send_order_to_apilo/order_id=<?= $orderId;?>">
<i class="fa fa-refresh"></i> Wyślij ponownie zamówienie do apilo.com
</a>
<a class="dropdown-item btn-toggle-trustmate" href="#">
@@ -237,452 +235,7 @@ echo $grid -> draw();
<?= $this -> order['trustmate_send'] ? 'Odznacz zamówienie jako wysłane do trustmate.io' : 'Zaznacz zamówienie jako wysłane do trustmate.io';?>
</a>
</div>
<script type="text/javascript">
$( function() {
var btn = $( '#integrationsDropdownBtn' );
var menu = $( '#integrationsDropdownMenu' );
// Opakuj przycisk w dropdown wrapper
btn.wrap( '<div class="dropdown d-inline-block pull-right"></div>' );
menu.appendTo( btn.parent() );
// Ręczna obsługa toggle dropdown
btn.on( 'click', function(e) {
e.preventDefault();
e.stopPropagation();
menu.toggleClass( 'show' );
});
// Zamknij dropdown po kliknięciu poza nim
$( document ).on( 'click', function(e) {
if ( !btn.is( e.target ) && !menu.is( e.target ) && menu.has( e.target ).length === 0 ) {
menu.removeClass( 'show' );
}
});
});
$( function()
{
var timer = '';
$( '#notes' ).keyup( function()
{
var _this = $( this);
clearTimeout( timer );
timer = setTimeout( function()
{
$.ajax(
{
type: 'POST',
cache: false,
url: '/admin/shop_order/notes_save/',
data:
{
order_id: <?= $this -> order['id'];?>,
notes: _this.val()
},
beforeSend: function()
{
},
success: function( response )
{
var time = 0;
}
});
}, 500 );
});
$( 'body' ).on( 'click', '.btn-send-order-to-apilo', function(e) {
e.preventDefault();
var href = $( this ).attr( 'href' );
$.alert({
title: 'Potwierdź',
content: 'Czy na pewno chcesz wysłać zamówienie do apilo.com?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
});
});
// set_order_as_unpaid
$( 'body' ).on( 'click', '.set_order_as_unpaid', function(e) {
var href = $( this ).attr( 'href' );
$.alert({
title: 'Pytanie',
content: 'Zmienić zamówienie na nieopłacone?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
// set_order_as_paid
$( 'body' ).on( 'click', '.set_order_as_paid', function(e) {
var href = $( this ).attr( 'href' );
$.alert({
title: 'Pytanie',
content: 'Zmienić zamówienie na opłacone?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
document.location.href = href;
}
},
confirm2: {
text: 'Tak (wyślij mail)',
btnClass: 'btn-primary',
keys: ['enter'],
action: function() {
document.location.href = href + '&send_mail=1';
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.order_status_change_email', function() {
$.alert({
title: 'Pytanie',
content: 'Na pewno chcesz wysłać mail o zmianie statusu?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
order_status_change(<?= $this -> order[ 'id' ];?>, $('#order-status').val(), true);
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$( 'body' ).on( 'click', '.resend_order_confirmation_email button', function() {
$.alert({
title: 'Pytanie',
content: 'Na pewno chcesz wysłać mail o złożonym zamówieniu?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function()
{
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/order_resend_confirmation_email/',
data: {
order_id: <?= $this -> order['id'];?>
},
beforeSend: function()
{
$( '#overlay' ).show();
},
success: function(response)
{
$( '#overlay' ).hide();
data = jQuery.parseJSON(response);
if ( data.result === true )
{
return $.alert({
title: 'Informacja',
content: 'Wiadomość została wysłana',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if ( data.result === false)
{
return $.alert({
title: 'Błąd',
content: 'Podczas wysyłania wiadomości wystąpił błąd',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-exclamation',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
}
});
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
return false;
});
$('body').on('click', '.order_status_change', function() {
order_status_change(<?= $this -> order[ 'id' ];?>, $('#order-status').val(), false);
return false;
});
function order_status_change($order_id, $status, $email) {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/order_status_change/',
data: {
order_id: $order_id,
status: $status,
email: $email
},
beforeSend: function() {
$('#overlay').show();
},
success: function(response) {
$('#overlay').hide();
data = jQuery.parseJSON(response);
if (data.email === true) {
return $.alert({
title: 'Informacja',
content: 'Wiadomość o zmiane statusu została wysłana',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if (data.email === false) {
return $.alert({
title: 'Błąd',
content: 'Podczas wysyłania wiadomości wystąpił błąd',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-exclamation',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-danger',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
if (data.result == true) {
return $.alert({
title: 'Informacja',
content: 'Status zamówienia został zmieniony',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-close',
typeAnimated: true,
animation: 'opacity',
autoClose: 'confirm|10000',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-info',
buttons: {
confirm: {
text: 'Zamknij',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
location.reload();
}
}
}
});
}
}
});
}
$( 'body' ).on( 'click', '.btn-toggle-trustmate', function(e) {
e.preventDefault();
var currentState = <?= $this -> order['trustmate_send'] ? 'true' : 'false';?>;
$.alert({
title: 'Potwierdź',
content: currentState ? 'Czy na pewno chcesz odznaczyć zamówienie jako wysłane do trustmate.io?' : 'Czy na pewno chcesz zaznaczyć zamówienie jako wysłane do trustmate.io?',
type: 'orange',
closeIcon: true,
closeIconClass: 'fa fa-times',
typeAnimated: true,
animation: 'opacity',
columnClass: 'col-12 col-lg-10',
theme: 'modern',
icon: 'fa fa-question',
buttons: {
confirm: {
text: 'Tak',
btnClass: 'btn-success',
keys: ['enter'],
action: function() {
$.ajax({
type: 'POST',
cache: false,
url: '/admin/shop_order/toggle_trustmate_send/',
data: {
order_id: <?= $this -> order['id'];?>
},
beforeSend: function() {
$( '#overlay' ).show();
},
success: function( response ) {
$( '#overlay' ).hide();
var data = jQuery.parseJSON( response );
if ( data.result === true ) {
location.reload();
}
}
});
}
},
cancel: {
text: 'Nie',
btnClass: 'btn-dark',
action: function() {}
}
}
});
});
</script>
<?= \Shared\Tpl\Tpl::view('shop-order/order-details-custom-script', [
'order_id' => $orderId,
'trustmate_send' => (int)($this -> order['trustmate_send'] ?? 0),
]);?>

View File

@@ -0,0 +1,244 @@
<script type="text/javascript">
$(function() {
// =========================================================================
// InPost paczkomat
// =========================================================================
function toggleInpostField() {
if ($('#transport_id').val() != '2') {
$('#inpost_paczkomat').closest('.row').hide();
} else {
$('#inpost_paczkomat').closest('.row').show();
}
}
toggleInpostField();
$('body').on('change', '#transport_id', function() {
toggleInpostField();
recalculateTotals();
});
$('body').on('click', '.btn-paczkomat', function() {
window.easyPackAsyncInit = function () {
easyPack.init({
mapType: 'osm',
searchType: 'osm',
});
easyPack.mapWidget('inpost-map', function(point) {
$('#inpost_paczkomat').val(point.name + ' | ' + point.address.line1 + ', ' + point.address.line2);
$('.inpost-map-container').hide();
});
};
$('.inpost-map-container').show();
});
// =========================================================================
// Order save
// =========================================================================
$('body').on('click', '#order-save', function(e) {
e.preventDefault();
$('#fg-order-details').attr('method', 'POST').attr('action', '/admin/shop_order/order_save/').submit();
});
// =========================================================================
// Product row index counter
// =========================================================================
var productIndex = $('#order-products-body .order-product-row').length;
// =========================================================================
// Remove product
// =========================================================================
$('body').on('click', '.btn-remove-product', function() {
var $row = $(this).closest('.order-product-row');
var orderProductId = $row.find('input[name$="[order_product_id]"]').val();
if (orderProductId && orderProductId !== '0') {
// Istniejący produkt — ukryj i oznacz do usunięcia
$row.hide();
$row.append('<input type="hidden" name="products[' + $row.data('index') + '][delete]" value="1">');
} else {
// Nowy produkt — po prostu usuń z DOM
$row.remove();
}
recalculateTotals();
});
// =========================================================================
// Quantity and price change — recalculate
// =========================================================================
$('body').on('change input', '.product-qty, .product-price, .product-price-promo', function() {
recalculateTotals();
});
// =========================================================================
// Product search (AJAX)
// =========================================================================
var searchTimer = null;
var $searchInput = $('#product-search-input');
var $searchResults = $('#product-search-results');
$searchInput.on('keyup', function() {
var query = $(this).val().trim();
clearTimeout(searchTimer);
if (query.length < 2) {
$searchResults.hide().empty();
return;
}
searchTimer = setTimeout(function() {
$.ajax({
url: '/admin/shop_order/search_products_ajax/',
type: 'GET',
data: { query: query },
dataType: 'json',
success: function(data) {
$searchResults.empty();
if (!data || !data.products || data.products.length === 0) {
$searchResults.append('<div style="padding:10px;color:#999">Brak wyników</div>');
$searchResults.show();
return;
}
for (var i = 0; i < data.products.length; i++) {
var p = data.products[i];
var priceDisplay = p.price_brutto_promo > 0
? '<span style="text-decoration:line-through;color:#999">' + parseFloat(p.price_brutto).toFixed(2) + ' zł</span> <strong>' + parseFloat(p.price_brutto_promo).toFixed(2) + ' zł</strong>'
: '<strong>' + parseFloat(p.price_brutto).toFixed(2) + ' zł</strong>';
var stockWarning = p.quantity <= 0
? ' <span style="color:#d9534f;font-size:11px">(brak na stanie)</span>'
: ' <span style="color:#5cb85c;font-size:11px">(stan: ' + p.quantity + ')</span>';
var imgHtml = p.image
? '<img src="' + p.image + '" style="width:35px;height:35px;object-fit:cover;margin-right:8px;border-radius:3px">'
: '<span style="display:inline-block;width:35px;height:35px;margin-right:8px;background:#eee;border-radius:3px"></span>';
var $item = $('<div class="product-search-item" style="padding:8px 10px;cursor:pointer;display:flex;align-items:center;border-bottom:1px solid #f0f0f0"></div>');
$item.html(imgHtml + '<div><div>' + $('<span>').text(p.name).html() + (p.sku ? ' <span style="color:#999;font-size:11px">(' + $('<span>').text(p.sku).html() + ')</span>' : '') + stockWarning + '</div><div>' + priceDisplay + '</div></div>');
$item.data('product', p);
$searchResults.append($item);
}
$searchResults.show();
}
});
}, 300);
});
// Kliknięcie w wynik wyszukiwania — dodaj produkt
$('body').on('click', '.product-search-item', function() {
var p = $(this).data('product');
if (p.quantity <= 0) {
if (!confirm('Produkt "' + p.name + '" nie jest dostępny na stanie. Czy na pewno chcesz go dodać?')) {
return;
}
}
addProductRow(p);
$searchInput.val('');
$searchResults.hide().empty();
});
// Ukryj wyniki przy kliknięciu poza
$(document).on('click', function(e) {
if (!$(e.target).closest('#add-product-section').length) {
$searchResults.hide();
}
});
// =========================================================================
// Add product row
// =========================================================================
function addProductRow(product) {
var idx = productIndex++;
var imgHtml = product.image
? '<img src="' + product.image + '" style="max-width:50px;max-height:50px">'
: '';
var effectivePrice = product.price_brutto_promo > 0 ? product.price_brutto_promo : product.price_brutto;
var $row = $('<tr class="order-product-row" data-index="' + idx + '"></tr>');
$row.html(
'<input type="hidden" name="products[' + idx + '][order_product_id]" value="0">' +
'<input type="hidden" name="products[' + idx + '][product_id]" value="' + product.product_id + '">' +
'<input type="hidden" name="products[' + idx + '][parent_product_id]" value="' + (product.parent_product_id || product.product_id) + '">' +
'<input type="hidden" name="products[' + idx + '][name]" value="' + $('<span>').text(product.name).html() + '">' +
'<input type="hidden" name="products[' + idx + '][vat]" value="' + product.vat + '">' +
'<td class="product-image">' + imgHtml + '</td>' +
'<td>' + $('<span>').text(product.name).html() +
(product.sku ? ' <span class="small text-muted">(' + $('<span>').text(product.sku).html() + ')</span>' : '') +
'</td>' +
'<td class="tab-center"><input type="number" name="products[' + idx + '][quantity]" value="1" min="1" class="form-control form-control-sm text-center product-qty" style="width:70px"></td>' +
'<td class="tab-right"><input type="number" name="products[' + idx + '][price_brutto]" value="' + parseFloat(product.price_brutto).toFixed(2) + '" step="0.01" min="0" class="form-control form-control-sm text-right product-price" style="width:110px"></td>' +
'<td class="tab-right"><input type="number" name="products[' + idx + '][price_brutto_promo]" value="' + parseFloat(product.price_brutto_promo).toFixed(2) + '" step="0.01" min="0" class="form-control form-control-sm text-right product-price-promo" style="width:110px"></td>' +
'<td class="tab-right product-row-total">' + parseFloat(effectivePrice).toFixed(2).replace('.', ',') + ' zł</td>' +
'<td class="text-center"><button type="button" class="btn btn-xs btn-danger btn-remove-product" title="Usuń produkt"><i class="fa fa-times"></i></button></td>'
);
$('#order-products-body').append($row);
recalculateTotals();
}
// =========================================================================
// Recalculate totals
// =========================================================================
function recalculateTotals() {
var productsTotal = 0;
$('#order-products-body .order-product-row:visible').each(function() {
var qty = parseFloat($(this).find('.product-qty').val()) || 0;
var price = parseFloat($(this).find('.product-price').val()) || 0;
var pricePromo = parseFloat($(this).find('.product-price-promo').val()) || 0;
var effectivePrice = pricePromo > 0 ? pricePromo : price;
var rowTotal = effectivePrice * qty;
$(this).find('.product-row-total').text(rowTotal.toFixed(2).replace('.', ',') + ' zł');
productsTotal += rowTotal;
});
// Transport cost (z uwzględnieniem progu darmowej dostawy)
var transportId = parseInt($('#transport_id').val()) || 0;
var transportCost = 0;
var transports = orderEditConfig.transports || [];
for (var i = 0; i < transports.length; i++) {
if (transports[i].id === transportId) {
var t = transports[i];
if (t.delivery_free === 1 && orderEditConfig.freeDelivery > 0 && productsTotal >= orderEditConfig.freeDelivery) {
transportCost = 0;
} else {
transportCost = t.cost;
}
break;
}
}
var orderTotal = productsTotal + transportCost;
$('#products-total-display').text(productsTotal.toFixed(2).replace('.', ','));
$('#transport-cost-display').text(transportCost.toFixed(2).replace('.', ','));
$('#order-summary-display').text(orderTotal.toFixed(2).replace('.', ',') + ' zł');
}
// Inicjalizacja sum przy załadowaniu strony
recalculateTotals();
});
</script>

View File

@@ -1,9 +1,22 @@
<?
global $db;
ob_start();
$orderId = (int)($this -> order['id'] ?? 0);
?>
<input type="hidden" name="order_id" value="<?= $this -> order['id'];?>">
<div class="details">
<div class="site-title">Edycja zamówienia: <?= htmlspecialchars((string)($this -> order['number'] ?? ''), ENT_QUOTES, 'UTF-8');?></div>
<div class="mb15">
<button type="button" id="order-save" class="btn btn-success btn-sm mr5 ml5">
<i class="fa fa-save"></i> Zapisz zamówienie
</button>
<a href="/admin/shop_order/order_details/order_id=<?= $orderId;?>" class="btn btn-dark btn-sm mr5">
<i class="fa fa-reply"></i> Wstecz
</a>
</div>
<form id="fg-order-details" method="POST" action="/admin/shop_order/order_save/">
<input type="hidden" name="order_id" value="<?= $orderId;?>">
<div class="details panel">
<div class="panel-body">
<div class="row">
<div class="col-xl-8">
<div class="row">
@@ -71,13 +84,18 @@ ob_start();
<? endif;?>
</div>
<div class="col-md-6">
<div>Kwota zamówienia <b><?= $this -> order[ 'summary' ];?> zł</b></div>
<div>Kwota zamówienia <b id="order-summary-display"><?= $this -> order[ 'summary' ];?> zł</b></div>
<div class="mt5">
<span>Produkty: <b id="products-total-display">0,00</b> zł</span>
&nbsp;|&nbsp;
<span>Dostawa: <b id="transport-cost-display"><?= number_format((float)($this -> order['transport_cost'] ?? 0), 2, ',', '');?></b> zł</span>
</div>
<br>
<div class="row">
<div class="col-12">
<select name="transport_id" class="form-control" id="transport_id">
<option value="0">--- wybierz formę transportu ---</option>
<? if ( \S::is_array_fix( $this -> transport ) ): foreach ( $this -> transport as $transport_tmp ):?>
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> transport ) ): foreach ( $this -> transport as $transport_tmp ):?>
<option value="<?= $transport_tmp['id'];?>" <? if ( $this -> order['transport_id'] == $transport_tmp['id'] ):?>selected="selected"<? endif;?>>
<?= $transport_tmp['name'];?> - <?= $transport_tmp['cost'];?> zł
</option>
@@ -100,7 +118,7 @@ ob_start();
<div class="col-12">
<select name="payment_method_id" class="form-control" id="payment_method_id">
<option value="0">--- wybierz formę płatności ---</option>
<? if ( \S::is_array_fix( $this -> payment_methods ) ): foreach ( $this -> payment_methods as $payment_method ):?>
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> payment_methods ) ): foreach ( $this -> payment_methods as $payment_method ):?>
<option value="<?= $payment_method['id'];?>" <? if ( $this -> order['payment_method_id'] == $payment_method['id'] ):?>selected="selected"<? endif;?>>
<?= $payment_method['name'];?>
</option>
@@ -130,7 +148,7 @@ ob_start();
<button class="btn btn-success order_status_change">zmień status</button>
</div>
<div class="col-12 order-history">
<? if ( \S::is_array_fix( $this -> order['statuses'] ) ): foreach ( $this -> order['statuses'] as $status ):?>
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> order['statuses'] ) ): foreach ( $this -> order['statuses'] as $status ):?>
<div><b><?= date( 'Y-m-d H:i', strtotime( $status['date'] ) );?></b>: <?= $this -> order_statuses[$status['status_id']];?></div>
<? endforeach; endif;?>
</div>
@@ -147,46 +165,75 @@ ob_start();
</div>
<div class="row">
<div class="col-12">
<div class="text-big mb5">Produkty zamówienia:</div>
<div class="table-responsive">
<table class="table">
<table class="table" id="order-products-table">
<thead>
<tr>
<th>Zdjęcie</th>
<th style="width:60px">Zdjęcie</th>
<th scope="col">Nazwa</th>
<th scope="col" class="tab-center">Ilość</th>
<th scope="col" class="tab-right">Cena / szt:</th>
<th scope="col" class="tab-right">Cena / szt (po rabacie):</th>
<th scope="col" class="tab-right">Suma (po rabacie):</th>
<th scope="col" class="tab-center" style="width:80px">Ilość</th>
<th scope="col" class="tab-right" style="width:130px">Cena / szt:</th>
<th scope="col" class="tab-right" style="width:130px">Cena promo:</th>
<th scope="col" class="tab-right" style="width:110px">Suma:</th>
<th scope="col" style="width:40px"></th>
</tr>
</thead>
<tbody>
<? if ( is_array( $this -> order[ 'products' ] ) ): foreach ( $this -> order[ 'products' ] as $product ):?>
<tr class="order-product-details">
<tbody id="order-products-body">
<? $productRepo = new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ); ?>
<? if ( is_array( $this -> order[ 'products' ] ) ): foreach ( $this -> order[ 'products' ] as $i => $product ):?>
<tr class="order-product-row" data-index="<?= $i;?>">
<input type="hidden" name="products[<?= $i;?>][order_product_id]" value="<?= (int)$product['id'];?>">
<input type="hidden" name="products[<?= $i;?>][product_id]" value="<?= (int)$product['product_id'];?>">
<input type="hidden" name="products[<?= $i;?>][parent_product_id]" value="<?= (int)($product['parent_product_id'] ?? $product['product_id']);?>">
<input type="hidden" name="products[<?= $i;?>][name]" value="<?= htmlspecialchars((string)$product['name'], ENT_QUOTES, 'UTF-8');?>">
<input type="hidden" name="products[<?= $i;?>][vat]" value="<?= (float)($product['vat'] ?? 0);?>">
<td class="product-image">
<? if ( $product['product_id'] ):?>
<img src="<?= \shop\Product::getProductImg( (int)$product['product_id'] );?>">
<img src="<?= $productRepo->getProductImg( (int)$product['product_id'] );?>" style="max-width:50px;max-height:50px;">
<? endif;?>
</td>
<td>
<a href="<?= \shop\Product::getProductUrl( (int)$product['product_id'] );?>" target="_blank"><?= $product[ 'name' ];?></a>
<br />
<div class="atributes">
<?= $product[ 'attributes' ];?>
</div>
<br />
<div class="product-message">
<?= $product[ 'message' ] != '' ? '<strong>Wiadomość:</strong> ' . $product['message'] : '';?>
</div>
<a href="<?= $productRepo->getProductUrl( (int)$product['product_id'] );?>" target="_blank"><?= $product[ 'name' ];?></a>
<? if ( $product['attributes'] ):?>
<div class="atributes small text-muted"><?= $product[ 'attributes' ];?></div>
<? endif;?>
<? if ( $product[ 'message' ] != '' ):?>
<div class="product-message small"><strong>Wiadomość:</strong> <?= $product['message'];?></div>
<? endif;?>
</td>
<td class="tab-center">
<input type="number" name="products[<?= $i;?>][quantity]" value="<?= (int)$product['quantity'];?>" min="1" class="form-control form-control-sm text-center product-qty" style="width:70px">
</td>
<td class="tab-right">
<input type="number" name="products[<?= $i;?>][price_brutto]" value="<?= number_format((float)$product['price_brutto'], 2, '.', '');?>" step="0.01" min="0" class="form-control form-control-sm text-right product-price" style="width:110px">
</td>
<td class="tab-right">
<input type="number" name="products[<?= $i;?>][price_brutto_promo]" value="<?= number_format((float)$product['price_brutto_promo'], 2, '.', '');?>" step="0.01" min="0" class="form-control form-control-sm text-right product-price-promo" style="width:110px">
</td>
<td class="tab-right product-row-total">
<?= number_format(((float)$product['price_brutto_promo'] > 0 ? (float)$product['price_brutto_promo'] : (float)$product['price_brutto']) * (int)$product['quantity'], 2, ',', '');?> zł
</td>
<td class="text-center">
<button type="button" class="btn btn-xs btn-danger btn-remove-product" title="Usuń produkt"><i class="fa fa-times"></i></button>
</td>
<td class="tab-center"><?= $product[ 'quantity' ];?></td>
<td class="tab-right"><?= $product[ 'price_brutto' ];?> zł</td>
<td class="tab-right"><?= $product[ 'price_brutto_promo' ];?> zł</td>
<td class="tab-right"><?= $product[ 'price_brutto_promo' ] * $product[ 'quantity' ];?> zł</td>
</tr>
<? endforeach; endif;?>
</tbody>
</table>
</div>
</div>
<div class="mb15" id="add-product-section">
<div class="text-big mb5">Dodaj produkt:</div>
<div class="row">
<div class="col-md-6">
<div style="position:relative">
<input type="text" id="product-search-input" class="form-control" placeholder="Wpisz nazwę produktu..." autocomplete="off">
<div id="product-search-results" style="display:none;position:absolute;z-index:1000;width:100%;max-height:300px;overflow-y:auto;background:#fff;border:1px solid #ddd;border-top:none;box-shadow:0 2px 8px rgba(0,0,0,0.15)"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
@@ -199,71 +246,21 @@ ob_start();
</form>
</div>
</div>
</div>
</div>
<?
$out = ob_get_clean();
</form>
$grid = new \gridEdit;
$grid -> id = 'order-details';
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> title = 'Szczegóły zamówienia: ' . $this -> order[ 'number' ];
$grid -> buttons = [
[
'label' => 'Zapisz zamówienie',
'icon' => 'fa-save',
'class' => 'btn btn-success btn-sm mr5 ml5',
'id' => 'order-save'
],
[
'label' => 'Wstecz',
'url' => '/admin/shop_order/order_details/order_id=' . $this -> order['id'],
'icon' => 'fa-reply',
'class' => 'btn btn-dark btn-sm mr5'
]
];
$grid -> default_buttons = false;
$grid -> external_code = $out;
echo $grid -> draw();
?>
<div class="inpost-map-container">
<a href="#" onclick="$( '.inpost-map-container' ).hide(); return false;" class="inpost-hide"><?= \S::lang( 'zamknij' );?></a>
<a href="#" onclick="$( '.inpost-map-container' ).hide(); return false;" class="inpost-hide"><?= \Shared\Helpers\Helpers::lang( 'zamknij' );?></a>
<div id="inpost-map"></div>
</div>
<link class="footer" rel="stylesheet" type="text/css" href="https://geowidget.easypack24.net/css/easypack.css">
<script class="footer" type="text/javascript" src="https://geowidget.easypack24.net/js/sdk-for-javascript.js"></script>
<script type="text/javascript">
$( function()
{
$( 'body' ).on( 'change', '#transport_id', function()
{
if ( $( this ).val() != '2' )
$( '#inpost_paczkomat' ).closest( '.row' ).hide();
else
$( '#inpost_paczkomat' ).closest( '.row' ).show();
});
$( 'body' ).on( 'click', '.btn-paczkomat', function()
{
window.easyPackAsyncInit = function () {
easyPack.init({
mapType: 'osm',
searchType: 'osm',
});
var map = easyPack.mapWidget( 'inpost-map', function(point)
{
$( '#inpost_paczkomat' ).val( point.name + ' | ' + point.address.line1 + ', ' + point.address.line2 );
$( '.inpost-map-container' ).hide();
});
};
$( '.inpost-map-container' ).show();
});
$( 'body' ).on( 'click', '#order-save', function(e)
{
e.preventDefault();
$( '#fg-order-details' ).attr( 'method', 'POST' ).attr( 'action', '/admin/shop_order/order_save/' ).submit();
});
});
</script>
var orderEditConfig = {
transports: <?= $this -> transports_json ?? '[]';?>,
freeDelivery: <?= (float)($this -> free_delivery ?? 0);?>,
currentTransportCost: <?= (float)($this -> order['transport_cost'] ?? 0);?>
};
</script>
<?= \Shared\Tpl\Tpl::view('shop-order/order-edit-custom-script');?>

View File

@@ -0,0 +1,2 @@
<div class="site-title">Lista zamówień</div>
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>