ver. 0.276: ShopOrder migration, Integrations cleanup, global admin search

This commit is contained in:
2026-02-15 16:37:57 +01:00
parent 0a2d13090f
commit d012a694c2
34 changed files with 2196 additions and 1063 deletions

View File

@@ -270,6 +270,19 @@ $isCompactColumn = function(array $column): bool {
</div>
<style type="text/css">
.table-list-table th,
.table-list-table td {
vertical-align: middle !important;
}
.table-list-table th.text-right,
.table-list-table td.text-right {
display: table-cell !important;
text-align: right !important;
justify-content: initial !important;
align-items: initial !important;
}
.table-list-table th:first-child,
.table-list-table td:first-child {
width: 70px;

View File

@@ -0,0 +1,432 @@
<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();
}
}
}
});
}
}
});
}
$('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,36 @@
<?
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>
<div class="mb15">
<a href="/admin/shop_order/list/" class="btn btn-dark btn-sm mr5">
<i class="fa fa-reply"></i> Wstecz
</a>
<a href="/admin/shop_order/order_edit/order_id=<?= $orderId;?>" class="btn btn-danger btn-sm mr5">
<i class="fa fa-pencil"></i> Edytuj zamówienie
</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 mr5">
<i class="fa fa-arrow-left"></i> Poprzednie zamówienie
</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 mr5">
<i class="fa fa-arrow-right"></i> Następne zamówienie
</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">
@@ -66,12 +94,12 @@ ob_start();
<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>
@@ -177,59 +205,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 +217,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>
<?= \Tpl::view('shop-order/order-details-custom-script', [
'order_id' => $orderId,
'trustmate_send' => (int)($this -> order['trustmate_send'] ?? 0),
]);?>

View File

@@ -0,0 +1,38 @@
<script type="text/javascript">
$(function() {
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();
});
$('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();
});
$('body').on('click', '#order-save', function(e) {
e.preventDefault();
$('#fg-order-details').attr('method', 'POST').attr('action', '/admin/shop_order/order_save/').submit();
});
});
</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">
@@ -199,71 +212,14 @@ 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>
<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>
<?= \Tpl::view('shop-order/order-edit-custom-script');?>

View File

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

View File

@@ -1,147 +0,0 @@
<?php
global $gdb;
$grid = new \grid( 'pp_shop_order' );
$grid -> gdb_opt = $gdb;
$grid->sql = '
SELECT
q1.*,
shop_order.total_orders
FROM (
SELECT
id,
number,
date_order,
CONCAT(client_name, \' \', client_surname) AS client,
client_email AS order_email,
CONCAT(client_street, \', \', client_postal_code, \' \', client_city) AS address,
status,
client_phone,
transport,
payment_method,
summary,
paid
FROM
pp_shop_orders AS pso
) AS q1
LEFT JOIN (
SELECT
client_email,
COUNT(*) AS total_orders
FROM
pp_shop_orders
WHERE
client_name IS NOT NULL AND client_surname IS NOT NULL AND client_email IS NOT NULL
GROUP BY
client_email
) AS shop_order ON q1.order_email = shop_order.client_email
WHERE
1=1 [where]
ORDER BY
[order_p1] [order_p2]
';
$grid->sql_count = '
SELECT COUNT(0)
FROM (
SELECT
id,
number,
date_order,
CONCAT(client_name, \' \', client_surname) AS client,
client_email AS order_email,
CONCAT(client_street, \', \', client_postal_code, \' \', client_city) AS address,
status,
client_phone,
transport,
payment_method,
summary,
paid
FROM
pp_shop_orders AS pso
) AS q1
WHERE
1=1 [where]
';
$grid -> debug = true;
$grid -> order = [ 'column' => 'date_order', 'type' => 'DESC' ];
$grid -> search = [
[ 'name' => 'Nr zamówienia', 'db' => 'number', 'type' => 'text' ],
[ 'name' => 'Data zamówienia', 'db' => 'date_order', 'type' => 'date_range' ],
[ 'name' => 'Status', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => \shop\Order::order_statuses() ] ],
[ 'name' => 'Klient', 'db' => 'client', 'type' => 'text' ],
[ 'name' => 'Adres', 'db' => 'address', 'type' => 'text' ],
[ 'name' => 'Email', 'db' => 'order_email', 'type' => 'text' ],
[ 'name' => 'Telefon', 'db' => 'client_phone', 'type' => 'text' ],
[ 'name' => 'Dostawa', 'db' => 'transport', 'type' => 'text' ],
[ 'name' => 'Płatność', 'db' => 'payment_method', 'type' => 'text' ]
];
$grid -> columns_view = [
[
'name' => 'Lp.',
'th' => [ 'class' => 'g-lp' ],
'td' => [ 'class' => 'g-center' ],
'autoincrement' => true
], [
'name' => 'Data dodania',
'db' => 'date_order',
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_order]" ) );',
'sort' => true
], [
'name' => 'Nr zamówienia',
'db' => 'number',
'sort' => true,
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
'php' => 'echo "<a href=\'/admin/shop_order/order_details/order_id=[id]\'>" . htmlspecialchars( \'[number]\' ) . "</a>";'
], [
'name' => '',
'db' => 'paid',
'sort' => true,
'td' => [ 'class' => 'g-center' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 25px;' ],
'php' => 'if ( [paid] === 1 ) echo "<i class=\'fa fa-check text-success\'></i>"; else echo "<i class=\'fa fa-times text-dark\'></i>";'
], [
'name' => 'Status',
'db' => 'status',
'sort' => true,
'th' => [ 'style' => 'width: 250px;' ],
'td' => [ 'class' => 'order-status' ],
'replace' => [ 'array' => \shop\Order::order_statuses() ]
], [
'name' => 'Wartość',
'db' => 'summary',
'sort' => true,
'td' => [ 'class' => 'g-right' ],
'th' => [ 'class' => 'g-right', 'style' => 'width: 90px;' ],
'php' => 'echo "[summary] zł"; echo "<script>$( \"tr#[id]\" ).addClass( \"status-[status]\" );</script>";'
], [
'name' => 'Klient',
'db' => 'client',
'php' => 'echo "[client] | zamówienia: <strong>[total_orders]</strong>";'
], [
'name' => 'Adres',
'db' => 'address',
], [
'name' => 'Email',
'db' => 'order_email',
], [
'name' => 'Telefon',
'db' => 'client_phone',
], [
'name' => 'Dostawa',
'db' => 'transport',
], [
'name' => 'Płatność',
'db' => 'payment_method',
], [
'name' => 'Usuń',
'action' => [ 'type' => 'delete', 'url' => '/admin/shop_order/order_delete/id=[id]' ],
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
'td' => [ 'class' => 'g-center' ]
]
];
echo $grid -> draw();

View File

@@ -54,7 +54,7 @@
Sklep
</div>
<ul>
<li> <a href="/admin/shop_order/view_list/"><img src="/admin/layout/icon/icon-menu/shopping-cart.svg">Zam&#243;wienia</a></li>
<li> <a href="/admin/shop_order/list/"><img src="/admin/layout/icon/icon-menu/shopping-cart.svg">Zam&#243;wienia</a></li>
<li> <a href="/admin/shop_clients/list/"><img src="/admin/layout/icon/icon-menu/people-fill.svg">Klienci</a></li>
<li><a href="/admin/shop_category/list/"><img src="/admin/layout/icon/icon-menu/bxs-category-alt.svg">Kategorie</a></li>
<li><a href="/admin/shop_product/view_list/"><img src="/admin/layout/icon/icon-menu/shopping-basket.svg">Produkty</a></li>
@@ -159,7 +159,19 @@
<div class="col-12 col-md-3 col-lg-2">
<button id="clear-cache-btn" class="btn btn-danger mt-3">Wyczy&#347;&#263; cache</button>
</div>
<div class="col-12 col-md-9 col-lg-10 top-user">
<div class="col-12 col-md-6 col-lg-7 mt-3">
<div class="admin-global-search" id="admin-global-search-wrap">
<input
type="text"
id="admin-global-search-input"
class="form-control"
placeholder="Szukaj produktu (EAN, Nazwa, SKU) lub zamówienia (email, imię, nazwisko, telefon, numer)"
autocomplete="off"
>
<div class="admin-global-search-results" id="admin-global-search-results"></div>
</div>
</div>
<div class="col-12 col-md-3 col-lg-3 top-user">
<div class="dropdown">
<?
if ( $user[ 'name' ] or $user[ 'surname' ] )
@@ -246,6 +258,101 @@
bindClearCacheButton();
})();
(function() {
var $input = $('#admin-global-search-input');
var $results = $('#admin-global-search-results');
var $wrap = $('#admin-global-search-wrap');
var timer = null;
function escapeHtml(value) {
return $('<div>').text(value || '').html();
}
function hideResults() {
$results.removeClass('open').empty();
}
function renderResults(items) {
if (!Array.isArray(items) || items.length === 0) {
$results
.html('<div class="admin-global-search-empty">Brak wyników</div>')
.addClass('open');
return;
}
var html = '';
items.forEach(function(item) {
var title = escapeHtml(item.title || '');
var subtitle = escapeHtml(item.subtitle || '');
var type = item.type === 'order' ? 'Zamówienie' : 'Produkt';
var url = escapeHtml(item.url || '#');
html += ''
+ '<a class="admin-global-search-item" href="' + url + '">'
+ ' <div class="admin-global-search-item-title">' + title + '</div>'
+ ' <div class="admin-global-search-item-subtitle">' + escapeHtml(type) + (subtitle ? ' | ' + subtitle : '') + '</div>'
+ '</a>';
});
$results.html(html).addClass('open');
}
function searchNow() {
var phrase = ($input.val() || '').trim();
if (phrase.length < 2) {
hideResults();
return;
}
$results.html('<div class="admin-global-search-empty">Szukam...</div>').addClass('open');
$.ajax({
url: '/admin/settings/globalSearchAjax/',
type: 'GET',
dataType: 'json',
data: { q: phrase },
success: function(response) {
if (!response || response.status !== 'ok') {
$results.html('<div class="admin-global-search-empty">Wystąpił błąd wyszukiwania</div>').addClass('open');
return;
}
renderResults(response.items || []);
},
error: function() {
$results.html('<div class="admin-global-search-empty">Błąd połączenia</div>').addClass('open');
}
});
}
$(document)
.off('input.adminGlobalSearch', '#admin-global-search-input')
.on('input.adminGlobalSearch', '#admin-global-search-input', function() {
clearTimeout(timer);
timer = setTimeout(searchNow, 250);
});
$(document)
.off('focus.adminGlobalSearch', '#admin-global-search-input')
.on('focus.adminGlobalSearch', '#admin-global-search-input', function() {
if (($input.val() || '').trim().length >= 2 && $results.children().length > 0) {
$results.addClass('open');
}
});
$(document)
.off('click.adminGlobalSearch')
.on('click.adminGlobalSearch', function(e) {
if ($wrap.length === 0) {
return;
}
if ($(e.target).closest('#admin-global-search-wrap').length === 0) {
hideResults();
}
});
})();
$(document).ready(function () {
var user_agent = navigator.userAgent.toLowerCase();
var click_event = user_agent.match(/(iphone|ipod|ipad)/) ? "touchend" : "click";
@@ -269,5 +376,62 @@
});
</script>
<style type="text/css">
.admin-global-search {
position: relative;
max-width: 900px;
}
.admin-global-search-results {
display: none;
position: absolute;
left: 0;
right: 0;
top: calc(100% + 4px);
z-index: 9999;
background: #fff;
border: 1px solid #e5e5e5;
border-radius: 4px;
max-height: 420px;
overflow: auto;
box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.admin-global-search-results.open {
display: block;
}
.admin-global-search-item {
display: block;
padding: 10px 12px;
border-bottom: 1px solid #f1f1f1;
color: #333;
text-decoration: none;
}
.admin-global-search-item:hover,
.admin-global-search-item:focus {
background: #f7f9fc;
color: #222;
text-decoration: none;
}
.admin-global-search-item-title {
font-weight: 600;
margin-bottom: 2px;
}
.admin-global-search-item-subtitle {
font-size: 12px;
color: #6c757d;
line-height: 1.3;
}
.admin-global-search-empty {
padding: 10px 12px;
color: #6c757d;
font-size: 13px;
}
</style>
</body>
</html>