update
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?
|
||||
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT ^ E_WARNING ^ E_DEPRECATED );
|
||||
error_reporting( E_ALL ^ E_NOTICE ^ E_STRICT );
|
||||
function __autoload_my_classes( $classname )
|
||||
{
|
||||
$q = explode( '\\' , $classname );
|
||||
@@ -12,12 +12,17 @@ function __autoload_my_classes( $classname )
|
||||
}
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
else
|
||||
{
|
||||
$f = '../autoload/' . implode( '/' , $q ) . '/' . $c . '.php';
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
}
|
||||
}
|
||||
spl_autoload_register( '__autoload_my_classes' );
|
||||
|
||||
require_once '../config.php';
|
||||
require_once '../libraries/medoo/medoo.php';
|
||||
require_once '../libraries/grid/config.php';
|
||||
date_default_timezone_set('Europe/Warsaw');
|
||||
|
||||
session_start();
|
||||
@@ -31,9 +36,6 @@ $mdb = new medoo( [
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
require_once 'ajax/pages.php';
|
||||
require_once 'ajax/articles.php';
|
||||
require_once 'ajax/shop-category.php';
|
||||
require_once 'ajax/users.php';
|
||||
require_once 'ajax/shop.php';
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
<?php
|
||||
$a = \S::get( 'a' );
|
||||
$a = \Shared\Helpers\Helpers::get( 'a' );
|
||||
|
||||
if ( $a == 'save_products_order' )
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kolejności wyświetlania produktów wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopCategory::save_product_order( \S::get( 'category_id' ), \S::get( 'products' ) ) )
|
||||
|
||||
$categoryRepository = new \Domain\Category\CategoryRepository( $mdb );
|
||||
|
||||
if ( $categoryRepository->saveProductOrder( \Shared\Helpers\Helpers::get( 'category_id' ), \Shared\Helpers\Helpers::get( 'products' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
|
||||
@@ -16,8 +16,10 @@ if ( $a == 'cookie_categories' )
|
||||
if ( $a == 'save_categories_order' )
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kolejności kategorii wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopCategory::save_categories_order( \S::get( 'categories' ) ) )
|
||||
|
||||
$categoryRepository = new \Domain\Category\CategoryRepository( $mdb );
|
||||
|
||||
if ( $categoryRepository->saveCategoriesOrder( \S::get( 'categories' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<?php
|
||||
$a = \S::get( 'a' );
|
||||
$a = \Shared\Helpers\Helpers::get( 'a' );
|
||||
|
||||
if ( $a == 'check_login' )
|
||||
{
|
||||
$response = \admin\factory\Users::check_login( \S::get( 'login' ), \S::get( 'user_id' ) );
|
||||
global $mdb;
|
||||
$repository = new \Domain\User\UserRepository( $mdb );
|
||||
$response = $repository->checkLogin( (string)\Shared\Helpers\Helpers::get( 'login' ), (int)\Shared\Helpers\Helpers::get( 'user_id' ) );
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,20 @@ function __autoload_my_classes( $classname )
|
||||
$q = explode( '\\', $classname );
|
||||
$c = array_pop( $q );
|
||||
$f = '../autoload/' . implode( '/', $q ) . '/class.' . $c . '.php';
|
||||
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
else
|
||||
{
|
||||
$f = '../autoload/' . implode( '/', $q ) . '/' . $c . '.php';
|
||||
if ( file_exists( $f ) )
|
||||
require_once( $f );
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register( '__autoload_my_classes' );
|
||||
require_once '../config.php';
|
||||
require_once '../libraries/medoo/medoo.php';
|
||||
require_once '../libraries/grid/config.php';
|
||||
require_once '../libraries/rb.php';
|
||||
require_once '../libraries/phpmailer/class.phpmailer.php';
|
||||
require_once '../libraries/phpmailer/class.smtp.php';
|
||||
@@ -38,7 +44,16 @@ define( 'REDBEAN_MODEL_PREFIX', '' );
|
||||
|
||||
date_default_timezone_set( 'Europe/Warsaw' );
|
||||
|
||||
$settings = \front\factory\Settings::settings_details();
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
$settings = ( new \Domain\Settings\SettingsRepository( $mdb ) )->allSettings();
|
||||
|
||||
if ( file_exists( 'config.php' ) )
|
||||
include 'config.php';
|
||||
@@ -59,42 +74,36 @@ if ( $_SESSION['ip'] !== $_SERVER['REMOTE_ADDR'] )
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( !$lang_id = \S::get_session( 'current-lang' ) )
|
||||
$langRepo = new \Domain\Languages\LanguagesRepository( $mdb );
|
||||
|
||||
if ( !$lang_id = \Shared\Helpers\Helpers::get_session( 'current-lang' ) )
|
||||
{
|
||||
$lang_id = \front\factory\Languages::default_language();
|
||||
\S::set_session( 'current-lang', $lang_id );
|
||||
$lang_id = $langRepo->defaultLanguage();
|
||||
\Shared\Helpers\Helpers::set_session( 'current-lang', $lang_id );
|
||||
}
|
||||
|
||||
if ( !$lang = \S::get_session( 'lang-' . $lang_id ) )
|
||||
if ( !$lang = \Shared\Helpers\Helpers::get_session( 'lang-' . $lang_id ) )
|
||||
{
|
||||
$lang = \front\factory\Languages::lang_translations( $lang_id );
|
||||
\S::set_session( 'lang-' . $lang_id, $lang );
|
||||
$lang = $langRepo->translations( $lang_id );
|
||||
\Shared\Helpers\Helpers::set_session( 'lang-' . $lang_id, $lang );
|
||||
}
|
||||
|
||||
$mdb = new medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $database['name'],
|
||||
'server' => $database['host'],
|
||||
'username' => $database['user'],
|
||||
'password' => $database['password'],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
$user = \Shared\Helpers\Helpers::get_session( 'user', true );
|
||||
|
||||
$user = \S::get_session( 'user', true );
|
||||
|
||||
\admin\Site::update();
|
||||
\admin\Site::special_actions();
|
||||
\admin\App::update();
|
||||
\admin\App::special_actions();
|
||||
|
||||
$domain = preg_replace( '/^www\./', '', $_SERVER['SERVER_NAME'] );
|
||||
$cookie_name = 'admin_remember_' . str_replace( '.', '-', $domain );
|
||||
|
||||
if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) )
|
||||
{
|
||||
$users = new \Domain\User\UserRepository($mdb);
|
||||
$payload = base64_decode($_COOKIE[$cookie_name]);
|
||||
if ($payload !== false && strpos($payload, '.') !== false)
|
||||
{
|
||||
list($json, $sig) = explode('.', $payload, 2);
|
||||
$expected_sig = hash_hmac('sha256', $json, \admin\Site::APP_SECRET_KEY);
|
||||
$expected_sig = hash_hmac('sha256', $json, \admin\App::APP_SECRET_KEY);
|
||||
|
||||
if (hash_equals($expected_sig, $sig))
|
||||
{
|
||||
@@ -107,7 +116,7 @@ if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) )
|
||||
$user_data = $mdb->get('pp_users', '*', ['AND' => ['login' => $data['login'], 'status' => 1]]);
|
||||
if ($user_data)
|
||||
{
|
||||
\S::set_session('user', \admin\factory\Users::details($data['login']));
|
||||
\Shared\Helpers\Helpers::set_session('user', $users->details($data['login']));
|
||||
$redirect = $_SERVER['REQUEST_URI'] ?: '/admin/articles/view_list/';
|
||||
header('Location: ' . $redirect);
|
||||
exit;
|
||||
@@ -127,5 +136,5 @@ if ( isset( $_COOKIE[$cookie_name] ) && !isset( $_SESSION['user'] ) )
|
||||
]);
|
||||
}
|
||||
|
||||
echo \admin\view\Page::show();
|
||||
?>
|
||||
echo \admin\App::render();
|
||||
?>
|
||||
|
||||
229
admin/layout/style-css/order-details-mobile.css
Normal file
229
admin/layout/style-css/order-details-mobile.css
Normal file
@@ -0,0 +1,229 @@
|
||||
/* ==========================================================================
|
||||
Order Details — Mobile Responsive
|
||||
Scoped to .od-actions and .order-details
|
||||
All rules inside @media (max-width: 767px) — desktop layout untouched
|
||||
========================================================================== */
|
||||
|
||||
@media (max-width: 767px) {
|
||||
|
||||
/* --- 1. Action buttons bar --- */
|
||||
|
||||
.od-actions {
|
||||
display: flex;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
padding-bottom: 8px;
|
||||
}
|
||||
|
||||
.od-actions .btn {
|
||||
flex-shrink: 0;
|
||||
font-size: 12px;
|
||||
padding: 6px 10px;
|
||||
margin-right: 0 !important;
|
||||
margin-left: 0 !important;
|
||||
}
|
||||
|
||||
/* Hide button labels on small screens — show only icons */
|
||||
.od-actions .od-actions-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Integrations dropdown — push to end, cancel float */
|
||||
.od-actions .pull-right,
|
||||
.od-actions .dropdown.pull-right {
|
||||
float: none !important;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
/* Dropdown menu must not clip inside scroll container */
|
||||
.od-actions .dropdown {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.od-actions + .order-details .dropdown-menu,
|
||||
#integrationsDropdownMenu.show {
|
||||
position: fixed;
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border-radius: 12px 12px 0 0;
|
||||
box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
|
||||
z-index: 1060;
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
#integrationsDropdownMenu.show .dropdown-item {
|
||||
padding: 12px 20px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* --- 2. Full-width columns stacking --- */
|
||||
|
||||
.order-details .col-sm-6,
|
||||
.order-details .col-lg-8,
|
||||
.order-details .col-lg-4,
|
||||
.order-details .col-xl-5,
|
||||
.order-details .col-xl-7 {
|
||||
width: 100%;
|
||||
flex: 0 0 100%;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* Spacing between stacked sections */
|
||||
.order-details .col-sm-6 {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
/* "Resend confirmation" button — allow text to wrap */
|
||||
.order-details .resend_order_confirmation_email .btn {
|
||||
font-size: 12px;
|
||||
white-space: normal;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
/* --- 3. Status section --- */
|
||||
|
||||
.order-details .status_select #order-status {
|
||||
max-width: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.order-details .buttons {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.order-details .buttons .btn {
|
||||
width: 100%;
|
||||
white-space: normal;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.order-details .order-status {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.order-details .order-history {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
/* --- 4. Products table — compact list --- */
|
||||
|
||||
.order-details table thead {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.order-details table {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.order-details table tbody {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.order-details table tr.order-product-details {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: flex-start;
|
||||
padding: 12px 0;
|
||||
border-bottom: 1px solid #eee;
|
||||
gap: 0;
|
||||
}
|
||||
|
||||
.order-details table tr.order-product-details:last-child {
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
/* Image cell */
|
||||
.order-details table td.product-image {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
flex-shrink: 0;
|
||||
border: none;
|
||||
padding: 0;
|
||||
margin-right: 10px;
|
||||
float: none;
|
||||
}
|
||||
|
||||
.order-details table td.product-image img {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
object-fit: contain;
|
||||
}
|
||||
|
||||
/* Name cell — takes remaining space next to image */
|
||||
.order-details table tr.order-product-details td:nth-child(2) {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
border: none;
|
||||
padding: 0;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
.order-details table tr.order-product-details td:nth-child(2) a {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
display: block;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* Hide quantity, price, discounted-price, total columns on mobile */
|
||||
.order-details table tr.order-product-details td.tab-center,
|
||||
.order-details table tr.order-product-details td.tab-right {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Show mobile price summary line */
|
||||
.od-mobile-price-line {
|
||||
display: block !important;
|
||||
margin-top: 4px;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: #2a3042;
|
||||
}
|
||||
|
||||
/* --- 5. Notes --- */
|
||||
|
||||
.order-details #notes {
|
||||
font-size: 14px;
|
||||
min-height: 120px;
|
||||
}
|
||||
|
||||
/* --- 6. Order summary panel --- */
|
||||
|
||||
.order-details .panel .panel-body {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* --- 7. Paid status --- */
|
||||
|
||||
.order-details .paid-status .panel-body a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
/* --- 8. Message section — hide empty spacer columns --- */
|
||||
|
||||
.order-details .d-none.d-lg-block {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Desktop: action bar spacing (replaces mr5 class) --- */
|
||||
.od-actions .btn + .btn,
|
||||
.od-actions .btn + .dropdown {
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
/* Mobile price line — hidden on desktop */
|
||||
.od-mobile-price-line {
|
||||
display: none;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
210
admin/layout/style-css/table-list.css
Normal file
210
admin/layout/style-css/table-list.css
Normal file
@@ -0,0 +1,210 @@
|
||||
.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;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.js-table-filters-form .js-filter-compact-select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.table-list-table th.table-col-compact,
|
||||
.table-list-table td.table-col-compact {
|
||||
width: 120px;
|
||||
min-width: 120px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.table-list-per-page-form {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-row {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box-container {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box {
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
/* --- Filter toggle --- */
|
||||
|
||||
.table-filters-wrapper {
|
||||
display: none;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table-filters-wrapper.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.js-filter-toggle-btn.active {
|
||||
background-color: #e8e8e8;
|
||||
border-color: #adadad;
|
||||
box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125);
|
||||
}
|
||||
|
||||
.table-filter-badge {
|
||||
display: inline-block;
|
||||
min-width: 16px;
|
||||
padding: 2px 5px;
|
||||
font-size: 10px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
background-color: #337ab7;
|
||||
border-radius: 10px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
/* --- Column visibility toggle --- */
|
||||
|
||||
.table-list-header-actions {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.table-col-toggle-wrapper {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.table-col-toggle-dropdown {
|
||||
display: none;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 100%;
|
||||
z-index: 1050;
|
||||
min-width: 220px;
|
||||
max-height: 400px;
|
||||
overflow-y: auto;
|
||||
background: #fff;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
|
||||
padding: 0;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.table-col-toggle-dropdown.open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.table-col-toggle-header {
|
||||
padding: 8px 12px;
|
||||
font-weight: 600;
|
||||
font-size: 12px;
|
||||
color: #555;
|
||||
border-bottom: 1px solid #eee;
|
||||
background: #f8f8f8;
|
||||
}
|
||||
|
||||
.table-col-toggle-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 5px 12px;
|
||||
margin: 0;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.table-col-toggle-item:hover {
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.table-col-toggle-footer {
|
||||
padding: 6px 12px;
|
||||
border-top: 1px solid #eee;
|
||||
background: #f8f8f8;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table-list-table th.table-col-hidden,
|
||||
.table-list-table td.table-col-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* Toggle switch */
|
||||
|
||||
.table-col-switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 34px;
|
||||
min-width: 34px;
|
||||
height: 18px;
|
||||
}
|
||||
|
||||
.table-col-switch input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.table-col-switch-slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-color: #ccc;
|
||||
border-radius: 18px;
|
||||
transition: background-color 0.2s;
|
||||
}
|
||||
|
||||
.table-col-switch-slider:before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 14px;
|
||||
width: 14px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
background-color: #fff;
|
||||
border-radius: 50%;
|
||||
transition: transform 0.2s;
|
||||
}
|
||||
|
||||
.table-col-switch input:checked + .table-col-switch-slider {
|
||||
background-color: #5cb85c;
|
||||
}
|
||||
|
||||
.table-col-switch input:checked + .table-col-switch-slider:before {
|
||||
transform: translateX(16px);
|
||||
}
|
||||
@@ -455,23 +455,14 @@ body {
|
||||
}
|
||||
|
||||
.site-content {
|
||||
|
||||
&.with-menu {
|
||||
width: 100%;
|
||||
|
||||
@include respond-above(xs) {
|
||||
width: calc(100% - 243px);
|
||||
|
||||
margin-left: 243px;
|
||||
}
|
||||
}
|
||||
|
||||
@include respond-below(md) {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
margin-left: 0;
|
||||
background-color: #fff;
|
||||
margin-left: 244px;
|
||||
|
||||
@include respond-above(xs) {
|
||||
width: calc(100% - 243px);
|
||||
margin-left: 243px;
|
||||
}
|
||||
|
||||
|
||||
.top-user {
|
||||
text-align: right;
|
||||
@@ -827,7 +818,7 @@ body {
|
||||
td {
|
||||
border-color: $cHoverBackground;
|
||||
|
||||
a {
|
||||
a:not(.btn) {
|
||||
transition: .15s ease;
|
||||
|
||||
&:hover {
|
||||
@@ -1351,39 +1342,6 @@ li.sort-collapsed.sort-hover div {
|
||||
}
|
||||
}
|
||||
|
||||
input[type="checkbox"] {
|
||||
position: relative;
|
||||
width: 40px;
|
||||
height: 20px;
|
||||
-webkit-appearance: none;
|
||||
background: $cGrayLight;
|
||||
outline: none;
|
||||
border-radius: 10px;
|
||||
box-shadow: inset 0 0 5px rgba(0, 0, 0, .2);
|
||||
}
|
||||
|
||||
input:checked[type="checkbox"] {
|
||||
background: $cMenuText;
|
||||
}
|
||||
|
||||
input[type="checkbox"]:before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 10px;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
transform: scale(1.1);
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, .2);
|
||||
transition: .5s;
|
||||
}
|
||||
|
||||
input:checked[type="checkbox"]:before {
|
||||
left: 20px;
|
||||
}
|
||||
|
||||
#images-uploader,
|
||||
#files-uploader {
|
||||
clear: both;
|
||||
@@ -1726,7 +1684,7 @@ input:checked[type="checkbox"]:before {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
a {
|
||||
a:not(.btn) {
|
||||
color: $cBlue;
|
||||
transition: .15s ease;
|
||||
font-weight: 500;
|
||||
@@ -1736,6 +1694,24 @@ input:checked[type="checkbox"]:before {
|
||||
}
|
||||
}
|
||||
|
||||
a.btn {
|
||||
color: #fff;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
a.btn-default {
|
||||
color: #000;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
thead {
|
||||
background-color: $cHoverBackground;
|
||||
|
||||
@@ -1765,33 +1741,16 @@ input:checked[type="checkbox"]:before {
|
||||
}
|
||||
}
|
||||
|
||||
#table-products {
|
||||
.product-categories {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-wrap: wrap;
|
||||
}
|
||||
.product-categories {
|
||||
display: block;
|
||||
width: 100%;
|
||||
text-wrap: wrap;
|
||||
|
||||
.product-name {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
|
||||
.duplicate-product {
|
||||
margin-left: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
.duplicate-product {
|
||||
float: right;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.btn-success {
|
||||
color: #FFF !important;
|
||||
|
||||
&.btn-create-product {
|
||||
margin-top: 5px;
|
||||
}
|
||||
&--cats {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
max-width: 600px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2119,6 +2078,10 @@ textarea.form-control {
|
||||
}
|
||||
|
||||
.order-details {
|
||||
.fa-copy {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.paid-status {
|
||||
margin-top: 10px;
|
||||
|
||||
|
||||
663
admin/templates/articles/article-edit-custom-script.php
Normal file
663
admin/templates/articles/article-edit-custom-script.php
Normal file
@@ -0,0 +1,663 @@
|
||||
<?php
|
||||
$article = is_array($this->article ?? null) ? $this->article : [];
|
||||
$articleId = (int)($article['id'] ?? 0);
|
||||
$userId = (int)($this->user['id'] ?? 0);
|
||||
$imagesCount = is_array($article['images'] ?? null) ? count($article['images']) : 0;
|
||||
$filesCount = is_array($article['files'] ?? null) ? count($article['files']) : 0;
|
||||
|
||||
$imageMaxPx = 1920;
|
||||
if (isset($this->settings['image_px']) && (int)$this->settings['image_px'] > 0) {
|
||||
$imageMaxPx = (int)$this->settings['image_px'];
|
||||
} elseif (isset($GLOBALS['settings']['image_px']) && (int)$GLOBALS['settings']['image_px'] > 0) {
|
||||
$imageMaxPx = (int)$GLOBALS['settings']['image_px'];
|
||||
}
|
||||
|
||||
$uploadToken = bin2hex(random_bytes(24));
|
||||
if (!isset($_SESSION['upload_tokens']) || !is_array($_SESSION['upload_tokens'])) {
|
||||
$_SESSION['upload_tokens'] = [];
|
||||
}
|
||||
$_SESSION['upload_tokens'][$uploadToken] = [
|
||||
'user_id' => $userId,
|
||||
'expires' => time() + 60 * 20,
|
||||
];
|
||||
|
||||
$cookiePages = [];
|
||||
$cookieMenus = [];
|
||||
if (!empty($_COOKIE['cookie_pages'])) {
|
||||
$decoded = @unserialize($_COOKIE['cookie_pages']);
|
||||
if (is_array($decoded)) {
|
||||
$cookiePages = $decoded;
|
||||
}
|
||||
}
|
||||
if (!empty($_COOKIE['cookie_menus'])) {
|
||||
$decoded = @unserialize($_COOKIE['cookie_menus']);
|
||||
if (is_array($decoded)) {
|
||||
$cookieMenus = $decoded;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/grid/plugins/impromptu/jquery-impromptu.css" />
|
||||
|
||||
<script type="text/javascript" src="/libraries/grid/plugins/impromptu/jquery-impromptu.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/i18n/pl.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/lozad.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#fg-article-edit .layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
text-indent: 0;
|
||||
background-image: none !important;
|
||||
}
|
||||
|
||||
#fg-article-edit .layout-tree-toggle:focus,
|
||||
#fg-article-edit .layout-tree-toggle:active,
|
||||
#fg-article-edit .layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
#fg-article-edit li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
#fg-article-edit .sortable li.sort-branch > div > .layout-tree-toggle {
|
||||
display: inline-flex;
|
||||
float: none;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
#fg-article-edit .menu_sortable .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
#fg-article-edit .menu_sortable .g-checkbox {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-row {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box-container {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box {
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
var images_count = <?= (int)$imagesCount ?>;
|
||||
var files_count = <?= (int)$filesCount ?>;
|
||||
var article_id = <?= (int)$articleId ?>;
|
||||
|
||||
$(function() {
|
||||
function confirmDialog(message, onConfirm, okLabel) {
|
||||
if (typeof $.confirm === 'function') {
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie',
|
||||
content: String(message),
|
||||
type: 'red',
|
||||
boxWidth: '560px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
backgroundDismissAnimation: 'shake',
|
||||
container: 'body',
|
||||
theme: 'modern',
|
||||
columnClass: '',
|
||||
typeAnimated: true,
|
||||
lazyOpen: false,
|
||||
draggable: false,
|
||||
closeIcon: true,
|
||||
containerFluid: true,
|
||||
escapeKey: true,
|
||||
backgroundDismiss: true,
|
||||
animationBounce: 1.1,
|
||||
watchInterval: 100,
|
||||
offsetTop: 0,
|
||||
offsetBottom: 0,
|
||||
customClass: 'table-list-confirm-dialog',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
btnClass: 'btn-default'
|
||||
},
|
||||
confirm: {
|
||||
text: okLabel || 'Usun',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {
|
||||
if (typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.confirm(message) && typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
function ensureGalleryOrderInput() {
|
||||
var $form = $('#fg-article-edit');
|
||||
if (!$form.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var $input = $form.find('input[name="gallery_order"]');
|
||||
if (!$input.length) {
|
||||
$input = $('<input>', {
|
||||
type: 'hidden',
|
||||
name: 'gallery_order',
|
||||
id: 'gallery_order'
|
||||
});
|
||||
$form.append($input);
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
function ensureFilesOrderInput() {
|
||||
var $form = $('#fg-article-edit');
|
||||
if (!$form.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var $input = $form.find('input[name="files_order"]');
|
||||
if (!$input.length) {
|
||||
$input = $('<input>', {
|
||||
type: 'hidden',
|
||||
name: 'files_order',
|
||||
id: 'files_order'
|
||||
});
|
||||
$form.append($input);
|
||||
}
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
function buildGalleryOrder() {
|
||||
var order = [];
|
||||
$('#images-list li').each(function() {
|
||||
var imageId = $(this).find('a.article_image_delete').attr('image-id');
|
||||
if (imageId) {
|
||||
order.push(imageId);
|
||||
}
|
||||
});
|
||||
return order.join(';');
|
||||
}
|
||||
|
||||
function refreshGalleryOrderInput() {
|
||||
var $input = ensureGalleryOrderInput();
|
||||
if ($input) {
|
||||
$input.val(buildGalleryOrder());
|
||||
}
|
||||
}
|
||||
|
||||
function buildFilesOrder() {
|
||||
var order = [];
|
||||
$('#files-list li').each(function() {
|
||||
var fileId = $(this).find('.article_file_edit').attr('file_id');
|
||||
if (fileId) {
|
||||
order.push(fileId);
|
||||
}
|
||||
});
|
||||
return order.join(';');
|
||||
}
|
||||
|
||||
function refreshFilesOrderInput() {
|
||||
var $input = ensureFilesOrderInput();
|
||||
if ($input) {
|
||||
$input.val(buildFilesOrder());
|
||||
}
|
||||
}
|
||||
|
||||
ensureGalleryOrderInput();
|
||||
refreshGalleryOrderInput();
|
||||
ensureFilesOrderInput();
|
||||
refreshFilesOrderInput();
|
||||
|
||||
var observer = lozad();
|
||||
observer.observe();
|
||||
|
||||
var imageList = document.getElementById('images-list');
|
||||
if (imageList) {
|
||||
Sortable.create(imageList, {
|
||||
onEnd: function() {
|
||||
var order = '';
|
||||
$('#images-list li').each(function() {
|
||||
if (order !== '') {
|
||||
order += ';';
|
||||
}
|
||||
order += $(this).children('a').attr('image-id');
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/galleryOrderSave/',
|
||||
data: {
|
||||
article_id: article_id,
|
||||
order: order
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refreshGalleryOrderInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var filesList = document.getElementById('files-list');
|
||||
if (filesList) {
|
||||
Sortable.create(filesList, {
|
||||
onEnd: function() {
|
||||
var order = buildFilesOrder();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/filesOrderSave/',
|
||||
data: {
|
||||
article_id: article_id,
|
||||
order: order
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
refreshFilesOrderInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#images-uploader').pluploadQueue({
|
||||
multipart_params: {
|
||||
upload_token: '<?= htmlspecialchars($uploadToken, ENT_QUOTES, 'UTF-8') ?>',
|
||||
article_id: article_id
|
||||
},
|
||||
runtimes: 'html5,flash,html4',
|
||||
init: {
|
||||
Refresh: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled');
|
||||
$('.plupload_start').removeClass('plupload_disabled');
|
||||
},
|
||||
UploadComplete: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled');
|
||||
$('.plupload_start').removeClass('plupload_disabled');
|
||||
},
|
||||
FileUploaded: function(up, file, response) {
|
||||
var data = jQuery.parseJSON(response.response);
|
||||
|
||||
$('#images-list').append(
|
||||
'<li id="image-' + data.image_id + '">' +
|
||||
'<img class="article-image lozad" data-src="/libraries/thumb.php?img=' + data.data_link + '&w=300&h=300">' +
|
||||
'<a href="#" class="input-group-addon btn btn-danger article_image_delete" image-id="' + data.image_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'<input type="text" class="form-control image-alt" value="" image-id="' + data.image_id + '" placeholder="atrybut alt...">' +
|
||||
'</li>'
|
||||
);
|
||||
images_count++;
|
||||
observer.observe();
|
||||
refreshGalleryOrderInput();
|
||||
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#images-uploader').offset().top
|
||||
}, 1);
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-articles-images.php',
|
||||
chunk_size: '1mb',
|
||||
max_file_size: '20mb',
|
||||
unique_names: false,
|
||||
resize: {
|
||||
width: <?= (int)$imageMaxPx ?>,
|
||||
height: <?= (int)$imageMaxPx ?>,
|
||||
quality: 95
|
||||
},
|
||||
filters: [
|
||||
{ title: 'Obrazki', extensions: 'jpg,gif,png,bmp,jpeg' }
|
||||
],
|
||||
flash_swf_url: '/../libraries/plupload/plupload.flash.swf'
|
||||
});
|
||||
|
||||
$('#files-uploader').pluploadQueue({
|
||||
multipart_params: {
|
||||
upload_token: '<?= htmlspecialchars($uploadToken, ENT_QUOTES, 'UTF-8') ?>'
|
||||
},
|
||||
runtimes: 'html5,flash,html4',
|
||||
init: {
|
||||
Refresh: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled');
|
||||
$('.plupload_start').removeClass('plupload_disabled');
|
||||
},
|
||||
FileUploaded: function(up, file, response) {
|
||||
var data = jQuery.parseJSON(response.response);
|
||||
$('#files-list').append(
|
||||
'<li id="file-' + data.file_id + '">' +
|
||||
'<div class="input-group">' +
|
||||
'<input type="text" class="form-control article_file_edit" file_id="' + data.file_id + '" value="' + data.file_name + '" />' +
|
||||
'<a href="#" class="input-group-addon btn btn-info article_file_delete" file_id="' + data.file_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'</li>'
|
||||
);
|
||||
files_count++;
|
||||
refreshFilesOrderInput();
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-articles-files.php',
|
||||
chunk_size: '1mb',
|
||||
max_file_size: '50mb',
|
||||
unique_names: false,
|
||||
filters: [
|
||||
{ title: 'Wszystkie pliki', extensions: '*' }
|
||||
],
|
||||
flash_swf_url: '/../libraries/plupload/plupload.flash.swf'
|
||||
});
|
||||
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded')) {
|
||||
$li.addClass('sort-collapsed');
|
||||
}
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($.fn && typeof $.fn.iCheck === 'function') {
|
||||
$('#fg-article-edit .menu_sortable .g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
cancel: 'input,textarea,button,select,option,.icheckbox_minimal-blue,.iradio_minimal-blue,ins.iCheck-helper',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(this).parent('div').hasClass('content_menu')) {
|
||||
var menu_id = $(this).parent('div').parent('li').attr('menu');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookieMenus/',
|
||||
data: {
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var page_id = $(this).parent('div').parent('li').attr('id').replace('list_', '');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookiePages/',
|
||||
data: {
|
||||
page_id: page_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php foreach ($cookiePages as $key => $val): ?>
|
||||
<?php if ($val): ?>$('.list_<?= (int)$key ?>').children('div').children('.disclose').click();<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ($cookieMenus as $key => $val): ?>
|
||||
<?php if ($val): ?>$('.menu_<?= (int)$key ?>').children('div').children('.disclose').click();<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
$('body').on('change', '.image-alt', function() {
|
||||
var image_alt = $(this).val();
|
||||
var image_id = $(this).attr('image-id');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/imageAltChange/',
|
||||
data: {
|
||||
image_id: image_id,
|
||||
image_alt: image_alt
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('change', '.article_file_edit', function() {
|
||||
var file_name = $(this).val();
|
||||
var file_id = $(this).attr('file_id');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/fileNameChange/',
|
||||
data: {
|
||||
file_id: file_id,
|
||||
file_name: file_name
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('body').on('click', '.article_file_delete', function() {
|
||||
$(this).blur();
|
||||
var file_id = $(this).attr('file_id');
|
||||
|
||||
confirmDialog('Na pewno chcesz usunac wybrany plik?', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/fileDelete/',
|
||||
data: {
|
||||
file_id: file_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#file-' + file_id).children('input').addClass('disabled');
|
||||
$('#file-' + file_id).children('a').addClass('disabled');
|
||||
},
|
||||
success: function(data) {
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#file-' + file_id).remove();
|
||||
refreshFilesOrderInput();
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 'Usun');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('body').on('click', '.article_image_delete', function() {
|
||||
$(this).blur();
|
||||
var image_id = $(this).attr('image-id');
|
||||
|
||||
confirmDialog('Na pewno chcesz usunac wybrane zdjecie?', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/imageDelete/',
|
||||
data: {
|
||||
image_id: image_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#image-' + image_id).remove();
|
||||
refreshGalleryOrderInput();
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}, 'Usun');
|
||||
return false;
|
||||
});
|
||||
|
||||
$('body').on('click', '#g-edit-save, #g-edit-save-close', function() {
|
||||
refreshGalleryOrderInput();
|
||||
refreshFilesOrderInput();
|
||||
});
|
||||
});
|
||||
|
||||
function generate_seo_links(lang, title, article_id) {
|
||||
if (title === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/generateSeoLink/',
|
||||
data: {
|
||||
title: title,
|
||||
article_id: article_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#seo_link_' + lang).parents('.g-form-data').find('input, a').each(function() {
|
||||
$(this).prop('disabled', true).addClass('disabled');
|
||||
});
|
||||
},
|
||||
success: function(data) {
|
||||
$('#seo_link_' + lang).parents('.g-form-data').find('input, a').each(function() {
|
||||
$(this).prop('disabled', false).removeClass('disabled');
|
||||
});
|
||||
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#seo_link_' + lang).val(response.seo_link);
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,804 +1,6 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
$upload_token = bin2hex( random_bytes(24) );
|
||||
$_SESSION['upload_tokens'][$upload_token] = [
|
||||
'user_id' => $this -> user['id'],
|
||||
'expires' => time() + 60*20
|
||||
];
|
||||
|
||||
$_SESSION['rfm_akey'] = bin2hex(random_bytes(16));
|
||||
$_SESSION['rfm_akey_expires'] = time() + 20*60;
|
||||
$_SESSION['can_use_rfm'] = true;
|
||||
$rfmAkeyJS = $_SESSION['rfm_akey'];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
<li><i class="fa fa-globe"></i>SEO</li>
|
||||
<li><i class="fa fa-share-alt"></i>Wyświetlanie</li>
|
||||
<li><i class="fa fa-file-image-o"></i>Galeria</li>
|
||||
<li><i class="fa fa-file-archive-o"></i>Załączniki</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-main">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<?
|
||||
$languages = array();
|
||||
|
||||
$languages[''] = '---- wersja językowa ----';
|
||||
if ( is_array( $this -> languages ) ) foreach ( $this -> languages as $lg_tmp )
|
||||
{
|
||||
if ( $lg_tmp['id'] != $lg['id'] )
|
||||
$languages[ $lg_tmp['id'] ] = $lg_tmp['name'];
|
||||
}
|
||||
?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Wyświetlaj treść z wersji',
|
||||
'name' => 'copy_from[' . $lg['id'] . ']',
|
||||
'values' => $languages,
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['copy_from'],
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Tytuł',
|
||||
'name' => 'title[' . $lg['id'] . ']',
|
||||
'id' => 'title_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['title'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_icon( [
|
||||
'label' => 'Zdjęcie tytułowe',
|
||||
'name' => 'main_image[' . $lg['id'] . ']',
|
||||
'id' => 'main_image_' . $lg['id'],
|
||||
'value' => htmlspecialchars( $this -> article['languages'][ $lg['id'] ]['main_image'] ),
|
||||
'icon_content' => 'przeglądaj',
|
||||
'inline' => true,
|
||||
'icon_js' => "window.open ( '/libraries/filemanager-9.14.2/dialog.php?type=1&popup=1&field_id=main_image_" . $lg['id'] . "&akey=" . $rfmAkeyJS . "', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
|
||||
] );
|
||||
?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Wstęp',
|
||||
'name' => 'entry[' . $lg['id'] . ']',
|
||||
'id' => 'entry_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['entry'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Treść',
|
||||
'name' => 'text[' . $lg['id'] . ']',
|
||||
'id' => 'text_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['text'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea( [
|
||||
'label' => 'Spis treści',
|
||||
'name' => 'table_of_contents[' . $lg['id'] . ']',
|
||||
'id' => 'table_of_contents_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['table_of_contents'],
|
||||
'inline' => true
|
||||
] );?>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
$( '#text_<?= $lg['id'];?>, #entry_<?= $lg['id'];?>, #table_of_contents_<?= $lg['id'];?>' ).ckeditor( {
|
||||
toolbar : 'MyToolbar',
|
||||
height:'250',
|
||||
filebrowserBrowseUrl: '/libraries/filemanager-9.14.2/dialog.php?type=2&editor=ckeditor&akey=<?= $rfmAkeyJS;?>',
|
||||
filebrowserImageBrowseUrl: '/libraries/filemanager-9.14.2/dialog.php?type=1&editor=ckeditor&akey=<?= $rfmAkeyJS;?>',
|
||||
filebrowserUploadUrl: '/libraries/filemanager-9.14.2/dialog.php?type=2&editor=ckeditor&upload=1&akey=<?= $rfmAkeyJS;?>',
|
||||
filebrowserImageUploadUrl: '/libraries/filemanager-9.14.2/dialog.php?type=1&editor=ckeditor&upload=1&akey=<?= $rfmAkeyJS;?>'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Opublikowany',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> article['status'] == 1 or !$this -> article['id'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Pokaż tytuł',
|
||||
'name' => 'show_title',
|
||||
'checked' => $this -> article['show_title'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Pokaż spis treści',
|
||||
'name' => 'show_table_of_contents',
|
||||
'checked' => $this -> article['show_table_of_contents'] == 1 ? true : false
|
||||
] );?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Pokaż datę dodania',
|
||||
'name' => 'show_date_add',
|
||||
'checked' => $this -> article['show_date_add'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Pokaż datę modyfikacji',
|
||||
'name' => 'show_date_modify',
|
||||
'checked' => $this -> article['show_date_modify'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Powtórz wprowadzenie',
|
||||
'name' => 'repeat_entry',
|
||||
'checked' => $this -> article['repeat_entry'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Linki do portali społecznościowych',
|
||||
'name' => 'social_icons',
|
||||
'checked' => $this -> article['social_icons'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
</div>
|
||||
<div>
|
||||
<div id="languages-seo">
|
||||
<ul class="resp-tabs-list languages-seo htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-seo">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input_icon(
|
||||
array(
|
||||
'label' => 'Link SEO',
|
||||
'name' => 'seo_link[' . $lg['id'] . ']',
|
||||
'id' => 'seo_link_' . $lg['id'],
|
||||
'value' => $this -> article['languages' ][ $lg['id'] ]['seo_link'],
|
||||
'icon_content' => 'generuj',
|
||||
'icon_js' => 'generate_seo_links( "' . $lg['id'] . '", $( "#title_' . $lg['id'] . '" ).val(), ' . (int)$this -> article['id'] . ' );'
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Meta title',
|
||||
'name' => 'meta_title[' . $lg['id'] . ']',
|
||||
'id' => 'meta_title_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['meta_title']
|
||||
]
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Meta description',
|
||||
'name' => 'meta_description[' . $lg['id'] . ']',
|
||||
'id' => 'meta_description_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['meta_description']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Meta keywords',
|
||||
'name' => 'meta_keywords[' . $lg['id'] . ']',
|
||||
'id' => 'meta_keywords_' . $lg['id'],
|
||||
'value' => $this -> article['languages'][ $lg['id'] ]['meta_keywords']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Blokuj indeksację',
|
||||
'name' => 'noindex[' . $lg['id'] . ']',
|
||||
'id' => 'noindex_' . $lg['id'],
|
||||
'checked' => $this -> article['languages'][ $lg['id'] ]['noindex'] == 1 ? 1 : 0
|
||||
]
|
||||
);?>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Blokuj bezpośredni dostęp',
|
||||
'name' => 'block_direct_access[' . $lg['id'] . ']',
|
||||
'id' => 'block_direct_access_' . $lg['id'],
|
||||
'checked' => $this -> article['languages'][ $lg['id'] ]['block_direct_access'] == 1 ? 1 : 0
|
||||
] );?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?
|
||||
$layouts[''] = '---- szablon domyślny ----';
|
||||
if ( is_array( $this -> layouts ) ): foreach ( $this -> layouts as $layout ):
|
||||
$layouts[ $layout['id'] ] = $layout['name'];
|
||||
endforeach; endif;
|
||||
?>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Szablon',
|
||||
'name' => 'layout_id',
|
||||
'id' => 'layout_id',
|
||||
'values' => $layouts,
|
||||
'value' => $this -> article['layout_id']
|
||||
)
|
||||
);?>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-4 control-label">Wyświetlaj na:</label>
|
||||
<div class="col-lg-8">
|
||||
<?
|
||||
if ( is_array( $this -> menus ) ) foreach ( $this -> menus as $menu )
|
||||
{
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu" <? if ( !$menu['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<span class="disclose"><span></span></span>
|
||||
Menu: <b><?= $menu['name'];?></b>
|
||||
</div>
|
||||
<?= \admin\view\Articles::subpages_list( \admin\factory\Pages::menu_pages( $menu['id'] ), $this -> article['pages'] );?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<ul id="images-list">
|
||||
<?
|
||||
$images_count = 0;
|
||||
if ( is_array( $this -> article['images'] ) ): foreach ( $this -> article['images'] as $img ):
|
||||
?>
|
||||
<li id="image-<?= $img['id'];?>">
|
||||
<img class="article-image lozad" data-src="/libraries/thumb.php?img=<?= $img['src'];?>&w=300&h=300">
|
||||
<a href="#" class="input-group-addon btn btn-danger article_image_delete" image-id="<?= $img['id'];?>">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
<input type="text" class="form-control image-alt" value="<?= $img['alt'];?>" image-id="<?= $img['id'];?>" placeholder="atrybut alt...">
|
||||
</li>
|
||||
<?
|
||||
$images_count++;
|
||||
endforeach; endif;
|
||||
?>
|
||||
</ul>
|
||||
<div id="images-uploader">You browser doesn't have Flash installed.</div>
|
||||
</div>
|
||||
<div>
|
||||
<ul id="files-list">
|
||||
<?
|
||||
$files_count = 0;
|
||||
if ( is_array( $this -> article['files'] ) ): foreach ( $this -> article['files'] as $file ):
|
||||
|
||||
if ( $file['name'] )
|
||||
$name = $file['name'];
|
||||
else
|
||||
{
|
||||
$name = explode( '/', $file['src'] );
|
||||
$name = $name[ count( $name ) - 1 ];
|
||||
}
|
||||
?>
|
||||
<li id="file-<?= $file['id'];?>">
|
||||
<div class="input-group">
|
||||
<input type="text" class="article_file_edit form-control" file_id="<?= $file['id'];?>" value="<?= $name;?>" />
|
||||
<a href="#" class="input-group-addon btn btn-info article_file_delete" file_id="<?= $file['id'];?>">
|
||||
<i class="fa fa-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
</li>
|
||||
<?
|
||||
$files_count++;
|
||||
endforeach; endif;
|
||||
?>
|
||||
</ul>
|
||||
<div id="files-uploader">You browser doesn't have Flash installed.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'article-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja artykułu';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> article['id']
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/articles/article_save/', 'back_url' => '/admin/articles/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/articles/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" />
|
||||
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.flash.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/i18n/pl.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/lozad.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var images_count = <?= $images_count;?>;
|
||||
var files_count = <?= $files_count;?>;
|
||||
|
||||
$( function()
|
||||
{
|
||||
const observer = lozad();
|
||||
observer.observe();
|
||||
|
||||
disable_menu();
|
||||
|
||||
var el = document.getElementById( 'images-list' );
|
||||
var sortable = Sortable.create(el, {
|
||||
onEnd: function ( evt ) {
|
||||
var order = '';
|
||||
$( '#images-list li' ).each( function()
|
||||
{
|
||||
if ( order !== '' )
|
||||
order += ';';
|
||||
order += $( this ).children( 'a' ).attr( 'image-id' );
|
||||
});
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/articles/gallery_order_save/',
|
||||
data:
|
||||
{
|
||||
article_id: '<?= $this -> article['id'];?>',
|
||||
order: order
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status !== 'ok' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$( "#images-uploader" ).pluploadQueue(
|
||||
{
|
||||
multipart_params: {
|
||||
upload_token: '<?= $upload_token ?>',
|
||||
},
|
||||
runtimes: 'html5,flash,html4',
|
||||
init:
|
||||
{
|
||||
Refresh: function(up)
|
||||
{
|
||||
$( ".plupload_buttons" ).css( "display", "inline" );
|
||||
$( ".plupload_upload_status" ).css( "display", "inline" );
|
||||
$( ".plupload_start" ).addClass( "plupload_disabled" );
|
||||
$( ".plupload_start" ).removeClass( "plupload_disabled" );
|
||||
},
|
||||
UploadComplete: function()
|
||||
{
|
||||
$( ".plupload_buttons" ).css( "display", "inline" );
|
||||
$( ".plupload_upload_status" ).css( "display", "inline" );
|
||||
$( ".plupload_start" ).addClass( "plupload_disabled" );
|
||||
$( ".plupload_start" ).removeClass( "plupload_disabled" );
|
||||
},
|
||||
FileUploaded: function( up, file, response )
|
||||
{
|
||||
data = jQuery.parseJSON( response.response );
|
||||
$( '#images-list' ).append(
|
||||
'<li id="image-' + data.image_id + '">' +
|
||||
'<img class="article-image lozad" data-src="/libraries/thumb.php?img=' + data.data_link + '&w=300&h=300">' +
|
||||
'<a href="#" class="input-group-addon btn btn-danger article_image_delete" image-id="' + data.image_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'<input type="text" class="form-control image-alt" value="" image-id="' + data.image_id + '" placeholder="atrybut alt...">' +
|
||||
'</li>'
|
||||
);
|
||||
images_count++;
|
||||
observer.observe();
|
||||
$( 'html, body' ).animate({
|
||||
scrollTop: $( "#images-uploader" ).offset().top
|
||||
}, 1 );
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-articles-images.php',
|
||||
chunk_size: '1mb',
|
||||
unique_names: false,
|
||||
resize : {
|
||||
width : <?= $this -> settings['image_px'] ? $this -> settings['image_px'] : '1920';?>,
|
||||
height : <?= $this -> settings['image_px'] ? $this -> settings['image_px'] : '1920';?>,
|
||||
quality : 95
|
||||
},
|
||||
filters: [
|
||||
{ title: "Obrazki", extensions : "jpg, gif, png, bmp, jpeg" }
|
||||
],
|
||||
flash_swf_url: '/../libraries/plupload/plupload.flash.swf'
|
||||
});
|
||||
|
||||
$( "#files-uploader" ).pluploadQueue(
|
||||
{
|
||||
multipart_params: {
|
||||
upload_token: '<?= $upload_token ?>',
|
||||
},
|
||||
runtimes: 'html5,flash,html4',
|
||||
init:
|
||||
{
|
||||
Refresh: function( up )
|
||||
{
|
||||
$( ".plupload_buttons" ).css( "display", "inline" );
|
||||
$( ".plupload_upload_status" ).css( "display", "inline" );
|
||||
$( ".plupload_start" ).addClass( "plupload_disabled" );
|
||||
$( ".plupload_start" ).removeClass( "plupload_disabled" );
|
||||
},
|
||||
FileUploaded: function( up, file, response )
|
||||
{
|
||||
data = jQuery.parseJSON( response.response );
|
||||
$( '#files-list' ).append(
|
||||
'<li id="file-' + data.file_id + '">' +
|
||||
'<div class="input-group">' +
|
||||
'<input type="text" class="form-control article_file_edit" file_id="' + data.file_id + '" value="' + data.file_name + '" />' +
|
||||
'<a href="#" class="input-group-addon btn btn-info article_file_delete" file_id="' + data.file_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'</li>'
|
||||
);
|
||||
files_count++;
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-articles-files.php',
|
||||
chunk_size: '1mb',
|
||||
unique_names: false,
|
||||
filters: [
|
||||
{ title: "Wszystkie pliki", extensions: "*" }
|
||||
],
|
||||
flash_swf_url: '/../libraries/plupload/plupload.flash.swf'
|
||||
});
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
$( '#languages-seo' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-seo'
|
||||
});
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function() {
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e) {
|
||||
if ( e.which === 1 ) {
|
||||
if ( $( this ).parent( 'div' ).hasClass( 'content_menu' ) )
|
||||
{
|
||||
var menu_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'menu' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_menus',
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var page_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_pages',
|
||||
page_id: page_id
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
|
||||
$( 'body' ).on( 'change', '.image-alt', function()
|
||||
{
|
||||
var image_alt = $( this ).val();
|
||||
var image_id = $( this ).attr( 'image-id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'article_image_alt_change',
|
||||
image_id: image_id,
|
||||
image_alt: image_alt
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status !== 'ok' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.article_file_edit', function()
|
||||
{
|
||||
var file_name = $( this ).val();
|
||||
var file_id = $( this ).attr( 'file_id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'article_file_name_change',
|
||||
file_id: file_id,
|
||||
file_name: file_name
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status !== 'ok' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.article_file_delete', function()
|
||||
{
|
||||
$( this ).blur();
|
||||
var file_id = $( this ).attr( 'file_id' );
|
||||
|
||||
$.prompt( 'Na pewno chcesz usunąć wybrany plik?', {
|
||||
title: 'Potwierdź?',
|
||||
submit: function(e,v,m,f)
|
||||
{
|
||||
if ( v === true )
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'article_file_delete',
|
||||
file_id: file_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#file-' + file_id ).children( 'input' ).addClass( 'disabled' );
|
||||
$( '#file-' + file_id ).children( 'a' ).addClass( 'disabled' );
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#file-' + file_id ).remove();
|
||||
else
|
||||
create_error( msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
'tak': true,
|
||||
'nie': false
|
||||
},
|
||||
focus: 0
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.article_image_delete', function()
|
||||
{
|
||||
$( this ).blur();
|
||||
var image_id = $( this ).attr( 'image-id' );
|
||||
|
||||
$.prompt( 'Na pewno chcesz usunąć wybrane zdjęcie?',
|
||||
{
|
||||
title: 'Potwierdź?',
|
||||
submit: function(e,v,m,f)
|
||||
{
|
||||
if ( v === true )
|
||||
{
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'article_image_delete',
|
||||
image_id: image_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#image-' + image_id ).remove();
|
||||
else
|
||||
create_error( msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
buttons: {
|
||||
'tak': true,
|
||||
'nie': false
|
||||
},
|
||||
focus: 0
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function generate_seo_links( lang, title, article_id )
|
||||
{
|
||||
if ( title === '' )
|
||||
return false;
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'generate_seo_link',
|
||||
title: title,
|
||||
article_id: article_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#seo_link_' + lang ).parents( '.g-form-data' ).find( 'input, a' ).each( function()
|
||||
{
|
||||
$( this ).prop( 'disabled', true ).addClass( 'disabled' );
|
||||
});
|
||||
},
|
||||
success: function( data ) {
|
||||
|
||||
$( '#seo_link_' + lang ).parents( '.g-form-data' ).find( 'input, a' ).each( function() {
|
||||
$( this ).prop( 'disabled', false ).removeClass( 'disabled' );
|
||||
});
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#seo_link_' + lang ).val( response.seo_link );
|
||||
else
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
<?= \Shared\Tpl\Tpl::view('articles/article-edit-custom-script', [
|
||||
'article' => $this->article,
|
||||
'user' => $this->user,
|
||||
'languages' => $this->form->languages ?? []
|
||||
]); ?>
|
||||
|
||||
@@ -1,67 +1,5 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_articles' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, date_add, date_modify, status, '
|
||||
. '( SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = pa.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS pa WHERE status = -1 '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, date_add, date_modify, status, '
|
||||
. '( SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = pa.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS pa WHERE status = -1 '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'date_add', 'type' => 'DESC' ];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Tytuł',
|
||||
'db' => 'id',
|
||||
'replace' => [ 'sql' => "SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = [id] AND title != '' ORDER BY o ASC LIMIT 1" ]
|
||||
],
|
||||
[
|
||||
'name' => 'Data dodania',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 140px;' ],
|
||||
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_add]" ) );'
|
||||
],
|
||||
[
|
||||
'name' => 'Data modyfikacji',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 140px;' ],
|
||||
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_modify]" ) );'
|
||||
],
|
||||
[
|
||||
'name' => 'Akcja',
|
||||
'th' => [ 'class' => 'g-center' ],
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 50px;' ],
|
||||
'content' => '<a href="/admin/articles_archive/article_restore/id=[id]">przywróć</a>'
|
||||
],
|
||||
[
|
||||
'name' => 'Akcja',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/articles_archive/article_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center' ],
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 50px;' ]
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -1,100 +1,5 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_articles' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, date_add, date_modify, status, '
|
||||
. '( SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = pa.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title, '
|
||||
. '( SELECT login FROM pp_users AS pu WHERE pu.id = pa.modify_by ) AS user '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS pa WHERE status != -1 '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, date_add, date_modify, status, '
|
||||
. '( SELECT title FROM pp_articles_langs AS pal, pp_langs AS pl WHERE lang_id = pl.id AND article_id = pa.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title, '
|
||||
. '( SELECT login FROM pp_users AS pu WHERE pu.id = pa.modify_by ) AS user '
|
||||
. 'FROM '
|
||||
. 'pp_articles AS pa WHERE status != -1 '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'date_add', 'type' => 'DESC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Tytuł', 'db' => 'title', 'type' => 'text' ],
|
||||
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
|
||||
[ 'name' => 'Data dodania', 'db' => 'date_add', 'type' => 'date_range' ],
|
||||
[ 'name' => 'Data modyfikacji', 'db' => 'date_modify', 'type' => 'date_range' ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Tytuł',
|
||||
'db' => 'title',
|
||||
'sort' => true,
|
||||
'php' => 'echo "<a href=\'/admin/articles/article_edit/id=[id]\'>[title]</a>"; echo "<small class=\'text-muted\'>" . \admin\factory\Articles::article_pages( [id] ) . "</small>";'
|
||||
],
|
||||
[
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Data dodania',
|
||||
'db' => 'date_add',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 220px;' ],
|
||||
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_add]" ) );'
|
||||
],
|
||||
[
|
||||
'name' => 'Data modyfikacji',
|
||||
'db' => 'date_modify',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 220px;' ],
|
||||
'php' => 'echo date( "Y-m-d H:i", strtotime( "[date_modify]" ) );'
|
||||
],
|
||||
[
|
||||
'name' => 'Modyfikowany przez',
|
||||
'db' => 'user',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 220px;' ],
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/articles/article_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/articles/article_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj artykuł',
|
||||
'url' => '/admin/articles/article_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -3,14 +3,19 @@
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="sort-nonesting list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
|
||||
<div class="content <?= $this -> step < 2 ? $tmp = 'content_page' : $tmp = 'content_page_last_level';?>" <? if ( !$page['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<span class="disclose"><span></span></span>
|
||||
<input type="checkbox" class="g-checkbox" name="pages[]" value="<?= $page['id'];?>" <? if ( is_array( $this -> article_pages ) and in_array( $page['id'], $this -> article_pages ) ):?>checked="checked"<? endif;?> /><?= $page['title'];?>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<input type="checkbox" class="g-checkbox" name="pages[]" id="article_page_<?= $page['id'];?>" value="<?= $page['id'];?>" <? if ( is_array( $this -> article_pages ) and in_array( $page['id'], $this -> article_pages ) ):?>checked="checked"<? endif;?> />
|
||||
<label for="article_page_<?= $page['id'];?>" class="mb0"><?= $page['title'];?></label>
|
||||
</div>
|
||||
<?
|
||||
if ( is_array( $page['subpages'] ) )
|
||||
echo \admin\view\Articles::subpages_list( $page['subpages'], $this -> article_pages, $page['id'], $this -> step + 1 );
|
||||
?>
|
||||
<?= \Shared\Tpl\Tpl::view( 'articles/subpages-list', [
|
||||
'pages' => $page['subpages'],
|
||||
'article_pages' => $this->article_pages,
|
||||
'parent_id' => $page['id'],
|
||||
'step' => $this->step + 1,
|
||||
] ); ?>
|
||||
</li>
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
<? endif;?>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<?
|
||||
\S::set_session( 'admin', true );
|
||||
\Shared\Helpers\Helpers::set_session( 'admin', true );
|
||||
global $db;
|
||||
|
||||
$_SESSION['rfm_akey'] = bin2hex(random_bytes(16));
|
||||
@@ -19,7 +19,7 @@ ob_start();
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa',
|
||||
'name' => 'name',
|
||||
@@ -28,7 +28,7 @@ ob_start();
|
||||
'class' => 'require'
|
||||
) );
|
||||
?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
@@ -46,7 +46,7 @@ ob_start();
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Data zakończenia',
|
||||
'name' => 'date_end',
|
||||
@@ -55,7 +55,7 @@ ob_start();
|
||||
'class' => 'date'
|
||||
) );
|
||||
?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Slajder / Strona główna',
|
||||
'name' => 'home_page',
|
||||
@@ -78,18 +78,18 @@ ob_start();
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input_icon(
|
||||
<?= \Shared\Html\Html::input_icon(
|
||||
array(
|
||||
'label' => 'Obraz',
|
||||
'name' => 'src[' . $lg['id'] . ']',
|
||||
'id' => 'src_' . $lg['id'],
|
||||
'value' => $this -> banner['languages'][ $lg['id'] ]['src'],
|
||||
'icon_content' => 'przeglądaj',
|
||||
'icon_js' => "window.open ( 'http://" . $_SERVER['SERVER_NAME'] . "/libraries/filemanager-9.14.2/dialog.php?type=1&popup=1&field_id=src_" . $lg['id'] . "&akey=" . $rfmAkeyJS . "', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
|
||||
'icon_js' => "window.open ( '/libraries/filemanager-9.14.2/dialog.php?type=1&popup=1&field_id=src_" . $lg['id'] . "&akey=" . $rfmAkeyJS . "', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Url',
|
||||
'name' => 'url[' . $lg['id'] . ']',
|
||||
@@ -98,7 +98,7 @@ ob_start();
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Kod html',
|
||||
'name' => 'html[' . $lg['id'] . ']',
|
||||
@@ -107,7 +107,7 @@ ob_start();
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Treść',
|
||||
'name' => 'text[' . $lg['id'] . ']',
|
||||
@@ -136,26 +136,14 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'banner-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja baneru';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> banner['id']
|
||||
]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/banners/banner_save/', 'back_url' => '/admin/banners/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/banners/view_list/' ]
|
||||
];
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
echo $grid -> draw();
|
||||
$gridId = 'banner-edit';
|
||||
$gridTitle = 'Edycja baneru';
|
||||
$gridSaveUrl = '/admin/banners/save/';
|
||||
$gridBackUrl = '/admin/banners/list/';
|
||||
$gridHidden = [['name' => 'id', 'value' => $this -> banner['id']]];
|
||||
$gridContent = $out;
|
||||
$gridPersist = true;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(function ()
|
||||
@@ -182,4 +170,4 @@ echo $grid -> draw();
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
|
||||
100
admin/templates/banners/banners-list-custom-script.php
Normal file
100
admin/templates/banners/banners-list-custom-script.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<style type="text/css">
|
||||
.banner-thumb-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.banner-thumb-image {
|
||||
width: 72px;
|
||||
height: 42px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.banner-thumb-popup {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: min(70vw, 760px);
|
||||
max-height: 80vh;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
|
||||
z-index: 3000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
|
||||
.banner-thumb-popup.is-visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.banner-thumb-popup img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: calc(80vh - 12px);
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.banner-thumb-popup').remove();
|
||||
var $popup = $('<div class="banner-thumb-popup" aria-hidden="true"><img src="" alt=""></div>');
|
||||
var $popupImage = $popup.find('img');
|
||||
$('body').append($popup);
|
||||
|
||||
function positionPopup(event) {
|
||||
var offset = 18;
|
||||
var viewportWidth = $(window).width();
|
||||
var viewportHeight = $(window).height();
|
||||
var popupWidth = $popup.outerWidth();
|
||||
var popupHeight = $popup.outerHeight();
|
||||
var left = (event.clientX || 0) + offset;
|
||||
var top = (event.clientY || 0) + offset;
|
||||
|
||||
if (left + popupWidth + 12 > viewportWidth) {
|
||||
left = Math.max(12, (event.clientX || 0) - popupWidth - offset);
|
||||
}
|
||||
|
||||
if (top + popupHeight + 12 > viewportHeight) {
|
||||
top = Math.max(12, viewportHeight - popupHeight - 12);
|
||||
}
|
||||
|
||||
$popup.css({ left: left + 'px', top: top + 'px' });
|
||||
}
|
||||
|
||||
$(document).off('.bannerThumbPopup');
|
||||
|
||||
$(document).on('mouseenter.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
var src = $(this).data('previewSrc');
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
$popupImage.attr('src', String(src));
|
||||
$popup.addClass('is-visible');
|
||||
positionPopup(event);
|
||||
});
|
||||
|
||||
$(document).on('mousemove.bannerThumbPopup', '.js-banner-thumb-preview', function(event) {
|
||||
if ($popup.hasClass('is-visible')) {
|
||||
positionPopup(event);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mouseleave.bannerThumbPopup', '.js-banner-thumb-preview', function() {
|
||||
$popup.removeClass('is-visible');
|
||||
$popupImage.attr('src', '');
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
@@ -1,78 +1,5 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_banners' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
|
||||
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'php' => 'echo "<a href=\'/admin/banners/banner_edit/id=[id]\'>[name]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Strona główna',
|
||||
'db' => 'home_page',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Slajder',
|
||||
'db' => 'home_page',
|
||||
'replace' => [ 'array' => [ 1 => 'nie', 0 => '<span class="text-system">tak</span>' ] ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Data rozpoczęcia',
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 140px;' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'php' => 'if ( "[date_start]" ) echo date( "Y-m-d", strtotime( "[date_start]" ) ); else echo "-";'
|
||||
],
|
||||
[
|
||||
'name' => 'Data zakończenia',
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 140px;' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'php' => 'if ( "[date_end]" ) echo date( "Y-m-d", strtotime( "[date_end]" ) ); else echo "-";'
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/banners/banner_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/banners/banner_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj baner',
|
||||
'url' => '/admin/banners/banner_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
282
admin/templates/components/form-edit.php
Normal file
282
admin/templates/components/form-edit.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
/**
|
||||
* Uniwersalny szablon formularza edycji
|
||||
*
|
||||
* @var FormEditViewModel $form
|
||||
*/
|
||||
use admin\Support\Forms\FormFieldRenderer;
|
||||
use admin\ViewModels\Forms\FormFieldType;
|
||||
|
||||
$form = $this->form;
|
||||
$renderer = new FormFieldRenderer($form);
|
||||
|
||||
// Przygotuj filemanager key
|
||||
\Shared\Helpers\Helpers::set_session('admin', true);
|
||||
if (
|
||||
empty($_SESSION['rfm_akey']) ||
|
||||
(($_SESSION['rfm_akey_expires'] ?? 0) < time())
|
||||
) {
|
||||
$_SESSION['rfm_akey'] = bin2hex(random_bytes(16));
|
||||
}
|
||||
$_SESSION['rfm_akey_expires'] = time() + 20 * 60;
|
||||
$_SESSION['can_use_rfm'] = true;
|
||||
?>
|
||||
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
|
||||
<!-- iCheck -->
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css" />
|
||||
<script type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
|
||||
<style>
|
||||
.icheckbox_minimal-blue { margin-top: 10px; }
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
<div class="col col-xs-12">
|
||||
<div class="g-container" data="table:<?= $form->formId ?>">
|
||||
<div class="panel panel-info panel-border top">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title"><?= htmlspecialchars($form->title) ?></span>
|
||||
</div>
|
||||
<div class="panel-heading p10 pl15" id="g-menu" style="height: auto;">
|
||||
<?php foreach ($form->actions as $action): ?>
|
||||
<?php if ($action->name === 'save'): ?>
|
||||
<?php if ($form->persist): ?>
|
||||
<a href="#" id="g-edit-save-close" class="btn btn-system btn-sm"
|
||||
persist_edit="0"
|
||||
back_url="<?= htmlspecialchars($action->backUrl ?? '') ?>"
|
||||
url="<?= htmlspecialchars($action->url) ?>">
|
||||
<i class="fa fa-check-circle mr5"></i>Zatwierdź i zamknij
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="#" id="g-edit-save" class="btn btn-success btn-sm"
|
||||
persist_edit="<?= $form->persist ? '1' : '0' ?>"
|
||||
back_url="<?= htmlspecialchars($action->backUrl ?? '') ?>"
|
||||
url="<?= htmlspecialchars($action->url) ?>">
|
||||
<i class="fa fa-check-circle mr5"></i>Zatwierdź
|
||||
</a>
|
||||
<?php elseif ($action->name === 'cancel'): ?>
|
||||
<a href="<?= htmlspecialchars($action->url) ?>" class="btn btn-dark btn-sm" id="g-edit-cancel">
|
||||
<i class="fa fa-reply mr5"></i>Wstecz
|
||||
</a>
|
||||
<?php elseif ($action->name === 'preview'): ?>
|
||||
<a href="<?= htmlspecialchars($action->url) ?>" class="btn btn-info btn-sm" target="_blank">
|
||||
<i class="fa fa-eye mr5"></i><?= htmlspecialchars($action->label) ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<a href="<?= htmlspecialchars($action->url) ?>" class="btn <?= htmlspecialchars($action->cssClass) ?> btn-sm">
|
||||
<?= htmlspecialchars($action->label) ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<form method="<?= $form->method ?>" id="fg-<?= $form->formId ?>" class="g-form form-horizontal"
|
||||
action="<?= htmlspecialchars($form->action) ?>" enctype="multipart/form-data">
|
||||
|
||||
<input type="hidden" name="_form_id" value="<?= htmlspecialchars($form->formId) ?>">
|
||||
|
||||
<?php foreach ($form->hiddenFields as $name => $value): ?>
|
||||
<input type="hidden" name="<?= htmlspecialchars($name) ?>" value="<?= htmlspecialchars($value ?? '') ?>">
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if ($form->hasTabs()): ?>
|
||||
<!-- Formularz z zakładkami -->
|
||||
<div id="form-tabs-<?= $form->formId ?>">
|
||||
<ul class="resp-tabs-list form-tabs">
|
||||
<?php foreach ($form->tabs as $tab): ?>
|
||||
<li><i class="fa <?= htmlspecialchars($tab->icon) ?>"></i><?= htmlspecialchars($tab->label) ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container form-tabs">
|
||||
<?php foreach ($form->tabs as $tab): ?>
|
||||
<div>
|
||||
<?php
|
||||
$tabFields = $form->getFieldsForTab($tab->id);
|
||||
$langSections = $form->getLangSectionsForTab($tab->id);
|
||||
?>
|
||||
|
||||
<?php foreach ($tabFields as $field): ?>
|
||||
<?= $renderer->renderField($field) ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php foreach ($langSections as $section): ?>
|
||||
<?= $renderer->renderLangSection($section) ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<!-- Formularz bez zakładek -->
|
||||
<?php foreach ($form->fields as $field): ?>
|
||||
<?php if ($field->type === FormFieldType::LANG_SECTION): ?>
|
||||
<?= $renderer->renderLangSection($field) ?>
|
||||
<?php else: ?>
|
||||
<?= $renderer->renderField($field) ?>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// Inicjalizacja datepickerów
|
||||
$('input.date').datetimepicker({
|
||||
format: "YYYY-MM-DD",
|
||||
pickTime: false
|
||||
});
|
||||
|
||||
$('input.datetime').datetimepicker({
|
||||
format: "YYYY-MM-DD HH:mm"
|
||||
});
|
||||
|
||||
// Inicjalizacja zakładek
|
||||
<?php if ($form->hasTabs()): ?>
|
||||
$('#form-tabs-<?= $form->formId ?>').easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'form-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
<?php endif; ?>
|
||||
|
||||
// Inicjalizacja iCheck
|
||||
$('.icheck').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
|
||||
function showFormMessage(type, text) {
|
||||
var safeText = $('<div/>').text(text || '').html();
|
||||
var alertClass = type === 'error' ? 'alert-danger' : 'alert-primary';
|
||||
var html = '' +
|
||||
'<div class="row js-form-message">' +
|
||||
'<div class="col col-xs-12">' +
|
||||
'<div class="alert ' + alertClass + ' alert-dismissable">' +
|
||||
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>' +
|
||||
'<i class="fa fa-info pr10"></i>' + safeText +
|
||||
'</div>' +
|
||||
'</div>' +
|
||||
'</div>';
|
||||
|
||||
$('#content .js-form-message').remove();
|
||||
$('#content').prepend(html);
|
||||
}
|
||||
// Obsługa przycisków zapisu
|
||||
$('#g-edit-save, #g-edit-save-close').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var $btn = $(this);
|
||||
var url = $btn.attr('url');
|
||||
var backUrl = $btn.attr('back_url');
|
||||
var persist = $btn.attr('persist_edit');
|
||||
var formId = 'fg-<?= $form->formId ?>';
|
||||
|
||||
// Synchronizuj zawartosc CKEditor do textarea przed serializacja
|
||||
if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances) {
|
||||
for (var instanceName in CKEDITOR.instances) {
|
||||
if (Object.prototype.hasOwnProperty.call(CKEDITOR.instances, instanceName)) {
|
||||
CKEDITOR.instances[instanceName].updateElement();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Zbierz dane formularza
|
||||
var formData = $('#' + formId).serialize();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
var successMessage = response.message || 'Zmiany zostały zapisane.';
|
||||
if (backUrl && persist === '0') {
|
||||
window.location.href = backUrl;
|
||||
} else {
|
||||
showFormMessage('success', successMessage);
|
||||
}
|
||||
} else {
|
||||
var errors = response.errors ? Object.values(response.errors).join(', ') : 'Błąd walidacji';
|
||||
showFormMessage('error', 'Błąd: ' + errors);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
// Fallback - tradycyjne submit formularza
|
||||
$('#' + formId).attr('action', url).submit();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
disable_menu();
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php
|
||||
// Renderowanie CKEditor dla pól edytora (zwykłych)
|
||||
foreach ($form->fields as $field):
|
||||
if ($field->type === FormFieldType::EDITOR):
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('#<?= $field->id ?>').ckeditor({
|
||||
toolbar: '<?= $field->editorToolbar ?>',
|
||||
height: '<?= $field->editorHeight ?>'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
|
||||
<?php if ($form->hasLangSections()): ?>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
// Inicjalizacja zakładek językowych
|
||||
$('[id^="languages-"].languages-tabs').each(function() {
|
||||
$(this).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-tabs',
|
||||
type: 'horizontal'
|
||||
});
|
||||
});
|
||||
|
||||
// Inicjalizacja CKEditor dla pól w sekcjach językowych
|
||||
<?php
|
||||
foreach ($form->fields as $section):
|
||||
if ($section->type === FormFieldType::LANG_SECTION && $section->langFields):
|
||||
foreach ($section->langFields as $langField):
|
||||
if ($langField->type === FormFieldType::EDITOR && $form->languages):
|
||||
foreach ($form->languages as $lang):
|
||||
if ($lang['status']):
|
||||
?>
|
||||
$('#<?= $langField->getLocalizedId($lang['id']) ?>').ckeditor({
|
||||
toolbar: '<?= $langField->editorToolbar ?>',
|
||||
height: '<?= $langField->editorHeight ?>'
|
||||
});
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
endforeach;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
|
||||
|
||||
171
admin/templates/components/grid-edit-replacement.php
Normal file
171
admin/templates/components/grid-edit-replacement.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
/**
|
||||
* Zastepnik gridEdit — generuje panel z przyciskami zapisu/anulowania i formularzem.
|
||||
*
|
||||
* Wymagane zmienne:
|
||||
* $gridId — identyfikator formularza (np. 'layout-edit')
|
||||
* $gridTitle — tytuł panelu
|
||||
* $gridSaveUrl — URL zapisu (AJAX POST)
|
||||
* $gridBackUrl — URL powrotu po zapisie / anulowaniu
|
||||
* $gridHidden — tablica ukrytych pól [['name' => ..., 'value' => ...], ...]
|
||||
* $gridContent — HTML zawartość formularza (z ob_get_clean())
|
||||
* $gridPersist — (bool) czy zostać na stronie po zapisie
|
||||
*/
|
||||
$gridPersist = !empty($gridPersist);
|
||||
?>
|
||||
<!-- iCheck -->
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css" />
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css" />
|
||||
<script type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
|
||||
<!-- impromptu -->
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/impromptu/jquery-impromptu.css" />
|
||||
<script type="text/javascript" src="/libraries/grid/plugins/impromptu/jquery-impromptu.js"></script>
|
||||
|
||||
<div class="row">
|
||||
<div class="col col-xs-12">
|
||||
<div class="g-container" data="table:<?= htmlspecialchars($gridId) ?>">
|
||||
<div class="panel panel-info panel-border top">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title"><?= htmlspecialchars($gridTitle) ?></span>
|
||||
</div>
|
||||
<?php if (!empty($gridSaveUrl)): ?>
|
||||
<div class="panel-heading p10 pl15" id="g-menu" style="height: auto;">
|
||||
<?php if ($gridPersist): ?>
|
||||
<a href="#" id="g-edit-save-close" class="btn btn-system btn-sm"
|
||||
persist_edit="0"
|
||||
back_url="<?= htmlspecialchars($gridBackUrl) ?>"
|
||||
url="<?= htmlspecialchars($gridSaveUrl) ?>">
|
||||
<i class="fa fa-check-circle mr5"></i>Zatwierdź i zamknij
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="#" id="g-edit-save" class="btn btn-success btn-sm"
|
||||
persist_edit="<?= $gridPersist ? '1' : '0' ?>"
|
||||
id_param="id"
|
||||
back_url="<?= htmlspecialchars($gridBackUrl) ?>"
|
||||
url="<?= htmlspecialchars($gridSaveUrl) ?>">
|
||||
<i class="fa fa-check-circle mr5"></i>Zatwierdź
|
||||
</a>
|
||||
<a href="<?= htmlspecialchars($gridBackUrl) ?>" class="btn btn-dark btn-sm" id="g-edit-cancel">
|
||||
<i class="fa fa-reply mr5"></i>Wstecz
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="panel-body">
|
||||
<form method="POST" id="fg-<?= htmlspecialchars($gridId) ?>" class="g-form form-horizontal" enctype="multipart/form-data">
|
||||
<?php if (!empty($gridHidden) && is_array($gridHidden)): ?>
|
||||
<?php foreach ($gridHidden as $h): ?>
|
||||
<input type="hidden" name="<?= htmlspecialchars($h['name']) ?>" id="<?= htmlspecialchars($h['name']) ?>" value="<?= htmlspecialchars($h['value'] ?? '') ?>" />
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?= $gridContent ?>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
jQuery(function() {
|
||||
jQuery('.g-checkbox, .g-radio, .icheck').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
|
||||
function showGridMessage(type, text) {
|
||||
var safeText = $('<div/>').text(text || '').html();
|
||||
var alertClass = type === 'error' ? 'alert-danger' : 'alert-primary';
|
||||
var html = '<div class="row js-form-message"><div class="col col-xs-12"><div class="alert ' + alertClass + ' alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><i class="fa fa-info pr10"></i>' + safeText + '</div></div></div>';
|
||||
$('#content .js-form-message').remove();
|
||||
$('#content').prepend(html);
|
||||
}
|
||||
|
||||
$('#g-edit-save, #g-edit-save-close').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var $btn = $(this);
|
||||
var url = $btn.attr('url');
|
||||
var backUrl = $btn.attr('back_url');
|
||||
var persist = $btn.attr('persist_edit');
|
||||
var formId = 'fg-<?= $gridId ?>';
|
||||
|
||||
if (typeof CKEDITOR !== 'undefined' && CKEDITOR.instances) {
|
||||
for (var i in CKEDITOR.instances) {
|
||||
if (CKEDITOR.instances.hasOwnProperty(i)) CKEDITOR.instances[i].updateElement();
|
||||
}
|
||||
}
|
||||
|
||||
// Serializacja kompatybilna z grid.js — JSON w parametrze 'values'
|
||||
var values = $('#' + formId).serializeArray();
|
||||
var formattedValues = {};
|
||||
|
||||
$.each(values, function(i, field) {
|
||||
var fieldName = field.name.replace(/\[\]$/, '');
|
||||
var nestedMatch = fieldName.match(/^(.+?)\[(.+?)\]$/);
|
||||
|
||||
if (nestedMatch) {
|
||||
var mainField = nestedMatch[1];
|
||||
var subField = nestedMatch[2];
|
||||
if (!formattedValues[mainField]) {
|
||||
formattedValues[mainField] = {};
|
||||
}
|
||||
formattedValues[mainField][subField] = field.value;
|
||||
} else if (field.name.indexOf('[]', field.name.length - 2) !== -1) {
|
||||
if (!formattedValues[fieldName]) {
|
||||
formattedValues[fieldName] = [];
|
||||
}
|
||||
formattedValues[fieldName].push(field.value);
|
||||
} else {
|
||||
formattedValues[fieldName] = field.value;
|
||||
}
|
||||
});
|
||||
|
||||
// Normalizacja checkboxów tablicowych (boolean-like)
|
||||
(function() {
|
||||
var $form = $('#' + formId);
|
||||
var groups = {};
|
||||
$form.find('input[type="checkbox"][name$="[]"]').each(function() {
|
||||
var n = this.name;
|
||||
(groups[n] = groups[n] || []).push(this);
|
||||
});
|
||||
$.each(groups, function(nameWithBrackets, inputs) {
|
||||
var vals = {};
|
||||
$.each(inputs, function(_, el) { vals[(el.getAttribute('value') || '').toLowerCase()] = true; });
|
||||
var boolSet = {'': true, '1': true, 'on': true, 'true': true, 'yes': true};
|
||||
var isBool = true;
|
||||
$.each(vals, function(v) { if (!boolSet[v]) isBool = false; });
|
||||
if (isBool) {
|
||||
var baseKey = nameWithBrackets.replace(/\[\]$/, '');
|
||||
formattedValues[baseKey] = $.map(inputs, function(el) { return el.checked ? '1' : '0'; });
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: 'POST',
|
||||
data: {
|
||||
gtable: formId.replace('fg-', ''),
|
||||
values: JSON.stringify(formattedValues),
|
||||
a: 'gsave'
|
||||
},
|
||||
dataType: 'json',
|
||||
success: function(r) {
|
||||
if (r.status === 'ok' || r.success) {
|
||||
if (backUrl && persist === '0') {
|
||||
window.location.href = backUrl;
|
||||
} else {
|
||||
showGridMessage('success', r.msg || r.message || 'Zmiany zostały zapisane.');
|
||||
if (r.id) {
|
||||
$('#fg-' + formId.replace('fg-','') + ' input[name="id"]').val(r.id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
showGridMessage('error', r.msg || r.message || 'Wystąpił błąd.');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
showGridMessage('error', 'Wystąpił błąd połączenia.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
600
admin/templates/components/table-list.php
Normal file
600
admin/templates/components/table-list.php
Normal file
@@ -0,0 +1,600 @@
|
||||
<?php
|
||||
$list = $this->list;
|
||||
|
||||
$buildUrl = function(array $params = []) use ($list): string {
|
||||
$query = array_merge($list->query, $params);
|
||||
foreach ($query as $key => $value) {
|
||||
if ($value === '' || $value === null) {
|
||||
unset($query[$key]);
|
||||
}
|
||||
}
|
||||
$qs = http_build_query($query);
|
||||
return $list->basePath . $qs;
|
||||
};
|
||||
|
||||
$currentSort = $list->sort['column'] ?? '';
|
||||
$currentDir = strtoupper($list->sort['dir'] ?? 'DESC');
|
||||
$page = max(1, (int)($list->pagination['page'] ?? 1));
|
||||
$totalPages = max(1, (int)($list->pagination['total_pages'] ?? 1));
|
||||
$total = (int)($list->pagination['total'] ?? 0);
|
||||
$perPage = (int)($list->pagination['per_page'] ?? 15);
|
||||
|
||||
$hasActiveFilters = false;
|
||||
foreach ($list->filters as $filter) {
|
||||
if (isset($filter['value']) && (string)$filter['value'] !== '') {
|
||||
$hasActiveFilters = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$isCompactColumn = function(array $column): bool {
|
||||
$key = strtolower(trim((string)($column['key'] ?? '')));
|
||||
$label = strtolower(trim((string)($column['label'] ?? '')));
|
||||
|
||||
if (in_array($key, ['status', 'active', 'enabled', 'is_active', 'start', 'default'], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (in_array($label, ['status', 'aktywny', 'aktywnosc', 'active', 'domyslny', 'domyślny', 'default'], true)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
?>
|
||||
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
<?php if (!empty($list->createUrl) && !empty($list->createLabel)): ?>
|
||||
<a href="<?= htmlspecialchars($list->createUrl, ENT_QUOTES, 'UTF-8'); ?>" class="btn btn-success btn-sm">
|
||||
<i class="fa fa-plus-circle mr5"></i><?= htmlspecialchars($list->createLabel, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="col-sm-4 text-right">
|
||||
<div class="table-list-header-actions">
|
||||
<span class="text-muted">Wyników: <?= $total; ?></span>
|
||||
<?php if (!empty($list->filters)): ?>
|
||||
<button type="button" class="btn btn-default btn-sm js-filter-toggle-btn<?= $hasActiveFilters ? ' active' : ''; ?>" title="Filtry">
|
||||
<i class="fa fa-filter"></i>
|
||||
<?php if ($hasActiveFilters): ?>
|
||||
<span class="badge badge-primary table-filter-badge"><?= count(array_filter($list->filters, function($f) { return isset($f['value']) && (string)$f['value'] !== ''; })); ?></span>
|
||||
<?php endif; ?>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<div class="table-col-toggle-wrapper">
|
||||
<button type="button" class="btn btn-default btn-sm js-col-toggle-btn" title="Widoczność kolumn">
|
||||
<i class="fa fa-columns"></i>
|
||||
</button>
|
||||
<div class="table-col-toggle-dropdown js-col-toggle-dropdown">
|
||||
<div class="table-col-toggle-header">Widoczność kolumn</div>
|
||||
<?php foreach ($list->columns as $colIndex => $column): ?>
|
||||
<?php $colKey = (string)($column['key'] ?? 'col_' . $colIndex); ?>
|
||||
<label class="table-col-toggle-item">
|
||||
<span class="table-col-switch">
|
||||
<input type="checkbox" class="js-col-toggle-checkbox" data-col-key="<?= htmlspecialchars($colKey, ENT_QUOTES, 'UTF-8'); ?>" checked />
|
||||
<span class="table-col-switch-slider"></span>
|
||||
</span>
|
||||
<?= htmlspecialchars((string)($column['label'] ?? $colKey), ENT_QUOTES, 'UTF-8'); ?>
|
||||
</label>
|
||||
<?php endforeach; ?>
|
||||
<div class="table-col-toggle-footer">
|
||||
<button type="button" class="btn btn-default btn-xs js-col-toggle-reset">Pokaż wszystkie</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
<div class="js-table-filters-wrapper table-filters-wrapper<?= $hasActiveFilters ? ' open' : ''; ?>">
|
||||
<form method="get" action="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" data-path-submit="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" class="row mb15 js-table-filters-form">
|
||||
<?php foreach ($list->filters as $filter): ?>
|
||||
<?php
|
||||
$filterKey = (string)($filter['key'] ?? '');
|
||||
$inputId = 'filter_' . preg_replace('/[^a-zA-Z0-9_]+/', '_', $filterKey);
|
||||
$filterType = (string)($filter['type'] ?? '');
|
||||
$isCompactFilter = false;
|
||||
if ($filterType === 'select') {
|
||||
$options = (array)($filter['options'] ?? []);
|
||||
$maxOptionLen = 0;
|
||||
foreach ($options as $optionLabel) {
|
||||
$len = strlen(trim((string)$optionLabel));
|
||||
if ($len > $maxOptionLen) {
|
||||
$maxOptionLen = $len;
|
||||
}
|
||||
}
|
||||
|
||||
// Krotkie selekty (np. tak/nie) nie musza zajmowac szerokiej kolumny.
|
||||
$isCompactFilter = count($options) <= 5 && $maxOptionLen <= 12;
|
||||
}
|
||||
$filterColClass = $isCompactFilter ? 'col-sm-1 col-xs-6 mb10' : 'col-sm-2 mb10';
|
||||
?>
|
||||
<div class="<?= htmlspecialchars($filterColClass, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<label for="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>" class="control-label">
|
||||
<?= htmlspecialchars((string)($filter['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
|
||||
</label>
|
||||
|
||||
<?php if ($filterType === 'select'): ?>
|
||||
<select
|
||||
id="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
name="<?= htmlspecialchars($filter['key'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
class="form-control input-sm<?= $isCompactFilter ? ' js-filter-compact-select' : ''; ?>"
|
||||
<?= $isCompactFilter ? 'data-compact-filter="1"' : ''; ?>
|
||||
title="<?= htmlspecialchars($filter['label'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
>
|
||||
<?php foreach (($filter['options'] ?? []) as $value => $label): ?>
|
||||
<option value="<?= htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); ?>"<?= ((string)($filter['value'] ?? '') === (string)$value) ? ' selected="selected"' : ''; ?>>
|
||||
<?= htmlspecialchars((string)$label, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<?php elseif (($filter['type'] ?? '') === 'date'): ?>
|
||||
<input
|
||||
type="date"
|
||||
id="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
name="<?= htmlspecialchars($filter['key'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= htmlspecialchars((string)($filter['value'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>"
|
||||
class="form-control input-sm"
|
||||
title="<?= htmlspecialchars($filter['label'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
/>
|
||||
<?php else: ?>
|
||||
<input
|
||||
type="text"
|
||||
id="<?= htmlspecialchars($inputId, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
name="<?= htmlspecialchars($filter['key'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= htmlspecialchars((string)($filter['value'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>"
|
||||
class="form-control input-sm"
|
||||
placeholder="<?= htmlspecialchars($filter['label'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
title="<?= htmlspecialchars($filter['label'], ENT_QUOTES, 'UTF-8'); ?>"
|
||||
/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<input type="hidden" name="sort" value="<?= htmlspecialchars((string)$currentSort, ENT_QUOTES, 'UTF-8'); ?>" />
|
||||
<input type="hidden" name="dir" value="<?= htmlspecialchars((string)$currentDir, ENT_QUOTES, 'UTF-8'); ?>" />
|
||||
<input type="hidden" name="per_page" value="<?= $perPage; ?>" />
|
||||
|
||||
<div class="col-sm-12">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Szukaj</button>
|
||||
<a href="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" class="btn btn-default btn-sm js-table-filters-clear">Wyczyść</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-striped table-bordered mbn table-list-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php foreach ($list->columns as $colIndex => $column): ?>
|
||||
<?php
|
||||
$colKey = (string)($column['key'] ?? 'col_' . $colIndex);
|
||||
$sortKey = (string)($column['sort_key'] ?? ($column['key'] ?? ''));
|
||||
$isAllowedSortKey = empty($list->sortableColumns) || in_array($sortKey, $list->sortableColumns, true);
|
||||
$isSortable = !empty($column['sortable']) && $sortKey !== '' && $isAllowedSortKey;
|
||||
$isCurrent = $isSortable && $currentSort === $sortKey;
|
||||
$nextDir = ($isCurrent && $currentDir === 'ASC') ? 'DESC' : 'ASC';
|
||||
$sortUrl = $buildUrl([
|
||||
'sort' => $sortKey,
|
||||
'dir' => $nextDir,
|
||||
'page' => 1,
|
||||
]);
|
||||
$headerClass = trim((string)($column['class'] ?? ''));
|
||||
if ($isCompactColumn($column)) {
|
||||
$headerClass = trim($headerClass . ' table-col-compact');
|
||||
}
|
||||
?>
|
||||
<th class="<?= htmlspecialchars($headerClass, ENT_QUOTES, 'UTF-8'); ?>" data-col-key="<?= htmlspecialchars($colKey, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php if ($isSortable): ?>
|
||||
<a href="<?= htmlspecialchars($sortUrl, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?= htmlspecialchars((string)($column['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php if ($isCurrent): ?>
|
||||
<span aria-hidden="true"><?= $currentDir === 'ASC' ? '↑' : '↓'; ?></span>
|
||||
<?php else: ?>
|
||||
<span class="text-muted" aria-hidden="true">↕</span>
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars((string)($column['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php endforeach; ?>
|
||||
<th class="text-center" style="width: 160px;">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php if (is_array($list->rows) && !empty($list->rows)): ?>
|
||||
<?php foreach ($list->rows as $row): ?>
|
||||
<tr>
|
||||
<?php foreach ($list->columns as $colIndex => $column): ?>
|
||||
<?php
|
||||
$key = $column['key'] ?? '';
|
||||
$colKey = (string)($column['key'] ?? 'col_' . $colIndex);
|
||||
$raw = !empty($column['raw']);
|
||||
$value = $row[$key] ?? '';
|
||||
$cellClass = trim((string)($column['class'] ?? ''));
|
||||
if ($isCompactColumn($column)) {
|
||||
$cellClass = trim($cellClass . ' table-col-compact');
|
||||
}
|
||||
?>
|
||||
<td class="<?= htmlspecialchars($cellClass, ENT_QUOTES, 'UTF-8'); ?>" data-col-key="<?= htmlspecialchars($colKey, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<?php if ($raw): ?>
|
||||
<?= (string)$value; ?>
|
||||
<?php else: ?>
|
||||
<?= htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endforeach; ?>
|
||||
<td class="text-center">
|
||||
<?php foreach (($row['_actions'] ?? []) as $action): ?>
|
||||
<?php
|
||||
$confirmMessage = (string)($action['confirm'] ?? '');
|
||||
$needsConfirm = $confirmMessage !== '';
|
||||
$actionClass = (string)($action['class'] ?? 'btn btn-default btn-xs');
|
||||
if ($needsConfirm) {
|
||||
$actionClass .= ' js-table-action-confirm';
|
||||
}
|
||||
?>
|
||||
<a
|
||||
href="<?= htmlspecialchars((string)($action['url'] ?? '#'), ENT_QUOTES, 'UTF-8'); ?>"
|
||||
class="<?= htmlspecialchars($actionClass, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php if ($needsConfirm): ?>
|
||||
data-confirm-title="Potwierdzenie"
|
||||
data-confirm-message="<?= htmlspecialchars($confirmMessage, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
data-confirm-ok="<?= htmlspecialchars((string)($action['confirm_ok'] ?? 'Usun'), ENT_QUOTES, 'UTF-8'); ?>"
|
||||
data-confirm-cancel="<?= htmlspecialchars((string)($action['confirm_cancel'] ?? 'Anuluj'), ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?php endif; ?>
|
||||
>
|
||||
<?= htmlspecialchars((string)($action['label'] ?? ''), ENT_QUOTES, 'UTF-8'); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
<?php else: ?>
|
||||
<tr>
|
||||
<td colspan="<?= count($list->columns) + 1; ?>">
|
||||
<div class="alert alert-danger mbn"><?= htmlspecialchars((string)$list->emptyMessage, ENT_QUOTES, 'UTF-8'); ?></div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="row mt15">
|
||||
<div class="col-sm-6">
|
||||
<ul class="pagination">
|
||||
<?php $prevPage = max(1, $page - 1); ?>
|
||||
<?php $nextPage = min($totalPages, $page + 1); ?>
|
||||
<li class="<?= $page <= 1 ? 'disabled' : ''; ?>">
|
||||
<a href="<?= htmlspecialchars($buildUrl(['page' => 1]), ENT_QUOTES, 'UTF-8'); ?>"><i class="fa fa-fast-backward"></i></a>
|
||||
</li>
|
||||
<li class="<?= $page <= 1 ? 'disabled' : ''; ?>">
|
||||
<a href="<?= htmlspecialchars($buildUrl(['page' => $prevPage]), ENT_QUOTES, 'UTF-8'); ?>"><i class="fa fa-backward"></i></a>
|
||||
</li>
|
||||
<?php for ($i = max(1, $page - 3); $i <= min($totalPages, $page + 3); $i++): ?>
|
||||
<li class="<?= $i === $page ? 'active' : ''; ?>">
|
||||
<a href="<?= htmlspecialchars($buildUrl(['page' => $i]), ENT_QUOTES, 'UTF-8'); ?>"><?= $i; ?></a>
|
||||
</li>
|
||||
<?php endfor; ?>
|
||||
<li class="<?= $page >= $totalPages ? 'disabled' : ''; ?>">
|
||||
<a href="<?= htmlspecialchars($buildUrl(['page' => $nextPage]), ENT_QUOTES, 'UTF-8'); ?>"><i class="fa fa-forward"></i></a>
|
||||
</li>
|
||||
<li class="<?= $page >= $totalPages ? 'disabled' : ''; ?>">
|
||||
<a href="<?= htmlspecialchars($buildUrl(['page' => $totalPages]), ENT_QUOTES, 'UTF-8'); ?>"><i class="fa fa-fast-forward"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-sm-6 text-right">
|
||||
<form method="get" action="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" data-path-submit="<?= htmlspecialchars($list->basePath, ENT_QUOTES, 'UTF-8'); ?>" class="form-inline table-list-per-page-form">
|
||||
<?php foreach ($list->query as $key => $value): ?>
|
||||
<?php if ($key !== 'per_page' && $key !== 'page'): ?>
|
||||
<input type="hidden" name="<?= htmlspecialchars((string)$key, ENT_QUOTES, 'UTF-8'); ?>" value="<?= htmlspecialchars((string)$value, ENT_QUOTES, 'UTF-8'); ?>" />
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<input type="hidden" name="page" value="1" />
|
||||
Wyświetlaj
|
||||
<select name="per_page" class="form-control input-sm js-per-page-select">
|
||||
<?php foreach ($list->perPageOptions as $opt): ?>
|
||||
<option value="<?= (int)$opt; ?>"<?= ((int)$opt === $perPage) ? ' selected="selected"' : ''; ?>><?= (int)$opt; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
rekordów
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Table state persistence — redirect ASAP to saved view
|
||||
(function() {
|
||||
var basePath = <?= json_encode($list->basePath); ?>;
|
||||
var stateKey = 'tableListQuery_' + basePath;
|
||||
var clearKey = 'tableListCleared_' + basePath;
|
||||
|
||||
var pathname = window.location.pathname.replace(/\/+$/, '/');
|
||||
var bp = basePath.replace(/\/+$/, '/');
|
||||
|
||||
var queryPart = '';
|
||||
if (pathname.length > bp.length && pathname.indexOf(bp) === 0) {
|
||||
queryPart = pathname.substring(bp.length);
|
||||
}
|
||||
if (!queryPart && window.location.search) {
|
||||
queryPart = window.location.search.substring(1);
|
||||
}
|
||||
|
||||
try {
|
||||
var justCleared = sessionStorage.getItem(clearKey) === '1';
|
||||
sessionStorage.removeItem(clearKey);
|
||||
|
||||
if (queryPart) {
|
||||
localStorage.setItem(stateKey, queryPart);
|
||||
} else if (!justCleared) {
|
||||
var saved = localStorage.getItem(stateKey);
|
||||
if (saved) {
|
||||
window.location.replace(basePath + saved);
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).off('click.tableListConfirm', '.js-table-action-confirm');
|
||||
$(document).on('click.tableListConfirm', '.js-table-action-confirm', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var $link = $(this);
|
||||
var href = $link.attr('href');
|
||||
var title = $link.data('confirmTitle') || 'Potwierdzenie';
|
||||
var message = $link.data('confirmMessage') || 'Czy na pewno chcesz kontynuowac?';
|
||||
var okLabel = $link.data('confirmOk') || 'Usun';
|
||||
var cancelLabel = $link.data('confirmCancel') || 'Anuluj';
|
||||
|
||||
if (!href) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (typeof $.confirm === 'function') {
|
||||
$.confirm({
|
||||
title: String(title),
|
||||
content: String(message),
|
||||
type: 'red',
|
||||
boxWidth: '560px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
backgroundDismissAnimation: 'shake',
|
||||
container: 'body',
|
||||
theme: 'modern',
|
||||
columnClass: '',
|
||||
typeAnimated: true,
|
||||
lazyOpen: false,
|
||||
draggable: false,
|
||||
closeIcon: true,
|
||||
containerFluid: true,
|
||||
escapeKey: true,
|
||||
backgroundDismiss: true,
|
||||
animationBounce: 1.1,
|
||||
watchInterval: 100,
|
||||
offsetTop: 0,
|
||||
offsetBottom: 0,
|
||||
customClass: 'table-list-confirm-dialog',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: String(cancelLabel),
|
||||
btnClass: 'btn-default'
|
||||
},
|
||||
confirm: {
|
||||
text: String(okLabel),
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {
|
||||
window.location.href = href;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
if (window.confirm(String(message))) {
|
||||
window.location.href = href;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(document).off(
|
||||
'change.tableListAutoFilter',
|
||||
'.js-table-filters-form select, .js-table-filters-form input[type="date"], .js-table-filters-form input[type="text"]'
|
||||
);
|
||||
$(document).on(
|
||||
'change.tableListAutoFilter',
|
||||
'.js-table-filters-form select, .js-table-filters-form input[type="date"], .js-table-filters-form input[type="text"]',
|
||||
function() {
|
||||
var form = $(this).closest('form');
|
||||
if (form.length) {
|
||||
form.trigger('submit');
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// --- Column visibility toggle ---
|
||||
var storageKey = 'tableListCols_' + <?= json_encode($list->basePath); ?>;
|
||||
|
||||
function getHiddenCols() {
|
||||
try {
|
||||
var data = localStorage.getItem(storageKey);
|
||||
if (data) {
|
||||
var parsed = JSON.parse(data);
|
||||
if (Array.isArray(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
return [];
|
||||
}
|
||||
|
||||
function saveHiddenCols(hiddenArr) {
|
||||
try {
|
||||
localStorage.setItem(storageKey, JSON.stringify(hiddenArr));
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
function applyColumnVisibility(hiddenCols) {
|
||||
var $table = $('.table-list-table');
|
||||
$table.find('th[data-col-key], td[data-col-key]').each(function() {
|
||||
var key = $(this).attr('data-col-key');
|
||||
if (hiddenCols.indexOf(key) !== -1) {
|
||||
$(this).addClass('table-col-hidden');
|
||||
} else {
|
||||
$(this).removeClass('table-col-hidden');
|
||||
}
|
||||
});
|
||||
|
||||
$('.js-col-toggle-checkbox').each(function() {
|
||||
var key = $(this).attr('data-col-key');
|
||||
$(this).prop('checked', hiddenCols.indexOf(key) === -1);
|
||||
});
|
||||
}
|
||||
|
||||
// Apply saved state on load
|
||||
var hiddenCols = getHiddenCols();
|
||||
if (hiddenCols.length) {
|
||||
applyColumnVisibility(hiddenCols);
|
||||
}
|
||||
|
||||
// Toggle dropdown open/close
|
||||
$(document).off('click.colToggleBtn', '.js-col-toggle-btn');
|
||||
$(document).on('click.colToggleBtn', '.js-col-toggle-btn', function(e) {
|
||||
e.stopPropagation();
|
||||
var $dropdown = $(this).siblings('.js-col-toggle-dropdown');
|
||||
$dropdown.toggleClass('open');
|
||||
});
|
||||
|
||||
// Prevent closing when clicking inside dropdown
|
||||
$(document).off('click.colToggleDropdown', '.js-col-toggle-dropdown');
|
||||
$(document).on('click.colToggleDropdown', '.js-col-toggle-dropdown', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
// Close dropdown on outside click
|
||||
$(document).off('click.colToggleClose');
|
||||
$(document).on('click.colToggleClose', function() {
|
||||
$('.js-col-toggle-dropdown').removeClass('open');
|
||||
});
|
||||
|
||||
// Checkbox change — toggle column
|
||||
$(document).off('change.colToggle', '.js-col-toggle-checkbox');
|
||||
$(document).on('change.colToggle', '.js-col-toggle-checkbox', function() {
|
||||
var key = $(this).attr('data-col-key');
|
||||
var isChecked = $(this).is(':checked');
|
||||
var current = getHiddenCols();
|
||||
|
||||
if (isChecked) {
|
||||
current = $.grep(current, function(v) { return v !== key; });
|
||||
} else {
|
||||
if (current.indexOf(key) === -1) {
|
||||
current.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
saveHiddenCols(current);
|
||||
applyColumnVisibility(current);
|
||||
});
|
||||
|
||||
// Reset — show all columns
|
||||
$(document).off('click.colToggleReset', '.js-col-toggle-reset');
|
||||
$(document).on('click.colToggleReset', '.js-col-toggle-reset', function() {
|
||||
saveHiddenCols([]);
|
||||
applyColumnVisibility([]);
|
||||
});
|
||||
|
||||
// --- Filter toggle ---
|
||||
var filterStorageKey = 'tableListFilters_' + <?= json_encode($list->basePath); ?>;
|
||||
|
||||
function isFilterVisible() {
|
||||
try {
|
||||
return localStorage.getItem(filterStorageKey) === '1';
|
||||
} catch (e) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
function saveFilterState(visible) {
|
||||
try {
|
||||
localStorage.setItem(filterStorageKey, visible ? '1' : '0');
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
var $filterWrapper = $('.js-table-filters-wrapper');
|
||||
var $filterBtn = $('.js-filter-toggle-btn');
|
||||
var hasActiveFilters = $filterWrapper.hasClass('open');
|
||||
|
||||
if (!hasActiveFilters && isFilterVisible()) {
|
||||
$filterWrapper.addClass('open');
|
||||
$filterBtn.addClass('active');
|
||||
}
|
||||
|
||||
$(document).off('click.filterToggle', '.js-filter-toggle-btn');
|
||||
$(document).on('click.filterToggle', '.js-filter-toggle-btn', function() {
|
||||
var $wrapper = $('.js-table-filters-wrapper');
|
||||
var $btn = $(this);
|
||||
var isOpen = $wrapper.hasClass('open');
|
||||
|
||||
if (isOpen) {
|
||||
$wrapper.removeClass('open');
|
||||
$btn.removeClass('active');
|
||||
saveFilterState(false);
|
||||
} else {
|
||||
$wrapper.addClass('open');
|
||||
$btn.addClass('active');
|
||||
saveFilterState(true);
|
||||
}
|
||||
});
|
||||
|
||||
// --- Path-based form submission (admin URL routing) ---
|
||||
$(document).off('submit.tablePathSubmit', 'form[data-path-submit]');
|
||||
$(document).on('submit.tablePathSubmit', 'form[data-path-submit]', function(e) {
|
||||
e.preventDefault();
|
||||
var basePath = $(this).attr('data-path-submit');
|
||||
var data = $(this).serializeArray();
|
||||
var parts = [];
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (String(data[i].value) !== '') {
|
||||
parts.push(encodeURIComponent(data[i].name) + '=' + encodeURIComponent(data[i].value));
|
||||
}
|
||||
}
|
||||
window.location.href = basePath + (parts.length ? parts.join('&') : '');
|
||||
});
|
||||
|
||||
// Per-page select auto-submit
|
||||
$(document).off('change.tablePerPage', '.js-per-page-select');
|
||||
$(document).on('change.tablePerPage', '.js-per-page-select', function() {
|
||||
$(this).closest('form').trigger('submit');
|
||||
});
|
||||
|
||||
// --- Table state clear on "Wyczyść" ---
|
||||
var stateStorageKey = 'tableListQuery_' + <?= json_encode($list->basePath); ?>;
|
||||
var stateClearKey = 'tableListCleared_' + <?= json_encode($list->basePath); ?>;
|
||||
|
||||
$(document).off('click.tableClearState', '.js-table-filters-clear');
|
||||
$(document).on('click.tableClearState', '.js-table-filters-clear', function() {
|
||||
try {
|
||||
localStorage.removeItem(stateStorageKey);
|
||||
sessionStorage.setItem(stateClearKey, '1');
|
||||
} catch (e) {}
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
@@ -32,7 +32,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( \S::is_array_fix( $this -> last_orders ) ): foreach ( $this -> last_orders as $order ):?>
|
||||
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> last_orders ) ): foreach ( $this -> last_orders as $order ):?>
|
||||
<tr class="status-<?= $order['status'];?>">
|
||||
<td><?= date( "Y-m-d H:i", strtotime( $order['date_order'] ) );?></td>
|
||||
<td>
|
||||
@@ -122,8 +122,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( \S::is_array_fix( $this -> best_sales_products ) ): foreach ( $this -> best_sales_products as $row ):?>
|
||||
<? $product = \shop\Product::getFromCache( (int)$row['parent_product_id'], \front\factory\Languages::default_language() );?>
|
||||
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> best_sales_products ) ): foreach ( $this -> best_sales_products as $row ):?>
|
||||
<? $product = (new \Domain\Product\ProductRepository($GLOBALS['mdb']))->findCached( (int)$row['parent_product_id'], ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->defaultLanguage() );?>
|
||||
<tr>
|
||||
<td>
|
||||
<?
|
||||
@@ -132,7 +132,7 @@
|
||||
echo '<img src="'. $product['images'][0]['src'] . '">';
|
||||
?>
|
||||
</td>
|
||||
<td><?= $product -> language['name'];?></td>
|
||||
<td><?= $product['language']['name'];?></td>
|
||||
<td class="text-center"><?= $row['quantity_summary'];?></td>
|
||||
<td class="text-right"><?= number_format( $row['sales'], 2, '.', " " );?> zł</td>
|
||||
</tr>
|
||||
@@ -157,8 +157,8 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( \S::is_array_fix( $this -> most_view_products ) ): foreach ( $this -> most_view_products as $row ):?>
|
||||
<? $product = new \shop\Product( $row['id'] );?>
|
||||
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> most_view_products ) ): foreach ( $this -> most_view_products as $row ):?>
|
||||
<? $product = ( new \Domain\Product\ProductRepository( $GLOBALS['mdb'] ) )->findCached( $row['id'] );?>
|
||||
<tr>
|
||||
<td>
|
||||
<?
|
||||
|
||||
@@ -1,91 +1 @@
|
||||
|
||||
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-main">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Tekst',
|
||||
'name' => 'text[' . $lg['id'] . ']',
|
||||
'id' => 'text_' . $lg['id'],
|
||||
'value' => $this -> unit['languages'][ $lg['id'] ]['text'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'unit-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja jednostki miary';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> unit['id']
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/dictionaries/unit_save/', 'back_url' => '/admin/dictionaries/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/dictionaries/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
@@ -1,67 +1,5 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_dictionaries_units' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id,'
|
||||
. '( SELECT text FROM pp_units_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND unit_id = ps.id AND text != \'\' ORDER BY o ASC LIMIT 1 ) AS text '
|
||||
. 'FROM '
|
||||
. 'pp_units AS ps '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id,'
|
||||
. '( SELECT text FROM pp_units_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND unit_id = ps.id AND text != \'\' ORDER BY o ASC LIMIT 1 ) AS text '
|
||||
. 'FROM '
|
||||
. 'pp_units AS ps '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'id', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Tekst', 'db' => 'text', 'type' => 'text' ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Tekst',
|
||||
'db' => 'text',
|
||||
'php' => 'echo "<a href=\'/admin/dictionaries/unit_edit/id=[id]\'>[text]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/dictionaries/unit_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/dictionaries/unit_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj jednostkę miary',
|
||||
'url' => '/admin/dictionaries/unit_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -1 +1,4 @@
|
||||
<iframe src="/libraries/filemanager-9.14.2/dialog.php?akey=c3cb2537d25c0efc9e573d059d79c3b8" style="border: 0px; width: 100%; height: 800px; background: #FFF; padding: 5px;"></iframe>
|
||||
<?php
|
||||
$filemanagerUrl = trim((string)($this->filemanager_url ?? '/libraries/filemanager-9.14.2/dialog.php'));
|
||||
?>
|
||||
<iframe src="<?= htmlspecialchars($filemanagerUrl, ENT_QUOTES, 'UTF-8'); ?>" style="border: 0px; width: 100%; height: 800px; background: #FFF; padding: 5px;"></iframe>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
$out .= 'id="' . $this -> params['id'] . '" ';
|
||||
else
|
||||
$out .= 'id="' . $this -> params['name'] . '" ';
|
||||
$out .= 'name="' . $this -> params['name'] . '" type="checkbox"';
|
||||
$out .= 'name="' . $this -> params['name'] . '" type="checkbox" value="on"';
|
||||
|
||||
if ( $this -> params['checked'] )
|
||||
$out .= 'checked="checked" ';
|
||||
@@ -24,4 +24,4 @@
|
||||
$out .= '</div>';
|
||||
$out .= '</div>';
|
||||
|
||||
echo $out;
|
||||
echo $out;
|
||||
|
||||
@@ -1,19 +1,43 @@
|
||||
<?
|
||||
$settings = is_array( $this -> settings ) ? $this -> settings : [];
|
||||
|
||||
$apilo_status = is_array( $this -> apilo_status ) ? $this -> apilo_status : [
|
||||
'is_valid' => false,
|
||||
'severity' => 'warning',
|
||||
'message' => 'Brak statusu integracji.',
|
||||
];
|
||||
|
||||
$status_class = 'alert-warning';
|
||||
if ( isset( $apilo_status['severity'] ) && $apilo_status['severity'] == 'success' ) $status_class = 'alert-success';
|
||||
if ( isset( $apilo_status['severity'] ) && $apilo_status['severity'] == 'danger' ) $status_class = 'alert-danger';
|
||||
|
||||
$status_message = trim( (string)($apilo_status['message'] ?? '') );
|
||||
if ( $status_message == '' ) $status_message = 'Brak szczegolow statusu integracji.';
|
||||
|
||||
$platform_list_raw = isset( $settings['platform-list'] ) ? $settings['platform-list'] : '';
|
||||
$platform_list = @unserialize( $platform_list_raw );
|
||||
if ( !is_array( $platform_list ) ) $platform_list = [];
|
||||
?>
|
||||
<div class="panel panel-danger">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Ustawienia apilo.com</span>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="alert <?= $status_class;?> mb15">
|
||||
<b>Status integracji Apilo:</b> <?= $status_message;?>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację z apilo.com</label>
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Wlacz synchronizacje z apilo.com</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="enabled" name="enabled">
|
||||
<option value="">--- wybierz ---</option>
|
||||
<option value="0" <? if ( !$this -> settings['enabled'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( $this -> settings['enabled'] ):?>selected<? endif;?>>tak</option>
|
||||
<option value="0" <? if ( !isset($settings['enabled']) || !$settings['enabled'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( isset($settings['enabled']) && $settings['enabled'] ):?>selected<? endif;?>>tak</option>
|
||||
</select>
|
||||
<span class="input-group-addon cursor" field-id="enabled">
|
||||
<i class="fa fa-save"></i>
|
||||
@@ -22,15 +46,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację produktów</label>
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Wlacz synchronizacje produktow</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="sync_products" name="sync_products">
|
||||
<option value="">--- wybierz ---</option>
|
||||
<option value="0" <? if ( !$this -> settings['sync_products'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( $this -> settings['sync_products'] ):?>selected<? endif;?>>tak</option>
|
||||
<option value="0" <? if ( !isset($settings['sync_products']) || !$settings['sync_products'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( isset($settings['sync_products']) && $settings['sync_products'] ):?>selected<? endif;?>>tak</option>
|
||||
</select>
|
||||
<span class="input-group-addon cursor" field-id="sync_products">
|
||||
<i class="fa fa-save"></i>
|
||||
@@ -39,15 +64,16 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Włącz synchronizację zamówień</label>
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Wlacz synchronizacje zamowien</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<select class="form-control" id="sync_orders" name="sync_orders">
|
||||
<option value="">--- wybierz ---</option>
|
||||
<option value="0" <? if ( !$this -> settings['sync_orders'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( $this -> settings['sync_orders'] ):?>selected<? endif;?>>tak</option>
|
||||
<option value="0" <? if ( !isset($settings['sync_orders']) || !$settings['sync_orders'] ):?>selected<? endif;?>>nie</option>
|
||||
<option value="1" <? if ( isset($settings['sync_orders']) && $settings['sync_orders'] ):?>selected<? endif;?>>tak</option>
|
||||
</select>
|
||||
<span class="input-group-addon cursor" field-id="sync_orders">
|
||||
<i class="fa fa-save"></i>
|
||||
@@ -56,12 +82,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Data rozpoczęcia synchronizacji zamówień</label>
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Data rozpoczecia synchronizacji zamowien</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="sync_orders_date_start" name="sync_orders_date_start" placeholder="" value="<?= $this -> settings['sync_orders_date_start'];?>">
|
||||
<input class="form-control" type="text" id="sync_orders_date_start" name="sync_orders_date_start" value="<?= isset($settings['sync_orders_date_start']) ? $settings['sync_orders_date_start'] : '';?>">
|
||||
<span class="input-group-addon cursor" field-id="sync_orders_date_start">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
@@ -69,18 +96,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Platforma</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<?
|
||||
$platform_list = unserialize( $this -> settings['platform-list'] );
|
||||
?>
|
||||
<select class="form-control" id="platform-id" name="platform-id">
|
||||
<option value="">--- wybierz platformę ---</option>
|
||||
<option value="">--- wybierz platforme ---</option>
|
||||
<? foreach ( $platform_list as $platform ):?>
|
||||
<option value="<?= $platform['id'];?>" <? if ( $this -> settings['platform-id'] == $platform['id'] ):?>selected<? endif;?>><?= $platform['name'];?> <?= $platform['description'];?></option>
|
||||
<? if ( is_array($platform) && isset($platform['id']) ):?>
|
||||
<option value="<?= $platform['id'];?>" <? if ( isset($settings['platform-id']) && $settings['platform-id'] == $platform['id'] ):?>selected<? endif;?>>
|
||||
<?= isset($platform['name']) ? $platform['name'] : '';?> <?= isset($platform['description']) ? $platform['description'] : '';?>
|
||||
</option>
|
||||
<? endif;?>
|
||||
<? endforeach;?>
|
||||
</select>
|
||||
<span class="input-group-addon cursor" field-id="platform-id">
|
||||
@@ -90,12 +119,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Client ID</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="client-id" name="client-id" placeholder="" value="<?= $this -> settings['client-id'];?>">
|
||||
<input class="form-control" type="text" id="client-id" name="client-id" value="<?= isset($settings['client-id']) ? $settings['client-id'] : '';?>">
|
||||
<span class="input-group-addon cursor" field-id="client-id">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
@@ -103,12 +133,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Client Secret</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="client-secret" name="client-secret" placeholder="" value="<?= $this -> settings['client-secret'];?>">
|
||||
<input class="form-control" type="text" id="client-secret" name="client-secret" value="<?= isset($settings['client-secret']) ? $settings['client-secret'] : '';?>">
|
||||
<span class="input-group-addon cursor" field-id="client-secret">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
@@ -116,12 +147,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">ID cennika</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="pricelist_id" name="pricelist_id" placeholder="" value="<?= $this -> settings['pricelist_id'];?>">
|
||||
<input class="form-control" type="text" id="pricelist_id" name="pricelist_id" value="<?= isset($settings['pricelist_id']) ? $settings['pricelist_id'] : '';?>">
|
||||
<span class="input-group-addon cursor" field-id="pricelist_id">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
@@ -129,86 +161,89 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Authorization Code</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="authorization-code" name="authorization-code" placeholder="" value="<?= $this -> settings['authorization-code'];?>" <? if ( $this -> settings['access-token'] ):?>readonly<? endif;?>>
|
||||
<? if ( !$this -> settings['access-token'] ):?>
|
||||
<span class="input-group-addon cursor" field-id="authorization-code">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
<? endif;?>
|
||||
<input class="form-control" type="text" id="authorization-code" name="authorization-code" value="<?= isset($settings['authorization-code']) ? $settings['authorization-code'] : '';?>">
|
||||
<span class="input-group-addon cursor" field-id="authorization-code">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? if ( $this -> settings['access-token'] ):?>
|
||||
|
||||
<? if ( !empty($settings['access-token']) ):?>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Access Token</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="access-token" name="access-token" placeholder="" value="<?= $this -> settings['access-token'];?>" readonly>
|
||||
<input class="form-control" type="text" id="access-token" name="access-token" value="<?= $settings['access-token'];?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? if ( $this -> settings['access-token-expire-at'] ):?>
|
||||
|
||||
<? if ( !empty($settings['access-token-expire-at']) ):?>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Access Token Expire At</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="access-token-expire-at" name="access-token-expire-at" placeholder="" value="<?= $this -> settings['access-token-expire-at'];?>" readonly>
|
||||
<input class="form-control" type="text" id="access-token-expire-at" name="access-token-expire-at" value="<?= $settings['access-token-expire-at'];?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? if ( $this -> settings['refresh-token'] ):?>
|
||||
|
||||
<? if ( !empty($settings['refresh-token']) ):?>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Refresh Token</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="refresh-token" name="refresh-token" placeholder="" value="<?= $this -> settings['refresh-token'];?>" readonly>
|
||||
<input class="form-control" type="text" id="refresh-token" name="refresh-token" value="<?= $settings['refresh-token'];?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? if ( $this -> settings['refresh-token-expire-at'] ):?>
|
||||
|
||||
<? if ( !empty($settings['refresh-token-expire-at']) ):?>
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Refresh Token Expire At</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="refresh-token-expire-at" name="refresh-token-expire-at" placeholder="" value="<?= $this -> settings['refresh-token-expire-at'];?>" readonly>
|
||||
<input class="form-control" type="text" id="refresh-token-expire-at" name="refresh-token-expire-at" value="<?= $settings['refresh-token-expire-at'];?>" readonly>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<? endif;?>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<? if ( !$this -> settings['access-token'] ):?>
|
||||
<a href="#" class="btn btn-primary btn-block apilo-authorization">Autoryzuj się w apilo.com</a>
|
||||
<? else:?>
|
||||
<a href="/admin/integrations/get_payment_types_list/" class="btn btn-primary btn-block">Pobierz listę metod płatności</a>
|
||||
<a href="/admin/integrations/get_carrier_account_list/" class="btn btn-primary btn-block">Pobierz listę kont przewoźników</a>
|
||||
<a href="/admin/integrations/get_status_types_list/" class="btn btn-primary btn-block">Pobierz statusy zamówień</a>
|
||||
<a href="/admin/integrations/get_platform_list/" class="btn btn-primary btn-block">Pobierz listę platform</a>
|
||||
<? endif;?>
|
||||
<a href="#" class="btn btn-primary btn-block apilo-authorization"><? if ( !empty($apilo_status['is_valid']) ):?>Ponow autoryzacje w apilo.com<? else:?>Autoryzuj sie w apilo.com<? endif;?></a>
|
||||
<a href="/admin/integrations/get_payment_types_list/" class="btn btn-primary btn-block">Pobierz liste metod platnosci</a>
|
||||
<a href="/admin/integrations/get_carrier_account_list/" class="btn btn-primary btn-block">Pobierz liste kont przewoznikow</a>
|
||||
<a href="/admin/integrations/get_status_types_list/" class="btn btn-primary btn-block">Pobierz statusy zamowien</a>
|
||||
<a href="/admin/integrations/get_platform_list/" class="btn btn-primary btn-block">Pobierz liste platform</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$( 'body' ).on( 'click', '.apilo-authorization', function() {
|
||||
$( 'body' ).on( 'click', '.apilo-authorization', function(e) {
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
url: '/admin/integrations/apilo_authorization/',
|
||||
type: 'POST',
|
||||
@@ -216,7 +251,12 @@
|
||||
response = JSON.parse( response );
|
||||
if ( response.status == 'ok' ) {
|
||||
location.reload();
|
||||
} else {
|
||||
alert( response.msg || 'Autoryzacja nieudana.' );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('Nie udalo sie polaczyc z endpointem autoryzacji.');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -238,10 +278,10 @@
|
||||
$('#' + field_id).closest('.form-group').addClass('has-success');
|
||||
setTimeout(function() {
|
||||
$('#' + field_id).closest('.form-group').removeClass('has-success');
|
||||
}, 5000);
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
19
admin/templates/integrations/logs.php
Normal file
19
admin/templates/integrations/logs.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
<div class="mt15">
|
||||
<a href="/admin/integrations/logs_clear/" class="btn btn-danger btn-sm"
|
||||
onclick="return confirm('Na pewno chcesz usunac wszystkie logi?');">
|
||||
<i class="fa fa-trash"></i> Wyczysc wszystkie logi
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$('body').on('click', '.log-context-btn', function(e) {
|
||||
e.preventDefault();
|
||||
var id = $(this).data('id');
|
||||
$('#log-context-' + id).toggle();
|
||||
$(this).text($('#log-context-' + id).is(':visible') ? 'Ukryj' : 'Pokaz');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -91,6 +91,20 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- API key -->
|
||||
<div class="form-group">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">API key</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
<input class="form-control" type="text" id="api_key" name="api_key" placeholder="" value="<?= $this -> settings['api_key'];?>">
|
||||
<span class="input-group-addon cursor" field-id="api_key">
|
||||
<i class="fa fa-save"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
|
||||
@@ -123,4 +137,4 @@
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
@@ -1,101 +1,2 @@
|
||||
<?
|
||||
global $db;
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<?
|
||||
if ( $this -> language['id'] )
|
||||
{
|
||||
echo \Html::input(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'id',
|
||||
'value' => $this -> language['id']
|
||||
)
|
||||
);
|
||||
echo \Html::input(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'o',
|
||||
'value' => $this -> language['o']
|
||||
)
|
||||
);
|
||||
echo \Html::input(
|
||||
array(
|
||||
'label' => 'Język',
|
||||
'type' => 'text',
|
||||
'class' => 'require',
|
||||
'name' => 'name',
|
||||
'value' => $this -> language['name']
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo \Html::input(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'o',
|
||||
'value' => $this -> order + 1
|
||||
)
|
||||
);
|
||||
echo \Html::input(
|
||||
array(
|
||||
'label' => 'Język',
|
||||
'type' => 'text',
|
||||
'class' => 'require',
|
||||
'name' => 'name'
|
||||
)
|
||||
);
|
||||
echo \Html::input(
|
||||
array(
|
||||
'label' => 'ID (2 znaki)',
|
||||
'class' => 'require',
|
||||
'type' => 'text',
|
||||
'name' => 'id'
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> language['status'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Domyślny',
|
||||
'name' => 'start',
|
||||
'checked' => $this -> language['start'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'language-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja języka';
|
||||
$grid -> external_code = $out;
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/languages/language_save/', 'back_url' => '/admin/languages/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/languages/view_list/' ]
|
||||
];
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( 'input[type="text"].date' ).datetimepicker({
|
||||
format: "YYYY-MM-DD",
|
||||
pickTime: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,58 +1,2 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_langs' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'o', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Język', 'db' => 'name', 'type' => 'text' ],
|
||||
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ],
|
||||
[ 'name' => 'Domyślny', 'db' => 'start', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Domyślny',
|
||||
'db' => 'start',
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'php' => 'if ( [start] ) echo "<span class=\'text-system\'>tak</span>"; else echo "nie";'
|
||||
],
|
||||
[
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Język',
|
||||
'db' => 'name'
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/languages/language_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/languages/language_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj język',
|
||||
'url' => '/admin/languages/language_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
@@ -1,60 +1,2 @@
|
||||
<?
|
||||
global $db;
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<?
|
||||
echo \Html::input(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => 'Tekst',
|
||||
'name' => 'text',
|
||||
'class' => 'require',
|
||||
'value' => $this -> translation['text']
|
||||
)
|
||||
);
|
||||
|
||||
if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $language ):
|
||||
echo \Html::input(
|
||||
array(
|
||||
'type' => 'text',
|
||||
'label' => $language['name'],
|
||||
'name' => $language['id'],
|
||||
'value' => $this -> translation[$language['id']]
|
||||
) );
|
||||
endforeach;
|
||||
endif;
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'translation-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja tłumaczenia';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> translation['id']
|
||||
]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/languages/translation_save/', 'back_url' => '/admin/languages/translation_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/languages/translation_list/' ]
|
||||
];
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(function ()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$('input[type="text"].date').datetimepicker({
|
||||
format: "YYYY-MM-DD",
|
||||
pickTime: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,44 +1,2 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
$grid = new \grid( 'pp_langs_translations' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'text', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Tekst', 'db' => 'text', 'type' => 'text' ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Tekst',
|
||||
'db' => 'text',
|
||||
'php' => 'echo "<a href=\'/admin/languages/translation_edit/id=[id]\'>[text]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/languages/translation_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/languages/translation_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj tłumaczenie',
|
||||
'url' => '/admin/languages/translation_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
@@ -7,6 +7,48 @@
|
||||
<script type="text/javascript" src="/libraries/codemirror/mode/javascript/javascript.js"></script>
|
||||
<script type="text/javascript" src="/libraries/codemirror/mode/htmlmixed/htmlmixed.js"></script>
|
||||
<script type="text/javascript" src="/libraries/codemirror/addon/mode/multiplex.js"></script>
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
#fg-layout-edit input[type=checkbox].g-checkbox {
|
||||
-webkit-appearance: checkbox;
|
||||
appearance: auto;
|
||||
position: static;
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
background: initial;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#fg-layout-edit input[type=checkbox].g-checkbox:before {
|
||||
content: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
@@ -76,9 +118,43 @@
|
||||
}
|
||||
});
|
||||
|
||||
function refreshTreeDisclosureState()
|
||||
{
|
||||
$( 'ol.sortable li' ).each( function()
|
||||
{
|
||||
var $li = $( this );
|
||||
var hasChildren = $li.children( 'ol' ).children( 'li' ).length > 0;
|
||||
var $disclose = $li.children( 'div' ).children( '.disclose' );
|
||||
|
||||
if ( hasChildren )
|
||||
{
|
||||
$li.removeClass( 'sort-leaf' );
|
||||
if ( !$li.hasClass( 'sort-collapsed' ) && !$li.hasClass( 'sort-expanded' ) )
|
||||
$li.addClass( 'sort-collapsed' );
|
||||
$li.addClass( 'sort-branch' );
|
||||
$disclose.attr( 'aria-expanded', $li.hasClass( 'sort-expanded' ) ? 'true' : 'false' );
|
||||
$disclose.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
$li.removeClass( 'sort-branch sort-collapsed sort-expanded' ).addClass( 'sort-leaf' );
|
||||
$disclose.attr( 'aria-expanded', 'false' );
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
var $li = $( this ).closest( 'li' );
|
||||
if ( !$li.hasClass( 'sort-branch' ) )
|
||||
return;
|
||||
|
||||
$li.toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
$( this ).attr( 'aria-expanded', $li.hasClass( 'sort-expanded' ) ? 'true' : 'false' );
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e)
|
||||
@@ -92,9 +168,8 @@
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
url: '/admin/pages/cookieMenus/',
|
||||
data: {
|
||||
a: 'cookie_menus',
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
@@ -107,10 +182,9 @@
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
url: '/admin/pages/cookiePages/',
|
||||
data: {
|
||||
a: 'cookie_pages',
|
||||
page_id: page_id
|
||||
page_id: page_id.replace( 'list_', '' )
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -118,21 +192,39 @@
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
$cookiePages = [];
|
||||
$cookieMenus = [];
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
if ( !empty( $_COOKIE['cookie_pages'] ) )
|
||||
{
|
||||
$decoded = @unserialize( (string)$_COOKIE['cookie_pages'], [ 'allowed_classes' => false ] );
|
||||
if ( is_array( $decoded ) )
|
||||
$cookiePages = $decoded;
|
||||
}
|
||||
|
||||
if ( !empty( $_COOKIE['cookie_menus'] ) )
|
||||
{
|
||||
$decoded = @unserialize( (string)$_COOKIE['cookie_menus'], [ 'allowed_classes' => false ] );
|
||||
if ( is_array( $decoded ) )
|
||||
$cookieMenus = $decoded;
|
||||
}
|
||||
?>
|
||||
|
||||
var cookiePages = <?= json_encode( $cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
|
||||
var cookieMenus = <?= json_encode( $cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES );?>;
|
||||
|
||||
Object.keys( cookiePages || {} ).forEach( function( key )
|
||||
{
|
||||
if ( String( cookiePages[key] ) === '1' && /^\d+$/.test( String( key ) ) )
|
||||
$( '.list_' + key ).children( 'div' ).children( '.disclose' ).click();
|
||||
});
|
||||
|
||||
Object.keys( cookieMenus || {} ).forEach( function( key )
|
||||
{
|
||||
if ( String( cookieMenus[key] ) === '1' && /^\d+$/.test( String( key ) ) )
|
||||
$( '.menu_' + key ).children( 'div' ).children( '.disclose' ).click();
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<?
|
||||
@@ -149,7 +241,7 @@ ob_start();
|
||||
</ul>
|
||||
<div class="resp-tabs-container layout-tabs">
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa',
|
||||
'name' => 'name',
|
||||
@@ -157,16 +249,16 @@ ob_start();
|
||||
'value' => $this -> layout['name']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Szablon domyślny',
|
||||
'label' => 'Szablon domyślny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> layout['status'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Szablon domyślny (kategorie)',
|
||||
'label' => 'Szablon domyślny (kategorie)',
|
||||
'name' => 'categories_default',
|
||||
'checked' => $this -> layout['categories_default'] == 1 ? true : false
|
||||
)
|
||||
@@ -179,10 +271,16 @@ ob_start();
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu" <? if ( !$menu['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
Menu: <b><?= $menu['name'];?></b>
|
||||
</div>
|
||||
<?= \admin\view\Layouts::subpages_list( \admin\factory\Pages::menu_pages( $menu['id'] ), $this -> layout['pages'] );?>
|
||||
<?= \Shared\Tpl\Tpl::view( 'layouts/subpages-list', [
|
||||
'pages' => $menu['pages'],
|
||||
'layout_pages' => $this -> layout['pages'],
|
||||
'step' => 1
|
||||
] );?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
@@ -197,13 +295,15 @@ ob_start();
|
||||
<? if ( is_array( $this -> categories ) ): foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="category_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<input type="checkbox" class="g-checkbox" name="categories[]" value="<?= $category['id'];?>" <? if ( is_array( $this -> layout['categories'] ) and in_array( $category['id'], $this -> layout['categories'] ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
<?= \Shared\Tpl\Tpl::view( 'layouts/subcategories-list', [
|
||||
'categories' => $category['subcategories'],
|
||||
'product_categories' => $this -> layout['categories'],
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
@@ -229,25 +329,13 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'layout-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja szablonu';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> layout['id']
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/layouts/layout_save/', 'back_url' => '/admin/layouts/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/layouts/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
$gridId = 'layout-edit';
|
||||
$gridTitle = 'Edycja szablonu';
|
||||
$gridSaveUrl = '/admin/layouts/save/';
|
||||
$gridBackUrl = '/admin/layouts/list/';
|
||||
$gridHidden = [['name' => 'id', 'value' => $this->layout['id']]];
|
||||
$gridContent = $out;
|
||||
$gridPersist = true;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
@@ -1,54 +1 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( 'pp_layouts' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Nazwa', 'db' => 'name', 'type' => 'text' ],
|
||||
[ 'name' => 'Szablon domyślny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'php' => 'echo "<a href=\'/admin/layouts/layout_edit/id=[id]\'>[name]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Szablon domyślny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Szablon domyślny (kategorie)',
|
||||
'db' => 'categories_default',
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => '<span class="text-system">tak</span>' ] ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Akcja',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/layouts/layout_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center' ],
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Akcja',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/layouts/layout_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center' ],
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[ 'label' => 'Dodaj szablon', 'url' => '/admin/layouts/layout_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success' ]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
21
admin/templates/layouts/subcategories-list.php
Normal file
21
admin/templates/layouts/subcategories-list.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<? if ( is_array( $this -> categories ) ):?>
|
||||
<ol>
|
||||
<? foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="list_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<input type="checkbox" class="g-checkbox" name="categories[]" value="<?= $category['id'];?>" <? if ( is_array( $this -> product_categories ) and in_array( $category['id'], $this -> product_categories ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
</div>
|
||||
<?= \Shared\Tpl\Tpl::view( 'layouts/subcategories-list', [
|
||||
'categories' => $category['subcategories'],
|
||||
'product_categories' => $this -> product_categories,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
</li>
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
@@ -3,14 +3,20 @@
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
|
||||
<div class="content <?= $this -> step < 2 ? $tmp = 'content_page' : $tmp = 'content_page_last_level';?>" <? if ( !$page['status'] ) echo 'style="color: #cc0000;"';?>>
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<input type="checkbox" class="g-checkbox" name="pages[]" value="<?= $page['id'];?>" <? if ( is_array( $this -> layout_pages ) and in_array( $page['id'], $this -> layout_pages ) ):?>checked="checked"<? endif;?> /><?= $page['title'];?>
|
||||
</div>
|
||||
<?
|
||||
if ( is_array( $page['subpages'] ) )
|
||||
echo \admin\view\Layouts::subpages_list( $page['subpages'], $this -> layout_pages, $page['id'], $this -> step + 1 );
|
||||
echo \Shared\Tpl\Tpl::view( 'layouts/subpages-list', [
|
||||
'pages' => $page['subpages'],
|
||||
'layout_pages' => $this -> layout_pages,
|
||||
'step' => $this -> step + 1
|
||||
] );
|
||||
?>
|
||||
</li>
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
<? endif;?>
|
||||
|
||||
@@ -1,67 +1 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<?
|
||||
global $db;
|
||||
ob_start();
|
||||
?>
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa',
|
||||
'name' => 'name',
|
||||
'id' => 'name',
|
||||
'value' => $this -> email_template['name'],
|
||||
'inline' => true,
|
||||
'readonly' => $this -> email_template['is_admin'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Treść',
|
||||
'name' => 'text',
|
||||
'id' => 'text',
|
||||
'value' => $this ->email_template['text'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'email-templates-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja szablonu newslettera';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> email_template['id']
|
||||
]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> actions = [
|
||||
'save' => [
|
||||
'url' => '/admin/newsletter/template_save/',
|
||||
'back_url' => $this -> email_template['is_admin'] ? '/admin/newsletter/email_templates_admin/' : '/admin/newsletter/email_templates_user/'
|
||||
],
|
||||
'cancel' => [
|
||||
'url' => $this -> email_template['is_admin'] ? '/admin/newsletter/email_templates_admin/' : '/admin/newsletter/email_templates_user/'
|
||||
]
|
||||
];
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#text' ).ckeditor(
|
||||
{
|
||||
toolbar : 'MyTool',
|
||||
height:'350'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
@@ -1,28 +1 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( 'pp_newsletter_templates' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'name', 'type' => 'ASC' ];
|
||||
$grid -> where = [ 'is_admin' => 1 ];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'php' => 'echo "<a href=\'/admin/newsletter/email_template_edit/id=[id]\'>[name]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/newsletter/email_template_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
@@ -1,30 +1 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( 'pp_newsletter' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> order = [ 'column' => 'email', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Email', 'db' => 'email', 'type' => 'text' ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Email',
|
||||
'db' => 'email',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Potwierdzony',
|
||||
'db' => 'status',
|
||||
'sort' => true,
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ]
|
||||
]
|
||||
];
|
||||
$grid -> actions = [ 'delete' => true ];
|
||||
echo $grid -> draw();
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
@@ -1,51 +1 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
$( 'textarea' ).ckeditor(
|
||||
{
|
||||
toolbar : 'MyTool',
|
||||
height: '150'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
ob_start();
|
||||
|
||||
echo \Html::textarea(
|
||||
array(
|
||||
'label' => 'Nagłówek',
|
||||
'name' => 'newsletter_header',
|
||||
'id' => 'newsletter_header',
|
||||
'value' => $this -> settings['newsletter_header'],
|
||||
'inline' => true
|
||||
)
|
||||
);
|
||||
echo \Html::textarea(
|
||||
array(
|
||||
'label' => 'Stopka',
|
||||
'name' => 'newsletter_footer',
|
||||
'id' => 'newsletter_footer',
|
||||
'value' => $this -> settings['newsletter_footer'],
|
||||
'inline' => true
|
||||
)
|
||||
);
|
||||
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'settings-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja ustawień';
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/newsletter/settings_save/', 'back_url' => '/admin/newsletter/settings/' ],
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<style type="text/css">#g-edit-cancel { display: none; }</style>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
@@ -1,42 +1 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Zapisz menu';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> menu['id']
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'type' => 'text',
|
||||
'value' => $this -> menu['name'],
|
||||
'params' => [ 'class' => 'require' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Aktywne',
|
||||
'db' => 'status',
|
||||
'type' => 'input_switch',
|
||||
'checked' => $this -> menu['status'] ? true : false,
|
||||
'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ]
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/pages/menu_save/', 'back_url' => '/admin/pages/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/pages/view_list/' ]
|
||||
];
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function()
|
||||
{
|
||||
disable_menu();
|
||||
});
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
@@ -1,89 +1,80 @@
|
||||
<?
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$pageId = (int)($this->page_id ?? 0);
|
||||
$articles = is_array($this->articles ?? null) ? $this->articles : [];
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<ol class="sortable" id="article-list">
|
||||
<?
|
||||
if ( is_array( $this -> articles ) ) foreach ( $this -> articles as $article )
|
||||
{
|
||||
?>
|
||||
<li id="list_<?= $article['article_id'];?>">
|
||||
<div class="content <? if ( !$article['status'] ) echo 'text-danger';?>"><span class="disclose"><span></span></span> <?= $article['title'];?></div>
|
||||
</li>
|
||||
<?
|
||||
}
|
||||
<ol class="sortable" id="article-list">
|
||||
<?php foreach ($articles as $article): ?>
|
||||
<?php
|
||||
$articleId = (int)($article['article_id'] ?? 0);
|
||||
$title = (string)($article['title'] ?? '');
|
||||
$status = (int)($article['status'] ?? 0);
|
||||
?>
|
||||
</ol>
|
||||
<?
|
||||
<li id="list_<?= $articleId; ?>">
|
||||
<div class="content <?= $status === 1 ? '' : 'text-danger'; ?>"><span class="disclose"><span></span></span> <?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = $out;
|
||||
$grid -> title = 'Lista artykułów';
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Wstecz',
|
||||
'url' => '/admin/pages/view_list/',
|
||||
'icon' => 'fa-reply',
|
||||
'class' => 'btn-dark'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
$gridId = 'page-articles';
|
||||
$gridTitle = 'Lista artykułów';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 1,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
$(document).ready(function() {
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: 0.6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 1,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
save_articles_order: true
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function save_articles_order()
|
||||
{
|
||||
articles = $( 'ol.sortable' ).nestedSortable( 'toArray', { startDepthCount: 0 } );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
|
||||
function save_articles_order() {
|
||||
var articles = $('ol.sortable').nestedSortable('toArray', { startDepthCount: 0 });
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'save_articles_order',
|
||||
page_id: <?= $this -> page_id;?>,
|
||||
url: '/admin/pages/saveArticlesOrder/',
|
||||
data: {
|
||||
page_id: <?= $pageId; ?>,
|
||||
articles: articles
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$.prompt( 'Trwa zapisywanie...', { title: 'Proszę czekać' } );
|
||||
beforeSend: function() {
|
||||
$.prompt('Trwa zapisywanie...', { title: 'Prosz\\u0119 czeka\\u0107' });
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '.jqibox' ).remove();
|
||||
response = jQuery.parseJSON( data );
|
||||
success: function(data) {
|
||||
$('.jqibox').remove();
|
||||
var response = jQuery.parseJSON(data);
|
||||
|
||||
if ( response.status === 'error' )
|
||||
create_error( response.msg );
|
||||
if (response.status === 'error') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -1,400 +1 @@
|
||||
<script type="text/javascript">
|
||||
var link_lang = '';
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$('body').on( 'change', '#page_type', function ()
|
||||
{
|
||||
var page_type = $(this).val();
|
||||
|
||||
if ( page_type == 0 || page_type == 1 || page_type == 2 )
|
||||
{
|
||||
$( '#articles_limit' ).parents( '.form-group' ).show();
|
||||
$( '#link-content' ).addClass( 'hide' );
|
||||
$( '#category-content' ).addClass( 'hide' );
|
||||
$( '#sort_type' ).parents( '.form-group' ).show();
|
||||
}
|
||||
else if ( page_type == 3 )
|
||||
{
|
||||
$( '#link-content' ).removeClass( 'hide' );
|
||||
$( '#articles_limit' ).parents( '.form-group' ).hide();
|
||||
$( '#sort_type' ).parents( '.form-group' ).hide();
|
||||
$( '#category-content' ).addClass( 'hide' );
|
||||
}
|
||||
else if ( page_type == 5 )
|
||||
{
|
||||
$( '#category-content' ).removeClass( 'hide' );
|
||||
$( '#articles_limit' ).parents( '.form-group' ).hide();
|
||||
$( '#sort_type' ).parents( '.form-group' ).hide();
|
||||
$( '#link-content' ).addClass( 'hide' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$( '#articles_limit' ).parents( '.form-group' ).hide();
|
||||
$( '#link-content' ).addClass( 'hide' );
|
||||
$( '#category-content' ).addClass( 'hide' );
|
||||
$( '#sort_type' ).parents( '.form-group' ).hide();
|
||||
}
|
||||
});
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#page_type' ).trigger( 'change' );
|
||||
|
||||
$( 'body').on( 'click', '.url-select', function() {
|
||||
$( '#link_' + link_lang ).val( $( this ).attr( 'url' ) );
|
||||
$.magnificPopup.close();
|
||||
});
|
||||
|
||||
$( 'body').on( 'click', '.category-select', function() {
|
||||
$( '#category_id' ).val( $( this ).attr( 'category-id' ) );
|
||||
$( '#category_title' ).val( $( this ).attr( 'category-title' ) );
|
||||
$.magnificPopup.close();
|
||||
});
|
||||
});
|
||||
|
||||
function generate_seo_links( lang, title, page_id )
|
||||
{
|
||||
if ( title === '' )
|
||||
return false;
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'generate_seo_link',
|
||||
title: title,
|
||||
page_id: page_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#seo_link_' + lang ).val( response.seo_link );
|
||||
else
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function pages_url_browser( lang_id ) {
|
||||
link_lang = lang_id;
|
||||
|
||||
$.magnificPopup.open({
|
||||
removalDelay: 500,
|
||||
items: {
|
||||
src: '/admin/pages/pages_url_browser/modal=true'
|
||||
},
|
||||
type: 'ajax',
|
||||
overflowY: 'scroll'
|
||||
});
|
||||
}
|
||||
|
||||
function category_url_browser() {
|
||||
$.magnificPopup.open({
|
||||
removalDelay: 500,
|
||||
items: {
|
||||
src: '/admin/shop_category/category_url_browser/modal=true'
|
||||
},
|
||||
type: 'ajax',
|
||||
overflowY: 'scroll'
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
<li><i class="fa fa-globe"></i>SEO</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<ul class="nav panel-tabs-border panel-tabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li>
|
||||
<a href="#laguages-main-<?= $lg['id'];?>" data-toggle="tab" aria-expanded="true"><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a>
|
||||
</li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="tab-content pn br-n">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div id="laguages-main-<?= $lg['id'];?>" class="tab-pane <? if ( !$z01++ ):?>active<? endif;?>">
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa strony',
|
||||
'name' => 'title[' . $lg['id'] . ']',
|
||||
'id' => 'title_' . $lg['id'],
|
||||
'value' => $this -> page[ 'languages' ][ $lg['id'] ]['title'],
|
||||
)
|
||||
);?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 15px;">
|
||||
<?
|
||||
if ( is_array( $this -> menus ) ): foreach ( $this -> menus as $menu ):
|
||||
$menus[ $menu['id'] ] = $menu['name'];
|
||||
endforeach; endif;
|
||||
?>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Menu',
|
||||
'name' => 'menu_id',
|
||||
'values' => $menus,
|
||||
'value' => $this -> page['id'] ? $this -> page['menu_id'] : $this -> menu_id
|
||||
)
|
||||
);?>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Typ strony',
|
||||
'name' => 'page_type',
|
||||
'id' => 'page_type',
|
||||
'values' => \admin\factory\Pages::$_page_types,
|
||||
'value' => $this -> page['page_type']
|
||||
)
|
||||
);?>
|
||||
<div id="link-content" class="hide">
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<ul class="nav panel-tabs-border panel-tabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li>
|
||||
<a href="#languages-links-<?= $lg['id'];?>" data-toggle="tab" aria-expanded="true"><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a>
|
||||
</li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="tab-content pn br-n">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div id="languages-links-<?= $lg['id'];?>" class="tab-pane <? if ( !$z02++ ):?>active<? endif;?>">
|
||||
<?= \Html::input_icon( [
|
||||
'label' => 'Link',
|
||||
'name' => 'link[' . $lg['id'] . ']',
|
||||
'id' => 'link_' . $lg['id'],
|
||||
'value' => $this -> page['languages'][$lg['id']]['link'],
|
||||
'icon_class' => 'fa fa-link',
|
||||
'icon_js' => 'pages_url_browser( "' . $lg['id'] . '");'
|
||||
] );
|
||||
?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="category-content" class="hide">
|
||||
<div id="languages-category">
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'type' => 'hidden',
|
||||
'name' => 'category_id',
|
||||
'id' => 'category_id',
|
||||
'value' => $this -> page['category_id']
|
||||
)
|
||||
);
|
||||
?>
|
||||
<?= \Html::input_icon(
|
||||
array(
|
||||
'label' => 'Kategoria',
|
||||
'name' => 'category_title',
|
||||
'id' => 'category_title',
|
||||
'value' => $this -> page['category_id'] ? \admin\factory\ShopCategory::category_title( $this -> page['category_id'] ) : '',
|
||||
'icon_class' => 'fa fa-link',
|
||||
'icon_js' => 'category_url_browser();'
|
||||
)
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Sortowanie artykułów',
|
||||
'name' => 'sort_type',
|
||||
'id' => 'sort_type',
|
||||
'values' => \admin\factory\Pages::$_sort_types,
|
||||
'value' => $this -> page['sort_type']
|
||||
)
|
||||
);?>
|
||||
<?
|
||||
$layouts[''] = '---- szablon ----';
|
||||
if ( is_array( $this -> layouts ) ): foreach ( $this -> layouts as $layout ):
|
||||
$layouts[ $layout['id'] ] = $layout['name'];
|
||||
endforeach; endif;
|
||||
?>
|
||||
<?= \Html::select(
|
||||
array(
|
||||
'label' => 'Szablon',
|
||||
'name' => 'layout_id',
|
||||
'id' => 'layout_id',
|
||||
'values' => $layouts,
|
||||
'value' => $this -> page['layout_id']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Liczba artykułów na stronę',
|
||||
'name' => 'articles_limit',
|
||||
'id' => 'articles_limit',
|
||||
'value' => $this -> page['articles_limit'] ? $this -> page['articles_limit'] : 2
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Pokaż tytuł',
|
||||
'name' => 'show_title',
|
||||
'checked' => $this -> page['show_title'] == 1 or !$this -> page['id'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktywna',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> page['status'] == 1 or !$this -> page['id'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Strona startowa',
|
||||
'name' => 'start',
|
||||
'checked' => $this -> page['start'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
</div>
|
||||
<div>
|
||||
<div class="panel">
|
||||
<div class="panel-heading">
|
||||
<ul class="nav panel-tabs-border panel-tabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li>
|
||||
<a href="#languages-seo-<?= $lg['id'];?>" data-toggle="tab" aria-expanded="true"><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a>
|
||||
</li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="tab-content pn br-n">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div id="languages-seo-<?= $lg['id'];?>" class="tab-pane <? if ( !$z03++ ):?>active<? endif;?>">
|
||||
<?= \Html::input_icon( [
|
||||
'label' => 'Link SEO',
|
||||
'name' => 'seo_link[' . $lg['id'] . ']',
|
||||
'id' => 'seo_link_' . $lg['id'],
|
||||
'value' => $this -> page['languages' ][ $lg['id'] ]['seo_link'],
|
||||
'icon_content' => 'generuj',
|
||||
'icon_js' => 'generate_seo_links( "' . $lg['id'] . '", $( "#title_' . $lg['id'] . '" ).val(), ' . (int)$this -> page['id'] . ' );'
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Tytuł strony (h1)',
|
||||
'name' => 'page_title[' . $lg['id'] . ']',
|
||||
'id' => 'page_title_' . $lg['id'],
|
||||
'value' => $this -> page['languages' ][ $lg['id'] ]['page_title']
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Meta title',
|
||||
'name' => 'meta_title[' . $lg['id'] . ']',
|
||||
'id' => 'meta_title_' . $lg['id'],
|
||||
'value' => $this -> page['languages'][ $lg['id'] ]['meta_title']
|
||||
] );?>
|
||||
<?= \Html::textarea( [
|
||||
'label' => 'Meta description',
|
||||
'name' => 'meta_description[' . $lg['id'] . ']',
|
||||
'id' => 'meta_description_' . $lg['id'],
|
||||
'value' => $this -> page['languages'][ $lg['id'] ]['meta_description']
|
||||
] );?>
|
||||
<?= \Html::textarea( [
|
||||
'label' => 'Meta keywords',
|
||||
'name' => 'meta_keywords[' . $lg['id'] . ']',
|
||||
'id' => 'meta_keywords_' . $lg['id'],
|
||||
'value' => $this -> page['languages'][ $lg['id'] ]['meta_keywords']
|
||||
] );?>
|
||||
<?= \Html::select( [
|
||||
'label' => 'Blokuj indeksację',
|
||||
'name' => 'noindex[' . $lg['id'] . ']',
|
||||
'id' => 'noindex_' . $lg['id'],
|
||||
'values' => [ 0 => 'nie', 1 => 'tak' ],
|
||||
'value' => $this -> page['languages'][ $lg['id'] ]['noindex'] == 1 ? 1 : 0
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Rel canonical',
|
||||
'name' => 'canonical[' . $lg['id'] . ']',
|
||||
'id' => 'canonical_' . $lg['id'],
|
||||
'value' => $this -> page['languages'][ $lg['id'] ]['canonical']
|
||||
] );?>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'page-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja strony';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> page['id']
|
||||
],
|
||||
[
|
||||
'db' => 'parent_id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> page['id'] ? $this -> page['parent_id'] : $this -> parent_id
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/pages/page_save/', 'back_url' => '/admin/pages/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/pages/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
@@ -1,48 +1,56 @@
|
||||
<?
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
ob_start();
|
||||
if ( is_array( $this -> menus ) ) foreach ( $this -> menus as $menu )
|
||||
{
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>" menu-id="<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$menu['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i>';?>
|
||||
Menu: <b><?= $menu['name'];?></b>
|
||||
</div>
|
||||
<?= \admin\view\Pages::subpages_browse_list( \admin\factory\Pages::menu_pages( $menu['id'] ) );?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
$menus = is_array($this->menus ?? null) ? $this->menus : [];
|
||||
$modal = !empty($this->modal);
|
||||
$cookiePages = is_array($this->cookie_pages ?? null) ? $this->cookie_pages : [];
|
||||
$cookieMenus = is_array($this->cookie_menus ?? null) ? $this->cookie_menus : [];
|
||||
|
||||
ob_start();
|
||||
foreach ($menus as $menu):
|
||||
$menuId = (int)($menu['id'] ?? 0);
|
||||
$menuName = (string)($menu['name'] ?? '');
|
||||
$menuStatus = (int)($menu['status'] ?? 0);
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menuId; ?>" menu-id="<?= $menuId; ?>">
|
||||
<li id="list_<?= $menuId; ?>" class="menu_<?= $menuId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<?php if ($menuStatus !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i><?php endif; ?>
|
||||
Menu: <b><?= htmlspecialchars($menuName, ENT_QUOTES, 'UTF-8'); ?></b>
|
||||
</div>
|
||||
<?= \Shared\Tpl\Tpl::view('pages/subpages-browse-list', [
|
||||
'pages' => $menu['pages'] ?? [],
|
||||
'step' => 1,
|
||||
]); ?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'pages-list';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Lista stron';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = $out;
|
||||
|
||||
echo $grid -> draw();
|
||||
$gridId = 'pages-list';
|
||||
$gridTitle = 'Lista stron';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<style type="text/css">
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> body.sb-top.sb-top-sm .navbar.navbar-fixed-top + #sidebar_left + #content_wrapper {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> body.sb-top.sb-top-sm .navbar.navbar-fixed-top + #sidebar_left + #content_wrapper {
|
||||
padding-top: 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content {
|
||||
padding: 27px 0 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content > .row {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content > .row {
|
||||
margin: 0;
|
||||
}
|
||||
<? if ( $this -> modal ): echo '.mfp-container'; endif;?> #content > .row > .col-lg-9 {
|
||||
<?php if ($modal): ?>.mfp-container<?php endif; ?> #content > .row > .col-lg-9 {
|
||||
padding: 0;
|
||||
width: 100%;
|
||||
float: none;
|
||||
@@ -50,113 +58,88 @@ echo $grid -> draw();
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
var menu_id = 0;
|
||||
|
||||
function getUrlParam(paramName)
|
||||
{
|
||||
var reParam = new RegExp('(?:[\?&]|&)' + paramName + '=([^&]+)', 'i');
|
||||
var cookiePages = <?= json_encode($cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
var cookieMenus = <?= json_encode($cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
|
||||
function getUrlParam(paramName) {
|
||||
var reParam = new RegExp('(?:[\\?&]|&)' + paramName + '=([^&]+)', 'i');
|
||||
var match = window.location.search.match(reParam);
|
||||
|
||||
return (match && match.length > 1) ? match[1] : '';
|
||||
}
|
||||
|
||||
$( document ).ready( function()
|
||||
{
|
||||
<? if ( !$this -> modal ):?>
|
||||
$( '#sidebar_left, .navbar-fixed-top' ).hide();
|
||||
<? endif;?>
|
||||
|
||||
|
||||
$(document).ready(function() {
|
||||
<?php if (!$modal): ?>
|
||||
$('#sidebar_left, .navbar-fixed-top').hide();
|
||||
<?php endif; ?>
|
||||
|
||||
var funcNum = getUrlParam('CKEditorFuncNum');
|
||||
|
||||
$( 'body' ).on( 'click', '.button', function()
|
||||
{
|
||||
if ( funcNum )
|
||||
{
|
||||
window.opener.CKEDITOR.tools.callFunction(funcNum, $( this ).attr( 'url' ) );
|
||||
|
||||
$('body').on('click', '.button', function() {
|
||||
if (funcNum) {
|
||||
window.opener.CKEDITOR.tools.callFunction(funcNum, $(this).attr('url'));
|
||||
window.close();
|
||||
}
|
||||
});
|
||||
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
stop: function() {
|
||||
save_pages_order();
|
||||
}
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( ".sortable *" ).mousedown( function(e)
|
||||
{
|
||||
menu_id = $( this ).parents( 'ol.sortable' ).attr( 'menu-id' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e)
|
||||
{
|
||||
if ( e.which === 1 ) {
|
||||
if ( $( this ).parent( 'div' ).hasClass( 'content_menu' ) )
|
||||
{
|
||||
var menu_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'menu' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_menus',
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var page_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_pages',
|
||||
page_id: page_id
|
||||
}
|
||||
});
|
||||
}
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: 0.9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 3,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
$(this).closest('li').toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(this).parent('div').hasClass('content_menu')) {
|
||||
var menuId = $(this).parent('div').parent('li').attr('menu');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookieMenus/',
|
||||
data: { menu_id: menuId }
|
||||
});
|
||||
} else {
|
||||
var pageId = $(this).parent('div').parent('li').attr('id').replace('list_', '');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookiePages/',
|
||||
data: { page_id: pageId }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(cookiePages || {}).forEach(function(key) {
|
||||
if (String(cookiePages[key]) === '1') {
|
||||
$('.list_' + key).children('div').children('span.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(cookieMenus || {}).forEach(function(key) {
|
||||
if (String(cookieMenus[key]) === '1') {
|
||||
$('.menu_' + key).children('div').children('span.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,208 +1,299 @@
|
||||
<?
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
ob_start();
|
||||
if ( is_array( $this -> menus ) ) foreach ( $this -> menus as $menu )
|
||||
{
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menu['id'];?>" menu-id="<?= $menu['id'];?>">
|
||||
<li id="list_<?= $menu['id'];?>" class="menu_<?= $menu['id'];?>" menu="<?= $menu['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$menu['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i>';?>
|
||||
<b>Menu: <?= $menu['name'];?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/menu_edit/id=<?= $menu['id'];?>" title="Edytuj menu" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj menu</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń menu" class="btn btn-sm btn-danger menu-delete" menu-id="<?= $menu['id'];?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń menu</span>
|
||||
</a>
|
||||
<a href="/admin/pages/page_edit/pid=0&menu_id=<?= $menu['id'];?>" title="Dodaj stronę" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-plus-circle"></i> <span class="hidden-xs">Dodaj stronę</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Tpl::view( 'pages/subpages-list', [
|
||||
'pages' => \admin\factory\Pages::menu_pages( $menu['id'] ),
|
||||
'menu_id' => $menu['id']
|
||||
] );
|
||||
?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?
|
||||
}
|
||||
$menus = is_array($this->menus ?? null) ? $this->menus : [];
|
||||
$cookiePages = is_array($this->cookie_pages ?? null) ? $this->cookie_pages : [];
|
||||
$cookieMenus = is_array($this->cookie_menus ?? null) ? $this->cookie_menus : [];
|
||||
|
||||
ob_start();
|
||||
foreach ($menus as $menu):
|
||||
$menuId = (int)($menu['id'] ?? 0);
|
||||
$menuName = (string)($menu['name'] ?? '');
|
||||
$menuStatus = (int)($menu['status'] ?? 0);
|
||||
?>
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable_<?= $menuId; ?>" menu-id="<?= $menuId; ?>">
|
||||
<li id="list_<?= $menuId; ?>" class="menu_<?= $menuId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ($menuStatus !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Menu nieaktywne"></i><?php endif; ?>
|
||||
<b>Menu: <?= htmlspecialchars($menuName, ENT_QUOTES, 'UTF-8'); ?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/menuEdit/id=<?= $menuId; ?>" title="Edytuj menu" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj menu</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń menu" class="btn btn-sm btn-danger menu-delete" menu-id="<?= $menuId; ?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń menu</span>
|
||||
</a>
|
||||
<a href="/admin/pages/edit/pid=0&menu_id=<?= $menuId; ?>" title="Dodaj stronę" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-plus-circle"></i> <span class="hidden-xs">Dodaj stronę</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Shared\Tpl\Tpl::view('pages/subpages-list', [
|
||||
'pages' => $menu['pages'] ?? [],
|
||||
'step' => 1,
|
||||
]); ?>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
<?php
|
||||
endforeach;
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'pages-list';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Lista stron';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj menu',
|
||||
'url' => '/admin/pages/menu_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
|
||||
echo $grid -> draw();
|
||||
$gridId = 'pages-list';
|
||||
$gridTitle = 'Lista stron';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-row {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box-container {
|
||||
width: 100%;
|
||||
max-width: 560px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.jconfirm.table-list-confirm-dialog .jconfirm-box {
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
var menu_id = 0;
|
||||
var menu_id = 0;
|
||||
var cookiePages = <?= json_encode($cookiePages, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
var cookieMenus = <?= json_encode($cookieMenus, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>;
|
||||
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'body' ).on( 'click', '.menu-delete', function()
|
||||
{
|
||||
var menu_id = $( this ).attr( 'menu-id' );
|
||||
$(document).ready(function() {
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
$.prompt( "Na pewno chcesz usunąć wybrane menu?",
|
||||
{
|
||||
title: "Potwierdź?",
|
||||
buttons: { "Tak": true, "Nie": false },
|
||||
submit: function( e, v, m, f )
|
||||
{
|
||||
if ( v === true )
|
||||
document.location.href = '/admin/pages/menu_delete/id=' + menu_id;
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded')) {
|
||||
$li.addClass('sort-collapsed');
|
||||
}
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDialog(message, onConfirm) {
|
||||
if (typeof $.confirm === 'function') {
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie',
|
||||
content: String(message),
|
||||
type: 'red',
|
||||
boxWidth: '560px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
backgroundDismissAnimation: 'shake',
|
||||
container: 'body',
|
||||
theme: 'modern',
|
||||
columnClass: '',
|
||||
typeAnimated: true,
|
||||
lazyOpen: false,
|
||||
draggable: false,
|
||||
closeIcon: true,
|
||||
containerFluid: true,
|
||||
escapeKey: true,
|
||||
backgroundDismiss: true,
|
||||
animationBounce: 1.1,
|
||||
watchInterval: 100,
|
||||
offsetTop: 0,
|
||||
offsetBottom: 0,
|
||||
customClass: 'table-list-confirm-dialog',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
btnClass: 'btn-default'
|
||||
},
|
||||
confirm: {
|
||||
text: 'Usuń',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {
|
||||
if (typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (window.confirm(message) && typeof onConfirm === 'function') {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
$('body').on('click', '.menu-delete', function() {
|
||||
var selectedMenuId = $(this).attr('menu-id');
|
||||
|
||||
confirmDialog('Na pewno chcesz usunąć wybrane menu?', function() {
|
||||
document.location.href = '/admin/pages/menuDelete/id=' + selectedMenuId;
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.page-delete', function()
|
||||
{
|
||||
var page_id = $( this ).attr( 'page-id' );
|
||||
$('body').on('click', '.page-delete', function() {
|
||||
var pageId = $(this).attr('page-id');
|
||||
|
||||
$.prompt( "Na pewno chcesz usunąć wybraną stronę?",
|
||||
{
|
||||
title: "Potwierdź?",
|
||||
buttons: { "Tak": true, "Nie": false },
|
||||
submit: function( e, v, m, f )
|
||||
{
|
||||
if ( v === true )
|
||||
document.location.href = '/admin/pages/page_delete/id=' + page_id;
|
||||
}
|
||||
confirmDialog('Na pewno chcesz usunąć wybraną stronę?', function() {
|
||||
document.location.href = '/admin/pages/delete/id=' + pageId;
|
||||
});
|
||||
});
|
||||
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: 0.9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
stop: function() {
|
||||
refreshTreeDisclosureState();
|
||||
save_pages_order();
|
||||
}
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( ".sortable *" ).mousedown( function(e)
|
||||
{
|
||||
menu_id = $( this ).parents( 'ol.sortable' ).attr( 'menu-id' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e)
|
||||
{
|
||||
if ( e.which === 1 ) {
|
||||
if ( $( this ).parent( 'div' ).hasClass( 'content_menu' ) )
|
||||
{
|
||||
var menu_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'menu' );
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_menus',
|
||||
menu_id: menu_id
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var page_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
$('.disclose').on('click', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_pages',
|
||||
page_id: page_id
|
||||
}
|
||||
});
|
||||
}
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.sortable *').mousedown(function() {
|
||||
menu_id = $(this).parents('ol.sortable').attr('menu-id');
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which !== 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($(this).parent('div').hasClass('content_menu')) {
|
||||
var selectedMenuId = $(this).parent('div').parent('li').attr('menu');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookieMenus/',
|
||||
data: { menu_id: selectedMenuId }
|
||||
});
|
||||
} else {
|
||||
var pageId = $(this).parent('div').parent('li').attr('id').replace('list_', '');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/cookiePages/',
|
||||
data: { page_id: pageId }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_pages' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
Object.keys(cookiePages || {}).forEach(function(key) {
|
||||
if (String(cookiePages[key]) === '1') {
|
||||
$('.list_' + key).children('div').children('.disclose').click();
|
||||
}
|
||||
});
|
||||
|
||||
$array = unserialize( $_COOKIE[ 'cookie_menus' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '.menu_<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
Object.keys(cookieMenus || {}).forEach(function(key) {
|
||||
if (String(cookieMenus[key]) === '1') {
|
||||
$('.menu_' + key).children('div').children('.disclose').click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function save_pages_order( )
|
||||
{
|
||||
pages = $( '#sortable_' + menu_id ).nestedSortable( 'toArray', { startDepthCount: 0 } );
|
||||
function save_pages_order() {
|
||||
if (!menu_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
var pages = $('#sortable_' + menu_id).nestedSortable('toArray', { startDepthCount: 0 });
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'save_pages_order',
|
||||
url: '/admin/pages/savePagesOrder/',
|
||||
data: {
|
||||
menu_id: menu_id,
|
||||
pages: pages
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$.prompt( 'Trwa zapisywanie...', { title: 'Proszę czekać' } );
|
||||
beforeSend: function() {
|
||||
$.prompt('Trwa zapisywanie...', { title: 'Prosz\\u0119 czeka\\u0107' });
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '.jqibox' ).remove();
|
||||
response = jQuery.parseJSON( data );
|
||||
success: function(data) {
|
||||
$('.jqibox').remove();
|
||||
|
||||
if ( response.status === 'error' )
|
||||
create_error( response.msg );
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'error') {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -1,77 +1,60 @@
|
||||
<? if ( is_array( $this -> pages ) ):?>
|
||||
<? $settings = \front\factory\Settings::settings_details();?>
|
||||
<ol>
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
|
||||
<div class="content">
|
||||
<span class="disclose"><span></span></span>
|
||||
<?
|
||||
if ( !$page['status'] )
|
||||
echo '<i class="fa fa-ban fa-lg text-danger" title="Strona nieaktywna"></i>';
|
||||
<?php
|
||||
$pages = is_array($this->pages ?? null) ? $this->pages : [];
|
||||
$step = (int)($this->step ?? 1);
|
||||
|
||||
if ( $page['start'] )
|
||||
echo '<i class="fa fa-star fa-lg text-system" title="Strona startowa"></i>';
|
||||
|
||||
echo $page['title'];
|
||||
|
||||
if ( is_array( $page['languages'] ) ):
|
||||
echo '<div class="btn-group flags" style="display: inline-block;">';
|
||||
foreach ( $page['languages'] as $lg )
|
||||
echo '<img src="/admin/layout/lang-' . $lg['lang_id'] . '.jpg" />';
|
||||
echo '</div>';
|
||||
endif;
|
||||
|
||||
$default_language = \front\factory\Languages::default_language();
|
||||
if ( is_array( $page['languages'] ) ):
|
||||
foreach ( $page['languages'] as $lg ):
|
||||
echo '<div class="btn-group ml20 pull-right">';
|
||||
echo '<a href="#" title="Wybierz stronę" class="btn btn-sm btn-system button url-select" url="';
|
||||
|
||||
if ( $settings['links_structure'] )
|
||||
{
|
||||
if ( $lg['seo_link'] )
|
||||
{
|
||||
$seo = '/' . \admin\factory\Pages::google_url_preview( $page['id'],
|
||||
$lg['title'], $lg['lang_id'], 0, 0,
|
||||
$lg['seo_link'] );
|
||||
echo $seo;
|
||||
}
|
||||
else
|
||||
{
|
||||
$seo = '/' . \admin\factory\Pages::google_url_preview( $page['id'],
|
||||
$lg['title'], $lg['lang_id'], 0, 0, 0 );
|
||||
echo $seo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $lg['seo_link'] )
|
||||
{
|
||||
if ( $default_language != $lg['lang_id'] )
|
||||
echo '/' . $lg['lang_id'];
|
||||
echo '/' . $lg['seo_link'];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $default_language != $lg['lang_id'] )
|
||||
echo '/' . $lg['lang_id'];
|
||||
echo '/s-' . $page['id'] . '-' . \S::seo( $lg['title'] );
|
||||
}
|
||||
}
|
||||
echo '">';
|
||||
echo '<i class="fa fa-check"></i> <span class="hidden-xs">' . strtoupper( $lg['lang_id'] ) . '</span>';
|
||||
echo '</a>';
|
||||
echo '</div>';
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
</div>
|
||||
<?
|
||||
if ( is_array( $page['subpages'] ) )
|
||||
echo \admin\view\Pages::subpages_browse_list( $page['subpages'],
|
||||
$page['id'], $this -> step + 1 );
|
||||
if (empty($pages)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<ol>
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<?php
|
||||
$pageId = (int)($page['id'] ?? 0);
|
||||
$menuId = (int)($page['menu_id'] ?? 0);
|
||||
$title = (string)($page['title'] ?? '');
|
||||
$status = (int)($page['status'] ?? 0);
|
||||
$start = (int)($page['start'] ?? 0);
|
||||
$languages = is_array($page['languages'] ?? null) ? $page['languages'] : [];
|
||||
$previewUrls = is_array($page['preview_urls'] ?? null) ? $page['preview_urls'] : [];
|
||||
?>
|
||||
</li>
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
<li id="list_<?= $pageId; ?>" class="list_<?= $pageId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="content">
|
||||
<span class="disclose"><span></span></span>
|
||||
<?php if ($status !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Strona nieaktywna"></i><?php endif; ?>
|
||||
<?php if ($start === 1): ?><i class="fa fa-star fa-lg text-system" title="Strona startowa"></i><?php endif; ?>
|
||||
<?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
|
||||
<?php if (!empty($languages)): ?>
|
||||
<div class="btn-group flags" style="display: inline-block;">
|
||||
<?php foreach ($languages as $language): ?>
|
||||
<?php $langId = (string)($language['lang_id'] ?? ''); ?>
|
||||
<?php if ($langId !== ''): ?>
|
||||
<img src="/admin/layout/lang-<?= htmlspecialchars($langId, ENT_QUOTES, 'UTF-8'); ?>.jpg" />
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php foreach ($languages as $language): ?>
|
||||
<?php
|
||||
$langId = (string)($language['lang_id'] ?? '');
|
||||
if ($langId === '') {
|
||||
continue;
|
||||
}
|
||||
$url = (string)($previewUrls[$langId] ?? '#');
|
||||
?>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="#" title="Wybierz stronę" class="btn btn-sm btn-system button url-select" url="<?= htmlspecialchars($url, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<i class="fa fa-check"></i> <span class="hidden-xs"><?= strtoupper(htmlspecialchars($langId, ENT_QUOTES, 'UTF-8')); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?= \Shared\Tpl\Tpl::view('pages/subpages-browse-list', [
|
||||
'pages' => $page['subpages'] ?? [],
|
||||
'step' => $step + 1,
|
||||
]); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
|
||||
@@ -1,60 +1,77 @@
|
||||
<? if ( is_array( $this -> pages ) ):?>
|
||||
<ol>
|
||||
<? foreach ( $this -> pages as $page ):?>
|
||||
<li id="list_<?= $page['id'];?>" idk="<?= $page['id'];?>" class="list_<?= $page['id'];?>" menu="<?= $page['menu_id'];?>">
|
||||
<div class="content">
|
||||
<div class="menu-box-title">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$page['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Strona nieaktywna"></i>';?>
|
||||
<? if ( $page['start'] ) echo '<i class="fa fa-star fa-lg text-system" title="Strona startowa"></i>';?>
|
||||
<?= $page['title'];?>
|
||||
<?
|
||||
if ( is_array( $page['languages'] ) ):
|
||||
echo '<div class="btn-group flags" style="display: inline-block;">';
|
||||
foreach ( $page['languages'] as $lg )
|
||||
echo '<img src="/admin/layout/lang-' . $lg['lang_id'] . '.jpg" />';
|
||||
echo '</div>';
|
||||
endif;
|
||||
?>
|
||||
<?php
|
||||
$pages = is_array($this->pages ?? null) ? $this->pages : [];
|
||||
$step = (int)($this->step ?? 1);
|
||||
|
||||
if (empty($pages)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<ol>
|
||||
<?php foreach ($pages as $page): ?>
|
||||
<?php
|
||||
$pageId = (int)($page['id'] ?? 0);
|
||||
$menuId = (int)($page['menu_id'] ?? 0);
|
||||
$title = (string)($page['title'] ?? '');
|
||||
$status = (int)($page['status'] ?? 0);
|
||||
$start = (int)($page['start'] ?? 0);
|
||||
$languages = is_array($page['languages'] ?? null) ? $page['languages'] : [];
|
||||
?>
|
||||
<li id="list_<?= $pageId; ?>" class="list_<?= $pageId; ?>" menu="<?= $menuId; ?>">
|
||||
<div class="content">
|
||||
<div class="menu-box-title">
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ($status !== 1): ?><i class="fa fa-ban fa-lg text-danger" title="Strona nieaktywna"></i><?php endif; ?>
|
||||
<?php if ($start === 1): ?><i class="fa fa-star fa-lg text-system" title="Strona startowa"></i><?php endif; ?>
|
||||
<?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?>
|
||||
|
||||
<?php if (!empty($languages)): ?>
|
||||
<div class="btn-group flags" style="display: inline-block;">
|
||||
<?php foreach ($languages as $language): ?>
|
||||
<?php $langId = (string)($language['lang_id'] ?? ''); ?>
|
||||
<?php if ($langId !== ''): ?>
|
||||
<img src="/admin/layout/lang-<?= htmlspecialchars($langId, ENT_QUOTES, 'UTF-8'); ?>.jpg" />
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<? if ( $this -> step < 3 ):?>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/page_edit/id=<?= $page['id'];?>&menu_id=<?= $page['menu_id'];?>" title="Edytuj stronę" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj stronę</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń stronę" class="btn btn-sm btn-danger page-delete" page-id="<?= $page['id'];?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń stronę</span>
|
||||
</a>
|
||||
<a href="/admin/pages/page_articles/id=<?= $page['id'];?>" title="Lista artykułów" class="btn btn-sm btn-info" page-id="<?= $page['id'];?>">
|
||||
<i class="fa fa-bars"></i> <span class="hidden-xs">Lista artykułów</span>
|
||||
</a>
|
||||
<a href="/admin/pages/page_edit/pid=<?= $page['id'];?>&menu_id=<?= $page['menu_id'];?>" title="Dodaj podstronę" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-plus-circle"></i> <span class="hidden-xs">Dodaj podstronę</span>
|
||||
</a>
|
||||
</div>
|
||||
<? else:?>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/page_edit/id=<?= $page['id'];?>&menu_id=<?= $page['menu_id'];?>" title="Edytuj stronę" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj stronę</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń stronę" class="btn btn-sm btn-danger page-delete" page-id="<?= $page['id'];?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń stronę</span>
|
||||
</a>
|
||||
<a href="/admin/pages/page_articles/id=<?= $page['id'];?>" title="Lista artykułów" class="btn btn-sm btn-info" page-id="<?= $page['id'];?>">
|
||||
<i class="fa fa-bars"></i> <span class="hidden-xs">Lista artykułów</span>
|
||||
</a>
|
||||
</div>
|
||||
<? endif;?>
|
||||
</div>
|
||||
<?= \Tpl::view( 'pages/subpages-list', [
|
||||
'pages' => \admin\factory\Pages::menu_pages( $this -> menu_id, $page['id'] ),
|
||||
'menu_id' => $this -> menu_id,
|
||||
'parent_id' => $page['id'],
|
||||
'step' => $this -> step + 1
|
||||
] );
|
||||
?>
|
||||
</li>
|
||||
<? endforeach;?>
|
||||
</ol>
|
||||
<? endif;?>
|
||||
<?php if ($step < 3): ?>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/edit/id=<?= $pageId; ?>&menu_id=<?= $menuId; ?>" title="Edytuj stronę" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj stronę</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń stronę" class="btn btn-sm btn-danger page-delete" page-id="<?= $pageId; ?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń stronę</span>
|
||||
</a>
|
||||
<a href="/admin/pages/pageArticles/id=<?= $pageId; ?>" title="Lista artykułów" class="btn btn-sm btn-info" page-id="<?= $pageId; ?>">
|
||||
<i class="fa fa-bars"></i> <span class="hidden-xs">Lista artykułów</span>
|
||||
</a>
|
||||
<a href="/admin/pages/edit/pid=<?= $pageId; ?>&menu_id=<?= $menuId; ?>" title="Dodaj podstronę" class="btn btn-sm btn-success">
|
||||
<i class="fa fa-plus-circle"></i> <span class="hidden-xs">Dodaj podstronę</span>
|
||||
</a>
|
||||
</div>
|
||||
<?php else: ?>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
<a href="/admin/pages/edit/id=<?= $pageId; ?>&menu_id=<?= $menuId; ?>" title="Edytuj stronę" class="btn btn-sm btn-system">
|
||||
<i class="fa fa-file-text"></i> <span class="hidden-xs">Edytuj stronę</span>
|
||||
</a>
|
||||
<a href="#" title="Usuń stronę" class="btn btn-sm btn-danger page-delete" page-id="<?= $pageId; ?>">
|
||||
<i class="fa fa-trash"></i> <span class="hidden-xs">Usuń stronę</span>
|
||||
</a>
|
||||
<a href="/admin/pages/pageArticles/id=<?= $pageId; ?>" title="Lista artykułów" class="btn btn-sm btn-info" page-id="<?= $pageId; ?>">
|
||||
<i class="fa fa-bars"></i> <span class="hidden-xs">Lista artykułów</span>
|
||||
</a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?= \Shared\Tpl\Tpl::view('pages/subpages-list', [
|
||||
'pages' => $page['subpages'] ?? [],
|
||||
'step' => $step + 1,
|
||||
]); ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
|
||||
|
||||
236
admin/templates/product-archive/products-list-custom-script.php
Normal file
236
admin/templates/product-archive/products-list-custom-script.php
Normal file
@@ -0,0 +1,236 @@
|
||||
<style type="text/css">
|
||||
.bulk-action-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 14px;
|
||||
margin-bottom: 10px;
|
||||
background: #fff3cd;
|
||||
border: 1px solid #ffc107;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.bulk-action-bar__info {
|
||||
font-weight: 600;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.table-col-bulk-check {
|
||||
width: 36px;
|
||||
padding-left: 10px !important;
|
||||
padding-right: 10px !important;
|
||||
}
|
||||
|
||||
.product-archive-thumb-wrap {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.product-archive-thumb-image {
|
||||
width: 72px;
|
||||
height: 42px;
|
||||
object-fit: cover;
|
||||
border-radius: 4px;
|
||||
cursor: zoom-in;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: min(70vw, 760px);
|
||||
max-height: 80vh;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 14px 30px rgba(0, 0, 0, .35);
|
||||
z-index: 3000;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
pointer-events: none;
|
||||
transition: opacity .1s ease;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup.is-visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.product-archive-thumb-popup img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-height: calc(80vh - 12px);
|
||||
object-fit: contain;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.product-archive-thumb-popup').remove();
|
||||
var $popup = $('<div class="product-archive-thumb-popup" aria-hidden="true"><img src="" alt=""></div>');
|
||||
var $popupImage = $popup.find('img');
|
||||
$('body').append($popup);
|
||||
|
||||
function positionPopup(event) {
|
||||
var offset = 18;
|
||||
var viewportWidth = $(window).width();
|
||||
var viewportHeight = $(window).height();
|
||||
var popupWidth = $popup.outerWidth();
|
||||
var popupHeight = $popup.outerHeight();
|
||||
var left = (event.clientX || 0) + offset;
|
||||
var top = (event.clientY || 0) + offset;
|
||||
|
||||
if (left + popupWidth + 12 > viewportWidth) {
|
||||
left = Math.max(12, (event.clientX || 0) - popupWidth - offset);
|
||||
}
|
||||
|
||||
if (top + popupHeight + 12 > viewportHeight) {
|
||||
top = Math.max(12, viewportHeight - popupHeight - 12);
|
||||
}
|
||||
|
||||
$popup.css({ left: left + 'px', top: top + 'px' });
|
||||
}
|
||||
|
||||
$(document).off('.productArchiveThumbPopup');
|
||||
|
||||
$(document).on('mouseenter.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function(event) {
|
||||
var src = $(this).data('previewSrc');
|
||||
if (!src) {
|
||||
return;
|
||||
}
|
||||
|
||||
$popupImage.attr('src', String(src));
|
||||
$popup.addClass('is-visible');
|
||||
positionPopup(event);
|
||||
});
|
||||
|
||||
$(document).on('mousemove.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function(event) {
|
||||
if ($popup.hasClass('is-visible')) {
|
||||
positionPopup(event);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('mouseleave.productArchiveThumbPopup', '.js-product-archive-thumb-preview', function() {
|
||||
$popup.removeClass('is-visible');
|
||||
$popupImage.attr('src', '');
|
||||
});
|
||||
|
||||
// --- Bulk select ---
|
||||
var $table = $('.table-list-table');
|
||||
var $bar = $('#js-bulk-action-bar');
|
||||
var $label = $bar.find('.js-bulk-count-label');
|
||||
|
||||
// Inject select-all checkbox into _checkbox column header
|
||||
$table.find('thead th.table-col-bulk-check').html(
|
||||
'<input type="checkbox" id="js-bulk-select-all" title="Zaznacz wszystkie">'
|
||||
);
|
||||
|
||||
function updateBar() {
|
||||
var count = $table.find('.js-bulk-check:checked').length;
|
||||
if (count > 0) {
|
||||
$label.text('Zaznaczono: ' + count);
|
||||
$bar.show();
|
||||
} else {
|
||||
$bar.hide();
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('change.bulkSelect', '#js-bulk-select-all', function() {
|
||||
var checked = $(this).is(':checked');
|
||||
$table.find('.js-bulk-check').prop('checked', checked);
|
||||
updateBar();
|
||||
});
|
||||
|
||||
$(document).on('change.bulkSelect', '.js-bulk-check', function() {
|
||||
var total = $table.find('.js-bulk-check').length;
|
||||
var checked = $table.find('.js-bulk-check:checked').length;
|
||||
$('#js-bulk-select-all').prop('indeterminate', checked > 0 && checked < total);
|
||||
$('#js-bulk-select-all').prop('checked', checked === total && total > 0);
|
||||
updateBar();
|
||||
});
|
||||
|
||||
$(document).on('click.bulkDelete', '.js-bulk-delete-btn', function() {
|
||||
var ids = [];
|
||||
$table.find('.js-bulk-check:checked').each(function() {
|
||||
ids.push($(this).val());
|
||||
});
|
||||
if (ids.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var confirmMsg = 'UWAGA! Operacja nieodwracalna!\n\n'
|
||||
+ 'Wybrane produkty (' + ids.length + ' szt.) zostaną trwale usunięte razem ze wszystkimi zdjęciami i załącznikami z serwera.\n\n'
|
||||
+ 'Czy na pewno chcesz usunąć zaznaczone produkty?';
|
||||
|
||||
var doDelete = function() {
|
||||
var $btn = $('.js-bulk-delete-btn');
|
||||
$btn.prop('disabled', true).text('Usuwanie…');
|
||||
|
||||
var formData = [];
|
||||
for (var i = 0; i < ids.length; i++) {
|
||||
formData.push('ids%5B%5D=' + encodeURIComponent(ids[i]));
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/admin/product_archive/bulk_delete_permanent/',
|
||||
type: 'POST',
|
||||
data: formData.join('&'),
|
||||
contentType: 'application/x-www-form-urlencoded',
|
||||
dataType: 'json',
|
||||
success: function(resp) {
|
||||
if (resp && resp.deleted > 0) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
alert('Nie udało się usunąć produktów. Spróbuj ponownie.');
|
||||
$btn.prop('disabled', false).html('<i class="fa fa-trash-o"></i> Usuń zaznaczone trwale');
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
alert('Błąd podczas usuwania produktów. Spróbuj ponownie.');
|
||||
$btn.prop('disabled', false).html('<i class="fa fa-trash-o"></i> Usuń zaznaczone trwale');
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (typeof $.confirm === 'function') {
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie',
|
||||
content: confirmMsg,
|
||||
type: 'red',
|
||||
boxWidth: '560px',
|
||||
useBootstrap: false,
|
||||
animation: 'scale',
|
||||
closeAnimation: 'scale',
|
||||
backgroundDismissAnimation: 'shake',
|
||||
container: 'body',
|
||||
theme: 'modern',
|
||||
columnClass: '',
|
||||
typeAnimated: true,
|
||||
lazyOpen: false,
|
||||
draggable: false,
|
||||
closeIcon: true,
|
||||
containerFluid: true,
|
||||
escapeKey: true,
|
||||
backgroundDismiss: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
btnClass: 'btn-default'
|
||||
},
|
||||
confirm: {
|
||||
text: 'Tak, usuń trwale',
|
||||
btnClass: 'btn-danger',
|
||||
action: doDelete
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (window.confirm(confirmMsg)) {
|
||||
doDelete();
|
||||
}
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
12
admin/templates/product-archive/products-list.php
Normal file
12
admin/templates/product-archive/products-list.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<div id="js-bulk-action-bar" class="bulk-action-bar" style="display:none;">
|
||||
<span class="bulk-action-bar__info js-bulk-count-label">Zaznaczono: 0</span>
|
||||
<button type="button" class="btn btn-danger btn-sm js-bulk-delete-btn">
|
||||
<i class="fa fa-trash-o"></i> Usuń zaznaczone trwale
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, ['list' => $this->viewModel]); ?>
|
||||
<?php endif; ?>
|
||||
41
admin/templates/product_archive/products-list-table.php
Normal file
41
admin/templates/product_archive/products-list-table.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<? $i = ( $this -> current_page - 1 ) * 10 + 1;?>
|
||||
<? foreach ( $this -> products as $product ):?>
|
||||
<tr>
|
||||
<td>
|
||||
<?= $i++;?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="product-image">
|
||||
<? if ( $product['images'][0]['src'] ):?>
|
||||
<img src="<?= $product['images'][0]['src'];?>" alt="<?= $product['images'][0]['alt'];?>" class="img-responsive">
|
||||
<? else:?>
|
||||
<img src="/admin/layout/images/no-image.png" alt="Brak zdjęcia" class="img-responsive">
|
||||
<? endif;?>
|
||||
</div>
|
||||
<div class="product-name">
|
||||
<a href="/admin/shop_product/product_edit/id=<?= $product['id'];?>">
|
||||
<?= $product['languages']['pl']['name'];?>
|
||||
</a>
|
||||
</div>
|
||||
<small class="text-muted"><?= \admin\factory\ShopProduct::product_categories( $product['id'] );?></small>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $product['price_brutto'];?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<?= $product['price_brutto_promo'];?>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<span class="text-muted"><?= (int)\admin\factory\shopProduct::get_product_quantity_list( $product['id'] );?></span>
|
||||
</td>
|
||||
<td>
|
||||
<a href='/admin/shop_product/product_combination/product_id=<?= $product['id'];?>'>kombinacje (<?= \admin\factory\shopProduct::count_product_combinations( $product['id'] );?>)</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href='/admin/shop_product/product_edit/id=<?= $product['id'];?>'>edytuj</a>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href='/admin/product_archive/unarchive/product_id=<?= $product['id'];?>' class="product-unarchive">przywróć</a>
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach;?>
|
||||
152
admin/templates/product_archive/products-list.php
Normal file
152
admin/templates/product_archive/products-list.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<div class="panel">
|
||||
<div class="panel-body pn">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped mbn" id="table-products">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10px;">#</th>
|
||||
<th>Nazwa</th>
|
||||
<th class="text-center" style="width: 100px;">Cena</th>
|
||||
<th class="text-center" style="width: 100px;">Cena promocyjna</th>
|
||||
<th class="text-center" style="width: 75px;">Stan MG</th>
|
||||
<th class="text-center" style="width: 100px;">Kombinacje</th>
|
||||
<th class="text-center" style="width: 75px;">Edytuj</th>
|
||||
<th class="text-center" style="width: 75px;">Przywróć</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>
|
||||
<input type="text" class="form-control table-search" field_name="name|ean|sku" placeholder="szukaj..." value="<?= htmlspecialchars( $this -> query_array['name'] ?? '', ENT_QUOTES, 'UTF-8');?>">
|
||||
</th>
|
||||
<th colspan="6"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<ul class="pagination" pagination_max="<?= $this -> pagination_max;?>">
|
||||
<li>
|
||||
<a href="#" page="1" title="pierwsza strona">
|
||||
<i class="fa fa-angle-double-left"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="previous" page="<?= ( $this -> current_page - 1 > 1 ) ? ( $this -> current_page - 1 ) : 1;?>" title="poprzednia strona">
|
||||
<i class="fa fa-angle-left" title="poprzednia strona"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
Strona <span id="current-page"><?= $this -> current_page;?></span> z <span id="max_page"><?= $this -> pagination_max;?></span>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="next" page="<?= ( $this -> current_page + 1 < $this -> pagination_max ) ? ( $this -> current_page + 1 ) : $this -> pagination_max;?>" title="następna strona">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="last" page="<?= $this -> pagination_max;?>" title="ostatnia strona">
|
||||
<i class="fa fa-angle-double-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
ajax_load_products( <?= $this -> current_page;?> );
|
||||
|
||||
$( 'body' ).on( 'change', '.table-search', function() {
|
||||
ajax_load_products( 1 );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.pagination a', function() {
|
||||
var current_page = $( this ).attr( 'page' );
|
||||
ajax_load_products( current_page );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.product-unarchive', function(e) {
|
||||
e.preventDefault();
|
||||
var href = $( this ).attr( 'href' );
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz przywrócić wybrany produkt z archiwum?',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'supervan',
|
||||
icon: 'fa fa-question',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-success',
|
||||
action: function() {}
|
||||
},
|
||||
confirm: {
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = href;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
function ajax_load_products( current_page ) {
|
||||
var pagination_max = parseInt( $( '.pagination' ).attr( 'pagination_max' ) );
|
||||
|
||||
var query = '';
|
||||
$( '.table-search' ).each(function(){
|
||||
query += $( this ).attr( 'field_name' ) + '=' + $( this ).val() + '&';
|
||||
});
|
||||
|
||||
current_page = parseInt( current_page );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/ajax_load_products_archive/',
|
||||
data: {
|
||||
current_page: current_page,
|
||||
query: query
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '#table-products tbody' ).html( data.html );
|
||||
$( '.pagination .previous' ).attr( 'page', ( current_page - 1 > 1 ) ? ( current_page - 1 ) : 1 );
|
||||
$( '.pagination .next' ).attr( 'page', ( current_page + 1 < pagination_max ) ? ( current_page + 1 ) : pagination_max );
|
||||
$( '.pagination span' ).html( current_page );
|
||||
if ( data.pagination_max ) {
|
||||
$( '.pagination' ).attr( 'pagination_max', data.pagination_max );
|
||||
$( '.pagination #max_page' ).html( data.pagination_max );
|
||||
$( '.pagination .last' ).attr( 'page', data.pagination_max );
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -1,123 +1 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-main">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
array(
|
||||
'label' => 'Tytuł',
|
||||
'name' => 'title[' . $lg['id'] . ']',
|
||||
'id' => 'title_' . $lg['id'],
|
||||
'value' => $this -> container['languages'][ $lg['id'] ]['title'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
array(
|
||||
'label' => 'Treść',
|
||||
'name' => 'text[' . $lg['id'] . ']',
|
||||
'id' => 'text_' . $lg['id'],
|
||||
'value' => $this -> container['languages'][ $lg['id'] ]['text'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
$( '#text_<?= $lg['id'];?>' ).ckeditor( {
|
||||
toolbar : 'MyToolbar',
|
||||
height:'300'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> container['status'] == 1 or !$this -> container['id'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
array(
|
||||
'label' => 'Pokaż tytuł',
|
||||
'name' => 'show_title',
|
||||
'checked' => $this -> container['show_title'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'container-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja kontenera statycznego';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> container['id']
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/scontainers/container_save/', 'back_url' => '/admin/scontainers/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/scontainers/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
@@ -1,79 +1 @@
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( 'pp_scontainers' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, '
|
||||
. '( SELECT title FROM pp_scontainers_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND container_id = ps.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_scontainers AS ps '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, '
|
||||
. '( SELECT title FROM pp_scontainers_langs AS psl, pp_langs AS pl WHERE lang_id = pl.id AND container_id = ps.id AND title != \'\' ORDER BY o ASC LIMIT 1 ) AS title '
|
||||
. 'FROM '
|
||||
. 'pp_scontainers AS ps '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'id', 'type' => 'DESC' ];
|
||||
$grid -> search = [
|
||||
[ 'name' => 'Tytuł', 'db' => 'title', 'type' => 'text' ],
|
||||
[ 'name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ]
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Tytuł',
|
||||
'db' => 'title',
|
||||
'php' => 'echo "<a href=\'/admin/scontainers/container_edit/id=[id]\'>[title]</a>";',
|
||||
'sort' => true
|
||||
],
|
||||
[
|
||||
'name' => 'Kod',
|
||||
'php' => 'echo "[KONTENER:[id]]";'
|
||||
],
|
||||
[
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => [ 'array' => [ 0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak' ] ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => [ 'type' => 'edit', 'url' => '/admin/scontainers/container_edit/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => [ 'type' => 'delete', 'url' => '/admin/scontainers/container_delete/id=[id]' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ],
|
||||
'td' => [ 'class' => 'g-center' ]
|
||||
]
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj kontener',
|
||||
'url' => '/admin/scontainers/container_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
@@ -41,7 +41,7 @@ ob_start();
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa firmy',
|
||||
'name' => 'firm_name',
|
||||
@@ -49,7 +49,7 @@ ob_start();
|
||||
'value' => $this -> settings['firm_name']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Dodatkowe informacje',
|
||||
'name' => 'additional_info',
|
||||
@@ -57,14 +57,14 @@ ob_start();
|
||||
'value' => $this -> settings['additional_info']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Mapa',
|
||||
'name' => 'google_maps',
|
||||
'checked' => $this -> settings['google_maps'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Mapa - adres',
|
||||
'name' => 'firm_adress',
|
||||
@@ -74,7 +74,7 @@ ob_start();
|
||||
);?>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Dane do przelewu',
|
||||
'name' => 'shop_bank_account_info',
|
||||
@@ -84,54 +84,54 @@ ob_start();
|
||||
'ckeditor' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Klucz API HotPay',
|
||||
'name' => 'hotpay_api',
|
||||
'id' => 'hotpay_api',
|
||||
'value' => $this -> settings['hotpay_api']
|
||||
] );?>
|
||||
<?= \Html::input_switch( [
|
||||
<?= \Shared\Html\Html::input_switch( [
|
||||
'label' => 'Tpay.com - tryb sandbox',
|
||||
'name' => 'tpay_sandbox',
|
||||
'checked' => $this -> settings['tpay_sandbox'] == 1 ? true : false
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Tpay.com ID',
|
||||
'name' => 'tpay_id',
|
||||
'id' => 'tpay_id',
|
||||
'value' => $this -> settings['tpay_id']
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Tpay.com - kod bezpieczeństwa',
|
||||
'name' => 'tpay_security_code',
|
||||
'id' => 'tpay_security_code',
|
||||
'value' => $this -> settings['tpay_security_code']
|
||||
] );?>
|
||||
<?= \Html::input_switch( [
|
||||
<?= \Shared\Html\Html::input_switch( [
|
||||
'label' => 'Przelewy24.pl - tryb sandbox',
|
||||
'name' => 'przelewy24_sandbox',
|
||||
'checked' => $this -> settings['przelewy24_sandbox'] == 1 ? true : false
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Przelewy24.pl - merchant ID',
|
||||
'name' => 'przelewy24_merchant_id',
|
||||
'id' => 'przelewy24_merchant_id',
|
||||
'value' => $this -> settings['przelewy24_merchant_id']
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Przelewy24.pl - klucz CRC',
|
||||
'name' => 'przelewy24_crc_key',
|
||||
'id' => 'przelewy24_crc_key',
|
||||
'value' => $this -> settings['przelewy24_crc_key']
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Darmowa dostawa od',
|
||||
'class' => 'number-format',
|
||||
'name' => 'free_delivery',
|
||||
'id' => 'free_delivery',
|
||||
'value' => $this -> settings['free_delivery']
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
<?= \Shared\Html\Html::input( [
|
||||
'label' => 'Orlen Paczka map token',
|
||||
'name' => 'orlen_paczka_map_token',
|
||||
'id' => 'orlen_paczka_map_token',
|
||||
@@ -143,7 +143,7 @@ ob_start();
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<li><? if ( $lg['id'] == ( new \Domain\Languages\LanguagesRepository( $GLOBALS['mdb'] ) )->defaultLanguage() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
@@ -161,7 +161,7 @@ ob_start();
|
||||
?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Komunikat gdy stan magazynowy równy 0',
|
||||
'name' => 'warehouse_message_zero[' . $lg['id'] . ']',
|
||||
@@ -170,7 +170,7 @@ ob_start();
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Komunikat gdy stan magazynowy większy niż 0',
|
||||
'name' => 'warehouse_message_nonzero[' . $lg['id'] . ']',
|
||||
@@ -187,14 +187,14 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Formularz kontaktowy',
|
||||
'name' => 'contact_form',
|
||||
'checked' => $this -> settings['contact_form'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Email kontaktowy',
|
||||
'name' => 'contact_email',
|
||||
@@ -202,7 +202,7 @@ ob_start();
|
||||
'value' => $this -> settings['contact_email']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Email - host',
|
||||
'name' => 'email_host',
|
||||
@@ -210,7 +210,7 @@ ob_start();
|
||||
'value' => $this -> settings['email_host']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Email - port',
|
||||
'name' => 'email_port',
|
||||
@@ -218,7 +218,7 @@ ob_start();
|
||||
'value' => $this -> settings['email_port']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Email - login',
|
||||
'name' => 'email_login',
|
||||
@@ -226,7 +226,7 @@ ob_start();
|
||||
'value' => $this -> settings['email_login']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Email - hasło',
|
||||
'name' => 'email_password',
|
||||
@@ -236,7 +236,7 @@ ob_start();
|
||||
);?>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Facebook link',
|
||||
'name' => 'facebook_link',
|
||||
@@ -252,7 +252,7 @@ ob_start();
|
||||
]
|
||||
);
|
||||
?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Kod statystyk',
|
||||
'name' => 'statistic_code',
|
||||
@@ -261,7 +261,7 @@ ob_start();
|
||||
'rows' => 10
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Własne reguły htacess',
|
||||
'name' => 'htaccess',
|
||||
@@ -270,7 +270,7 @@ ob_start();
|
||||
'rows' => 10
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Własne reguły robots.txt',
|
||||
'name' => 'robots',
|
||||
@@ -281,7 +281,7 @@ ob_start();
|
||||
);?>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktualizacja',
|
||||
'name' => 'update',
|
||||
@@ -296,31 +296,31 @@ ob_start();
|
||||
]
|
||||
);
|
||||
?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Strona konstrukcyjna',
|
||||
'name' => 'devel',
|
||||
'checked' => $this -> settings['devel'] == 1 ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input_switch( [
|
||||
<?= \Shared\Html\Html::input_switch( [
|
||||
'label' => 'Lazy loading obrazów',
|
||||
'name' => 'lazy_loading',
|
||||
'checked' => $this -> settings['lazy_loading'] == 1 ? true : false
|
||||
] );?>
|
||||
|
||||
<?= \Html::input_switch( [
|
||||
<?= \Shared\Html\Html::input_switch( [
|
||||
'label' => 'Generowanie obrazków WEBP',
|
||||
'name' => 'generate_webp',
|
||||
'checked' => $this -> settings['generate_webp'] == 1 ? true : false
|
||||
] );?>
|
||||
|
||||
<?= \Html::input_switch( [
|
||||
<?= \Shared\Html\Html::input_switch( [
|
||||
'label' => 'Infinitescroll',
|
||||
'name' => 'infinitescroll',
|
||||
'checked' => $this -> settings['infinitescroll'] == 1 ? true : false
|
||||
] );?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Htaccess cache',
|
||||
'name' => 'htaccess_cache',
|
||||
@@ -335,14 +335,14 @@ ob_start();
|
||||
'id' => 'google_tag_manager_id',
|
||||
'value' => $this -> settings['google_tag_manager_id']
|
||||
] ); ?>
|
||||
<?= \Html::textarea( [
|
||||
<?= \Shared\Html\Html::textarea( [
|
||||
'label' => 'Własny kod GTM JS (bez tagu script)',
|
||||
'name' => 'own_gtm_js',
|
||||
'id' => 'own_gtm_js',
|
||||
'value' => $this -> settings['own_gtm_js'],
|
||||
'rows' => 10
|
||||
] );?>
|
||||
<?= \Html::textarea( [
|
||||
<?= \Shared\Html\Html::textarea( [
|
||||
'label' => 'Własny kod GTM HTML',
|
||||
'name' => 'own_gtm_html',
|
||||
'id' => 'own_gtm_html',
|
||||
@@ -355,19 +355,17 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'settings-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja ustawień';
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/settings/settings_save/', 'back_url' => '/admin/settings/view/' ],
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
echo $grid -> draw();
|
||||
$gridId = 'settings-edit';
|
||||
$gridTitle = 'Edycja ustawień';
|
||||
$gridSaveUrl = '/admin/settings/save/';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = true;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
<style type="text/css">#g-edit-cancel { display: none; }</style>
|
||||
<style type="text/css">#g-edit-cancel, #g-edit-save.btn-system { display: none; }</style>
|
||||
<script type="text/javascript">
|
||||
$( document).ready( function ()
|
||||
{
|
||||
@@ -377,4 +375,4 @@ echo $grid -> draw();
|
||||
html: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
68
admin/templates/shop-attribute/_partials/value-row.php
Normal file
68
admin/templates/shop-attribute/_partials/value-row.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$value = is_array($this->value ?? null) ? $this->value : [];
|
||||
$languages = is_array($this->languages ?? null) ? $this->languages : [];
|
||||
$rowKey = (string)($this->rowKey ?? '');
|
||||
$defaultLanguageId = (string)($this->defaultLanguageId ?? '');
|
||||
$valueId = (int)($value['id'] ?? 0);
|
||||
$isDefault = !empty($value['is_default']);
|
||||
$impact = (string)($value['impact_on_the_price'] ?? '');
|
||||
?>
|
||||
<tr class="attribute-value-row" data-row-key="<?= htmlspecialchars($rowKey, ENT_QUOTES, 'UTF-8'); ?>">
|
||||
<td class="text-center" style="width: 90px;">
|
||||
<input
|
||||
type="radio"
|
||||
class="js-default-row"
|
||||
name="default_row_key"
|
||||
value="<?= htmlspecialchars($rowKey, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
<?= $isDefault ? 'checked="checked"' : ''; ?>
|
||||
/>
|
||||
</td>
|
||||
<td style="width: 180px;">
|
||||
<input type="hidden" class="js-value-id" value="<?= $valueId; ?>" />
|
||||
<input
|
||||
type="text"
|
||||
class="form-control input-sm js-impact-on-price"
|
||||
value="<?= htmlspecialchars($impact, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
placeholder="+10.00 / -5.50"
|
||||
/>
|
||||
</td>
|
||||
<td>
|
||||
<?php foreach ($languages as $language): ?>
|
||||
<?php
|
||||
if ((int)($language['status'] ?? 0) !== 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$langId = (string)($language['id'] ?? '');
|
||||
if ($langId === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$langName = (string)($language['name'] ?? $langId);
|
||||
$langValue = '';
|
||||
if (is_array($value['languages'] ?? null) && isset($value['languages'][$langId]['name'])) {
|
||||
$langValue = (string)$value['languages'][$langId]['name'];
|
||||
}
|
||||
?>
|
||||
<div class="form-group mb10">
|
||||
<label class="control-label" style="display:block;">
|
||||
<?= htmlspecialchars($langName, ENT_QUOTES, 'UTF-8'); ?>
|
||||
<?= $langId === $defaultLanguageId ? '<span style="color:#e74c3c;">*</span>' : ''; ?>
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
class="form-control input-sm js-value-name"
|
||||
data-lang-id="<?= htmlspecialchars($langId, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= htmlspecialchars($langValue, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
placeholder="Nazwa wartosci"
|
||||
/>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</td>
|
||||
<td class="text-center" style="width: 100px;">
|
||||
<button type="button" class="btn btn-xs btn-danger js-value-remove">
|
||||
<i class="fa fa-trash"></i> Usun
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,106 +1,2 @@
|
||||
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/framework/vendor/plugins/ckeditor/adapters/jquery.js"></script>
|
||||
<?php
|
||||
global $db;
|
||||
ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
</ul>
|
||||
<div class="resp-tabs-container settings-tabs">
|
||||
<div>
|
||||
<div id="languages-main">
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
|
||||
<?php if ($lg['status']) : ?>
|
||||
<li><?php echo $lg['name']; ?></a></li>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; endif; ?>
|
||||
</ul>
|
||||
<div class="resp-tabs-container languages-main">
|
||||
<?php if (is_array($this -> languages)) : foreach ($this -> languages as $lg) : ?>
|
||||
<?php if ($lg['status']) : ?>
|
||||
<div>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Tytuł',
|
||||
'name' => 'name[' . $lg['id'] . ']',
|
||||
'id' => 'name_' . $lg['id'],
|
||||
'value' => $this -> attribute['languages'][ $lg['id'] ]['name'],
|
||||
'inline' => true,
|
||||
] ); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<?= \Html::input_switch( [
|
||||
'label' => 'Aktywny',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> attribute['status'] || !$this -> attribute['id'] ? true : false,
|
||||
] );?>
|
||||
<?= \Html::select( [
|
||||
'label' => 'Typ',
|
||||
'name' => 'type',
|
||||
'values' => [0 => 'tekst'],//, 1 => 'kolor', 2 => 'wzór'],
|
||||
'value' => $this -> attribute['type'],
|
||||
] );?>
|
||||
<?= \Html::input( [
|
||||
'label' => 'Kolejność',
|
||||
'name' => 'o',
|
||||
'id' => 'o',
|
||||
'value' => $this -> attribute['o'],
|
||||
] );?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$out = ob_get_clean();
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
|
||||
$grid = new \gridEdit();
|
||||
$grid -> id = 'attribute-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja cechy';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> attribute['id'],
|
||||
],
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => ['url' => '/admin/shop_attribute/attribute_save/', 'back_url' => '/admin/shop_attribute/view_list/'],
|
||||
'cancel' => ['url' => '/admin/shop_attribute/view_list/'],
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
<script>CKEDITOR.dtd.$removeEmpty['span'] = false;</script>
|
||||
|
||||
@@ -1,95 +1,2 @@
|
||||
<?php
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid('pp_shop_attributes');
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> sql = 'SELECT *'
|
||||
. 'FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, type, o, '
|
||||
. '( SELECT psal.name FROM pp_shop_attributes_langs AS psal, pp_langs AS pl WHERE lang_id = pl.id AND attribute_id = psa.id AND psal.name != \'\' ORDER BY o ASC LIMIT 1 ) AS name '
|
||||
. 'FROM '
|
||||
. 'pp_shop_attributes AS psa '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] '
|
||||
. 'ORDER BY '
|
||||
. '[order_p1] [order_p2]';
|
||||
$grid -> sql_count = 'SELECT '
|
||||
. 'COUNT(0) FROM ( '
|
||||
. 'SELECT '
|
||||
. 'id, status, type, o, '
|
||||
. '( SELECT psal.name FROM pp_shop_attributes_langs AS psal, pp_langs AS pl WHERE lang_id = pl.id AND attribute_id = psa.id AND psal.name != \'\' ORDER BY o ASC LIMIT 1 ) AS name '
|
||||
. 'FROM '
|
||||
. 'pp_shop_attributes AS psa '
|
||||
. ') AS q1 '
|
||||
. 'WHERE '
|
||||
. '1=1 [where] ';
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'o', 'type' => 'ASC' ];
|
||||
$grid -> search = [
|
||||
['name' => 'Nazwa', 'db' => 'name', 'type' => 'text'],
|
||||
['name' => 'Aktywny', 'db' => 'status', 'type' => 'select', 'replace' => ['array' => [0 => 'nie', 1 => 'tak']]],
|
||||
];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => ['class' => 'g-lp'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
'autoincrement' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Kolejność',
|
||||
'td' => [ 'class' => 'g-center', 'style' => 'width: 100px' ],
|
||||
'db' => 'o',
|
||||
'sort' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Nazwa',
|
||||
'db' => 'name',
|
||||
'php' => 'echo "<a href=\'/admin/shop_attribute/attribute_edit/id=[id]\'>[name]</a>";',
|
||||
'sort' => true,
|
||||
],
|
||||
[
|
||||
'name' => 'Typ',
|
||||
'db' => 'type',
|
||||
'replace' => ['array' => [0 => 'tekst', 1 => 'kolor', 2 => 'wzór']],
|
||||
'td' => ['class' => 'g-center'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 150px;'],
|
||||
'sort' => true,
|
||||
], [
|
||||
'name' => 'Aktywny',
|
||||
'db' => 'status',
|
||||
'replace' => ['array' => [0 => '<span style="color: #FF0000;">nie</span>', 1 => 'tak']],
|
||||
'td' => ['class' => 'g-center'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 150px;'],
|
||||
'sort' => true,
|
||||
], [
|
||||
'name' => 'Wartości',
|
||||
'td' => ['class' => 'g-center'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 150px;'],
|
||||
'php' => 'echo "<a href=\'/admin/shop_attribute/values_edit/attribute-id=[id]\'>edytuj wartości</a>";',
|
||||
],
|
||||
[
|
||||
'name' => 'Edytuj',
|
||||
'action' => ['type' => 'edit', 'url' => '/admin/shop_attribute/attribute_edit/id=[id]'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 70px;'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
],
|
||||
[
|
||||
'name' => 'Usuń',
|
||||
'action' => ['type' => 'delete', 'url' => '/admin/shop_attribute/delete_attribute/id=[id]'],
|
||||
'th' => ['class' => 'g-center', 'style' => 'width: 70px;'],
|
||||
'td' => ['class' => 'g-center'],
|
||||
],
|
||||
];
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj cechę',
|
||||
'url' => '/admin/shop_attribute/attribute_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success',
|
||||
],
|
||||
];
|
||||
echo $grid -> draw();
|
||||
|
||||
@@ -1,138 +1,274 @@
|
||||
<div class="panel panel-widget draft-widget" value-numer="<?= $this -> i;?>">
|
||||
<?php
|
||||
$attribute = is_array($this->attribute ?? null) ? $this->attribute : [];
|
||||
$values = is_array($this->values ?? null) ? $this->values : [];
|
||||
$languages = is_array($this->languages ?? null) ? $this->languages : [];
|
||||
$defaultLanguageId = (string)($this->defaultLanguageId ?? '');
|
||||
|
||||
$activeLanguages = [];
|
||||
foreach ($languages as $language) {
|
||||
if ((int)($language['status'] ?? 0) === 1) {
|
||||
$activeLanguages[] = $language;
|
||||
}
|
||||
}
|
||||
|
||||
if ($defaultLanguageId === '' && !empty($activeLanguages[0]['id'])) {
|
||||
$defaultLanguageId = (string)$activeLanguages[0]['id'];
|
||||
}
|
||||
|
||||
$attributeName = '';
|
||||
if ($defaultLanguageId !== '' && isset($attribute['languages'][$defaultLanguageId]['name'])) {
|
||||
$attributeName = trim((string)$attribute['languages'][$defaultLanguageId]['name']);
|
||||
}
|
||||
if ($attributeName === '' && is_array($attribute['languages'] ?? null)) {
|
||||
foreach ($attribute['languages'] as $languageData) {
|
||||
$candidateName = trim((string)($languageData['name'] ?? ''));
|
||||
if ($candidateName !== '') {
|
||||
$attributeName = $candidateName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($attributeName === '') {
|
||||
$attributeName = 'ID: ' . (int)($attribute['id'] ?? 0);
|
||||
}
|
||||
|
||||
$rowCounter = 0;
|
||||
$initialRowsHtml = '';
|
||||
if (!empty($values)) {
|
||||
foreach ($values as $value) {
|
||||
++$rowCounter;
|
||||
$rowKey = 'existing-' . (int)($value['id'] ?? 0);
|
||||
$initialRowsHtml .= \Shared\Tpl\Tpl::view('shop-attribute/_partials/value-row', [
|
||||
'rowKey' => $rowKey,
|
||||
'value' => $value,
|
||||
'languages' => $activeLanguages,
|
||||
'defaultLanguageId' => $defaultLanguageId,
|
||||
]);
|
||||
}
|
||||
} else {
|
||||
$rowCounter = 1;
|
||||
$initialRowsHtml .= \Shared\Tpl\Tpl::view('shop-attribute/_partials/value-row', [
|
||||
'rowKey' => 'new-1',
|
||||
'value' => ['id' => 0, 'is_default' => 1, 'impact_on_the_price' => null, 'languages' => []],
|
||||
'languages' => $activeLanguages,
|
||||
'defaultLanguageId' => $defaultLanguageId,
|
||||
]);
|
||||
}
|
||||
|
||||
$newRowTemplate = \Shared\Tpl\Tpl::view('shop-attribute/_partials/value-row', [
|
||||
'rowKey' => '__ROW_KEY__',
|
||||
'value' => ['id' => 0, 'is_default' => 0, 'impact_on_the_price' => null, 'languages' => []],
|
||||
'languages' => $activeLanguages,
|
||||
'defaultLanguageId' => $defaultLanguageId,
|
||||
]);
|
||||
?>
|
||||
|
||||
<div class="panel panel-widget draft-widget">
|
||||
<div class="panel-heading with-buttons">
|
||||
<span class="panel-title">Edycja wartości dla cechy: <?= $this -> attribute['languages']['pl']['name'];?></span>
|
||||
<span class="panel-title">Wartosci cechy: <?= htmlspecialchars($attributeName, ENT_QUOTES, 'UTF-8'); ?></span>
|
||||
<div class="buttons">
|
||||
<a class="btn btn-success btn-save" href="#">
|
||||
<a class="btn btn-success js-values-save" href="#">
|
||||
<i class="fa fa-save"></i> zapisz
|
||||
</a>
|
||||
<a class="btn btn-dark" href="/admin/shop_attribute/view_list/">
|
||||
<a class="btn btn-dark" href="/admin/shop_attribute/list/">
|
||||
<i class="fa fa-ban"></i> wstecz
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body p20">
|
||||
<button class="btn btn-success mb10 btn-value-add">
|
||||
<i class="fa fa-plus-circle mr5"></i>Dodaj wartość
|
||||
</button>
|
||||
<div class="values-content">
|
||||
<?
|
||||
if ( $this -> values ):
|
||||
foreach ( $this -> values as $value ):
|
||||
echo \Tpl::view( 'shop-attribute/_partials/value', [
|
||||
'i' => ++$i,
|
||||
'value' => $value,
|
||||
'languages' => $this -> languages,
|
||||
'attribute' => $this -> attribute
|
||||
] );
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
<div class="mb10">
|
||||
<button type="button" class="btn btn-success js-value-add">
|
||||
<i class="fa fa-plus-circle mr5"></i>Dodaj wartosc
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<strong>Wskazowka:</strong> zaznacz jedna wartosc domyslna i uzupelnij nazwe w jezyku domyslnym.
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-striped" id="attribute-values-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-center" style="width: 90px;">Domyslna</th>
|
||||
<th style="width: 180px;">Wplyw na cene</th>
|
||||
<th>Nazwy w jezykach</th>
|
||||
<th class="text-center" style="width: 100px;">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="attribute-values-body">
|
||||
<?= $initialRowsHtml; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function ()
|
||||
{
|
||||
disable_menu();
|
||||
$(function() {
|
||||
disable_menu();
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-save', function()
|
||||
{
|
||||
var values = jQuery( '.dashboard-page' ).find( 'input, select, textarea' ).serializeObject();
|
||||
var attributeId = <?= (int)($attribute['id'] ?? 0); ?>;
|
||||
var defaultLanguageId = <?= json_encode($defaultLanguageId); ?>;
|
||||
var rowCounter = <?= (int)$rowCounter; ?>;
|
||||
var newRowTemplate = <?= json_encode($newRowTemplate); ?>;
|
||||
|
||||
jQuery.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_attribute/values_save/',
|
||||
data: {
|
||||
values: JSON.stringify( values ),
|
||||
attribute_id: <?= $this -> attribute['id'];?>,
|
||||
},
|
||||
beforeSend: function() {
|
||||
jQuery( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
var data = jQuery.parseJSON( response );
|
||||
jQuery( '#overlay' ).hide();
|
||||
if ( data.status === 'ok' )
|
||||
{
|
||||
var msg = "Zapisano wartości atrybutu";
|
||||
alert_message( msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( data.msg )
|
||||
var msg = data.msg;
|
||||
else
|
||||
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
|
||||
create_error( msg );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
function showError(message) {
|
||||
if (typeof create_error === 'function') {
|
||||
create_error(message);
|
||||
return;
|
||||
}
|
||||
alert(message);
|
||||
}
|
||||
|
||||
$( 'body').on( 'click', '.btn-value-add', function ()
|
||||
{
|
||||
var maxVal = Math.max.apply(null, $('div[value-number]').map(function() {
|
||||
var val = parseInt($(this).attr('value-number'));
|
||||
return isNaN(val) ? 0 : val; // Jeżeli wartość nie jest liczbą, zwróć 0
|
||||
}).get());
|
||||
function showSuccess(message) {
|
||||
if (typeof alert_message === 'function') {
|
||||
alert_message(message);
|
||||
return;
|
||||
}
|
||||
alert(message);
|
||||
}
|
||||
|
||||
if (!isFinite(maxVal)) {
|
||||
maxVal = 0;
|
||||
function addRow() {
|
||||
rowCounter += 1;
|
||||
var rowKey = 'new-' + rowCounter;
|
||||
var rowHtml = newRowTemplate.split('__ROW_KEY__').join(rowKey);
|
||||
$('#attribute-values-body').append(rowHtml);
|
||||
|
||||
if ($('input[name="default_row_key"]:checked').length === 0) {
|
||||
$('input[name="default_row_key"][value="' + rowKey + '"]').prop('checked', true);
|
||||
}
|
||||
}
|
||||
|
||||
function collectRows() {
|
||||
var defaultRowKey = $('input[name="default_row_key"]:checked').val() || '';
|
||||
var rows = [];
|
||||
|
||||
$('#attribute-values-body .attribute-value-row').each(function() {
|
||||
var $row = $(this);
|
||||
var rowKey = String($row.data('rowKey') || '');
|
||||
var valueId = parseInt($row.find('.js-value-id').val(), 10);
|
||||
if (isNaN(valueId)) {
|
||||
valueId = 0;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/admin/shop_attribute/attribute_value_tpl/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
i: maxVal + 1,
|
||||
value: null,
|
||||
languages: <?= json_encode( $this -> languages );?>,
|
||||
attribute: <?= json_encode( $this -> attribute );?>
|
||||
},
|
||||
success: function( response )
|
||||
{
|
||||
$('.values-content').append(response);
|
||||
var impactOnPrice = $.trim(String($row.find('.js-impact-on-price').val() || ''));
|
||||
var translations = {};
|
||||
|
||||
$row.find('.js-value-name').each(function() {
|
||||
var $input = $(this);
|
||||
var langId = String($input.data('langId') || '');
|
||||
if (langId === '') {
|
||||
return;
|
||||
}
|
||||
|
||||
translations[langId] = {
|
||||
name: $.trim(String($input.val() || '')),
|
||||
value: ''
|
||||
};
|
||||
});
|
||||
|
||||
rows.push({
|
||||
id: valueId,
|
||||
row_key: rowKey,
|
||||
is_default: rowKey !== '' && rowKey === defaultRowKey,
|
||||
impact_on_the_price: impactOnPrice,
|
||||
translations: translations
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-value-remove', function()
|
||||
{
|
||||
var button = $( this );
|
||||
$.alert({
|
||||
title: 'Potwierdź',
|
||||
content: 'Na pewno chcesz usunąć wybraną wartość?',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
autoClose: 'confirm|10000',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'cancel|10000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons:
|
||||
{
|
||||
confirm:
|
||||
{
|
||||
text: 'TAK usuń',
|
||||
btnClass: 'btn-orange',
|
||||
keys: ['enter'],
|
||||
action: function()
|
||||
{
|
||||
button.closest( '.panel' ).remove();
|
||||
}
|
||||
},
|
||||
cancel:
|
||||
{
|
||||
text: 'anuluj',
|
||||
btnClass: 'btn-blue',
|
||||
action: function() {}
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
function validateRows(rows) {
|
||||
if (!Array.isArray(rows) || rows.length === 0) {
|
||||
return 'Dodaj co najmniej jedna wartosc cechy.';
|
||||
}
|
||||
|
||||
var defaultCount = 0;
|
||||
var decimalRegex = /^-?[0-9]+([.,][0-9]{1,4})?$/;
|
||||
|
||||
for (var i = 0; i < rows.length; i += 1) {
|
||||
var row = rows[i] || {};
|
||||
if (row.is_default) {
|
||||
defaultCount += 1;
|
||||
}
|
||||
|
||||
var translations = row.translations || {};
|
||||
var defaultLang = translations[defaultLanguageId] || {};
|
||||
var defaultName = $.trim(String(defaultLang.name || ''));
|
||||
if (defaultName === '') {
|
||||
return 'Wiersz nr ' + (i + 1) + ': nazwa w jezyku domyslnym jest wymagana.';
|
||||
}
|
||||
|
||||
var impact = $.trim(String(row.impact_on_the_price || ''));
|
||||
if (impact !== '' && !decimalRegex.test(impact)) {
|
||||
return 'Wiersz nr ' + (i + 1) + ': nieprawidlowy format "wplyw na cene".';
|
||||
}
|
||||
}
|
||||
|
||||
if (defaultCount !== 1) {
|
||||
return 'Wybierz dokladnie jedna wartosc domyslna.';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
$('body').on('click', '.js-value-add', function() {
|
||||
addRow();
|
||||
});
|
||||
|
||||
$('body').on('click', '.js-value-remove', function() {
|
||||
var $row = $(this).closest('.attribute-value-row');
|
||||
if ($('#attribute-values-body .attribute-value-row').length <= 1) {
|
||||
showError('Musi pozostac przynajmniej jeden wiersz wartosci.');
|
||||
return;
|
||||
}
|
||||
|
||||
$row.remove();
|
||||
if ($('input[name="default_row_key"]:checked').length === 0) {
|
||||
$('#attribute-values-body .attribute-value-row:first .js-default-row').prop('checked', true);
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('click', '.js-values-save', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var rows = collectRows();
|
||||
var validationError = validateRows(rows);
|
||||
if (validationError !== '') {
|
||||
showError(validationError);
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_attribute/values_save/id=' + attributeId,
|
||||
dataType: 'json',
|
||||
data: {
|
||||
payload: JSON.stringify({ rows: rows })
|
||||
},
|
||||
beforeSend: function() {
|
||||
$('#overlay').show();
|
||||
},
|
||||
success: function(response) {
|
||||
$('#overlay').hide();
|
||||
|
||||
if (response && response.status === 'ok') {
|
||||
showSuccess('Wartosci cechy zostaly zapisane.');
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
var message = (response && response.msg) ? response.msg : 'Wystapil blad podczas zapisu danych.';
|
||||
showError(message);
|
||||
},
|
||||
error: function() {
|
||||
$('#overlay').hide();
|
||||
showError('Wystapil blad polaczenia podczas zapisu danych.');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
153
admin/templates/shop-category/categories-list-custom-script.php
Normal file
153
admin/templates/shop-category/categories-list-custom-script.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
margin-top: -2px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.layout-tree-toggle i.fa.fa-caret-right {
|
||||
position: relative;
|
||||
top: -11px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded'))
|
||||
$li.addClass('sort-collapsed');
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function saveCategoriesOrder() {
|
||||
var categories = $('#sortable').nestedSortable('toArray', { startDepthCount: 0 });
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/save_categories_order/',
|
||||
data: {
|
||||
categories: categories
|
||||
},
|
||||
beforeSend: function() {
|
||||
$.prompt('Trwa zapisywanie...', { title: 'Proszę czekać' });
|
||||
},
|
||||
success: function(data) {
|
||||
$('.jqibox').remove();
|
||||
var response = jQuery.parseJSON(data);
|
||||
|
||||
if (response.status === 'error')
|
||||
create_error(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('body').on('click', '.category-delete', function() {
|
||||
var category_id = $(this).attr('category-id');
|
||||
|
||||
$.prompt('Na pewno chcesz usunąć wybraną kategorię?', {
|
||||
title: 'Potwierdź?',
|
||||
buttons: { 'Tak': true, 'Nie': false },
|
||||
submit: function(e, v) {
|
||||
if (v === true)
|
||||
document.location.href = '/admin/shop_category/category_delete/id=' + category_id;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false,
|
||||
stop: function() {
|
||||
saveCategoriesOrder();
|
||||
}
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$('body').on('click', '.disclose', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) return;
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which === 1) {
|
||||
var category_id = $(this).parent('div').parent('li').attr('id');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/cookie_categories/',
|
||||
data: {
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = isset($_COOKIE['cookie_categories']) ? @unserialize($_COOKIE['cookie_categories']) : [];
|
||||
if (is_array($array)):
|
||||
foreach ($array as $key => $val):
|
||||
if ($val):
|
||||
?>
|
||||
$('#<?= $key; ?>').children('div').children('button.disclose').click();
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
@@ -8,7 +8,9 @@ ob_start();
|
||||
<? if ( is_array( $this -> categories ) ): foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="category_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
@@ -26,8 +28,8 @@ ob_start();
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-category/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/subcategories-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
@@ -38,126 +40,13 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'pages-list';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Lista kategorii';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Dodaj kategorię',
|
||||
'url' => '/admin/shop_category/category_edit/',
|
||||
'icon' => 'fa-plus-circle',
|
||||
'class' => 'btn-success'
|
||||
]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
|
||||
echo $grid -> draw();
|
||||
$gridId = 'pages-list';
|
||||
$gridTitle = 'Lista kategorii';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'body' ).on( 'click', '.category-delete', function()
|
||||
{
|
||||
var category_id = $( this ).attr( 'category-id' );
|
||||
|
||||
$.prompt( "Na pewno chcesz usunąć wybraną kategorię?",
|
||||
{
|
||||
title: "Potwierdź?",
|
||||
buttons: { "Tak": true, "Nie": false },
|
||||
submit: function( e, v, m, f )
|
||||
{
|
||||
if ( v === true )
|
||||
document.location.href = '/admin/shop_category/category_delete/id=' + category_id;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false,
|
||||
stop: function() {
|
||||
save_categories_order();
|
||||
}
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e)
|
||||
{
|
||||
if ( e.which === 1 )
|
||||
{
|
||||
var category_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_categories',
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_categories' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '#<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
});
|
||||
|
||||
function save_categories_order( )
|
||||
{
|
||||
categories = $( '#sortable' ).nestedSortable( 'toArray', { startDepthCount: 0 } );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'save_categories_order',
|
||||
categories: categories
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$.prompt( 'Trwa zapisywanie...', { title: 'Proszę czekać' } );
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '.jqibox' ).remove();
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'error' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/categories-list-custom-script' ); ?>
|
||||
106
admin/templates/shop-category/category-browse-custom-script.php
Normal file
106
admin/templates/shop-category/category-browse-custom-script.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded'))
|
||||
$li.addClass('sort-collapsed');
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
$('body').on('click', '.disclose', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) return;
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which === 1) {
|
||||
var category_id = $(this).parent('div').parent('li').attr('id');
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/cookie_categories/',
|
||||
data: {
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = isset($_COOKIE['cookie_categories']) ? @unserialize($_COOKIE['cookie_categories']) : [];
|
||||
if (is_array($array)):
|
||||
foreach ($array as $key => $val):
|
||||
if ($val):
|
||||
?>
|
||||
$('#<?= $key; ?>').children('div').children('button.disclose').click();
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
@@ -7,7 +7,9 @@ ob_start();
|
||||
<? if ( is_array( $this -> categories ) ): foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="category_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
@@ -16,8 +18,8 @@ ob_start();
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-category/subcategory-browse-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/subcategory-browse-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
@@ -28,15 +30,14 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'pages-list';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = false;
|
||||
$grid -> title = 'Lista kategorii';
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = $out;
|
||||
|
||||
echo $grid -> draw();
|
||||
$gridId = 'pages-list';
|
||||
$gridTitle = 'Lista kategorii';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<style type="text/css">
|
||||
.mfp-container body.sb-top.sb-top-sm .navbar.navbar-fixed-top + #sidebar_left + #content_wrapper {
|
||||
@@ -54,53 +55,4 @@ echo $grid -> draw();
|
||||
float: none;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function() {
|
||||
$( 'ol.sortable' ).nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function() {
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e) {
|
||||
if ( e.which === 1 ) {
|
||||
var category_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_categories',
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_categories' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '#<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
});
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/category-browse-custom-script' ); ?>
|
||||
@@ -0,0 +1,53 @@
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
$( '#languages-seo' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-seo'
|
||||
});
|
||||
});
|
||||
|
||||
function generate_seo_links( lang, title, category_id )
|
||||
{
|
||||
if ( title === '' )
|
||||
return false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/generateSeoLink/',
|
||||
data: {
|
||||
title: title,
|
||||
category_id: category_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
var response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#seo_link_' + lang ).val( response.seo_link );
|
||||
else
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@@ -1,65 +1,5 @@
|
||||
<script type="text/javascript" src="/libraries/ckeditor/ckeditor.js"></script>
|
||||
<script type="text/javascript" src="/libraries/ckeditor/adapters/jquery.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
disable_menu();
|
||||
|
||||
$( '#settings-tabs' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'settings-tabs',
|
||||
type: 'vertical'
|
||||
});
|
||||
|
||||
$( '#languages-main' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
|
||||
$( '#languages-seo' ).easyResponsiveTabs({
|
||||
width: 'auto',
|
||||
fit: true,
|
||||
tabidentify: 'languages-seo'
|
||||
});
|
||||
|
||||
$( '#page_type' ).trigger( 'change' );
|
||||
});
|
||||
|
||||
function generate_seo_links( lang, title, category_id )
|
||||
{
|
||||
if ( title === '' )
|
||||
return false;
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'generate_seo_link',
|
||||
title: title,
|
||||
category_id: category_id
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'ok' )
|
||||
$( '#seo_link_' + lang ).val( response.seo_link );
|
||||
else
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?
|
||||
global $db;
|
||||
|
||||
@@ -67,7 +7,7 @@ ob_start();
|
||||
?>
|
||||
<div id="settings-tabs">
|
||||
<ul class="resp-tabs-list settings-tabs">
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-file"></i>Treść</li>
|
||||
<li><i class="fa fa-wrench"></i>Ustawienia</li>
|
||||
<li><i class="fa fa-globe"></i>SEO</li>
|
||||
</ul>
|
||||
@@ -77,7 +17,7 @@ ob_start();
|
||||
<ul class="resp-tabs-list languages-main htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<li><? if ( $lg['id'] == $this->dlang ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
@@ -85,7 +25,7 @@ ob_start();
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Nazwa kategorii',
|
||||
'name' => 'title[' . $lg['id'] . ']',
|
||||
@@ -94,7 +34,7 @@ ob_start();
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Opis kategorii',
|
||||
'name' => 'text[' . $lg['id'] . ']',
|
||||
@@ -103,16 +43,16 @@ ob_start();
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Opis kategorii (rozwinięcie)',
|
||||
'label' => 'Opis kategorii (rozwinięcie)',
|
||||
'name' => 'text_hidden[' . $lg['id'] . ']',
|
||||
'id' => 'text_hidden_' . $lg['id'],
|
||||
'value' => $this -> category['languages'][ $lg['id'] ]['text_hidden'],
|
||||
'inline' => true
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea( [
|
||||
<?= \Shared\Html\Html::textarea( [
|
||||
'label' => 'Dodatkowy tekst (nad produktami)',
|
||||
'name' => 'additional_text[' . $lg['id'] . ']',
|
||||
'id' => 'additional_text_' . $lg['id'],
|
||||
@@ -135,25 +75,25 @@ ob_start();
|
||||
</div>
|
||||
</div>
|
||||
<div style="padding: 15px;">
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Aktywna',
|
||||
'name' => 'status',
|
||||
'checked' => $this -> category['status'] == 1 or !$this -> category['id'] ? true : false
|
||||
)
|
||||
);?>
|
||||
<?= \Html::select(
|
||||
<?= \Shared\Html\Html::select(
|
||||
[
|
||||
'label' => 'Sortowanie produktów',
|
||||
'label' => 'Sortowanie produktĂłw',
|
||||
'name' => 'sort_type',
|
||||
'id' => 'sort_type',
|
||||
'values' => \admin\factory\ShopCategory::$_sort_types,
|
||||
'values' => is_array( $this -> sort_types ) ? $this -> sort_types : [],
|
||||
'value' => $this -> category['sort_type']
|
||||
]
|
||||
);?>
|
||||
<?= \Html::input_switch(
|
||||
<?= \Shared\Html\Html::input_switch(
|
||||
array(
|
||||
'label' => 'Wyświetlić podkategorie',
|
||||
'label' => 'Wyświetlić podkategorie',
|
||||
'name' => 'view_subcategories',
|
||||
'checked' => $this -> category['view_subcategories'] == 1 ? true : false
|
||||
)
|
||||
@@ -164,7 +104,7 @@ ob_start();
|
||||
<ul class="resp-tabs-list languages-seo htabs">
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<li><? if ( $lg['id'] == \front\factory\Languages::default_language() ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<li><? if ( $lg['id'] == $this->dlang ) echo '<i class="fa fa-star fa-lg text-system" title="Język domyślny"></i> ';?><?= $lg['name'];?></a></li>
|
||||
<? endif;?>
|
||||
<? endforeach; endif;?>
|
||||
</ul>
|
||||
@@ -172,7 +112,7 @@ ob_start();
|
||||
<? if ( is_array( $this -> languages ) ): foreach ( $this -> languages as $lg ):?>
|
||||
<? if ( $lg['status'] ):?>
|
||||
<div>
|
||||
<?= \Html::input_icon(
|
||||
<?= \Shared\Html\Html::input_icon(
|
||||
array(
|
||||
'label' => 'Link SEO',
|
||||
'name' => 'seo_link[' . $lg['id'] . ']',
|
||||
@@ -182,15 +122,15 @@ ob_start();
|
||||
'icon_js' => 'generate_seo_links( "' . $lg['id'] . '", $( "#title_' . $lg['id'] . '" ).val(), ' . (int)$this -> category['id'] . ' );'
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Tytuł kategorii (h1)',
|
||||
'label' => 'Tytuł kategorii (h1)',
|
||||
'name' => 'category_title[' . $lg['id'] . ']',
|
||||
'id' => 'category_title_' . $lg['id'],
|
||||
'value' => $this -> category['languages' ][ $lg['id'] ]['category_title']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::input(
|
||||
<?= \Shared\Html\Html::input(
|
||||
array(
|
||||
'label' => 'Meta title',
|
||||
'name' => 'meta_title[' . $lg['id'] . ']',
|
||||
@@ -198,7 +138,7 @@ ob_start();
|
||||
'value' => $this -> category['languages'][ $lg['id'] ]['meta_title']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Meta description',
|
||||
'name' => 'meta_description[' . $lg['id'] . ']',
|
||||
@@ -206,7 +146,7 @@ ob_start();
|
||||
'value' => $this -> category['languages'][ $lg['id'] ]['meta_description']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::textarea(
|
||||
<?= \Shared\Html\Html::textarea(
|
||||
array(
|
||||
'label' => 'Meta keywords',
|
||||
'name' => 'meta_keywords[' . $lg['id'] . ']',
|
||||
@@ -214,9 +154,9 @@ ob_start();
|
||||
'value' => $this -> category['languages'][ $lg['id'] ]['meta_keywords']
|
||||
)
|
||||
);?>
|
||||
<?= \Html::select(
|
||||
<?= \Shared\Html\Html::select(
|
||||
array(
|
||||
'label' => 'Blokuj indeksację',
|
||||
'label' => 'Blokuj indeksacjÄ™',
|
||||
'name' => 'noindex[' . $lg['id'] . ']',
|
||||
'id' => 'noindex_' . $lg['id'],
|
||||
'values' => array(
|
||||
@@ -237,30 +177,18 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> id = 'category-edit';
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> title = 'Edycja kategorii';
|
||||
$grid -> fields = [
|
||||
[
|
||||
'db' => 'id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> category['id']
|
||||
],
|
||||
[
|
||||
'db' => 'parent_id',
|
||||
'type' => 'hidden',
|
||||
'value' => $this -> category['id'] ? $this -> category['parent_id'] : $this -> pid
|
||||
]
|
||||
];
|
||||
$grid -> actions = [
|
||||
'save' => [ 'url' => '/admin/shop_category/save/', 'back_url' => '/admin/shop_category/view_list/' ],
|
||||
'cancel' => [ 'url' => '/admin/shop_category/view_list/' ]
|
||||
];
|
||||
$grid -> external_code = $out;
|
||||
$grid -> persist_edit = true;
|
||||
$grid -> id_param = 'id';
|
||||
$gridId = 'category-edit';
|
||||
$gridTitle = 'Edycja kategorii';
|
||||
$gridSaveUrl = '/admin/shop_category/save/';
|
||||
$gridBackUrl = '/admin/shop_category/view_list/';
|
||||
$gridHidden = [
|
||||
['name' => 'id', 'value' => $this -> category['id']],
|
||||
['name' => 'parent_id', 'value' => $this -> category['id'] ? $this -> category['parent_id'] : $this -> pid]
|
||||
];
|
||||
$gridContent = $out;
|
||||
$gridPersist = true;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/category-edit-custom-script' ); ?>
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
@@ -0,0 +1,62 @@
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 6px;
|
||||
color: #666;
|
||||
cursor: move;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
function saveProductsOrder() {
|
||||
var products = $('ol.sortable').nestedSortable('toArray', { startDepthCount: 0 });
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/save_products_order/',
|
||||
data: {
|
||||
category_id: <?= (int)$this->category_id; ?>,
|
||||
products: products
|
||||
},
|
||||
beforeSend: function() {
|
||||
$.prompt('Trwa zapisywanie...', { title: 'Proszę czekać' });
|
||||
},
|
||||
success: function(data) {
|
||||
$('.jqibox').remove();
|
||||
var response = jQuery.parseJSON(data);
|
||||
|
||||
if (response.status === 'error')
|
||||
create_error(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 1,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
stop: function() {
|
||||
saveProductsOrder();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -9,7 +9,7 @@ ob_start();
|
||||
{
|
||||
?>
|
||||
<li id="list_<?= $product['product_id'];?>">
|
||||
<div class="content <? if ( !$product['status'] ) echo 'text-danger';?>"><span class="disclose"><span></span></span> <?= $product['name'];?></div>
|
||||
<div class="content <? if ( !$product['status'] ) echo 'text-danger';?>"><button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Przesuń"><i class="fa fa-arrows"></i></button> <?= $product['name'];?></div>
|
||||
</li>
|
||||
<?
|
||||
}
|
||||
@@ -18,72 +18,13 @@ ob_start();
|
||||
<?
|
||||
$out = ob_get_clean();
|
||||
|
||||
$grid = new \gridEdit;
|
||||
$grid -> gdb_opt = $gdb;
|
||||
$grid -> include_plugins = true;
|
||||
$grid -> default_buttons = false;
|
||||
$grid -> external_code = $out;
|
||||
$grid -> title = 'Lista produktów';
|
||||
$grid -> buttons = [
|
||||
[
|
||||
'label' => 'Wstecz',
|
||||
'url' => '/admin/shop_category/view_list/',
|
||||
'icon' => 'fa-reply',
|
||||
'class' => 'btn-dark'
|
||||
]
|
||||
];
|
||||
echo $grid -> draw();
|
||||
$gridId = 'category-products';
|
||||
$gridTitle = 'Lista produktów';
|
||||
$gridSaveUrl = '';
|
||||
$gridBackUrl = '';
|
||||
$gridHidden = [];
|
||||
$gridContent = $out;
|
||||
$gridPersist = false;
|
||||
include __DIR__ . '/../components/grid-edit-replacement.php';
|
||||
?>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 1,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
save_articles_order: true
|
||||
});
|
||||
});
|
||||
|
||||
function save_articles_order()
|
||||
{
|
||||
products = $( 'ol.sortable' ).nestedSortable( 'toArray', { startDepthCount: 0 } );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data:
|
||||
{
|
||||
a: 'save_products_order',
|
||||
category_id: <?= $this -> category_id;?>,
|
||||
products: products
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$.prompt( 'Trwa zapisywanie...', { title: 'Proszę czekać' } );
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '.jqibox' ).remove();
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status === 'error' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/category-products-custom-script', [ 'category_id' => $this -> category_id ] ); ?>
|
||||
@@ -3,7 +3,9 @@
|
||||
<? foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="list_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
@@ -23,8 +25,8 @@
|
||||
<? endif;?>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-category/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/subcategories-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
<? foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="list_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<div class="btn-group ml20 pull-right">
|
||||
@@ -12,8 +14,8 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-category/subcategory-browse-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-category/subcategory-browse-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
|
||||
@@ -1,48 +1,9 @@
|
||||
<div class="site-title"><?php echo $this->name . ' ' . $this->surname; ?></div>
|
||||
<div class="site-subtitle">Łączne zakupy w wysokości: <?php echo $this->total_spent; ?> zł</div>
|
||||
<div class="site-title"><?= htmlspecialchars($this->name . ' ' . $this->surname, ENT_QUOTES, 'UTF-8'); ?></div>
|
||||
<div class="site-subtitle">
|
||||
Łączne zakupy: <?= number_format((float)$this->total_spent, 2, '.', ' '); ?> zl,
|
||||
liczba zamówień: <?= (int)$this->total_orders; ?>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<br />
|
||||
|
||||
<?
|
||||
global $gdb;
|
||||
$grid = new \grid( 'pp_shop_orders' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
|
||||
$grid->src = $this->orders_info;
|
||||
|
||||
$grid -> debug = true;
|
||||
$grid -> order = [ 'column' => 'date_order', 'type' => 'DESC' ];
|
||||
$grid -> search = [];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
], [
|
||||
'name' => 'Data zamówienia',
|
||||
'db' => 'date_order',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 175px;' ],
|
||||
], [
|
||||
'name' => 'Wartość',
|
||||
'db' => 'summary',
|
||||
'td' => [ 'class' => 'g-right' ],
|
||||
'th' => [ 'class' => 'g-right', 'style' => 'width: 150px;' ],
|
||||
'php' => 'echo number_format( "[summary]", 2, ".", " " ) . " zł";',
|
||||
], [
|
||||
'name' => 'Typ płatności',
|
||||
'db' => 'payment_method',
|
||||
'th' => [ 'style' => 'width: 350px;' ],
|
||||
], [
|
||||
'name' => 'Rodzaj transportu',
|
||||
'db' => 'transport',
|
||||
'th' => [ 'style' => 'width: 350px;' ],
|
||||
], [
|
||||
'name' => 'Wiadomość',
|
||||
'db' => 'message',
|
||||
],
|
||||
];
|
||||
|
||||
echo $grid -> draw();
|
||||
?>
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->ordersTable]); ?>
|
||||
@@ -1,84 +1,2 @@
|
||||
<div class="site-title">Lista klientów</div>
|
||||
<?php
|
||||
global $gdb;
|
||||
|
||||
$grid = new \grid( '__shop_clients' );
|
||||
$grid -> gdb_opt = $gdb;
|
||||
|
||||
$grid->sql = "
|
||||
SELECT
|
||||
MAX( client_id ) AS client_id, client_name, client_surname, client_email, MAX( client_phone ) AS client_phone, MAX( client_city ) AS client_city, COUNT(*) AS total_orders, SUM(summary) AS total_spent,
|
||||
CASE
|
||||
WHEN MAX(client_id) IS NOT NULL
|
||||
THEN 'Zarejestrowany'
|
||||
ELSE
|
||||
'Gość'
|
||||
END AS client_type
|
||||
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_name, client_surname, client_email
|
||||
ORDER BY
|
||||
CASE
|
||||
WHEN MAX(client_id) IS NOT NULL THEN 1
|
||||
ELSE 2
|
||||
END,
|
||||
client_name ASC";
|
||||
$grid -> sql_count = "
|
||||
SELECT COUNT(*)
|
||||
FROM ( SELECT client_name, client_surname, client_email
|
||||
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_name, client_surname, client_email
|
||||
) AS unique_clients";
|
||||
|
||||
$grid -> order = [ 'column' => 'date_order', 'type' => 'DESC' ];
|
||||
$grid -> search = [];
|
||||
$grid -> columns_view = [
|
||||
[
|
||||
'name' => 'Lp.',
|
||||
'th' => [ 'class' => 'g-lp' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'autoincrement' => true
|
||||
], [
|
||||
'name' => 'Typ klienta',
|
||||
'db' => 'client_type',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 100px;' ],
|
||||
], [
|
||||
'name' => 'Nazwisko, imię',
|
||||
'th' => [ 'style' => 'width: 225px;' ],
|
||||
'php' => 'echo "[client_surname]" . " " . "[client_name]";',
|
||||
], [
|
||||
'name' => 'Email',
|
||||
'db' => 'client_email',
|
||||
'th' => [ 'style' => 'width: 150px;' ],
|
||||
],
|
||||
[
|
||||
'name' => 'Telefon',
|
||||
'db' => 'client_phone',
|
||||
'th' => [ 'style' => 'width: 150px;' ],
|
||||
], [
|
||||
'name' => 'Miasto',
|
||||
'db' => 'client_city',
|
||||
'th' => [ 'style' => 'width: 150px;' ],
|
||||
], [
|
||||
'name' => 'Wartość zamówień',
|
||||
'db' => 'total_spent',
|
||||
'td' => [ 'class' => 'g-right' ],
|
||||
'th' => [ 'class' => 'g-right', 'style' => 'width: 150px;' ],
|
||||
'php' => 'echo number_format( "[total_spent]", 2, ".", " " ) . " zł";',
|
||||
], [
|
||||
'name' => 'Ilosc zamówień',
|
||||
'db' => 'total_orders',
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ],
|
||||
'php' => 'echo "<a href=\'/admin/shop_clients/clients_details/?name=[client_name]&surname=[client_surname]&email=[client_email]&total_spent=[total_spent]\'>[total_orders]</a>";'
|
||||
], [
|
||||
'name' => 'Akcje',
|
||||
'th' => [ 'class' => 'g-center', 'style' => 'width: 100px;' ],
|
||||
'td' => [ 'class' => 'g-center' ],
|
||||
'php' => 'echo "<a href=\'/admin/shop_clients/clients_details/?name=[client_name]&surname=[client_surname]&email=[client_email]&total_spent=[total_spent]\'>zobacz zamówienia</a>";',
|
||||
]
|
||||
];
|
||||
|
||||
echo $grid -> draw();
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
19
admin/templates/shop-coupon/coupon-categories-selector.php
Normal file
19
admin/templates/shop-coupon/coupon-categories-selector.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$label = trim((string)($this->label ?? 'Kategorie'));
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$selectedIds = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
?>
|
||||
<div class="form-group row js-coupon-row js-coupon-row-categories">
|
||||
<label class="col-lg-4 control-label"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8'); ?>:</label>
|
||||
<div class="col-lg-8">
|
||||
<div class="coupon-categories-box">
|
||||
<?= \Shared\Tpl\Tpl::view('shop-coupon/coupon-categories-tree', [
|
||||
'categories' => $categories,
|
||||
'selectedIds' => $selectedIds,
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
68
admin/templates/shop-coupon/coupon-categories-tree.php
Normal file
68
admin/templates/shop-coupon/coupon-categories-tree.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$selectedRaw = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
$selected = [];
|
||||
foreach ($selectedRaw as $value) {
|
||||
$id = (int)$value;
|
||||
if ($id > 0) {
|
||||
$selected[$id] = true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($categories)): ?>
|
||||
<ol class="coupon-categories-tree">
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<?php
|
||||
$categoryId = (int)($category['id'] ?? 0);
|
||||
if ($categoryId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = trim((string)($category['title'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = 'Kategoria #' . $categoryId;
|
||||
}
|
||||
|
||||
$isActive = (int)($category['status'] ?? 0) === 1;
|
||||
$children = is_array($category['subcategories'] ?? null) ? $category['subcategories'] : [];
|
||||
$hasChildren = !empty($children);
|
||||
?>
|
||||
<li class="coupon-category-item<?= $hasChildren ? ' has-children is-collapsed' : ''; ?>">
|
||||
<div class="coupon-category-row">
|
||||
<?php if ($hasChildren): ?>
|
||||
<button type="button" class="coupon-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<span class="coupon-tree-spacer"></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$isActive): ?>
|
||||
<i class="fa fa-ban text-danger" title="Kategoria nieaktywna"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<label class="coupon-category-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="g-checkbox"
|
||||
name="<?= htmlspecialchars($inputName, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= $categoryId; ?>"
|
||||
<?= isset($selected[$categoryId]) ? 'checked="checked"' : ''; ?>
|
||||
/>
|
||||
<span><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php if ($hasChildren): ?>
|
||||
<?= \Shared\Tpl\Tpl::view('shop-coupon/coupon-categories-tree', [
|
||||
'categories' => $children,
|
||||
'selectedIds' => array_keys($selected),
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
109
admin/templates/shop-coupon/coupon-edit-custom-script.php
Normal file
109
admin/templates/shop-coupon/coupon-edit-custom-script.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<style type="text/css">
|
||||
.coupon-categories-box {
|
||||
max-height: 420px;
|
||||
overflow: auto;
|
||||
border: 1px solid #d6d6d6;
|
||||
border-radius: 4px;
|
||||
padding: 8px 10px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.coupon-categories-tree {
|
||||
margin: 0;
|
||||
padding: 0 0 0 16px;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.coupon-category-item {
|
||||
margin: 2px 0;
|
||||
}
|
||||
|
||||
.coupon-category-item.is-collapsed > ol {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.coupon-category-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle,
|
||||
.coupon-tree-spacer {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle {
|
||||
cursor: pointer;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.coupon-tree-toggle:focus,
|
||||
.coupon-tree-toggle:active,
|
||||
.coupon-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.coupon-category-item:not(.is-collapsed) > .coupon-category-row .coupon-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
.coupon-category-label {
|
||||
margin: 0;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.coupon-category-row .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) {
|
||||
return;
|
||||
}
|
||||
|
||||
$(document).off('click.shopCouponTree', '.coupon-tree-toggle');
|
||||
$(document).on('click.shopCouponTree', '.coupon-tree-toggle', function(e) {
|
||||
e.preventDefault();
|
||||
var $item = $(this).closest('.coupon-category-item');
|
||||
$item.toggleClass('is-collapsed');
|
||||
$(this).attr('aria-expanded', $item.hasClass('is-collapsed') ? 'false' : 'true');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
function initCouponCategoryCheckboxes() {
|
||||
if (!$.fn || typeof $.fn.iCheck !== 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
$('.coupon-categories-box .g-checkbox').each(function() {
|
||||
var $checkbox = $(this);
|
||||
if ($checkbox.parent().hasClass('icheckbox_minimal-blue')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$checkbox.iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
initCouponCategoryCheckboxes();
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
3
admin/templates/shop-coupon/coupon-edit-new.php
Normal file
3
admin/templates/shop-coupon/coupon-edit-new.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
<?= \Shared\Tpl\Tpl::view('shop-coupon/coupon-edit-custom-script'); ?>
|
||||
|
||||
2
admin/templates/shop-coupon/coupons-list.php
Normal file
2
admin/templates/shop-coupon/coupons-list.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
521
admin/templates/shop-order/order-details-custom-script.php
Normal file
521
admin/templates/shop-order/order-details-custom-script.php
Normal 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>
|
||||
@@ -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>
|
||||
— 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'];?> × <?= \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),
|
||||
]);?>
|
||||
244
admin/templates/shop-order/order-edit-custom-script.php
Normal file
244
admin/templates/shop-order/order-edit-custom-script.php
Normal 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>
|
||||
@@ -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>
|
||||
|
|
||||
<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');?>
|
||||
2
admin/templates/shop-order/orders-list.php
Normal file
2
admin/templates/shop-order/orders-list.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<div class="site-title">Lista zamówień</div>
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
@@ -36,7 +36,7 @@ ob_start();
|
||||
'id' => 'img',
|
||||
'value' => $this -> producer['img'],
|
||||
'icon_content' => 'przeglądaj',
|
||||
'icon_js' => "window.open ( 'http://" . $_SERVER['SERVER_NAME'] . "/libraries/filemanager-9.14.2/dialog.php?type=1&popup=1&field_id=img&akey=" . $rfmAkeyJS . "', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
|
||||
'icon_js' => "window.open ( '/libraries/filemanager-9.14.2/dialog.php?type=1&popup=1&field_id=img&akey=" . $rfmAkeyJS . "', 'mywindow', 'location=1,status=1,scrollbars=1, width=1100,height=700');"
|
||||
] );
|
||||
?>
|
||||
</div>
|
||||
@@ -177,4 +177,4 @@ echo $grid -> draw();
|
||||
tabidentify: 'languages-main'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
1
admin/templates/shop-producer/producer-edit.php
Normal file
1
admin/templates/shop-producer/producer-edit.php
Normal file
@@ -0,0 +1 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
1
admin/templates/shop-producer/producers-list.php
Normal file
1
admin/templates/shop-producer/producers-list.php
Normal file
@@ -0,0 +1 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
@@ -0,0 +1,64 @@
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.css">
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.default.css">
|
||||
<script type="text/javascript" src="/libraries/selectize/js/standalone/selectize.js"></script>
|
||||
<script type="text/javascript">
|
||||
(function($) {
|
||||
if (!$) return;
|
||||
|
||||
$(function() {
|
||||
$('#set_products_id').selectize({
|
||||
maxItems: 999,
|
||||
plugins: ['remove_button']
|
||||
});
|
||||
|
||||
var $form = $('#shop-product-set-edit');
|
||||
if ($form.length) {
|
||||
var origSerialize = $form.data('origSerialize');
|
||||
if (!origSerialize) {
|
||||
$form.on('submit', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
}
|
||||
|
||||
$form.find('[data-action="save"]').off('click.productSetSave').on('click.productSetSave', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
var formData = $form.serializeArray();
|
||||
|
||||
var selectedProducts = $('#set_products_id').val();
|
||||
if (selectedProducts && selectedProducts.length) {
|
||||
for (var i = 0; i < selectedProducts.length; i++) {
|
||||
formData.push({ name: 'set_products_id[]', value: selectedProducts[i] });
|
||||
}
|
||||
}
|
||||
|
||||
var actionUrl = $(this).data('url') || $form.attr('action');
|
||||
var backUrl = $(this).data('back-url') || '/admin/shop_product_sets/list/';
|
||||
|
||||
$.ajax({
|
||||
url: actionUrl,
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if (response.success || response.status === 'ok') {
|
||||
var msg = response.message || response.msg || 'Zapisano.';
|
||||
$('<div class="alert alert-success">' + msg + '</div>').insertBefore($form).delay(2000).fadeOut();
|
||||
|
||||
if (response.id && !$form.find('input[name="id"]').val()) {
|
||||
$form.find('input[name="id"]').val(response.id);
|
||||
}
|
||||
} else {
|
||||
var errorMsg = (response.errors && response.errors.general) || response.msg || 'Wystapil blad.';
|
||||
$('<div class="alert alert-danger">' + errorMsg + '</div>').insertBefore($form).delay(3000).fadeOut();
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$('<div class="alert alert-danger">Blad komunikacji z serwerem.</div>').insertBefore($form).delay(3000).fadeOut();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
})(window.jQuery);
|
||||
</script>
|
||||
2
admin/templates/shop-product-sets/product-set-edit.php
Normal file
2
admin/templates/shop-product-sets/product-set-edit.php
Normal file
@@ -0,0 +1,2 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/form-edit', ['form' => $this->form]); ?>
|
||||
<?= \Shared\Tpl\Tpl::view('shop-product-sets/product-set-edit-custom-script'); ?>
|
||||
1
admin/templates/shop-product-sets/product-sets-list.php
Normal file
1
admin/templates/shop-product-sets/product-sets-list.php
Normal file
@@ -0,0 +1 @@
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
158
admin/templates/shop-product/mass-edit-custom-script.php
Normal file
158
admin/templates/shop-product/mass-edit-custom-script.php
Normal file
@@ -0,0 +1,158 @@
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div.content',
|
||||
cancel: 'input,textarea,button,select,option,.icheckbox_minimal-blue,.iradio_minimal-blue,ins.iCheck-helper',
|
||||
helper: 'original',
|
||||
items: 'li',
|
||||
opacity: .6,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 25,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div.content',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
isAllowed: function() { return false; }
|
||||
});
|
||||
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $disclose = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded'))
|
||||
$li.addClass('sort-collapsed');
|
||||
$li.addClass('sort-branch');
|
||||
$disclose.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
$disclose.show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$disclose.attr('aria-expanded', 'false');
|
||||
$disclose.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
// Inicjalizacja iCheck — osobno dla produktów i kategorii
|
||||
if ($.fn && typeof $.fn.iCheck === 'function') {
|
||||
$('.product-item .g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
$('#sortable input.g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
}
|
||||
|
||||
$('body').on('click', '.disclose', function() {
|
||||
var $li = $(this).closest('li');
|
||||
if (!$li.hasClass('sort-branch')) return;
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
this.blur();
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which === 1) {
|
||||
var category_id = $(this).parent('div').parent('li').attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/cookie_categories/',
|
||||
data: { category_id: category_id }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = isset($_COOKIE['cookie_categories']) ? @unserialize($_COOKIE['cookie_categories']) : [];
|
||||
if (is_array($array)):
|
||||
foreach ($array as $key => $val):
|
||||
if ($val):
|
||||
?>
|
||||
$('#<?= $key; ?>').children('div').children('button.disclose').click();
|
||||
<?php
|
||||
endif;
|
||||
endforeach;
|
||||
endif;
|
||||
?>
|
||||
|
||||
$('.select-all').click(function() {
|
||||
$('.product-item .g-checkbox').iCheck('check');
|
||||
});
|
||||
|
||||
$('.deselect-all').click(function() {
|
||||
$('.product-item .g-checkbox').iCheck('uncheck');
|
||||
});
|
||||
|
||||
$('body').on('click', 'span[field-id="discount_percent"]', function() {
|
||||
$('.ajax-msg').remove();
|
||||
var discount_percent = $('#discount_percent').val();
|
||||
var products = [];
|
||||
$('input[name="products[]"]:checked').each(function() {
|
||||
products.push($(this).val());
|
||||
});
|
||||
|
||||
function saveProduct(index) {
|
||||
if (index < products.length) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/mass_edit_save/',
|
||||
type: 'post',
|
||||
data: { discount_percent: discount_percent, products: [products[index]] },
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if (data.status == 'ok') {
|
||||
if (data.price_brutto_promo)
|
||||
$('label[for="product' + products[index] + '"]').append(' <span class="ajax-msg text-success">cena promocyjna: ' + data.price_brutto_promo + ' zł, cena zwykła: ' + data.price_brutto + '</span>');
|
||||
else
|
||||
$('label[for="product' + products[index] + '"]').append(' <span class="ajax-msg text-success">cena zwykła: ' + data.price_brutto + '</span>');
|
||||
} else {
|
||||
alert('Błąd przy zapisie produktu: ' + products[index]);
|
||||
}
|
||||
saveProduct(index + 1);
|
||||
},
|
||||
error: function() {
|
||||
alert('Błąd przy zapisie produktu: ' + products[index]);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.alert({
|
||||
title: 'Informacja',
|
||||
content: 'Zakończono zapisywanie produktów',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'cancel|10000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (products.length > 0) {
|
||||
saveProduct(0);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@@ -1,4 +1,56 @@
|
||||
<div class="panel mb50 panel-primary">
|
||||
<style type="text/css">
|
||||
.layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layout-tree-toggle:focus,
|
||||
.layout-tree-toggle:active,
|
||||
.layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
|
||||
#mass-edit-panel .product-item {
|
||||
margin-bottom: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
#mass-edit-panel .product-item label {
|
||||
cursor: pointer;
|
||||
font-weight: normal;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
#mass-edit-panel .content_menu .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
#mass-edit-panel .icheckbox_minimal-blue {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css">
|
||||
|
||||
<div class="panel mb50 panel-primary" id="mass-edit-panel">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Masowa edycja produktów</span>
|
||||
</div>
|
||||
@@ -8,7 +60,7 @@
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div class="form-group mb10">
|
||||
<label class="col-lg-3 control-label" for="inputDefault">Ustaw cenę promocyjną (minus X procent)</label>
|
||||
<label class="col-lg-3 control-label" for="discount_percent">Ustaw cenę promocyjną (minus X procent)</label>
|
||||
<div class="col-lg-9">
|
||||
<div class="bs-component">
|
||||
<div class="input-group">
|
||||
@@ -24,200 +76,39 @@
|
||||
<div class="panel-body">
|
||||
<div class="row">
|
||||
<div class="col-lg-6">
|
||||
<? foreach ( $this -> products as $key => $product ):?>
|
||||
<div class="checkbox-custom fill mb5">
|
||||
<input type="checkbox" name="products[]" id="product<?= $key;?>" value="<?= $key;?>">
|
||||
<label for="product<?= $key;?>"><?= $product;?></label>
|
||||
<?php if ( is_array( $this->products ) ): foreach ( $this->products as $key => $product ): ?>
|
||||
<div class="product-item">
|
||||
<input type="checkbox" class="g-checkbox" name="products[]" id="product<?= $key; ?>" value="<?= $key; ?>">
|
||||
<label for="product<?= $key; ?>"><?= htmlspecialchars( $product ); ?></label>
|
||||
</div>
|
||||
<? endforeach;?>
|
||||
<?php endforeach; endif; ?>
|
||||
</div>
|
||||
<div class="col-lg-6">
|
||||
<div class="menu_sortable">
|
||||
<ol class="sortable" id="sortable">
|
||||
<? if ( is_array( $this -> categories ) ): foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category['id'];?>" class="category_<?= $category['id'];?>" category="<?= $category['id'];?>">
|
||||
<?php if ( is_array( $this->categories ) ): foreach ( $this->categories as $category ): ?>
|
||||
<li id="list_<?= $category['id']; ?>" class="category_<?= $category['id']; ?>" category="<?= $category['id']; ?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<? if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<b><?= $category['languages'][$this -> dlang]['title'];?></b>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php if ( !$category['status'] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>'; ?>
|
||||
<input type="checkbox" class="g-checkbox" name="mass_categories[]" value="<?= $category['id']; ?>" />
|
||||
<b><?= $category['languages'][$this->dlang]['title']; ?></b>
|
||||
</div>
|
||||
<?= \Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category['id'] ),
|
||||
'level' => $this -> level + 1,
|
||||
'dlang' => $this -> dlang
|
||||
] );?>
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category['id'] ),
|
||||
'level' => ($this->level ?? 0) + 1,
|
||||
'dlang' => $this->dlang,
|
||||
'name' => 'mass_categories[]'
|
||||
] ); ?>
|
||||
</li>
|
||||
<? endforeach; endif;?>
|
||||
<?php endforeach; endif; ?>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( document ).ready( function()
|
||||
{
|
||||
$( 'ol.sortable' ).nestedSortable(
|
||||
{
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 4,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false
|
||||
});
|
||||
|
||||
$( '.disclose' ).on( 'click', function()
|
||||
{
|
||||
$( this ).closest( 'li' ).toggleClass( 'sort-collapsed' ).toggleClass( 'sort-expanded' );
|
||||
});
|
||||
|
||||
$( '.disclose' ).mousedown( function(e) {
|
||||
if ( e.which === 1 ) {
|
||||
var category_id = $( this ).parent( 'div' ).parent( 'li' ).attr( 'id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/ajax.php',
|
||||
data: {
|
||||
a: 'cookie_categories',
|
||||
category_id: category_id
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
<?php
|
||||
$array = unserialize( $_COOKIE[ 'cookie_categories' ] );
|
||||
if ( is_array( $array ) ): foreach ( $array as $key => $val ):
|
||||
if ( $val ):
|
||||
?>$( '#<?= $key;?>' ).children( 'div' ).children( 'span.disclose' ).click();<?
|
||||
endif;
|
||||
endforeach; endif;
|
||||
?>
|
||||
|
||||
$( '.select-all' ).click( function()
|
||||
{
|
||||
$( '.checkbox-custom input' ).prop( 'checked', true );
|
||||
});
|
||||
|
||||
$( '.deselect-all' ).click( function()
|
||||
{
|
||||
$( '.checkbox-custom input' ).prop( 'checked', false );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '#sortable input[type="checkbox"]', function(){
|
||||
if ( $( this ).is( ':checked' ) ) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/get_products_by_category/',
|
||||
type: 'post',
|
||||
data: {
|
||||
category_id: $( this ).val()
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok' ) {
|
||||
$.each( data.products, function( key, value ) {
|
||||
$( '#product' + value ).prop( 'checked', true );
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/get_products_by_category/',
|
||||
type: 'post',
|
||||
data: {
|
||||
category_id: $( this ).val()
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok' ) {
|
||||
$.each( data.products, function( key, value ) {
|
||||
$( '#product' + value ).prop( 'checked', false );
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', 'span[field-id="discount_percent"]', function()
|
||||
{
|
||||
$( '.ajax-msg' ).remove();
|
||||
var discount_percent = $( '#discount_percent' ).val();
|
||||
var products = [];
|
||||
$( 'input[name="products[]"]:checked' ).each( function(){
|
||||
products.push( $( this ).val() );
|
||||
});
|
||||
|
||||
function saveProduct(index) {
|
||||
if (index < products.length) {
|
||||
$.ajax({
|
||||
url: '/admin/shop_product/mass_edit_save/',
|
||||
type: 'post',
|
||||
data: {
|
||||
discount_percent: discount_percent,
|
||||
products: [products[index]]
|
||||
},
|
||||
success: function(data) {
|
||||
data = JSON.parse(data);
|
||||
if ( data.status == 'ok') {
|
||||
if ( data.price_brutto_promo )
|
||||
$( 'label[for="product' + products[index] + '"]' ).append( ' <span class="ajax-msg text-success">cena promocyjna: ' + data.price_brutto_promo + ' zł, cena zwykła: ' + data.price_brutto + '</span>' );
|
||||
else
|
||||
$( 'label[for="product' + products[index] + '"]' ).append( ' <span class="ajax-msg text-success">cena zwykła: ' + data.price_brutto + '</span>' );
|
||||
} else {
|
||||
alert('Błąd przy zapisie produktu: ', products[index]);
|
||||
}
|
||||
// Wywołanie dla następnego produktu
|
||||
saveProduct(index + 1);
|
||||
},
|
||||
error: function(err) {
|
||||
alert('Błąd przy zapisie produktu: ', err);
|
||||
// Można dodać obsługę błędu lub przerwać proces
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$.alert({
|
||||
title: 'Informacja',
|
||||
content: 'Zakończono zapisywanie produktów',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-close',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
autoClose: 'confirm|10000',
|
||||
useBootstrap: false,
|
||||
theme: 'modern',
|
||||
autoClose: 'cancel|10000',
|
||||
icon: 'fa fa-exclamation',
|
||||
buttons:
|
||||
{
|
||||
confirm:
|
||||
{
|
||||
text: 'Zamknij',
|
||||
btnClass: 'btn-blue',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (products.length > 0) {
|
||||
saveProduct(0); // Rozpoczęcie od pierwszego produktu
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view( 'shop-product/mass-edit-custom-script' ); ?>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="g-container" data="table:order-details">
|
||||
<div class="panel panel-info panel-border top">
|
||||
<div class="panel-heading">
|
||||
<span class="panel-title">Kobinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
|
||||
<span class="panel-title">Kombinacje produktu: <?= $this -> product['languages'][ $this -> default_language ]['name'];?></span>
|
||||
</div>
|
||||
<div class="panel-heading p10 pl15" id="g-menu" style="height: auto;">
|
||||
<a class="btn btn btn-dark btn-sm mr5 btn-sm mr5" href="/admin/shop_product/view_list/"><i class="fa fa-reply mr5"></i>Wstecz</a>
|
||||
@@ -13,53 +13,43 @@
|
||||
<table class="table table-hover table-bordered table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>Kombinacja</th>
|
||||
<th>SKU</th>
|
||||
<th>Stan magazynowy</th>
|
||||
<th>Cena netto</th>
|
||||
<th>Zam. SM 0</th>
|
||||
<th>Baselinker</th>
|
||||
<th>Zam. przy braku</th>
|
||||
<th style="width: 100px;">Opcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<? if ( \S::is_array_fix( $this -> product_permutations ) ): foreach ( $this -> product_permutations as $product ):?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<? if ( \Shared\Helpers\Helpers::is_array_fix( $this -> product_permutations ) ): foreach ( $this -> product_permutations as $product ):?>
|
||||
<tr data-combination-id="<?= $product['id'];?>">
|
||||
<td>
|
||||
<?
|
||||
$attributes = explode( '|', $product['permutation_hash'] );
|
||||
foreach ( $attributes as $attribute ):
|
||||
$attribute_tmp = explode( '-', $attribute );
|
||||
echo \admin\factory\ShopAttribute::get_attribute_name_by_id( $attribute_tmp[0] ) . ' - <b>' . \admin\factory\ShopAttribute::get_attribute_value_by_id( $attribute_tmp[1] ) . '</b>';
|
||||
$attrRepo = new \Domain\Attribute\AttributeRepository( $GLOBALS['mdb'] );
|
||||
echo $attrRepo->getAttributeNameById( (int)$attribute_tmp[0], $this -> default_language ) . ' - <b>' . $attrRepo->getAttributeValueById( (int)$attribute_tmp[1], $this -> default_language ) . '</b>';
|
||||
if ( $attribute != end( $attributes ) )
|
||||
echo ', ';
|
||||
endforeach;
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="sku" value="<?= $product['sku'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_sku_save/', data: { product_id: <?= $product['id'];?>, sku: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['sku'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="sku">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="quantity" value="<?= $product['quantity'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_quantity_save/', data: { product_id: <?= $product['id'];?>, quantity: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['quantity'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="quantity">
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="price" value="<?= $product['price_netto'];?>" class="form-control" style="max-width: 100px;" onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_price_save/', data: { product_id: <?= $product['id'];?>, price: $( this ).val() } } );">
|
||||
<input type="text" value="<?= $product['price_netto'];?>" class="form-control combination-field" style="max-width: 100px;" data-product-id="<?= $product['id'];?>" data-field="price">
|
||||
</td>
|
||||
<td>
|
||||
<input type="checkbox" name="stock_0_buy" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?> onchange="$.ajax({ type: 'POST', cache: false, url: '/admin/shop_product/product_combination_stock_0_buy_save/', data: { product_id: <?= $product['id'];?>, stock_0_buy: $( this ).is( ':checked' ) } } );">
|
||||
</td>
|
||||
<td>
|
||||
<?
|
||||
if ( $product['baselinker_product_name'] != "" )
|
||||
echo "<span title='" . $product['baselinker_product_name'] . "'>" . substr( $product['baselinker_product_name'], 0, 25 ) . "...</span>";
|
||||
else
|
||||
echo "<span class='text-danger baselinker-product-search' product-id='" . $product['id'] . "'>nie przypisano <i class='fa fa-search'></i></span>";
|
||||
?>
|
||||
<input type="checkbox" class="g-checkbox combination-checkbox" data-product-id="<?= $product['id'];?>" <? if ( $product['stock_0_buy'] ): echo 'checked="checked"'; endif;?>>
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="/admin/shop_product/delete_combination/combination_id=<?= $product['id'];?>&product_id=<?= $product['parent_id'];?>" class="btn btn-danger btn-delete-permutation"><i class="fa fa-trash"></i></a>
|
||||
<button type="button" class="btn btn-danger btn-delete-permutation" data-combination-id="<?= $product['id'];?>"><i class="fa fa-trash"></i></button>
|
||||
</td>
|
||||
</tr>
|
||||
<? endforeach; endif;?>
|
||||
@@ -74,6 +64,7 @@
|
||||
<div class="combination-attribute">
|
||||
<div class="title">
|
||||
<?= $attribute['languages'][ $this -> default_language ]['name'];?>
|
||||
<label style="float: right; font-weight: normal; font-size: 12px; cursor: pointer;"><input type="checkbox" class="g-checkbox select-all-attr"> wszystkie</label>
|
||||
</div>
|
||||
<ul class="values">
|
||||
<? foreach ( $attribute['values'] as $value ):?>
|
||||
@@ -90,9 +81,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/minimal.css">
|
||||
<link rel="stylesheet" type="text/css" href="/libraries/grid/plugins/icheck/skins/minimal/blue.css">
|
||||
<script type="text/javascript" src="/libraries/grid/plugins/icheck/icheck.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$( function()
|
||||
{
|
||||
@@ -101,10 +89,90 @@
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
|
||||
// "Zaznacz wszystkie" per atrybut
|
||||
$( '.select-all-attr' ).on( 'ifChanged', function()
|
||||
{
|
||||
var checked = $( this ).is( ':checked' );
|
||||
$( this ).closest( '.combination-attribute' ).find( '.g-checkbox' ).each( function()
|
||||
{
|
||||
$( this ).iCheck( checked ? 'check' : 'uncheck' );
|
||||
});
|
||||
});
|
||||
|
||||
// Inline save — SKU, ilość, cena
|
||||
var fieldUrlMap = {
|
||||
'sku': '/admin/shop_product/product_combination_sku_save/',
|
||||
'quantity': '/admin/shop_product/product_combination_quantity_save/',
|
||||
'price': '/admin/shop_product/product_combination_price_save/'
|
||||
};
|
||||
|
||||
$( 'body' ).on( 'change', '.combination-field', function()
|
||||
{
|
||||
var $input = $( this );
|
||||
var field = $input.data( 'field' );
|
||||
var data = { product_id: $input.data( 'product-id' ) };
|
||||
data[ field ] = $input.val();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: fieldUrlMap[ field ],
|
||||
data: data,
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status === 'ok' ) {
|
||||
$input.css( 'border-color', '#1cbb8c' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
} else {
|
||||
$input.css( 'border-color', '#ff3d60' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
if ( response.msg ) create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
$input.css( 'border-color', '#ff3d60' );
|
||||
setTimeout( function() { $input.css( 'border-color', '' ); }, 1500 );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Inline save — checkbox stock_0_buy (iCheck event)
|
||||
$( 'body' ).on( 'ifChanged', '.combination-checkbox', function()
|
||||
{
|
||||
var $cb = $( this );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_combination_stock_0_buy_save/',
|
||||
data: { product_id: $cb.data( 'product-id' ), stock_0_buy: $cb.is( ':checked' ) },
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status !== 'ok' && response.msg ) {
|
||||
create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Usuwanie kombinacji — AJAX
|
||||
$( 'body' ).on( 'click', '.btn-delete-permutation', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var href = $( this ).attr( 'href' );
|
||||
var combinationId = $( this ).data( 'combination-id' );
|
||||
var $row = $( this ).closest( 'tr' );
|
||||
|
||||
$.alert(
|
||||
{
|
||||
@@ -128,96 +196,34 @@
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = href;
|
||||
action: function()
|
||||
{
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/delete_combination_ajax/',
|
||||
data: { combination_id: combinationId },
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status === 'ok' ) {
|
||||
$row.fadeOut( 300, function() { $( this ).remove(); } );
|
||||
} else {
|
||||
if ( response.msg ) create_error( response.msg );
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$( '#overlay' ).hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.baselinker-product-search', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/baselinker_product_search/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'SUCCESS' ) {
|
||||
$('.baselinker-found-products').remove();
|
||||
var html = '<div class="baselinker-found-products">';
|
||||
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
|
||||
html += '<select class="form-control baselinker-product-select" product-id="' + product_id + '">';
|
||||
$.each( data.products, function( index, value ) {
|
||||
html += '<option value="' + value.product_id + '">' + value.name + ' SKU: ' + value.sku + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
html += '<button class="btn btn-success baselinker-product-select-save" product-id="' + product_id + '">Zapisz</button>';
|
||||
html += '</div>';
|
||||
$( 'span[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
} else if ( data.status == 'error' ) {
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.msg,
|
||||
type: 'red',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'OK',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.baselinker-product-select-save', function(){
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var baselinker_product_id = $( '.baselinker-product-select[product-id="' + product_id + '"]' ).val();
|
||||
var baselinker_product_name = $( '.baselinker-product-select[product-id="' + product_id + '"] option:selected' ).text();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/baselinker_product_select_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
baselinker_product_id: baselinker_product_id,
|
||||
baselinker_product_name: baselinker_product_name
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '.baselinker-product-select[product-id="' + product_id + '"]' ).closest( '.baselinker-found-products' ).remove();
|
||||
$( 'span[product-id="' + product_id + '"]' ).html( '<span title="' + baselinker_product_name + '">' + baselinker_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'baselinker-product-search' ).removeClass( 'text-danger' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</script>
|
||||
|
||||
631
admin/templates/shop-product/product-edit-custom-script.php
Normal file
631
admin/templates/shop-product/product-edit-custom-script.php
Normal file
@@ -0,0 +1,631 @@
|
||||
<?php
|
||||
$product = is_array($this->product ?? null) ? $this->product : [];
|
||||
$productId = (int)($product['id'] ?? 0);
|
||||
$userId = (int)($this->user['id'] ?? 0);
|
||||
$imagesCount = is_array($product['images'] ?? null) ? count($product['images']) : 0;
|
||||
$filesCount = is_array($product['files'] ?? null) ? count($product['files']) : 0;
|
||||
|
||||
$imageMaxPx = 1920;
|
||||
if (isset($GLOBALS['settings']['image_px']) && (int)$GLOBALS['settings']['image_px'] > 0) {
|
||||
$imageMaxPx = (int)$GLOBALS['settings']['image_px'];
|
||||
}
|
||||
|
||||
$uploadToken = bin2hex(random_bytes(24));
|
||||
if (!isset($_SESSION['upload_tokens']) || !is_array($_SESSION['upload_tokens'])) {
|
||||
$_SESSION['upload_tokens'] = [];
|
||||
}
|
||||
$_SESSION['upload_tokens'][$uploadToken] = [
|
||||
'user_id' => $userId,
|
||||
'expires' => time() + 60 * 20,
|
||||
];
|
||||
|
||||
$cookieCategories = [];
|
||||
if (!empty($_COOKIE['cookie_categories'])) {
|
||||
$decoded = @unserialize($_COOKIE['cookie_categories']);
|
||||
if (is_array($decoded)) {
|
||||
$cookieCategories = $decoded;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/plupload/jquery.plupload.queue/css/jquery.plupload.queue.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.css" />
|
||||
<link type="text/css" rel="stylesheet" href="/libraries/selectize/css/selectize.default.css" />
|
||||
|
||||
<script type="text/javascript" src="/libraries/jquery/sortable/sortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html5.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/plupload.html4.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/jquery.plupload.queue/jquery.plupload.queue.js"></script>
|
||||
<script type="text/javascript" src="/libraries/plupload/i18n/pl.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
|
||||
<script type="text/javascript" src="/libraries/jquery/lozad.js"></script>
|
||||
<script type="text/javascript" src="/libraries/selectize/js/standalone/selectize.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
#fg-product-edit .layout-tree-toggle {
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
margin-right: 4px;
|
||||
color: #666;
|
||||
cursor: pointer;
|
||||
text-indent: 0;
|
||||
background-image: none !important;
|
||||
}
|
||||
#fg-product-edit .layout-tree-toggle:focus,
|
||||
#fg-product-edit .layout-tree-toggle:active,
|
||||
#fg-product-edit .layout-tree-toggle:focus-visible {
|
||||
outline: none;
|
||||
box-shadow: none;
|
||||
}
|
||||
#fg-product-edit li.sort-expanded > div .layout-tree-toggle i {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
#fg-product-edit .sortable li.sort-branch > div > .layout-tree-toggle {
|
||||
display: inline-flex;
|
||||
float: none;
|
||||
margin-right: 4px;
|
||||
}
|
||||
#fg-product-edit .menu_sortable .icheckbox_minimal-blue {
|
||||
margin-top: 0;
|
||||
margin-right: 5px;
|
||||
}
|
||||
#fg-product-edit .menu_sortable .g-checkbox {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
#files-list {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
margin: 0 0 15px 0;
|
||||
}
|
||||
#files-list li {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-bottom: 6px;
|
||||
cursor: move;
|
||||
}
|
||||
#files-list li .input-group {
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
var images_count = <?= (int)$imagesCount ?>;
|
||||
var files_count = <?= (int)$filesCount ?>;
|
||||
var product_id = <?= (int)$productId ?>;
|
||||
|
||||
function remove_custom_filed(el) {
|
||||
confirm_delete_element(function() {
|
||||
el.parent().parent().parent().remove();
|
||||
});
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
// --- Podgląd produktu ---
|
||||
$('body').on('click', '#product-preview', function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/ajax_product_url/',
|
||||
data: { product_id: $('#id').val() },
|
||||
success: function(response) {
|
||||
var data = jQuery.parseJSON(response);
|
||||
var win = window.open(data.url, '_blank');
|
||||
if (win) win.focus();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- Selectize: produkty powiązane ---
|
||||
$('#products_related').selectize({
|
||||
maxItems: 999,
|
||||
plugins: ['remove_button']
|
||||
});
|
||||
|
||||
// --- Lozad: lazy load obrazków ---
|
||||
var observer = lozad();
|
||||
observer.observe();
|
||||
|
||||
// --- Śledzenie kolejności galerii i plików (hidden inputs) ---
|
||||
function ensureGalleryOrderInput() {
|
||||
var $form = $('#fg-product-edit');
|
||||
if (!$form.length) return null;
|
||||
var $input = $form.find('input[name="gallery_order"]');
|
||||
if (!$input.length) {
|
||||
$input = $('<input>', { type: 'hidden', name: 'gallery_order', id: 'gallery_order' });
|
||||
$form.append($input);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
function buildGalleryOrder() {
|
||||
var order = [];
|
||||
$('#images-list li').each(function() {
|
||||
var imageId = $(this).find('a.article_image_delete').attr('image-id');
|
||||
if (imageId) order.push(imageId);
|
||||
});
|
||||
return order.join(';');
|
||||
}
|
||||
|
||||
function refreshGalleryOrderInput() {
|
||||
var $input = ensureGalleryOrderInput();
|
||||
if ($input) $input.val(buildGalleryOrder());
|
||||
}
|
||||
|
||||
function ensureFilesOrderInput() {
|
||||
var $form = $('#fg-product-edit');
|
||||
if (!$form.length) return null;
|
||||
var $input = $form.find('input[name="files_order"]');
|
||||
if (!$input.length) {
|
||||
$input = $('<input>', { type: 'hidden', name: 'files_order', id: 'files_order' });
|
||||
$form.append($input);
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
|
||||
function buildFilesOrder() {
|
||||
var order = [];
|
||||
$('#files-list li').each(function() {
|
||||
var fileId = $(this).find('.product_file_edit').attr('file_id');
|
||||
if (fileId) order.push(fileId);
|
||||
});
|
||||
return order.join(';');
|
||||
}
|
||||
|
||||
function refreshFilesOrderInput() {
|
||||
var $input = ensureFilesOrderInput();
|
||||
if ($input) $input.val(buildFilesOrder());
|
||||
}
|
||||
|
||||
ensureGalleryOrderInput();
|
||||
refreshGalleryOrderInput();
|
||||
ensureFilesOrderInput();
|
||||
refreshFilesOrderInput();
|
||||
|
||||
// --- Sortable: galeria zdjęć ---
|
||||
var imageList = document.getElementById('images-list');
|
||||
if (imageList) {
|
||||
Sortable.create(imageList, {
|
||||
onEnd: function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/images_order_save/',
|
||||
data: { product_id: product_id, order: buildGalleryOrder() },
|
||||
beforeSend: function() { $('#overlay').show(); },
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') create_error(response.msg);
|
||||
}
|
||||
});
|
||||
refreshGalleryOrderInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Sortable: pliki ---
|
||||
var filesList = document.getElementById('files-list');
|
||||
if (filesList) {
|
||||
Sortable.create(filesList, {
|
||||
onEnd: function() {
|
||||
refreshFilesOrderInput();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Plupload: upload zdjęć ---
|
||||
$('#images-uploader').pluploadQueue({
|
||||
multipart_params: {
|
||||
upload_token: '<?= htmlspecialchars($uploadToken, ENT_QUOTES, 'UTF-8') ?>'
|
||||
},
|
||||
runtimes: 'html5,html4',
|
||||
init: {
|
||||
Refresh: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled').removeClass('plupload_disabled');
|
||||
},
|
||||
UploadComplete: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled').removeClass('plupload_disabled');
|
||||
},
|
||||
FileUploaded: function(up, file, response) {
|
||||
var data = jQuery.parseJSON(response.response);
|
||||
$('#images-list').append(
|
||||
'<li id="image-' + data.image_id + '">' +
|
||||
'<img class="article-image lozad" data-src="/libraries/thumb.php?img=' + data.data_link + '&w=300&h=300">' +
|
||||
'<a href="#" class="input-group-addon btn btn-danger article_image_delete" image-id="' + data.image_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'<input type="text" class="form-control image-alt" value="" image-id="' + data.image_id + '" placeholder="atrybut alt...">' +
|
||||
'</li>'
|
||||
);
|
||||
images_count++;
|
||||
observer.observe();
|
||||
refreshGalleryOrderInput();
|
||||
$('html, body').animate({ scrollTop: $('#images-uploader').offset().top }, 1);
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-product-images.php',
|
||||
chunk_size: '1mb',
|
||||
max_file_size: '20mb',
|
||||
unique_names: false,
|
||||
resize: {
|
||||
width: <?= (int)$imageMaxPx ?>,
|
||||
height: <?= (int)$imageMaxPx ?>,
|
||||
quality: 95
|
||||
},
|
||||
filters: [{ title: 'Obrazki', extensions: 'jpg,gif,png,bmp,jpeg' }]
|
||||
});
|
||||
|
||||
// --- Plupload: upload plików ---
|
||||
$('#files-uploader').pluploadQueue({
|
||||
multipart_params: {
|
||||
upload_token: '<?= htmlspecialchars($uploadToken, ENT_QUOTES, 'UTF-8') ?>'
|
||||
},
|
||||
runtimes: 'html5,html4',
|
||||
init: {
|
||||
Refresh: function() {
|
||||
$('.plupload_buttons').css('display', 'inline');
|
||||
$('.plupload_upload_status').css('display', 'inline');
|
||||
$('.plupload_start').addClass('plupload_disabled').removeClass('plupload_disabled');
|
||||
},
|
||||
FileUploaded: function(up, file, response) {
|
||||
var data = jQuery.parseJSON(response.response);
|
||||
$('#files-list').append(
|
||||
'<li id="file-' + data.file_id + '">' +
|
||||
'<div class="input-group">' +
|
||||
'<input type="text" class="form-control product_file_edit" file_id="' + data.file_id + '" value="' + data.file_name + '" />' +
|
||||
'<a href="#" class="input-group-addon btn btn-info product_file_delete" file_id="' + data.file_id + '">' +
|
||||
'<i class="fa fa-trash"></i>' +
|
||||
'</a>' +
|
||||
'</div>' +
|
||||
'</li>'
|
||||
);
|
||||
files_count++;
|
||||
refreshFilesOrderInput();
|
||||
}
|
||||
},
|
||||
url: '/libraries/plupload/upload-product-files.php',
|
||||
chunk_size: '1mb',
|
||||
max_file_size: '50mb',
|
||||
unique_names: false,
|
||||
filters: [{ title: 'Wszystkie pliki', extensions: '*' }]
|
||||
});
|
||||
|
||||
// --- Drzewo kategorii: ukryj strzałki na liściach ---
|
||||
function refreshTreeDisclosureState() {
|
||||
$('ol.sortable li').each(function() {
|
||||
var $li = $(this);
|
||||
var hasChildren = $li.children('ol').children('li').length > 0;
|
||||
var $toggle = $li.children('div').children('.disclose');
|
||||
|
||||
if (hasChildren) {
|
||||
$li.removeClass('sort-leaf').addClass('sort-branch');
|
||||
if (!$li.hasClass('sort-collapsed') && !$li.hasClass('sort-expanded')) {
|
||||
$li.addClass('sort-collapsed');
|
||||
}
|
||||
$toggle.attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false').show();
|
||||
} else {
|
||||
$li.removeClass('sort-branch sort-collapsed sort-expanded').addClass('sort-leaf');
|
||||
$toggle.attr('aria-expanded', 'false').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Drzewo kategorii: nestedSortable + iCheck ---
|
||||
if ($.fn && typeof $.fn.iCheck === 'function') {
|
||||
$('#fg-product-edit .menu_sortable .g-checkbox').iCheck({
|
||||
checkboxClass: 'icheckbox_minimal-blue',
|
||||
radioClass: 'iradio_minimal-blue'
|
||||
});
|
||||
}
|
||||
|
||||
$('ol.sortable').nestedSortable({
|
||||
forcePlaceholderSize: true,
|
||||
handle: 'div',
|
||||
helper: 'clone',
|
||||
items: 'li',
|
||||
opacity: .9,
|
||||
placeholder: 'placeholder',
|
||||
revert: 250,
|
||||
tabSize: 45,
|
||||
tolerance: 'pointer',
|
||||
toleranceElement: '> div',
|
||||
maxLevels: 2,
|
||||
isTree: true,
|
||||
expandOnHover: 700,
|
||||
protectRoot: false
|
||||
});
|
||||
|
||||
$('.disclose').on('click', function() {
|
||||
var $li = $(this).closest('li');
|
||||
$li.toggleClass('sort-collapsed').toggleClass('sort-expanded');
|
||||
$(this).attr('aria-expanded', $li.hasClass('sort-expanded') ? 'true' : 'false');
|
||||
});
|
||||
|
||||
$('.disclose').mousedown(function(e) {
|
||||
if (e.which === 1) {
|
||||
var category_id = $(this).parent('div').parent('li').attr('id');
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_category/cookie_categories/',
|
||||
data: { category_id: category_id }
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
refreshTreeDisclosureState();
|
||||
|
||||
<?php foreach ($cookieCategories as $key => $val): ?>
|
||||
<?php if ($val): ?>$('#<?= $key ?>').children('div').children('.disclose').click();<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
// --- AJAX: zmiana alt zdjęcia ---
|
||||
$('body').on('change', '.image-alt', function() {
|
||||
var $input = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/image_alt_change/',
|
||||
data: { image_id: $input.attr('image-id'), image_alt: $input.val() },
|
||||
beforeSend: function() { $('#overlay').show(); },
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') create_error(response.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- AJAX: zmiana nazwy pliku ---
|
||||
$('body').on('change', '.product_file_edit', function() {
|
||||
var $input = $(this);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_file_name_change/',
|
||||
data: { file_id: $input.attr('file_id'), file_name: $input.val() },
|
||||
beforeSend: function() { $('#overlay').show(); },
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status !== 'ok') create_error(response.msg);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- AJAX: usunięcie pliku ---
|
||||
$('body').on('click', '.product_file_delete', function() {
|
||||
$(this).blur();
|
||||
var file_id = $(this).attr('file_id');
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz usunąć wybrany plik?',
|
||||
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: {
|
||||
cancel: { text: 'Nie', btnClass: 'btn-dark', action: function() {} },
|
||||
confirm: {
|
||||
text: 'Tak', btnClass: 'btn-danger', keys: ['enter'],
|
||||
action: function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_file_delete/',
|
||||
data: { file_id: file_id },
|
||||
beforeSend: function() {
|
||||
$('#file-' + file_id).find('input').addClass('disabled');
|
||||
$('#file-' + file_id).find('a').addClass('disabled');
|
||||
},
|
||||
success: function(data) {
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#file-' + file_id).remove();
|
||||
refreshFilesOrderInput();
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// --- AJAX: usunięcie zdjęcia ---
|
||||
$('body').on('click', '.article_image_delete', function() {
|
||||
$(this).blur();
|
||||
var image_id = $(this).attr('image-id');
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz usunąć wybrane zdjęcie?',
|
||||
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: {
|
||||
cancel: { text: 'Nie', btnClass: 'btn-dark', action: function() {} },
|
||||
confirm: {
|
||||
text: 'Tak', btnClass: 'btn-danger', keys: ['enter'],
|
||||
action: function() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/image_delete/',
|
||||
data: { image_id: image_id },
|
||||
beforeSend: function() { $('#overlay').show(); },
|
||||
success: function(data) {
|
||||
$('#overlay').hide();
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#image-' + image_id).remove();
|
||||
refreshGalleryOrderInput();
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
// --- Odśwież kolejność galerii/plików przed zapisem ---
|
||||
$('body').on('click', '#g-edit-save, #g-edit-save-close', function() {
|
||||
refreshGalleryOrderInput();
|
||||
refreshFilesOrderInput();
|
||||
});
|
||||
|
||||
// --- Kalkulator cen netto/brutto ---
|
||||
$('body').on('keyup', '#price_netto', function() { calculate_price_brutto(); });
|
||||
$('body').on('keyup', '#price_brutto', function() { calculate_price_netto(); });
|
||||
$('body').on('keyup', '#price_netto_promo', function() { calculate_price_brutto_promo(); });
|
||||
$('body').on('keyup', '#price_brutto_promo', function() { calculate_price_netto_promo(); });
|
||||
$('body').on('change', '#vat', function() { calculate_price_brutto(); });
|
||||
|
||||
// --- Dodawanie custom field ---
|
||||
$('body').on('click', '#add_custom_field', function(e) {
|
||||
e.preventDefault();
|
||||
var html = '';
|
||||
html += '<div class="form-group row custom-field-row bg-white p-4">';
|
||||
html += '<div class="form-group row"><label class="col-sm-3 control-label">Nazwa pola:</label>';
|
||||
html += '<div class="col-sm-9"><input type="text" class="form-control" name="custom_field_name[]" value=""></div></div>';
|
||||
html += '<div class="form-group row"><label class="col-sm-3 control-label">Rodzaj pola:</label>';
|
||||
html += '<div class="col-sm-9"><select class="form-control" name="custom_field_type[]">';
|
||||
html += '<option value="text" selected>Tekst</option>';
|
||||
html += '<option value="image">Obrazek</option>';
|
||||
html += '</select></div></div>';
|
||||
html += '<div class="form-group row"><label class="col-sm-3 control-label">Status pola:</label>';
|
||||
html += '<div class="col-sm-9"><label style="margin:0; font-weight:normal;" class="d-flex align-items-center mt-3">';
|
||||
html += '<input type="checkbox" class="custom-field-required" name="custom_field_required[]"> wymagane</label></div></div>';
|
||||
html += '<div class="form-group row"><div class="col-sm-12 text-right">';
|
||||
html += '<span class="input-group-addon btn btn-info" onclick="remove_custom_filed( $( this ) );">usuń</span>';
|
||||
html += '</div></div>';
|
||||
html += '</div>';
|
||||
$('.additional_fields').append(html);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// --- Funkcje kalkulacji cen ---
|
||||
function calculate_price_brutto() {
|
||||
var price_netto = $('#price_netto').val().replace(',', '.');
|
||||
if (!price_netto) return false;
|
||||
var vat = $('#vat').val().replace(',', '.');
|
||||
var price_brutto = price_netto * 1 + price_netto * vat / 100;
|
||||
price_brutto = Math.floor(price_brutto * 100) / 100;
|
||||
price_brutto = number_format(price_brutto, 2, '.', '');
|
||||
return $('#price_brutto').val(price_brutto);
|
||||
}
|
||||
|
||||
function calculate_price_netto() {
|
||||
var price_brutto = $('#price_brutto').val().replace(',', '.');
|
||||
var vat = $('#vat').val().replace(',', '.');
|
||||
var price_netto = price_brutto / (vat / 100 + 1);
|
||||
price_netto = number_format(price_netto, 2, '.', '');
|
||||
return $('#price_netto').val(price_netto);
|
||||
}
|
||||
|
||||
function calculate_price_brutto_promo() {
|
||||
var price_netto = $('#price_netto_promo').val().replace(',', '.');
|
||||
var vat = $('#vat').val().replace(',', '.');
|
||||
var price_brutto = price_netto * 1 + price_netto * vat / 100;
|
||||
price_brutto = Math.floor(price_brutto * 100) / 100;
|
||||
price_brutto = number_format(price_brutto, 2, '.', '');
|
||||
if (Math.floor(price_netto) <= 0) {
|
||||
$('#price_netto_promo').val('');
|
||||
$('#price_brutto_promo').val('');
|
||||
return true;
|
||||
}
|
||||
return $('#price_brutto_promo').val(price_brutto);
|
||||
}
|
||||
|
||||
function calculate_price_netto_promo() {
|
||||
var price_brutto = $('#price_brutto_promo').val().replace(',', '.');
|
||||
var vat = $('#vat').val().replace(',', '.');
|
||||
var price_netto = price_brutto / (vat / 100 + 1);
|
||||
price_netto = number_format(price_netto, 2, '.', '');
|
||||
if (Math.floor(price_brutto) <= 0) {
|
||||
$('#price_netto_promo').val('');
|
||||
$('#price_brutto_promo').val('');
|
||||
return true;
|
||||
}
|
||||
return $('#price_netto_promo').val(price_netto);
|
||||
}
|
||||
|
||||
// --- Generowanie SKU ---
|
||||
function generate_sku_code(product_id) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/generate_sku_code/',
|
||||
data: { product_id: product_id },
|
||||
beforeSend: function() { $('#sku').addClass('disabled'); },
|
||||
success: function(data) {
|
||||
$('#sku').removeClass('disabled');
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#sku').val(response.sku);
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// --- Generowanie linku SEO ---
|
||||
function generate_seo_links(lang, title, article_id) {
|
||||
if (title === '') return false;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/pages/generateSeoLink/',
|
||||
data: { title: title, article_id: article_id },
|
||||
beforeSend: function() {
|
||||
$('#seo_link_' + lang).parents('.g-form-data').find('input, a').each(function() {
|
||||
$(this).prop('disabled', true).addClass('disabled');
|
||||
});
|
||||
},
|
||||
success: function(data) {
|
||||
$('#seo_link_' + lang).parents('.g-form-data').find('input, a').each(function() {
|
||||
$(this).prop('disabled', false).removeClass('disabled');
|
||||
});
|
||||
var response = jQuery.parseJSON(data);
|
||||
if (response.status === 'ok') {
|
||||
$('#seo_link_' + lang).val(response.seo_link);
|
||||
} else {
|
||||
create_error(response.msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
File diff suppressed because it is too large
Load Diff
302
admin/templates/shop-product/products-list-custom-script.php
Normal file
302
admin/templates/shop-product/products-list-custom-script.php
Normal file
@@ -0,0 +1,302 @@
|
||||
<? if ( $this -> shoppro_enabled ):?>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var $header = $( '.panel-heading .col-sm-8' );
|
||||
if ( $header.length ) {
|
||||
$header.append( ' <a href="#" class="btn btn-danger btn-sm btn-shoppro-product-import"><i class="fa fa-download mr5"></i>Pobierz produkt z shopPRO</a>' );
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<? endif;?>
|
||||
|
||||
<style type="text/css">
|
||||
.product-image {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
width: 50px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.product-image img {
|
||||
max-width: 50px;
|
||||
max-height: 50px;
|
||||
}
|
||||
.product-name {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
.product-categories {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
||||
// --- Inline price save ---
|
||||
$( 'body' ).on( 'change', '.product-price', function() {
|
||||
var $el = $( this );
|
||||
var price = $el.val().replace( ' ', '' );
|
||||
price = parseFloat( price.replace( ',', '.' ) * 1 );
|
||||
price = number_format( price, 2, '.', '' );
|
||||
$el.val( price );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_change_price_brutto/',
|
||||
data: { product_id: $el.attr( 'product-id' ), price: price },
|
||||
beforeSend: function() { $( '#overlay' ).show(); },
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status !== 'ok' ) create_error( response.msg );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.product-price-promo', function() {
|
||||
var $el = $( this );
|
||||
var price = $el.val().replace( ' ', '' );
|
||||
price = parseFloat( price.replace( ',', '.' ) * 1 );
|
||||
price = number_format( price, 2, '.', '' );
|
||||
$el.val( price );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_change_price_brutto_promo/',
|
||||
data: { product_id: $el.attr( 'product-id' ), price: price },
|
||||
beforeSend: function() { $( '#overlay' ).show(); },
|
||||
success: function( data ) {
|
||||
$( '#overlay' ).hide();
|
||||
var response = jQuery.parseJSON( data );
|
||||
if ( response.status !== 'ok' ) create_error( response.msg );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- Duplicate product ---
|
||||
$( 'body' ).on( 'click', '.duplicate-product', function(e) {
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz wykonać duplikat produktu?',
|
||||
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 (produkt bez kombinacji)',
|
||||
btnClass: 'btn-success',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = '/admin/shop_product/duplicate_product/product-id=' + product_id;
|
||||
}
|
||||
},
|
||||
confirm2: {
|
||||
text: 'Tak (produkt z KOMBINACJAMI)',
|
||||
btnClass: 'btn-primary',
|
||||
action: function() {
|
||||
document.location.href = '/admin/shop_product/duplicate_product/product-id=' + product_id + '&combination=1';
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-dark',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- shopPRO import ---
|
||||
$( 'body' ).on( 'click', '.btn-shoppro-product-import', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
$.alert({
|
||||
title: 'Import produktu',
|
||||
content: 'Wprowadź ID produktu z shopPRO',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-8',
|
||||
theme: 'material',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Importuj',
|
||||
btnClass: 'btn-success',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
var product_id = $( '#shoppro-product-id' ).val();
|
||||
if ( product_id ) {
|
||||
document.location.href = '/admin/integrations/shoppro_product_import/product_id=' + product_id;
|
||||
}
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {}
|
||||
}
|
||||
},
|
||||
onOpenBefore: function() {
|
||||
this.setContent( '<input type="text" class="form-control" id="shoppro-product-id" placeholder="ID produktu z shopPRO">' );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// --- Apilo ---
|
||||
$( 'body' ).on( 'click', '.apilo-product-search', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_search/',
|
||||
data: { product_id: product_id },
|
||||
beforeSend: function() { $( '#overlay' ).show(); },
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
var data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'SUCCESS' ) {
|
||||
if ( data.products.length == 0 ) {
|
||||
var html = '<div class="apilo-found-products">';
|
||||
html += '<p>Nie znaleziono produktów</p>';
|
||||
html += '<a href="/admin/integrations/apilo_create_product/product-id=' + product_id + '" class="btn btn-success btn_apilo_create_product" product_id="' + product_id + '">Utwórz produkt</a> ';
|
||||
html += '<button class="btn btn-default apilo-cancel">Anuluj</button>';
|
||||
html += '</div>';
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
} else {
|
||||
var html = '<div class="apilo-found-products">';
|
||||
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
|
||||
html += '<select class="form-control apilo-product-select" product-id="' + product_id + '">';
|
||||
$.each( data.products, function( index, value ) {
|
||||
html += '<option value="' + value.id + '">' + value.name + ' SKU: ' + value.sku + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
html += '<button class="btn btn-success apilo-product-select-save" product-id="' + product_id + '">Zapisz</button> ';
|
||||
html += '<button class="btn btn-default apilo-cancel">Anuluj</button>';
|
||||
html += '</div>';
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
}
|
||||
} else if ( data.status == 'error' ) {
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.msg,
|
||||
type: 'red',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'OK',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.apilo-cancel', function() {
|
||||
$( this ).closest( '.apilo-found-products' ).remove();
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.apilo-delete-linking', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_select_delete/',
|
||||
data: { product_id: product_id },
|
||||
beforeSend: function() { $( '#overlay' ).show(); },
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
var data = jQuery.parseJSON( response );
|
||||
if ( data.status == 'ok' ) {
|
||||
$( 'span.apilo-delete-linking[product-id="' + product_id + '"]' ).closest( 'td' ).html( '<span class="text-danger apilo-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.btn_apilo_create_product', function(e) {
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product_id' );
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz utworzyć produkt w bazie Apilo?',
|
||||
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 = '/admin/integrations/apilo_create_product/product_id=' + product_id;
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.apilo-product-select-save', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var apilo_product_id = $( '.apilo-product-select[product-id="' + product_id + '"]' ).val();
|
||||
var apilo_product_name = $( '.apilo-product-select[product-id="' + product_id + '"] option:selected' ).text();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_select_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
apilo_product_id: apilo_product_id,
|
||||
apilo_product_name: apilo_product_name
|
||||
},
|
||||
beforeSend: function() { $( '#overlay' ).show(); },
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
var data = jQuery.parseJSON( response );
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '.apilo-product-select[product-id="' + product_id + '"]' ).closest( '.apilo-found-products' ).remove();
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + apilo_product_name + '">' + apilo_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'apilo-product-search' ).removeClass( 'text-danger' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -36,23 +36,6 @@
|
||||
<td class="text-center">
|
||||
<span class="text-muted"><?= (int)\admin\factory\shopProduct::get_product_quantity_list( $product['id'] );?></span>
|
||||
</td>
|
||||
<? if ( $this -> baselinker_enabled ):?>
|
||||
<td class="text-center">
|
||||
<?
|
||||
if ( $product['baselinker_product_name'] != "" ) {
|
||||
echo "<span title='" . htmlspecialchars( $product['baselinker_product_name'] ) . "'>" . mb_substr( $product['baselinker_product_name'], 0, 25, 'UTF-8' ) . "...</span>";
|
||||
echo "<br>";
|
||||
echo "<span class='text-danger baselinker-delete-linking' product-id='" . $product['id'] . "'>";
|
||||
echo "<i class='fa fa-times'></i>usuń powiązanie";
|
||||
echo "</span>";
|
||||
} else {
|
||||
echo "<span class='text-danger baselinker-product-search' product-id='" . $product['id'] . "'>";
|
||||
echo "nie przypisano <i class='fa fa-search'></i>";
|
||||
echo "</span>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<? endif;?>
|
||||
<? if ( $this -> apilo_enabled ):?>
|
||||
<td class="text-center">
|
||||
<?
|
||||
@@ -70,24 +53,6 @@
|
||||
?>
|
||||
</td>
|
||||
<? endif;?>
|
||||
<!-- sellasist -->
|
||||
<? if ( $this -> sellasist_enabled ):?>
|
||||
<td class="text-center">
|
||||
<?
|
||||
if ( $product['sellasist_product_name'] != "" ) {
|
||||
echo "<span title='" . htmlspecialchars( $product['sellasist_product_name'] ) . "'>" . mb_substr( $product['sellasist_product_name'], 0, 25, "UTF-8" ) . "...</span>";
|
||||
echo "<br>";
|
||||
echo "<span class='text-danger sellasist-delete-linking' product-id='" . $product['id'] . "'>";
|
||||
echo "<i class='fa fa-times'></i>usuń powiązanie";
|
||||
echo "</span>";
|
||||
} else {
|
||||
echo "<span class='text-danger sellasist-product-search' product-id='" . $product['id'] . "'>";
|
||||
echo "nie przypisano <i class='fa fa-search'></i>";
|
||||
echo "</span>";
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<? endif;?>
|
||||
<td>
|
||||
<a href='/admin/shop_product/product_combination/product_id=<?= $product['id'];?>'>kombinacje (<?= \admin\factory\shopProduct::count_product_combinations( $product['id'] );?>)</a>
|
||||
</td>
|
||||
|
||||
@@ -1,871 +1,9 @@
|
||||
<div class="panel">
|
||||
<div class="panel-body">
|
||||
<a href="/admin/shop_product/product_edit/" class="btn btn-success">Dodaj produkt</a>
|
||||
<!-- przycisk pokaż dane z XML -->
|
||||
<? if ( !$this -> show_xml_data ):?>
|
||||
<a href="/admin/shop_product/view_list/show_xml_data=true" class="btn btn-dark">Pokaż dane z XML</a>
|
||||
<? else:?>
|
||||
<a href="/admin/shop_product/view_list/show_xml_data=false" class="btn btn-danger">Ukryj dane z XML</a>
|
||||
<? endif;?>
|
||||
<? if ( $this -> shoppro_enabled ):?>
|
||||
<a href="#" class="btn btn-danger btn-shoppro-product-import">Pobierz produkt z shopPRO</a>
|
||||
<? endif;?>
|
||||
</div>
|
||||
<div class="panel-body pn">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-striped mbn" id="table-products">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 10px;">#</th>
|
||||
<th>Nazwa</th>
|
||||
<th class="text-center" style="width: 100px;">Cena</th>
|
||||
<th class="text-center" style="width: 100px;">Cena promocyjna</th>
|
||||
<th class="text-center" style="width: 25px;">Promowany</th>
|
||||
<th class="text-center" style="width: 25px;">Aktywny</th>
|
||||
<th class="text-center" style="width: 75px;">Stan MG</th>
|
||||
<? if ( $this -> baselinker_enabled ):?>
|
||||
<th class="text-center" style="width: 100px;">Baselinker</th>
|
||||
<? endif;?>
|
||||
<? if ( $this -> apilo_enabled ):?>
|
||||
<th class="text-center" style="width: 100px;">Apilo</th>
|
||||
<? endif;?>
|
||||
<? if ( $this -> sellasist_enabled ):?>
|
||||
<th class="text-center" style="width: 100px;">Sellasist</th>
|
||||
<? endif;?>
|
||||
<th class="text-center" style="width: 100px;">Kombinacje</th>
|
||||
<th class="text-center" style="width: 75px;">Edytuj</th>
|
||||
<th class="text-center" style="width: 75px;">Archiwizuj</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>
|
||||
<input type="text" class="form-control table-search" field_name="name|ean|sku" placeholder="szukaj..." value="<?= htmlspecialchars( $this -> query_array['name|ean|sku'], ENT_QUOTES, 'UTF-8');?>">
|
||||
</th>
|
||||
<th colspan="10"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="12">
|
||||
<ul class="pagination" pagination_max="<?= $this -> pagination_max;?>">
|
||||
<li>
|
||||
<a href="#" page="1" title="pierwsza strona">
|
||||
<i class="fa fa-angle-double-left"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="previous" page="<?= ( $this -> current_page - 1 > 1 ) ? ( $this -> current_page - 1 ) : 1;?>" title="poprzednia strona">
|
||||
<i class="fa fa-angle-left" title="poprzednia strona"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<div>
|
||||
Strona <input type="number" id="current-page" value="<?= $this -> current_page;?>"> z <span id="max_page"><?= $this -> pagination_max;?></span>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="next" page="<?= ( $this -> current_page + 1 < $this -> pagination_max ) ? ( $this -> current_page + 1 ) : $this -> pagination_max;?>" title="następna strona">
|
||||
<i class="fa fa-angle-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="last" page="<?= $this -> pagination_max;?>" title="ostatnia strona">
|
||||
<i class="fa fa-angle-double-right"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$( function() {
|
||||
ajax_load_products( <?= $this -> current_page;?>, null );
|
||||
|
||||
$( 'body' ).on( 'change', '.table-search', function() {
|
||||
ajax_load_products( 1 );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.pagination input[type="number"]', function() {
|
||||
var current_page = $( this ).val();
|
||||
var pagination_max = parseInt( $( '.pagination' ).attr( 'pagination_max' ) );
|
||||
|
||||
if ( current_page > pagination_max ) {
|
||||
current_page = pagination_max;
|
||||
$( this ).val( current_page );
|
||||
}
|
||||
|
||||
if ( current_page < 1 ) {
|
||||
current_page = 1;
|
||||
$( this ).val( current_page );
|
||||
}
|
||||
|
||||
ajax_load_products( current_page );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.pagination a', function() {
|
||||
var current_page = $( this ).attr( 'page' );
|
||||
ajax_load_products( current_page );
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.btn-shoppro-product-import', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
// show alert with form with product_id field
|
||||
$.alert({
|
||||
title: 'Import produktu',
|
||||
content: 'Wprowadź ID produktu z shopPRO',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-8',
|
||||
theme: 'material',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Importuj',
|
||||
btnClass: 'btn-success',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
var product_id = $( '#shoppro-product-id' ).val();
|
||||
if ( product_id )
|
||||
{
|
||||
document.location.href = '/admin/integrations/shoppro_product_import/product_id=' + product_id;
|
||||
}
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {}
|
||||
}
|
||||
},
|
||||
onOpenBefore: function() {
|
||||
this.setContent( '<input type="text" class="form-control" id="shoppro-product-id" placeholder="ID produktu z shopPRO">' );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.product-delete', function(e) {
|
||||
e.preventDefault();
|
||||
var href = $( this ).attr( 'href' );
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz przenieść wybrany produkt do archiwum?',
|
||||
type: 'orange',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'supervan',
|
||||
icon: 'fa fa-question',
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-success',
|
||||
action: function() {}
|
||||
},
|
||||
confirm: {
|
||||
text: 'Tak',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = href;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
$( 'body' ).on( 'change', '.product-price-promo', function(e)
|
||||
{
|
||||
var price = $( this ).val();
|
||||
price = price.replace( ' ', '' );
|
||||
price = parseFloat( price.replace( ',', '.' ) * 1 );
|
||||
price = number_format( price, 2, '.', '' );
|
||||
|
||||
$( this ).val( price );
|
||||
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_change_price_brutto_promo/',
|
||||
data:
|
||||
{
|
||||
product_id: product_id,
|
||||
price: price
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status !== 'ok' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.product-price', function(e)
|
||||
{
|
||||
var price = $( this ).val();
|
||||
price = price.replace( ' ', '' );
|
||||
price = parseFloat( price.replace( ',', '.' ) * 1 );
|
||||
price = number_format( price, 2, '.', '' );
|
||||
|
||||
$( this ).val( price );
|
||||
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_change_price_brutto/',
|
||||
data:
|
||||
{
|
||||
product_id: product_id,
|
||||
price: price
|
||||
},
|
||||
beforeSend: function()
|
||||
{
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( data )
|
||||
{
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
response = jQuery.parseJSON( data );
|
||||
|
||||
if ( response.status !== 'ok' )
|
||||
create_error( response.msg );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.duplicate-product', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz wykonać duplikat produktu?',
|
||||
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 (produkt bez kombinacji)',
|
||||
btnClass: 'btn-success',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = '/admin/shop_product/duplicate_product/product-id=' + product_id;
|
||||
}
|
||||
},
|
||||
confirm2: {
|
||||
text: 'Tak (produkt z KOMBINACJAMI)',
|
||||
btnClass: 'btn-primary',
|
||||
keys: ['enter'],
|
||||
action: function() {
|
||||
document.location.href = '/admin/shop_product/duplicate_product/product-id=' + product_id + '&combination=1';
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-dark',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
// sellasist product search
|
||||
$( 'body' ).on( 'click', '.sellasist-product-search', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/sellasist_product_search/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'SUCCESS' ) {
|
||||
var html = '<div class="sellasist-found-products">';
|
||||
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
|
||||
html += '<select class="form-control sellasist-product-select" product-id="' + product_id + '">';
|
||||
$.each( data.products, function( index, value ) {
|
||||
html += '<option value="' + value.id + '">' + value.name + ' SKU: ' + value.symbol + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
html += '<button class="btn btn-success sellasist-product-select-save" product-id="' + product_id + '">Zapisz</button>';
|
||||
html += '</div>';
|
||||
$( 'span.sellasist-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
} else if ( data.status == 'error' ) {
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.msg,
|
||||
type: 'red',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'OK',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// apilo product search
|
||||
$( 'body' ).on( 'click', '.apilo-product-search', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_search/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'SUCCESS' )
|
||||
{
|
||||
if ( data.products.length == 0 )
|
||||
{
|
||||
var html = '<div class="baselinker-found-products">';
|
||||
html += '<p>Nie znaleziono produktów</p>';
|
||||
// button to create product on baselinker
|
||||
html += '<a href="/admin/integrations/apilo_create_product/product-id=' + product_id + '" class="btn btn-success btn_apilo_create_product" product_id="' + product_id + '">Utwórz produkt</a>';
|
||||
html += '</div>';
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
}
|
||||
else
|
||||
{
|
||||
var html = '<div class="apilo-found-products">';
|
||||
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
|
||||
html += '<select class="form-control apilo-product-select" product-id="' + product_id + '">';
|
||||
$.each( data.products, function( index, value ) {
|
||||
html += '<option value="' + value.id + '">' + value.name + ' SKU: ' + value.sku + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
html += '<button class="btn btn-success apilo-product-select-save" product-id="' + product_id + '">Zapisz</button>';
|
||||
html += '</div>';
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
}
|
||||
}
|
||||
else if ( data.status == 'error' )
|
||||
{
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.msg,
|
||||
type: 'red',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'OK',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// sellasist product delete linking
|
||||
$( 'body' ).on( 'click', '.sellasist-delete-linking', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/sellasist_product_select_delete/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( 'span.sellasist-delete-linking[product-id="' + product_id + '"]' ).closest('td').html( '<span class="text-danger sellasist-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// delete apilo product linking
|
||||
$( 'body' ).on( 'click', '.apilo-delete-linking', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_select_delete/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( 'span.apilo-delete-linking[product-id="' + product_id + '"]' ).closest('td').html( '<span class="text-danger apilo-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// delete baselinker product linking
|
||||
$( 'body' ).on( 'click', '.baselinker-delete-linking', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/baselinker_product_select_delete/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( 'span.baselinker-delete-linking[product-id="' + product_id + '"]' ).closest('td').html( '<span class="text-danger baselinker-product-search" product-id="' + product_id + '">nie przypisano <i class="fa fa-search"></i></span>' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// aplio product create button click with alert confirmation
|
||||
$( 'body' ).on( 'click', '.btn_apilo_create_product', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product_id' );
|
||||
|
||||
$.alert(
|
||||
{
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz utworzyć produkt w bazie Apilo?',
|
||||
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 = '/admin/integrations/apilo_create_product/product_id=' + product_id;
|
||||
}
|
||||
},
|
||||
cancel:
|
||||
{
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// baselinker product create button click with alert confirmation
|
||||
$( 'body' ).on( 'click', '.btn-create-product', function(e) {
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.alert({
|
||||
title: 'Pytanie',
|
||||
content: 'Na pewno chcesz utworzyć produkt w bazie Baselinker?',
|
||||
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 = '/admin/integrations/baselinker_create_product/product_id=' + product_id;
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Nie',
|
||||
btnClass: 'btn-danger',
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.baselinker-product-search', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/baselinker_product_search/',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'SUCCESS' )
|
||||
{
|
||||
if ( data.products.length == 0 )
|
||||
{
|
||||
var html = '<div class="baselinker-found-products">';
|
||||
html += '<p>Nie znaleziono produktów</p>';
|
||||
// button to create product on baselinker
|
||||
html += '<a href="/admin/integrations/baselinker_create_product/product-id=' + product_id + '" class="btn btn-success btn-create-product" product-id="' + product_id + '">Utwórz produkt</a>';
|
||||
html += '</div>';
|
||||
$( 'span.baselinker-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
}
|
||||
else
|
||||
{
|
||||
var html = '<div class="baselinker-found-products">';
|
||||
html += '<p>Znaleziono ' + data.products.length + ' produktów</p>';
|
||||
html += '<select class="form-control baselinker-product-select" product-id="' + product_id + '">';
|
||||
$.each( data.products, function( index, value ) {
|
||||
html += '<option value="' + value.product_id + '">' + value.name + ' SKU: ' + value.sku + '</option>';
|
||||
});
|
||||
html += '</select>';
|
||||
html += '<button class="btn btn-success baselinker-product-select-save" product-id="' + product_id + '">Zapisz</button>';
|
||||
html += '</div>';
|
||||
$( 'span.baselinker-product-search[product-id="' + product_id + '"]' ).closest( 'td' ).append( html );
|
||||
}
|
||||
}
|
||||
else if ( data.status == 'error' )
|
||||
{
|
||||
$.alert({
|
||||
title: 'Błąd',
|
||||
content: data.msg,
|
||||
type: 'red',
|
||||
closeIcon: true,
|
||||
closeIconClass: 'fa fa-times',
|
||||
typeAnimated: true,
|
||||
animation: 'opacity',
|
||||
columnClass: 'col-12 col-lg-10',
|
||||
theme: 'modern',
|
||||
icon: 'fa fa-exclamation-triangle',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'OK',
|
||||
btnClass: 'btn-danger',
|
||||
keys: ['enter'],
|
||||
action: function() {}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// sellasist product select save
|
||||
$( 'body' ).on( 'click', '.sellasist-product-select-save', function(){
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var sellasist_product_id = $( '.sellasist-product-select[product-id="' + product_id + '"]' ).val();
|
||||
var sellasist_product_name = $( '.sellasist-product-select[product-id="' + product_id + '"] option:selected' ).text();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/sellasist_product_select_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
sellasist_product_id: sellasist_product_id,
|
||||
sellasist_product_name: sellasist_product_name
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '.sellasist-product-select[product-id="' + product_id + '"]' ).closest( '.sellasist-found-products' ).remove();
|
||||
$( 'span.sellasist-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + sellasist_product_name + '">' + sellasist_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'sellasist-product-search' ).removeClass( 'text-danger' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// apilo product select save
|
||||
$( 'body' ).on( 'click', '.apilo-product-select-save', function(){
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var apilo_product_id = $( '.apilo-product-select[product-id="' + product_id + '"]' ).val();
|
||||
var apilo_product_name = $( '.apilo-product-select[product-id="' + product_id + '"] option:selected' ).text();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/apilo_product_select_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
apilo_product_id: apilo_product_id,
|
||||
apilo_product_name: apilo_product_name
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '.apilo-product-select[product-id="' + product_id + '"]' ).closest( '.apilo-found-products' ).remove();
|
||||
$( 'span.apilo-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + apilo_product_name + '">' + apilo_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'apilo-product-search' ).removeClass( 'text-danger' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.baselinker-product-select-save', function(){
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var baselinker_product_id = $( '.baselinker-product-select[product-id="' + product_id + '"]' ).val();
|
||||
var baselinker_product_name = $( '.baselinker-product-select[product-id="' + product_id + '"] option:selected' ).text();
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/integrations/baselinker_product_select_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
baselinker_product_id: baselinker_product_id,
|
||||
baselinker_product_name: baselinker_product_name
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' ) {
|
||||
$( '.baselinker-product-select[product-id="' + product_id + '"]' ).closest( '.baselinker-found-products' ).remove();
|
||||
$( 'span.baselinker-product-search[product-id="' + product_id + '"]' ).html( '<span title="' + baselinker_product_name + '">' + baselinker_product_name.substr( 0, 25 ) + '...</span>' ).removeClass( 'baselinker-product-search' ).removeClass( 'text-danger' );
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.product_xml_name', function() {
|
||||
var product_id = $( this ).attr( 'product-id' );
|
||||
var product_xml_name = $( this ).val();
|
||||
var lang_id = $( this ).attr( 'lang-id' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_xml_name_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
product_xml_name: product_xml_name,
|
||||
lang_id: lang_id
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// save custom_label on change
|
||||
$( 'body' ).on( 'change', '.custom_label_0, .custom_label_1, .custom_label_2, .custom_label_3, .custom_label_4', function() {
|
||||
var element = $( this );
|
||||
var product_id = element.attr( 'product-id' );
|
||||
var custom_label = element.val();
|
||||
var label_type = element.attr( 'label-type' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_custom_label_save/',
|
||||
data: {
|
||||
product_id: product_id,
|
||||
custom_label: custom_label,
|
||||
label_type: label_type
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
// hide after 1 seconds
|
||||
setTimeout(function(){
|
||||
element.parent( '.' + label_type + '_container' ).find( '.' + label_type + '_suggestions' ).hide();
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// on keyup
|
||||
$( 'body' ).on( 'keyup', '.custom_label_0, .custom_label_1, .custom_label_2, .custom_label_3, .custom_label_4', function() {
|
||||
var element = $( this );
|
||||
var product_id = element.attr( 'product-id' );
|
||||
var custom_label = element.val();
|
||||
var label_type = element.attr( 'label-type' );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/product_custom_label_suggestions/',
|
||||
data: {
|
||||
custom_label: custom_label,
|
||||
label_type: label_type
|
||||
},
|
||||
beforeSend: function() {
|
||||
|
||||
},
|
||||
success: function( response ) {
|
||||
var data = jQuery.parseJSON( response );
|
||||
var suggestions = "";
|
||||
if ( data.suggestions.length > 0 ) {
|
||||
for ( var i = 0; i < data.suggestions.length; i++ ) {
|
||||
suggestions += "<div>" + data.suggestions[i].label + "</div>";
|
||||
}
|
||||
element.parent( '.' + label_type + '_container' ).find( '.' + label_type + '_suggestions' ).html( suggestions ).show();
|
||||
} else {
|
||||
element.parent( '.' + label_type + '_container' ).find( '.' + label_type + '_suggestions' ).hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.custom_label_0_suggestions div, .custom_label_1_suggestions div, .custom_label_2_suggestions div, .custom_label_3_suggestions div, .custom_label_4_suggestions div', function(){
|
||||
var element = $( this );
|
||||
var label_type = element.parent().attr( 'label-type' );
|
||||
var custom_label = element.html();
|
||||
|
||||
element.parents( '.' + label_type + '_container' ).find( 'input' ).val( custom_label );
|
||||
// trigger change
|
||||
element.parents( '.' + label_type + '_container' ).find( 'input' ).trigger( 'change' );
|
||||
element.parents( '.' + label_type + '_container' ).find( '.' + label_type + '_suggestions' ).hide();
|
||||
});
|
||||
|
||||
function ajax_load_products( current_page ) {
|
||||
var pagination_max = parseInt( $( '.pagination' ).attr( 'pagination_max' ) );
|
||||
|
||||
var query = '';
|
||||
$( '.table-search' ).each(function(){
|
||||
query += $( this ).attr( 'field_name' ) + '=' + $( this ).val() + '&';
|
||||
});
|
||||
|
||||
current_page = parseInt( current_page );
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
cache: false,
|
||||
url: '/admin/shop_product/ajax_load_products/',
|
||||
data: {
|
||||
current_page: current_page,
|
||||
query: query
|
||||
},
|
||||
beforeSend: function() {
|
||||
$( '#overlay' ).show();
|
||||
},
|
||||
success: function( response ) {
|
||||
$( '#overlay' ).hide();
|
||||
|
||||
data = jQuery.parseJSON( response );
|
||||
|
||||
if ( data.status == 'ok' )
|
||||
{
|
||||
$( '#table-products tbody' ).html( data.html );
|
||||
$( '.pagination .previous' ).attr( 'page', ( current_page - 1 > 1 ) ? ( current_page - 1 ) : 1 );
|
||||
$( '.pagination .next' ).attr( 'page', ( current_page + 1 < pagination_max ) ? ( current_page + 1 ) : pagination_max );
|
||||
$( '.pagination span' ).html( current_page );
|
||||
if ( data.pagination_max )
|
||||
{
|
||||
$( '.pagination' ).attr( 'pagination_max', data.pagination_max );
|
||||
$( '.pagination #max_page' ).html( data.pagination_max );
|
||||
$( '.pagination .last' ).attr( 'page', data.pagination_max );
|
||||
}
|
||||
$( '#current-page' ).val( current_page );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?= \Shared\Tpl\Tpl::view('components/table-list', ['list' => $this->viewModel]); ?>
|
||||
|
||||
<?php if (!empty($this->viewModel->customScriptView)): ?>
|
||||
<?= \Shared\Tpl\Tpl::view($this->viewModel->customScriptView, [
|
||||
'list' => $this->viewModel,
|
||||
'apilo_enabled' => $this->apilo_enabled,
|
||||
'shoppro_enabled' => $this->shoppro_enabled,
|
||||
]); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -3,14 +3,16 @@
|
||||
<? foreach ( $this -> categories as $category ):?>
|
||||
<li id="list_<?= $category[ 'id' ];?>" class="list_<?= $category[ 'id' ];?>" category="<?= $category[ 'id' ];?>">
|
||||
<div class="context_0 content content_menu">
|
||||
<span class="disclose"><span></span></span>
|
||||
<button type="button" class="disclose layout-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<? if ( !$category[ 'status' ] ) echo '<i class="fa fa-ban fa-lg text-danger" title="Kategoria nieaktywna"></i>';?>
|
||||
<input type="checkbox" class="g-checkbox" name="<?= $this -> name ? $this -> name : 'categories[]';?>" value="<?= $category[ 'id' ];?>" <? if ( is_array( $this -> product_categories ) and in_array( $category[ 'id' ], $this -> product_categories ) ):?>checked="checked"<? endif;?> />
|
||||
<b><?= $category[ 'languages' ][ $this -> dlang ][ 'title' ];?></b>
|
||||
</div>
|
||||
<?=
|
||||
\Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( $category[ 'id' ] ),
|
||||
\Shared\Tpl\Tpl::view( 'shop-product/subcategories-list', [
|
||||
'categories' => ( new \Domain\Category\CategoryRepository( $GLOBALS['mdb'] ) )->subcategories( $category[ 'id' ] ),
|
||||
'product_categories' => $this -> product_categories,
|
||||
'dlang' => $this -> dlang,
|
||||
'name' => $this -> name
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
$label = trim((string)($this->label ?? 'Kategorie'));
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$selectedIds = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
?>
|
||||
<div class="form-group row js-promotion-row js-promotion-row-categories">
|
||||
<label class="col-lg-4 control-label"><?= htmlspecialchars($label, ENT_QUOTES, 'UTF-8'); ?>:</label>
|
||||
<div class="col-lg-8">
|
||||
<div class="promotion-categories-box">
|
||||
<?= \Shared\Tpl\Tpl::view('shop-promotion/promotion-categories-tree', [
|
||||
'categories' => $categories,
|
||||
'selectedIds' => $selectedIds,
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
68
admin/templates/shop-promotion/promotion-categories-tree.php
Normal file
68
admin/templates/shop-promotion/promotion-categories-tree.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
$categories = is_array($this->categories ?? null) ? $this->categories : [];
|
||||
$inputName = trim((string)($this->inputName ?? 'categories[]'));
|
||||
$selectedRaw = is_array($this->selectedIds ?? null) ? $this->selectedIds : [];
|
||||
$selected = [];
|
||||
foreach ($selectedRaw as $value) {
|
||||
$id = (int)$value;
|
||||
if ($id > 0) {
|
||||
$selected[$id] = true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($categories)): ?>
|
||||
<ol class="promotion-categories-tree">
|
||||
<?php foreach ($categories as $category): ?>
|
||||
<?php
|
||||
$categoryId = (int)($category['id'] ?? 0);
|
||||
if ($categoryId <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = trim((string)($category['title'] ?? ''));
|
||||
if ($title === '') {
|
||||
$title = 'Kategoria #' . $categoryId;
|
||||
}
|
||||
|
||||
$isActive = (int)($category['status'] ?? 0) === 1;
|
||||
$children = is_array($category['subcategories'] ?? null) ? $category['subcategories'] : [];
|
||||
$hasChildren = !empty($children);
|
||||
?>
|
||||
<li class="promotion-category-item<?= $hasChildren ? ' has-children is-collapsed' : ''; ?>">
|
||||
<div class="promotion-category-row">
|
||||
<?php if ($hasChildren): ?>
|
||||
<button type="button" class="promotion-tree-toggle" aria-expanded="false" title="Rozwin / zwin">
|
||||
<i class="fa fa-caret-right"></i>
|
||||
</button>
|
||||
<?php else: ?>
|
||||
<span class="promotion-tree-spacer"></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!$isActive): ?>
|
||||
<i class="fa fa-ban text-danger" title="Kategoria nieaktywna"></i>
|
||||
<?php endif; ?>
|
||||
|
||||
<label class="promotion-category-label">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="g-checkbox"
|
||||
name="<?= htmlspecialchars($inputName, ENT_QUOTES, 'UTF-8'); ?>"
|
||||
value="<?= $categoryId; ?>"
|
||||
<?= isset($selected[$categoryId]) ? 'checked="checked"' : ''; ?>
|
||||
/>
|
||||
<span><?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<?php if ($hasChildren): ?>
|
||||
<?= \Shared\Tpl\Tpl::view('shop-promotion/promotion-categories-tree', [
|
||||
'categories' => $children,
|
||||
'selectedIds' => array_keys($selected),
|
||||
'inputName' => $inputName,
|
||||
]); ?>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user