first commit
This commit is contained in:
25
autoload/admin/controls/class.Archive.php
Normal file
25
autoload/admin/controls/class.Archive.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
class Archive {
|
||||
static public function products_list() {
|
||||
|
||||
$current_page = \S::get_session( 'archive_products_list_current_page' );
|
||||
|
||||
if ( !$current_page ) {
|
||||
$current_page = 1;
|
||||
\S::set_session( 'archive_products_list_current_page', $current_page );
|
||||
}
|
||||
|
||||
$query = \S::get_session( 'archive_products_list_query' );
|
||||
if ( $query ) {
|
||||
$query_array = [];
|
||||
parse_str( $query, $query_array );
|
||||
}
|
||||
|
||||
return \Tpl::view( 'archive/products-list', [
|
||||
'current_page' => $current_page,
|
||||
'query_array' => $query_array,
|
||||
'pagination_max' => ceil( \admin\factory\ShopProduct::count_product() / 10 )
|
||||
] );
|
||||
}
|
||||
}
|
||||
62
autoload/admin/controls/class.Articles.php
Normal file
62
autoload/admin/controls/class.Articles.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Articles
|
||||
{
|
||||
public static function gallery_order_save()
|
||||
{
|
||||
if ( \admin\factory\Articles::gallery_order_save( \S::get( 'article_id' ), \S::get( 'order' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.' ] );
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function browse_list()
|
||||
{
|
||||
return \admin\view\Articles::browse_list();
|
||||
}
|
||||
|
||||
public static function article_delete()
|
||||
{
|
||||
if ( \admin\factory\Articles::articles_set_archive( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Artykuł został przeniesiony do archiwum.' );
|
||||
header( 'Location: /admin/articles/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function article_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania artykułu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Articles::article_save(
|
||||
$values['id'], $values['title'], $values['main_image'], $values['entry'], $values['text'], $values['table_of_contents'], $values['status'], $values['show_title'], $values['show_table_of_contents'], $values['show_date_add'], $values['date_add'], $values['show_date_modify'], $values['date_modify'], $values['seo_link'], $values['meta_title'],
|
||||
$values['meta_description'], $values['meta_keywords'], $values['layout_id'], $values['pages'], $values['noindex'], $values['repeat_entry'], $values['copy_from'], $values['social_icons'], $values['block_direct_access']
|
||||
) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Artykuł został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function article_edit()
|
||||
{
|
||||
\admin\factory\Articles::delete_nonassigned_images();
|
||||
\admin\factory\Articles::delete_nonassigned_files();
|
||||
|
||||
return \admin\view\Articles::article_edit(
|
||||
\admin\factory\Articles::article_details(
|
||||
\S::get( 'id' )
|
||||
),
|
||||
\admin\factory\Pages::menus_list(),
|
||||
\admin\factory\Languages::languages_list(),
|
||||
\admin\factory\Layouts::layouts_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Articles::articles_list();
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
autoload/admin/controls/class.ArticlesArchive.php
Normal file
26
autoload/admin/controls/class.ArticlesArchive.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class ArticlesArchive
|
||||
{
|
||||
public static function article_restore()
|
||||
{
|
||||
if ( \admin\factory\ArticlesArchive::article_restore( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Artykuł został przywrócony.' );
|
||||
header( 'Location: /admin/articles_archive/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function article_delete()
|
||||
{
|
||||
if ( \admin\factory\ArticlesArchive::article_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Artykuł został usunięty.' );
|
||||
header( 'Location: /admin/articles_archive/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\ArticlesArchive::articles_list();
|
||||
}
|
||||
}
|
||||
43
autoload/admin/controls/class.Banners.php
Normal file
43
autoload/admin/controls/class.Banners.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace admin\controls;
|
||||
|
||||
class Banners
|
||||
{
|
||||
public static function banner_delete()
|
||||
{
|
||||
if ( \admin\factory\Banners::banner_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Baner został usunięty.' );
|
||||
header( 'Location: /admin/banners/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function banner_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania baneru wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $banner_id = \admin\factory\Banners::banner_save( $values['id'], $values['name'], $values['status'], $values['date_start'], $values['date_end'],
|
||||
$values['home_page'], $values['src'], $values['url'], $values['html'], $values['text'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Baner został zapisany.', 'id' => $banner_id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function banner_edit()
|
||||
{
|
||||
return \admin\view\Banners::banner_edit(
|
||||
\admin\factory\Banners::banner_details(
|
||||
\S::get( 'id' )
|
||||
),
|
||||
\admin\factory\Languages::languages_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Banners::banners_list();
|
||||
}
|
||||
}
|
||||
?>
|
||||
20
autoload/admin/controls/class.Baselinker.php
Normal file
20
autoload/admin/controls/class.Baselinker.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Baselinker {
|
||||
|
||||
// widok wiązania produktów
|
||||
static public function bundling_products() {
|
||||
return \Tpl::view( 'baselinker/bundling-products', [
|
||||
'products' => \admin\factory\ShopProduct::products_list_for_baselinker(),
|
||||
'baselinker_products' => \admin\factory\Baselinker::products_list()
|
||||
] );
|
||||
}
|
||||
|
||||
// zapis wiązania produktów
|
||||
static public function bundling_products_save() {
|
||||
\admin\factory\Baselinker::bundling_products_save( $_POST );
|
||||
header( 'Location: /admin/baselinker/bundling_products/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
18
autoload/admin/controls/class.Dashboard.php
Normal file
18
autoload/admin/controls/class.Dashboard.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
class Dashboard
|
||||
{
|
||||
static public function main_view()
|
||||
{
|
||||
return \Tpl::view( 'dashboard/main-view', [
|
||||
'last_orders' => \shop\Dashboard::last_orders(),
|
||||
'order_statuses' => \shop\Order::order_statuses(),
|
||||
'sales' => \shop\Dashboard::last_24_months_sales(),
|
||||
'best_sales_products' => \shop\Dashboard::best_sales_products(),
|
||||
'most_view_products' => \shop\Dashboard::most_view_products(),
|
||||
'sales_grid' => \shop\Dashboard::sales_grid(),
|
||||
'summary_sales' => \shop\Dashboard::summary_sales(),
|
||||
'summary_orders' => \shop\Dashboard::summary_orders(),
|
||||
] );
|
||||
}
|
||||
}
|
||||
39
autoload/admin/controls/class.Dictionaries.php
Normal file
39
autoload/admin/controls/class.Dictionaries.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Dictionaries {
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'dictionaries/units-list' );
|
||||
}
|
||||
|
||||
public static function unit_edit()
|
||||
{
|
||||
return \Tpl::view( 'dictionaries/unit-edit', [
|
||||
'unit' => \admin\factory\Dictionaries::unit_details( \S::get( 'id' )),
|
||||
'languages' => \admin\factory\Languages::languages_list(),
|
||||
] );
|
||||
}
|
||||
|
||||
static public function unit_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania jednostki miary wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Dictionaries::unit_save( $values['id'], $values['text']) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Jednostka miary została zapisana.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
static public function unit_delete()
|
||||
{
|
||||
if ( \admin\factory\Dictionaries::unit_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Jesdnostka miary została usunięta.' );
|
||||
|
||||
header( 'Location: /admin/dictionaries/view_list/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
11
autoload/admin/controls/class.Filemanager.php
Normal file
11
autoload/admin/controls/class.Filemanager.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Filemanager
|
||||
{
|
||||
public function draw()
|
||||
{
|
||||
return \admin\view\FileManager::filemanager();
|
||||
}
|
||||
}
|
||||
?>
|
||||
846
autoload/admin/controls/class.Integrations.php
Normal file
846
autoload/admin/controls/class.Integrations.php
Normal file
@@ -0,0 +1,846 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class Integrations {
|
||||
|
||||
// apilo_create_product
|
||||
static public function apilo_create_product()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$product_id = \S::get( 'product_id' );
|
||||
$product = new \shop\Product( $product_id );
|
||||
|
||||
$methodParams = [
|
||||
"sku" => $product -> sku,
|
||||
"ean" => $product -> ean,
|
||||
"name" => $product -> language['name'],
|
||||
"tax" => (int) $product -> vat,
|
||||
'status' => 1,
|
||||
"quantity" => (int) $product -> quantity,
|
||||
"priceWithTax" => $product -> price_brutto,
|
||||
'description' => $product -> language['description'] . '<br>' . $product -> language['short_description'],
|
||||
'shortDescription' => '',
|
||||
'images' => []
|
||||
];
|
||||
|
||||
foreach ($product->images as $image) {
|
||||
$methodParams["images"][] = "https://" . $_SERVER['HTTP_HOST'] . $image['src'];
|
||||
}
|
||||
|
||||
$ch = curl_init( "https://projectpro.apilo.com/rest/api/warehouse/product/" );
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode( [ $methodParams ] ) );
|
||||
curl_setopt( $ch, CURLOPT_CUSTOMREQUEST, "POST" );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Content-Type: application/json",
|
||||
"Accept: application/json"
|
||||
] );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData['products'] )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_products', [ 'apilo_product_id' => reset( $responseData['products'] ), 'apilo_product_name' => $product->language['name'] ], [ 'id' => $product -> id ] );
|
||||
}
|
||||
|
||||
\S::alert( 'Produkt został dodany do magazynu APILO.' );
|
||||
}
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// baselinker_create_product
|
||||
static public function baselinker_create_product()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$api_code = \admin\factory\Integrations::baselinker_settings( 'api_code' );
|
||||
|
||||
$product_id = \S::get( 'product_id' );
|
||||
$product = \shop\Product::getFromCache( $product_id, 'pl' );
|
||||
|
||||
$methodParams = [
|
||||
"storage_id" => \admin\factory\Integrations::baselinker_settings('storage_id'),
|
||||
"ean" => $product->ean,
|
||||
"sku" => $product->sku,
|
||||
"name" => $product->language['name'],
|
||||
"quantity" => "0",
|
||||
"price_brutto" => $product->price_brutto,
|
||||
"tax_rate" => $product->vat,
|
||||
"description" => $product->language['short_description'],
|
||||
"description_extra1" => $product->language['description'],
|
||||
"images" => []
|
||||
];
|
||||
|
||||
foreach ($product->images as $image) {
|
||||
$methodParams["images"][] = "url:https://" . $_SERVER['HTTP_HOST'] . $image['src'];
|
||||
}
|
||||
|
||||
$methodParams = json_encode( $methodParams, JSON_UNESCAPED_SLASHES );
|
||||
|
||||
$apiParams = [
|
||||
"token" => $api_code,
|
||||
"method" => "addProduct",
|
||||
"parameters" => $methodParams
|
||||
];
|
||||
|
||||
$curl = curl_init( "https://api.baselinker.com/connector.php" );
|
||||
curl_setopt( $curl, CURLOPT_POST, 1 );
|
||||
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $apiParams ) );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = json_decode( curl_exec( $curl ), true );
|
||||
|
||||
if ( $response['status'] == 'SUCCESS' )
|
||||
{
|
||||
if ( $response['product_id'] )
|
||||
{
|
||||
$mdb -> update( 'pp_shop_products', [ 'baselinker_product_id' => $response['product_id'], 'baselinker_product_name' => $product->language['name'] ], [ 'id' => $product -> id ] );
|
||||
}
|
||||
|
||||
\S::alert( 'Produkt został dodany do magazynu Baselinker.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Podczas dodawania produktu wystąpił błąd.' );
|
||||
}
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// baselinker pobierz listę magazynów
|
||||
static public function baselinker_get_storages_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$api_code = \admin\factory\Integrations::baselinker_settings( 'api_code' );
|
||||
|
||||
$methodParams = '{
|
||||
"storage_id": "bl_1"
|
||||
}';
|
||||
|
||||
$apiParams = [
|
||||
"token" => $api_code,
|
||||
"method" => "getStoragesList",
|
||||
"parameters" => $methodParams
|
||||
];
|
||||
|
||||
$curl = curl_init( "https://api.baselinker.com/connector.php" );
|
||||
curl_setopt( $curl, CURLOPT_POST, 1 );
|
||||
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $apiParams ) );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = json_decode( curl_exec( $curl ), true );
|
||||
|
||||
if ( $response['status'] == 'SUCCESS' )
|
||||
{
|
||||
\admin\factory\Integrations::baselinker_settings_save( 'storages_list', $response['storages'] );
|
||||
\S::alert( 'Lista magazynów została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
header( 'Location: /admin/integrations/baselinker_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// baselinker_get_order_status_list
|
||||
static public function baselinker_get_order_status_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$api_code = \admin\factory\Integrations::baselinker_settings( 'api_code' );
|
||||
|
||||
$apiParams = [
|
||||
"token" => $api_code,
|
||||
"method" => "getOrderStatusList",
|
||||
"parameters" => []
|
||||
];
|
||||
|
||||
$curl = curl_init( "https://api.baselinker.com/connector.php" );
|
||||
curl_setopt( $curl, CURLOPT_POST, 1 );
|
||||
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $apiParams ) );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = json_decode( curl_exec( $curl ), true );
|
||||
|
||||
if ( $response['status'] == 'SUCCESS' )
|
||||
{
|
||||
\admin\factory\Integrations::baselinker_settings_save( 'order_status_list', $response['statuses'] );
|
||||
\S::alert( 'Lista statusów została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
header( 'Location: /admin/integrations/baselinker_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_sellasist_carriers_list
|
||||
static public function get_sellasist_shipments_list()
|
||||
{
|
||||
$api_code = \admin\factory\Integrations::sellasist_settings( 'api_code' );
|
||||
|
||||
$ch = curl_init( "https://projectpro.sellasist.pl/api/v1/shipments" );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"apiKey: " . $api_code,
|
||||
"accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
else {
|
||||
if ( $responseData ) {
|
||||
\admin\factory\Integrations::sellasist_settings_save( 'shipments_methods', $responseData );
|
||||
\S::alert( 'Lista przewoźników została pobrana.' );
|
||||
} else
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
header( 'Location: /admin/integrations/sellasist_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_sellasist_payment_types_list
|
||||
static public function get_sellasist_payment_types_list()
|
||||
{
|
||||
$api_code = \admin\factory\Integrations::sellasist_settings( 'api_code' );
|
||||
|
||||
$ch = curl_init( "https://projectpro.sellasist.pl/api/v1/payments" );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"apiKey: " . $api_code,
|
||||
"accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
else {
|
||||
if ( $responseData ) {
|
||||
\admin\factory\Integrations::sellasist_settings_save( 'payment_types_list', $responseData );
|
||||
\S::alert( 'Lista metod płatności została pobrana.' );
|
||||
} else
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
header( 'Location: /admin/integrations/sellasist_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function get_sellasist_status_types_list()
|
||||
{
|
||||
$api_code = \admin\factory\Integrations::sellasist_settings( 'api_code' );
|
||||
|
||||
$ch = curl_init( "https://projectpro.sellasist.pl/api/v1/statuses" );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"apiKey: " . $api_code,
|
||||
"accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
else {
|
||||
if ( $responseData ) {
|
||||
\admin\factory\Integrations::sellasist_settings_save( 'status_types_list', $responseData );
|
||||
\S::alert( 'Lista statusów została pobrana.' );
|
||||
} else
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
header( 'Location: /admin/integrations/sellasist_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_platform_list
|
||||
static public function get_platform_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$url = "https://projectpro.apilo.com/rest/api/orders/platform/map/";
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData )
|
||||
{
|
||||
\admin\factory\Integrations::apilo_settings_save( 'platform-list', $responseData );
|
||||
\S::alert( 'Lista platform została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
}
|
||||
header( 'Location: /admin/integrations/apilo_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_status_types_list
|
||||
static public function get_status_types_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$url = "https://projectpro.apilo.com/rest/api/orders/status/map/";
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData )
|
||||
{
|
||||
\admin\factory\Integrations::apilo_settings_save( 'status-types-list', $responseData );
|
||||
\S::alert( 'Lista statusów została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
}
|
||||
header( 'Location: /admin/integrations/apilo_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_carrier_account_list
|
||||
static public function get_carrier_account_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$url = "https://projectpro.apilo.com/rest/api/orders/carrier-account/map/";
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData )
|
||||
{
|
||||
\admin\factory\Integrations::apilo_settings_save( 'carrier-account-list', $responseData );
|
||||
\S::alert( 'Lista kont przewoźników została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
}
|
||||
header( 'Location: /admin/integrations/apilo_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_payment_types_list
|
||||
static public function get_payment_types_list()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$url = "https://projectpro.apilo.com/rest/api/orders/payment/map/";
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
\S::alert( 'Błąd cURL: ' . curl_error( $ch ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData )
|
||||
{
|
||||
\admin\factory\Integrations::apilo_settings_save( 'payment-types-list', $responseData );
|
||||
\S::alert( 'Lista metod płatności została pobrana.' );
|
||||
}
|
||||
else
|
||||
{
|
||||
\S::alert( 'Brak wyników.' );
|
||||
}
|
||||
}
|
||||
header( 'Location: /admin/integrations/apilo_settings/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// settings for the sellasist integration
|
||||
static public function sellasist_settings()
|
||||
{
|
||||
return \Tpl::view( 'integrations/sellasist-settings', [
|
||||
'settings' => \admin\factory\Integrations::sellasist_settings(),
|
||||
] );
|
||||
}
|
||||
|
||||
// settings for the Baselinker integration
|
||||
static public function baselinker_settings()
|
||||
{
|
||||
return \Tpl::view( 'integrations/baselinker-settings', [
|
||||
'settings' => \admin\factory\Integrations::baselinker_settings(),
|
||||
] );
|
||||
}
|
||||
|
||||
// settings for shoppro
|
||||
static public function shoppro_settings()
|
||||
{
|
||||
return \Tpl::view( 'integrations/shoppro-settings', [
|
||||
'settings' => \admin\factory\Integrations::shoppro_settings(),
|
||||
] );
|
||||
}
|
||||
|
||||
// Settings for the APILO plugin
|
||||
static public function apilo_settings()
|
||||
{
|
||||
|
||||
return \Tpl::view( 'integrations/apilo-settings', [
|
||||
'settings' => \admin\factory\Integrations::apilo_settings(),
|
||||
] );
|
||||
}
|
||||
|
||||
// save settings for the shoppro integration
|
||||
static public function shoppro_settings_save()
|
||||
{
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania ustawień wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$field_id = \S::get( 'field_id' );
|
||||
$value = \S::get( 'value' );
|
||||
|
||||
if ( \admin\factory\Integrations::shoppro_settings_save( $field_id, $value ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.', 'value' => $value ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// save settings for the sellasist integration
|
||||
static public function sellasist_settings_save()
|
||||
{
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania ustawień wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$field_id = \S::get( 'field_id' );
|
||||
$value = \S::get( 'value' );
|
||||
|
||||
if ( \admin\factory\Integrations::sellasist_settings_save( $field_id, $value ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.', 'value' => $value ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// save settings for the Baselinker integration
|
||||
static public function baselinker_settings_save()
|
||||
{
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania ustawień wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$field_id = \S::get( 'field_id' );
|
||||
$value = \S::get( 'value' );
|
||||
|
||||
if ( \admin\factory\Integrations::baselinker_settings_save( $field_id, $value ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.', 'value' => $value ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Save settings for the APILO plugin
|
||||
static public function apilo_settings_save() {
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania ustawień wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$field_id = \S::get( 'field_id' );
|
||||
$value = \S::get( 'value' );
|
||||
|
||||
if ( \admin\factory\Integrations::apilo_settings_save( $field_id, $value ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.', 'value' => $value ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Authorization in apilo.com
|
||||
static public function apilo_authorization() {
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas autoryzacji wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$settings = \admin\factory\Integrations::apilo_settings();
|
||||
|
||||
if ( \admin\factory\Integrations::apilo_authorization( $settings['client-id'], $settings['client-secret'], $settings['authorization-code'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Autoryzacja przebiegła pomyślnie.' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// sellasist product search by sku
|
||||
static public function sellasist_product_search() {
|
||||
global $mdb, $settings;
|
||||
|
||||
$sku = $mdb -> get( 'pp_shop_products', 'sku', [ 'id' => \S::get( 'product_id' ) ] );
|
||||
|
||||
if ( !$sku ) {
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podany produkt nie posiada kodu SKU.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$url = "https://projectpro.sellasist.pl/api/v1/products";
|
||||
$params['symbol '] = $sku;
|
||||
$url .= '?' . http_build_query( $params );
|
||||
|
||||
$api_code = \admin\factory\Integrations::sellasist_settings( 'api_code' );
|
||||
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"apiKey: " . $api_code,
|
||||
"accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) )
|
||||
{
|
||||
echo 'Błąd cURL: ' . curl_error( $ch );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $responseData['error'] )
|
||||
{
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Brak wyników dla podanego SKU.' ] );
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$return_data = array();
|
||||
$return_data['status'] = 'SUCCESS';
|
||||
$return_data['products'] = $responseData;
|
||||
echo json_encode( $return_data );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Brak wyników dla podanego SKU.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// apilo product search by sku
|
||||
static public function apilo_product_search() {
|
||||
global $mdb, $settings;
|
||||
|
||||
$sku = $mdb -> get( 'pp_shop_products', 'sku', [ 'id' => \S::get( 'product_id' ) ] );
|
||||
|
||||
if ( !$sku ) {
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podany produkt nie posiada kodu SKU.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$access_token = \admin\factory\Integrations::apilo_get_access_token();
|
||||
|
||||
$url = "https://projectpro.apilo.com/rest/api/warehouse/product/";
|
||||
$params['sku'] = $sku;
|
||||
$url .= '?' . http_build_query( $params );
|
||||
|
||||
$ch = curl_init( $url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, [
|
||||
"Authorization: Bearer " . $access_token,
|
||||
"Accept: application/json"
|
||||
] );
|
||||
|
||||
$response = curl_exec( $ch );
|
||||
$responseData = json_decode( $response, true );
|
||||
|
||||
if ( curl_errno( $ch ) ) {
|
||||
echo 'Błąd cURL: ' . curl_error( $ch );
|
||||
} else {
|
||||
if ( $responseData && isset( $responseData['products'] ) ) {
|
||||
$responseData['status'] = 'SUCCESS';
|
||||
echo json_encode( $responseData );
|
||||
exit;
|
||||
} else {
|
||||
echo json_encode( [ 'status' => 'SUCCESS', 'msg' => 'Brak wyników dla podanego SKU.', 'products' => '' ] );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
echo json_encode( [ 'status' => 'SUCCESS', 'msg' => 'Brak wyników dla podanego SKU.', 'products' => '' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// wyszukiwanie produktu w bazie baselinkera
|
||||
static public function baselinker_product_search()
|
||||
{
|
||||
global $mdb, $settings;
|
||||
|
||||
$api_code = \admin\factory\Integrations::baselinker_settings( 'api_code' );
|
||||
|
||||
$sku = $mdb -> get( 'pp_shop_products', 'sku', [ 'id' => \S::get( 'product_id' ) ] );
|
||||
|
||||
if ( !$sku ) {
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podany produkt nie posiada kodu SKU.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
$methodParams = '{
|
||||
"storage_id": "bl_1",
|
||||
"filter_sku": "' . $sku . '"
|
||||
}';
|
||||
|
||||
$apiParams = [
|
||||
"token" => $api_code,
|
||||
"method" => "getProductsList",
|
||||
"parameters" => $methodParams
|
||||
];
|
||||
|
||||
$curl = curl_init( "https://api.baselinker.com/connector.php" );
|
||||
curl_setopt( $curl, CURLOPT_POST, 1 );
|
||||
curl_setopt( $curl, CURLOPT_POSTFIELDS, http_build_query( $apiParams ) );
|
||||
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||
$response = json_decode( curl_exec( $curl ), true );
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// sellasist_product_select_delete
|
||||
static public function sellasist_product_select_delete()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::sellasist_product_select_delete( \S::get( 'product_id' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas usuwania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// apilo product select delete
|
||||
static public function apilo_product_select_delete()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::apilo_product_select_delete( \S::get( 'product_id' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas usuwania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// baselinker delete product linking
|
||||
static public function baselinker_product_select_delete()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::baselinker_product_select_delete( \S::get( 'product_id' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas usuwania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// sellasist_product_select_save
|
||||
static public function sellasist_product_select_save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::sellasist_product_select_save( \S::get( 'product_id' ), \S::get( 'sellasist_product_id' ), \S::get( 'sellasist_product_name' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas zapisywania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// apilo product select save
|
||||
static public function apilo_product_select_save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::apilo_product_select_save( \S::get( 'product_id' ), \S::get( 'apilo_product_id' ), \S::get( 'apilo_product_name' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas zapisywania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function baselinker_product_select_save() {
|
||||
global $mdb;
|
||||
|
||||
if ( \admin\factory\Integrations::baselinker_product_select_save( \S::get( 'product_id' ), \S::get( 'baselinker_product_id' ), \S::get( 'baselinker_product_name' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok' ] );
|
||||
else
|
||||
echo json_encode( [ 'status' => 'error', 'msg' => 'Podczas zapisywania produktu wystąpił błąd. Proszę spróbować ponownie.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// shoppro_product_import
|
||||
static public function shoppro_product_import()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$shoppro_settings = \admin\factory\Integrations::shoppro_settings();
|
||||
|
||||
$mdb2 = new \medoo( [
|
||||
'database_type' => 'mysql',
|
||||
'database_name' => $shoppro_settings[ 'db_name' ],
|
||||
'server' => $shoppro_settings[ 'db_host' ],
|
||||
'username' => $shoppro_settings[ 'db_user' ],
|
||||
'password' => $shoppro_settings[ 'db_password' ],
|
||||
'charset' => 'utf8'
|
||||
] );
|
||||
|
||||
$product_id = \S::get( 'product_id' );
|
||||
|
||||
$product = $mdb2 -> get( 'pp_shop_products', '*', [ 'id' => $product_id ] );
|
||||
if ( $product )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_products', [
|
||||
'price_netto' => $product[ 'price_netto' ],
|
||||
'price_brutto' => $product[ 'price_brutto' ],
|
||||
'vat' => $product[ 'vat' ],
|
||||
'stock_0_buy' => $product[ 'stock_0_buy' ],
|
||||
'quantity' => $product[ 'quantity' ],
|
||||
'wp' => $product[ 'wp' ],
|
||||
'sku' => $product[ 'sku' ],
|
||||
'ean' => $product[ 'ean' ],
|
||||
'custom_label_0' => $product[ 'custom_label_0' ],
|
||||
'custom_label_1' => $product[ 'custom_label_1' ],
|
||||
'custom_label_2' => $product[ 'custom_label_2' ],
|
||||
'custom_label_3' => $product[ 'custom_label_3' ],
|
||||
'custom_label_4' => $product[ 'custom_label_4' ],
|
||||
'additional_message' => $product[ 'additional_message' ],
|
||||
'additional_message_text' => $product[ 'additional_message_text' ],
|
||||
'additional_message_required' => $product[ 'additional_message_required' ],
|
||||
'weight' => $product[ 'weight' ]
|
||||
] );
|
||||
|
||||
$new_product_id = $mdb -> id();
|
||||
if ( $new_product_id )
|
||||
{
|
||||
$languages = $mdb2 -> select( 'pp_shop_products_langs', '*', [ 'product_id' => $product_id ] );
|
||||
if ( is_array( $languages ) )
|
||||
{
|
||||
foreach ( $languages as $language )
|
||||
{
|
||||
$mdb -> insert( 'pp_shop_products_langs', [
|
||||
'product_id' => $new_product_id,
|
||||
'lang_id' => $language['lang_id'],
|
||||
'name' => $language['name'],
|
||||
'short_description' => $language['short_description'],
|
||||
'description' => $language['description'],
|
||||
'tab_name_1' => $language['tab_name_1'],
|
||||
'tab_description_1' => $language['tab_description_1'],
|
||||
'tab_name_2' => $language['tab_name_2'],
|
||||
'tab_description_2' => $language['tab_description_2'],
|
||||
'meta_title' => $language['meta_title'],
|
||||
'meta_description' => $language['meta_description'],
|
||||
'meta_keywords' => $language['meta_keywords'],
|
||||
'seo_link' => $language['seo_link'],
|
||||
'copy_from' => $language['copy_from'],
|
||||
'warehouse_message_zero' => $language['warehouse_message_zero'],
|
||||
'warehouse_message_nonzero' => $language['warehouse_message_nonzero'],
|
||||
'canonical' => $language['canonical'],
|
||||
'xml_name' => $language['xml_name']
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
$images = $mdb2 -> select( 'pp_shop_products_images', '*', [ 'product_id' => $product_id ] );
|
||||
if ( is_array( $images ) )
|
||||
{
|
||||
foreach ( $images as $image )
|
||||
{
|
||||
$image_url = 'https://' . $shoppro_settings['domain'] . $image['src'];
|
||||
|
||||
// pobierz zdjęcie za pomocą curl
|
||||
$ch = curl_init( $image_url );
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
|
||||
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
|
||||
$image_data = curl_exec( $ch );
|
||||
$image_data;
|
||||
curl_close( $ch );
|
||||
|
||||
// ścieżdka do nowego zdjęcia to "/upload/product_images/product_[product_id]/[nazwa_zdjęcia]
|
||||
$image_name = basename( $image_url );
|
||||
$image_path = '../upload/product_images/product_' . $new_product_id . '/' . $image_name;
|
||||
|
||||
// utwórz katalog dla zdjęć produktu jeśli nie istnieje
|
||||
if ( !file_exists( '../upload/product_images/product_' . $new_product_id ) )
|
||||
mkdir( '../upload/product_images/product_' . $new_product_id, 0777, true );
|
||||
|
||||
// zapisz zdjęcie
|
||||
file_put_contents( $image_path, $image_data );
|
||||
|
||||
// zapisz zdjęcie w bazie danych
|
||||
$mdb -> insert( 'pp_shop_products_images', [
|
||||
'product_id' => $new_product_id,
|
||||
'src' => '/upload/product_images/product_' . $new_product_id . '/' . $image_name,
|
||||
'o' => $image['o']
|
||||
] );
|
||||
}
|
||||
}
|
||||
|
||||
\S::alert( 'Produkt został zaimportowany.' );
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
\S::alert( 'Podczas importowania produktu wystąpił błąd.' );
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
83
autoload/admin/controls/class.Languages.php
Normal file
83
autoload/admin/controls/class.Languages.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class Languages
|
||||
{
|
||||
public static function language_delete()
|
||||
{
|
||||
if ( \admin\factory\Languages::language_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Język został usunięty.' );
|
||||
header( 'Location: /admin/languages/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function language_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania języka wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( \admin\factory\Languages::language_save(
|
||||
$values['id'], $values['name'], $values['status'],
|
||||
$values['start'], $values['o'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Język został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function language_edit()
|
||||
{
|
||||
return \admin\view\Languages::language_edit(
|
||||
\admin\factory\Languages::language_details(
|
||||
\S::get( 'id' )
|
||||
), \admin\factory\Languages::max_order()
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Languages::languages_list();
|
||||
}
|
||||
|
||||
public static function translation_delete()
|
||||
{
|
||||
if ( \admin\factory\Languages::translation_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Tłumaczenie zostało usunięte.' );
|
||||
header( 'Location: /admin/languages/translation_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function translation_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania tłumaczenia wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
$languages_list = \admin\factory\Languages::languages_list();
|
||||
if ( is_array( $languages_list ) and !empty( $languages_list ) ) foreach ( $languages_list as $language )
|
||||
{
|
||||
\S::delete_session( 'lang-' . $language['id'] );
|
||||
$languages[ $language['id'] ] = $values[ $language['id'] ];
|
||||
}
|
||||
|
||||
if ( $id = \admin\factory\Languages::translation_save( $values['id'], $values['text'], $languages ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Tłumaczenie zostało zapisane.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function translation_edit()
|
||||
{
|
||||
return \admin\view\Languages::translation_edit(
|
||||
\admin\factory\Languages::translation_details( \S::get( 'id' ) ),
|
||||
\admin\factory\Languages::languages_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function translation_list()
|
||||
{
|
||||
return \admin\view\Languages::translations_list();
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
autoload/admin/controls/class.Layouts.php
Normal file
43
autoload/admin/controls/class.Layouts.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Layouts
|
||||
{
|
||||
public static function layout_delete()
|
||||
{
|
||||
if ( \admin\factory\Layouts::layout_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Szablon został usunięty.' );
|
||||
header( 'Location: /admin/layouts/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function layout_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania szablonu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Layouts::layout_save( $values['id'], $values['name'], $values['status'], $values['pages'], $values['html'], $values['css'], $values['js'], $values['m_html'],
|
||||
$values['m_css'], $values['m_js'], $values['categories'], $values['categories_default'] )
|
||||
)
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Szablon został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function layout_edit()
|
||||
{
|
||||
return \Tpl::view( 'layouts/layout-edit', [
|
||||
'layout' => \admin\factory\Layouts::layout_details( \S::get( 'id' ) ),
|
||||
'menus' => \admin\factory\Layouts::menus_list(),
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Layouts::layouts_list();
|
||||
}
|
||||
}
|
||||
?>
|
||||
92
autoload/admin/controls/class.Newsletter.php
Normal file
92
autoload/admin/controls/class.Newsletter.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Newsletter
|
||||
{
|
||||
public static function emails_list()
|
||||
{
|
||||
return \admin\view\Newsletter::emails_list();
|
||||
}
|
||||
|
||||
public static function send()
|
||||
{
|
||||
if ( \admin\factory\Newsletter::send( \S::get( 'dates' ), \S::get('template')) )
|
||||
\S::alert( 'Newsletter został dodany do kolejki wysyłania.' );
|
||||
|
||||
header( 'Location: /admin/newsletter/prepare/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function prepare()
|
||||
{
|
||||
return \admin\view\Newsletter::prepare(
|
||||
\admin\factory\Newsletter::templates_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function settings_save()
|
||||
{
|
||||
$settings = \admin\factory\Settings::settings_details();
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
\admin\factory\Settings::settings_update( 'newsletter_footer', $values['newsletter_footer'] );
|
||||
\admin\factory\Settings::settings_update( 'newsletter_header', $values['newsletter_header'] );
|
||||
|
||||
\S::alert( 'Ustawienia zostały zapisane.' );
|
||||
|
||||
echo json_encode( [ 'status' => 'ok', 'msg' => 'Ustawienia zostały zapisane.' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function settings()
|
||||
{
|
||||
return \admin\view\Newsletter::settings(
|
||||
\admin\factory\Settings::settings_details()
|
||||
);
|
||||
}
|
||||
|
||||
public static function email_templates_user()
|
||||
{
|
||||
return \admin\view\Newsletter::email_templates_user();
|
||||
}
|
||||
|
||||
public static function email_templates_admin()
|
||||
{
|
||||
return \admin\view\Newsletter::email_templates_admin();
|
||||
}
|
||||
|
||||
public static function email_template_delete()
|
||||
{
|
||||
$is_admin = \admin\factory\Newsletter::is_admin_template( \S::get( 'id' ) );
|
||||
|
||||
if ( !$is_admin and \admin\factory\Newsletter::newsletter_template_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Szablon newslettera został usunięty.' );
|
||||
|
||||
if ( $is_admin )
|
||||
header( 'Location: /admin/newsletter/email_templates_admin/' );
|
||||
else
|
||||
header( 'Location: /admin/newsletter/email_templates_user/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function email_template_edit()
|
||||
{
|
||||
return \admin\view\Newsletter::email_template_edit(
|
||||
\admin\factory\Newsletter::email_template_detalis(
|
||||
\S::get( 'id' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function template_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Newsletter::template_save( $values['id'], $values['name'], $values['text'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Zmiany zostały zapisane.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
100
autoload/admin/controls/class.Pages.php
Normal file
100
autoload/admin/controls/class.Pages.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class Pages
|
||||
{
|
||||
public static function pages_url_browser()
|
||||
{
|
||||
echo \Tpl::view( 'pages/pages-browse-list', [
|
||||
'menus' => \admin\factory\Pages::menus_list(),
|
||||
'modal' => \S::get( 'modal' )
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function browse_list()
|
||||
{
|
||||
return \admin\view\Pages::browse_list(
|
||||
\admin\factory\Pages::menus_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function menu_delete()
|
||||
{
|
||||
if ( \admin\factory\Pages::menu_delete( \S::get( 'id' ) ) )
|
||||
\S::set_message( 'Menu zostało usunięte.' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania menu wystąpił błąd. Aby usunąć menu nie może ono posiadać przypiętych stron.' );
|
||||
header( 'Location: /admin/pages/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function page_delete()
|
||||
{
|
||||
if ( \admin\factory\Pages::page_delete( \S::get( 'id' ) ) )
|
||||
\S::set_message( 'Strona została usunięta.' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania strony wystąpił błąd. Aby usunąć stronę nie może ona posiadać przypiętych podstron.' );
|
||||
header( 'Location: /admin/pages/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function page_articles()
|
||||
{
|
||||
return \admin\view\Pages::page_articles( \S::get( 'id' ), \admin\factory\Pages::page_articles( \S::get( 'id' ) ) );
|
||||
}
|
||||
|
||||
public static function page_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania strony wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Pages::page_save(
|
||||
$values['id'], $values['title'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['menu_id'], $values['parent_id'], $values['page_type'],
|
||||
$values['sort_type'], $values['layout_id'], $values['articles_limit'], $values['show_title'], $values['status'], $values['link'], $values['noindex'], $values['start'], $values['page_title'],
|
||||
$values['canonical'], $values['category_id']
|
||||
) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Strona została zapisana.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function page_edit()
|
||||
{
|
||||
return \Tpl::view( 'pages/page-edit', [
|
||||
'page' => \admin\factory\Pages::page_details( \S::get( 'id' ) ),
|
||||
'parent_id' => \S::get( 'pid' ),
|
||||
'menu_id' => \S::get( 'menu_id' ),
|
||||
'menus' => \admin\factory\Pages::menu_lists(),
|
||||
'layouts' => \admin\factory\Layouts::layouts_list(),
|
||||
'languages' => \admin\factory\Languages::languages_list()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function menu_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania menu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( \admin\factory\Pages::menu_save( $values['id'], $values['name'], $values['status'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Menu zostało zapisane.' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function menu_edit()
|
||||
{
|
||||
return \admin\view\Pages::menu_edit(
|
||||
\admin\factory\Pages::menu_details( \S::get( 'id' ) )
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'pages/pages-list', [
|
||||
'menus' => \admin\factory\Pages::menus_list()
|
||||
] );
|
||||
}
|
||||
}
|
||||
?>
|
||||
40
autoload/admin/controls/class.Scontainers.php
Normal file
40
autoload/admin/controls/class.Scontainers.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Scontainers
|
||||
{
|
||||
public static function container_delete()
|
||||
{
|
||||
if ( \admin\factory\Scontainers::container_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Kontener został usunięty.' );
|
||||
header( 'Location: /admin/scontainers/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function container_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kontenera wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\Scontainers::container_save( $values['id'], $values['title'], $values['text'], $values['status'], $values['show_title'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Kontener został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function container_edit()
|
||||
{
|
||||
return \admin\view\Scontainers::container_edit(
|
||||
\admin\factory\Scontainers::container_details(
|
||||
\S::get( 'id' )
|
||||
),
|
||||
\admin\factory\Languages::languages_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Scontainers::containers_list();
|
||||
}
|
||||
}
|
||||
60
autoload/admin/controls/class.Settings.php
Normal file
60
autoload/admin/controls/class.Settings.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class Settings
|
||||
{
|
||||
public static function settings_save()
|
||||
{
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$settings = \admin\factory\Settings::settings_details( true );
|
||||
|
||||
$response = \admin\factory\Settings::settings_save(
|
||||
$values['firm_name'], $values['firm_adress'], $values['additional_info'], $values['contact_form'], $values['contact_email'], $values['email_host'],
|
||||
$values['email_port'], $values['email_login'], $values['email_password'], $values['google_maps'], $values['facebook_link'], $values['statistic_code'], $values['htaccess'],
|
||||
$values['robots'], $values['shop_bank_account_info'], $values['update'], $values['boot_animation'], $settings['newsletter_header'], $settings['newsletter_footer'], $values['hotpay_api']
|
||||
);
|
||||
|
||||
\admin\factory\Settings::settings_update( 'devel', $values['devel'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'ssl', $values['ssl'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'htaccess_cache', $values['htaccess_cache'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'free_delivery', $values['free_delivery'] );
|
||||
\admin\factory\Settings::settings_update( 'przelewy24_sandbox', $values['przelewy24_sandbox'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'przelewy24_merchant_id', $values['przelewy24_merchant_id'] );
|
||||
\admin\factory\Settings::settings_update( 'przelewy24_crc_key', $values['przelewy24_crc_key'] );
|
||||
\admin\factory\Settings::settings_update( 'update_key', $values['update_key'] );
|
||||
\admin\factory\Settings::settings_update( 'tpay_id', $values['tpay_id'] );
|
||||
\admin\factory\Settings::settings_update( 'tpay_sandbox', $values['tpay_sandbox'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'tpay_security_code', $values['tpay_security_code'] );
|
||||
\admin\factory\Settings::settings_update( 'piksel', $values['piksel'] );
|
||||
\admin\factory\Settings::settings_update( 'generate_webp', $values['generate_webp'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'lazy_loading', $values['lazy_loading'] == 'on' ? 1 : 0 );
|
||||
\admin\factory\Settings::settings_update( 'ekomi_survey', $values['ekomi_survey'] );
|
||||
\admin\factory\Settings::settings_update( 'google_tag_manager_id', $values['google_tag_manager_id'] );
|
||||
\admin\factory\Settings::settings_update( 'infinitescroll', $values['infinitescroll'] == 'on' ? 1 : 0 );
|
||||
// own_gtm_js
|
||||
\admin\factory\Settings::settings_update( 'own_gtm_js', $values['own_gtm_js'] );
|
||||
// own_gtm_html
|
||||
\admin\factory\Settings::settings_update( 'own_gtm_html', $values['own_gtm_html'] );
|
||||
|
||||
foreach ( $values[ 'warehouse_message_zero'] as $key => $val )
|
||||
\admin\factory\Settings::settings_update( 'warehouse_message_zero_' . $key, $val );
|
||||
|
||||
foreach ( $values[ 'warehouse_message_nonzero'] as $key => $val )
|
||||
\admin\factory\Settings::settings_update( 'warehouse_message_nonzero_' . $key, $val );
|
||||
|
||||
\S::delete_dir( '../temp/' );
|
||||
\S::htacces();
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function view()
|
||||
{
|
||||
return \Tpl::view( 'settings/settings', [
|
||||
'languages' => \admin\factory\Languages::languages_list(),
|
||||
'settings' => \admin\factory\Settings::settings_details()
|
||||
] );
|
||||
}
|
||||
}
|
||||
?>
|
||||
71
autoload/admin/controls/class.ShopAttribute.php
Normal file
71
autoload/admin/controls/class.ShopAttribute.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopAttribute
|
||||
{
|
||||
static public function attribute_value_tpl()
|
||||
{
|
||||
$html = \Tpl::view( 'shop-attribute/_partials/value', [
|
||||
'i' => \S::get( 'i' ),
|
||||
'value' => \S::get( 'value' ),
|
||||
'languages' => \S::get( 'languages' ),
|
||||
'attribute' => \S::get( 'attribute' ),
|
||||
] );
|
||||
echo $html;
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function values_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania wartości atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
;
|
||||
if ( $id = \admin\factory\ShopAttribute::values_save( (int) \S::get( 'attribute_id' ), $values['name'], $values['value'], $values['ids'], $values['default_value'], $values['impact_on_the_price'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Wartości atrybutu zostały zapisane.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function values_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/values-edit', [
|
||||
'attribute' => \admin\factory\ShopAttribute::attribute_details( (int) \S::get( 'attribute-id' ) ),
|
||||
'values' => \admin\factory\ShopAttribute::get_attribute_values( (int) \S::get( 'attribute-id' ) ),
|
||||
'languages' => \admin\factory\Languages::languages_list()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function delete_attribute()
|
||||
{
|
||||
if ( \admin\factory\ShopAttribute::delete_attribute( (int) \S::get( 'id' ) ) )
|
||||
\S::alert( 'Atrybut został usunięty.' );
|
||||
|
||||
header( 'Location: /admin/shop_attribute/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function attribute_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania atrybutu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopAttribute::attribute_save( (int) $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, (int) $values['type'], (int) $values['o'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Atrybut został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function attribute_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/attribute-edit', [
|
||||
'attribute' => \admin\factory\ShopAttribute::attribute_details( (int) \S::get( 'id' ) ),
|
||||
'languages' => \admin\factory\Languages::languages_list()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-attribute/attributes-list' );
|
||||
}
|
||||
}
|
||||
66
autoload/admin/controls/class.ShopCategory.php
Normal file
66
autoload/admin/controls/class.ShopCategory.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopCategory
|
||||
{
|
||||
public static function category_products()
|
||||
{
|
||||
return \Tpl::view( 'shop-category/category-products', [
|
||||
'category_id' => \S::get( 'id' ),
|
||||
'products' => \admin\factory\ShopCategory::category_products( (int)\S::get( 'id' ) )
|
||||
] );
|
||||
}
|
||||
|
||||
public static function category_url_browser() {
|
||||
echo \Tpl::view( 'shop-category/category-browse-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'level' => 0,
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function category_delete()
|
||||
{
|
||||
if ( \admin\factory\ShopCategory::category_delete( \S::get( 'id' ) ) )
|
||||
\S::set_message( 'Kategoria została usunięta.' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania kategorii wystąpił błąd. Aby usunąć kategorię nie może ona posiadać przypiętych podkategorii.' );
|
||||
header( 'Location: /admin/shop_category/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kategorii wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopCategory::save(
|
||||
$values['id'], $values['title'], $values['text'], $values['text_hidden'], $values['seo_link'], $values['meta_title'], $values['meta_description'], $values['meta_keywords'], $values['parent_id'], $values['status'],
|
||||
$values['noindex'], $values['category_title'], $values['sort_type'], $values['additional_text'], $values['view_subcategories']
|
||||
) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Kategoria została zapisana.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function category_edit()
|
||||
{
|
||||
return \admin\view\ShopCategory::category_edit(
|
||||
\admin\factory\ShopCategory::category_details(
|
||||
\S::get( 'id' )
|
||||
),
|
||||
\S::get( 'pid' ),
|
||||
\admin\factory\Languages::languages_list()
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-category/categories-list', [
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'level' => 0,
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
}
|
||||
}
|
||||
28
autoload/admin/controls/class.ShopClients.php
Normal file
28
autoload/admin/controls/class.ShopClients.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopClients
|
||||
{
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view(
|
||||
'shop-clients/view-list'
|
||||
);
|
||||
}
|
||||
|
||||
public static function clients_details()
|
||||
{
|
||||
$query_string = $_SERVER['REDIRECT_QUERY_STRING'];
|
||||
parse_str($query_string, $query_array);
|
||||
|
||||
$orders_info = \admin\factory\ShopClients::get_order_all_info( $query_array['name'], $query_array['surname'], $query_array['email'] );
|
||||
|
||||
return \Tpl::view('shop-clients/clients-details', [
|
||||
'name' => $query_array['name'],
|
||||
'surname' => $query_array['surname'],
|
||||
'email' => $query_array['email'],
|
||||
'total_spent' => $query_array['total_spent'],
|
||||
'orders_info' => $orders_info
|
||||
]);
|
||||
}
|
||||
}
|
||||
?>
|
||||
58
autoload/admin/controls/class.ShopCoupon.php
Normal file
58
autoload/admin/controls/class.ShopCoupon.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class ShopCoupon
|
||||
{
|
||||
public static function coupon_delete()
|
||||
{
|
||||
$coupon = new \shop\Coupon( (int)\S::get( 'id' ) );
|
||||
if ( $coupon -> delete() )
|
||||
\S::alert( 'Kupon został usunięty.' );
|
||||
header( 'Location: /admin/shop_coupon/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function coupon_save()
|
||||
{
|
||||
$response = ['status' => 'error', 'msg' => 'Podczas zapisywania kuponu wystąpił błąd. Proszę spróbować ponownie.'];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $values['categories'] != null )
|
||||
$categories = is_array( $values['categories'] ) ? json_encode( $values['categories'] ) : json_encode( [ $values['categories'] ] );
|
||||
else
|
||||
$categories = null;
|
||||
|
||||
if ( \admin\factory\ShopCoupon::save(
|
||||
$values['id'],
|
||||
$values['name'],
|
||||
$values['status'] == 'on' ? 1 : 0,
|
||||
$values['send'] == 'on' ? 1 : 0,
|
||||
$values['used'] == 'on' ? 1 : 0,
|
||||
$values['type'],
|
||||
$values['amount'],
|
||||
$values['one_time'] == 'on' ? 1 : 0,
|
||||
$values['include_discounted_product'] == 'on' ? 1 : 0,
|
||||
$categories
|
||||
)
|
||||
)
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Kupon został zapisany.', 'id' => $values['id'] ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function coupon_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-coupon/coupon-edit', [
|
||||
'coupon' => \admin\factory\ShopCoupon::details( (int)\S::get( 'id' ) ),
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-coupon/view-list' );
|
||||
}
|
||||
|
||||
}
|
||||
103
autoload/admin/controls/class.ShopOrder.php
Normal file
103
autoload/admin/controls/class.ShopOrder.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopOrder
|
||||
{
|
||||
static public function order_resend_confirmation_email()
|
||||
{
|
||||
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
|
||||
$response = $order -> order_resend_confirmation_email();
|
||||
|
||||
echo json_encode( [ 'result' => $response ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function notes_save()
|
||||
{
|
||||
\shop\Order::notes_save( \S::get( 'order_id' ), \S::get( 'notes' ) );
|
||||
}
|
||||
|
||||
static public function order_save()
|
||||
{
|
||||
if ( \shop\Order::order_save_by_admin(
|
||||
\S::get( 'order_id' ), \S::get( 'client_name' ), \S::get( 'client_surname' ), \S::get( 'client_firm' ), \S::get( 'client_street' ), \S::get( 'client_postal_code' ), \S::get( 'client_city' ), \S::get( 'client_email' ),
|
||||
\S::get( 'transport_id' ), \S::get( 'inpost_paczkomat' ), \S::get( 'payment_method_id' )
|
||||
) )
|
||||
\S::alert( 'Zamówienie zostało zapisane.' );
|
||||
|
||||
header( 'Location: /admin/shop_order/order_details/order_id=' . \S::get( 'order_id' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function order_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-order/order-edit', [
|
||||
'order' => new \shop\Order( (int)\S::get( 'order_id' ) ),
|
||||
'order_statuses' => \shop\Order::order_statuses(),
|
||||
'transport' => \shop\Transport::transport_list(),
|
||||
'payment_methods' => \shop\PaymentMethod::method_list()
|
||||
] );
|
||||
}
|
||||
|
||||
public static function order_details()
|
||||
{
|
||||
return \Tpl::view( 'shop-order/order-details', [
|
||||
'order' => new \shop\Order( (int)\S::get( 'order_id' ) ),
|
||||
'order_statuses' => \shop\Order::order_statuses(),
|
||||
'next_order_id' => \admin\factory\ShopOrder::next_order_id( (int)\S::get( 'order_id' ) ),
|
||||
'prev_order_id' => \admin\factory\ShopOrder::prev_order_id( (int)\S::get( 'order_id' ) ),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view(
|
||||
'shop-order/view-list'
|
||||
);
|
||||
}
|
||||
|
||||
public static function order_status_change()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
|
||||
$response = $order -> update_status( (int)\S::get( 'status' ), \S::get( 'email' ) == 'true' ? 1 : 0 );
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function order_delete()
|
||||
{
|
||||
global $user;
|
||||
|
||||
if ( \shop\Order::order_delete( (int)\S::get( 'id' ) ) )
|
||||
{
|
||||
\S::alert( 'Zamówienie zostało usunięte' );
|
||||
\Log::save_log( 'Usunięcie zamówienia | ID: ' . (int)\S::get( 'id' ), $user['id'] );
|
||||
}
|
||||
|
||||
header( 'Location: /admin/shop_order/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// set_order_as_unpaid
|
||||
public static function set_order_as_unpaid()
|
||||
{
|
||||
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
|
||||
$order -> set_as_unpaid();
|
||||
header( 'Location: /admin/shop_order/order_details/order_id=' . (int)\S::get( 'order_id' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// set_order_as_paid
|
||||
public static function set_order_as_paid()
|
||||
{
|
||||
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
|
||||
if ( $order -> set_as_paid() )
|
||||
{
|
||||
$order -> update_status( 4, (int)\S::get( 'send_mail' ) );
|
||||
}
|
||||
header( 'Location: /admin/shop_order/order_details/order_id=' . (int)\S::get( 'order_id' ) );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
12
autoload/admin/controls/class.ShopPaymentMethod.php
Normal file
12
autoload/admin/controls/class.ShopPaymentMethod.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopPaymentMethod
|
||||
{
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-payment-method/view-list', [
|
||||
'apilo_payment_types_list' => unserialize( \admin\factory\Integrations::apilo_settings( 'payment-types-list' ) ),
|
||||
'sellasist_payment_types_list' => unserialize( \admin\factory\Integrations::sellasist_settings( 'payment_types_list' ) ),
|
||||
] );
|
||||
}
|
||||
}
|
||||
37
autoload/admin/controls/class.ShopProducer.php
Normal file
37
autoload/admin/controls/class.ShopProducer.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
class ShopProducer
|
||||
{
|
||||
static public function delete()
|
||||
{
|
||||
if ( \admin\factory\ShopProducer::delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Producent został usunięty' );
|
||||
header( 'Location: /admin/shop_producer/list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania producenta wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $producer_id = \admin\factory\ShopProducer::save( $values['id'], $values['name'], $values['status'] == 'on' ? 1 : 0, $values['img'], $values['description'], $values['meta_title'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Producent został zapisany.', 'id' => $producer_id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-producer/edit', [
|
||||
'producer' => \S::get( 'id' ) ? new \shop\Producer( \S::get( 'id' ) ) : null,
|
||||
'languages' => \admin\factory\Languages::languages_list()
|
||||
] );
|
||||
}
|
||||
|
||||
static public function list()
|
||||
{
|
||||
return \Tpl::view( 'shop-producer/list' );
|
||||
}
|
||||
}
|
||||
423
autoload/admin/controls/class.ShopProduct.php
Normal file
423
autoload/admin/controls/class.ShopProduct.php
Normal file
@@ -0,0 +1,423 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopProduct
|
||||
{
|
||||
static public function mass_edit_save()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
if ( \S::get( 'discount_percent' ) != '' and \S::get( 'products' ) )
|
||||
{
|
||||
$product_details = \admin\factory\ShopProduct::product_details( \S::get( 'products' )[0] );
|
||||
|
||||
$vat = $product_details['vat'];
|
||||
$price_brutto = $product_details['price_brutto'];
|
||||
$price_brutto_promo = $price_brutto - ( $price_brutto * ( \S::get( 'discount_percent' ) / 100 ) );
|
||||
$price_netto = $product_details['price_netto'];
|
||||
$price_netto_promo = $price_netto - ( $price_netto * ( \S::get( 'discount_percent' ) / 100 ) );
|
||||
|
||||
if ( $price_brutto == $price_brutto_promo)
|
||||
$price_brutto_promo = null;
|
||||
|
||||
if ( $price_netto == $price_netto_promo )
|
||||
$price_netto_promo = null;
|
||||
|
||||
$mdb -> update( 'pp_shop_products', [ 'price_brutto_promo' => $price_brutto_promo, 'price_netto_promo' => $price_netto_promo ], [ 'id' => \S::get( 'products' )[0] ] );
|
||||
|
||||
\admin\factory\ShopProduct::update_product_combinations_prices( \S::get( 'products' )[0], $price_netto, $vat, $price_netto_promo );
|
||||
|
||||
echo json_encode( [ 'status' => 'ok', 'price_brutto_promo' => $price_brutto_promo, 'price_brutto' => $price_brutto ] );
|
||||
exit;
|
||||
}
|
||||
echo json_encode( [ 'status' => 'error' ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// get_products_by_category
|
||||
static public function get_products_by_category() {
|
||||
global $mdb;
|
||||
|
||||
$products = $mdb -> select( 'pp_shop_products_categories', 'product_id', [ 'category_id' => \S::get( 'category_id' ) ] );
|
||||
|
||||
echo json_encode( [ 'status' => 'ok', 'products' => $products ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function mass_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-product/mass-edit', [
|
||||
'products' => \admin\factory\ShopProduct::products_list(),
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
}
|
||||
|
||||
static public function generate_combination()
|
||||
{
|
||||
foreach ( $_POST as $key => $val )
|
||||
{
|
||||
if ( strpos( $key, 'attribute_' ) !== false )
|
||||
{
|
||||
$attribute = explode( 'attribute_', $key );
|
||||
$attributes[ $attribute[1] ] = $val;
|
||||
}
|
||||
}
|
||||
|
||||
if ( \admin\factory\ShopProduct::generate_permutation( (int) \S::get( 'product_id' ), $attributes ) )
|
||||
\S::alert( 'Kombinacje produktu zostały wygenerowane.' );
|
||||
|
||||
header( 'Location: /admin/shop_product/product_combination/product_id=' . (int) \S::get( 'product_id' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
//usunięcie kombinacji produktu
|
||||
static public function delete_combination()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::delete_combination( (int)\S::get( 'combination_id' ) ) )
|
||||
\S::alert( 'Kombinacja produktu została usunięta' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania kombinacji produktu wystąpił błąd. Proszę spróbować ponownie' );
|
||||
|
||||
header( 'Location: /admin/shop_product/product_combination/product_id=' . \S::get( 'product_id' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function duplicate_product()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::duplicate_product( (int)\S::get( 'product-id' ), (int)\S::get( 'combination' ) ) )
|
||||
\S::set_message( 'Produkt został zduplikowany.' );
|
||||
else
|
||||
\S::alert( 'Podczas duplikowania produktu wystąpił błąd. Proszę spróbować ponownie' );
|
||||
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function image_delete()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas usuwania zdjecia wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopProduct::delete_img( \S::get( 'image_id' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function images_order_save()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::images_order_save( \S::get( 'product_id' ), \S::get( 'order' ) ) )
|
||||
echo json_encode( [ 'status' => 'ok', 'msg' => 'Produkt został zapisany.' ] );
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function image_alt_change()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zmiany atrybutu alt zdjęcia wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopProduct::image_alt_change( \S::get( 'image_id' ), \S::get( 'image_alt' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// szybka zmiana statusu produktu
|
||||
static public function change_product_status() {
|
||||
|
||||
if ( \admin\factory\ShopProduct::change_product_status( (int)\S::get( 'product-id' ) ) )
|
||||
\S::set_message( 'Status produktu został zmieniony' );
|
||||
|
||||
header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// szybka zmiana google xml label
|
||||
static public function product_change_custom_label()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zmiany google xml label wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopProduct::product_change_custom_label( (int) \S::get( 'product_id' ), \S::get( 'custom_label' ), \S::get( 'value' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// szybka zmiana ceny promocyjnej
|
||||
static public function product_change_price_brutto_promo()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zmiany ceny wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopProduct::product_change_price_brutto_promo( (int) \S::get( 'product_id' ), \S::get( 'price' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// szybka zmiana ceny
|
||||
static public function product_change_price_brutto()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zmiany ceny wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \admin\factory\ShopProduct::product_change_price_brutto( (int) \S::get( 'product_id' ), \S::get( 'price' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// pobierz bezpośredni url produktu
|
||||
static public function ajax_product_url()
|
||||
{
|
||||
echo json_encode( [ 'url' => \shop\Product::getProductUrl( \S::get( 'product_id' ) ) ] );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapisanie produktu
|
||||
public static function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania produktu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopProduct::save(
|
||||
$values['id'], $values['name'], $values['short_description'], $values['description'], $values['status'], $values['meta_description'], $values['meta_keywords'], $values['seo_link'],
|
||||
$values['copy_from'], $values['categories'], $values['price_netto'], $values['price_brutto'], $values['vat'], $values['promoted'], $values['warehouse_message_zero'], $values['warehouse_message_nonzero'], $values['tab_name_1'],
|
||||
$values['tab_description_1'], $values['tab_name_2'], $values['tab_description_2'], $values['layout_id'], $values['products_related'], (int) $values['set'], $values['price_netto_promo'], $values['price_brutto_promo'],
|
||||
$values['new_to_date'], $values['stock_0_buy'], $values['wp'], $values['custom_label_0'], $values['custom_label_1'], $values['custom_label_2'], $values['custom_label_3'], $values['custom_label_4'], $values['additional_message'], (int)$values['quantity'], $values['additional_message_text'], $values['additional_message_required'] == 'on' ? 1 : 0, $values['canonical'], $values['meta_title'], $values['producer_id'], $values['sku'], $values['ean'], $values['product_unit'], $values['weight'], $values['xml_name'], $values['custom_field_name']
|
||||
) ) {
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Produkt został zapisany.', 'id' => $id ];
|
||||
}
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// product_unarchive
|
||||
static public function product_unarchive()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::product_unarchive( (int) \S::get( 'product_id' ) ) )
|
||||
\S::alert( 'Produkt został przywrócony z archiwum.' );
|
||||
else
|
||||
\S::alert( 'Podczas przywracania produktu z archiwum wystąpił błąd. Proszę spróbować ponownie' );
|
||||
|
||||
header( 'Location: /admin/archive/products_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function product_archive()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::product_archive( (int) \S::get( 'product_id' ) ) )
|
||||
\S::alert( 'Produkt został przeniesiony do archiwum.' );
|
||||
else
|
||||
\S::alert( 'Podczas przenoszenia produktu do archiwum wystąpił błąd. Proszę spróbować ponownie' );
|
||||
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function product_delete()
|
||||
{
|
||||
if ( \admin\factory\ShopProduct::product_delete( (int) \S::get( 'id' ) ) )
|
||||
\S::set_message( 'Produkt został usunięty.' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania produktu wystąpił błąd. Proszę spróbować ponownie' );
|
||||
header( 'Location: /admin/shop_product/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// edycja produktu
|
||||
public static function product_edit()
|
||||
{
|
||||
\admin\factory\ShopProduct::delete_nonassigned_images();
|
||||
\admin\factory\ShopProduct::delete_nonassigned_files();
|
||||
|
||||
return \Tpl::view( 'shop-product/product-edit', [
|
||||
'product' => \admin\factory\ShopProduct::product_details( (int) \S::get( 'id' ) ),
|
||||
'languages' => \admin\factory\Languages::languages_list(),
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'layouts' => \admin\factory\Layouts::layouts_list(),
|
||||
'products' => \admin\factory\ShopProduct::products_list(),
|
||||
'dlang' => \front\factory\Languages::default_language(),
|
||||
'sets' => \shop\ProductSet::sets_list(),
|
||||
'producers' => \admin\factory\ShopProducer::all(),
|
||||
'units' => \admin\factory\Dictionaries::all_units()
|
||||
] );
|
||||
}
|
||||
|
||||
// ajax_load_products ARCHIVE
|
||||
static public function ajax_load_products_archive()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas ładowania produktów wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
\S::set_session( 'products_list_current_page', \S::get( 'current_page' ) );
|
||||
\S::set_session( 'products_list_query', \S::get( 'query' ) );
|
||||
|
||||
if ( $products = \admin\factory\ShopProduct::ajax_products_list_archive( \S::get_session( 'products_list_current_page' ), \S::get_session( 'products_list_query' ) ) ) {
|
||||
$response = [
|
||||
'status' => 'ok',
|
||||
'pagination_max' => ceil( $products['products_count'] / 10 ),
|
||||
'html' => \Tpl::view( 'archive/products-list-table', [
|
||||
'products' => $products['products'],
|
||||
'current_page' => \S::get( 'current_page' ),
|
||||
] )
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// ajax_load_products
|
||||
static public function ajax_load_products() {
|
||||
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas ładowania produktów wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
\S::set_session( 'products_list_current_page', \S::get( 'current_page' ) );
|
||||
if ( \S::get( 'query' ) )
|
||||
\S::set_session( 'products_list_query', \S::get( 'query' ) );
|
||||
|
||||
if ( $products = \admin\factory\ShopProduct::ajax_products_list( \S::get_session( 'products_list_current_page' ), \S::get_session( 'products_list_query' ) ) ) {
|
||||
$response = [
|
||||
'status' => 'ok',
|
||||
'pagination_max' => ceil( $products['products_count'] / 10 ),
|
||||
'html' => \Tpl::view( 'shop-product/products-list-table', [
|
||||
'products' => $products['products'],
|
||||
'current_page' => \S::get( 'current_page' ),
|
||||
'baselinker_enabled' => \admin\factory\Integrations::baselinker_settings( 'enabled' ),
|
||||
'apilo_enabled' => \admin\factory\Integrations::apilo_settings( 'enabled' ),
|
||||
'sellasist_enabled' => \admin\factory\Integrations::sellasist_settings( 'enabled' ),
|
||||
'show_xml_data' => \S::get_session( 'show_xml_data' )
|
||||
] )
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function view_list()
|
||||
{
|
||||
$current_page = \S::get_session( 'products_list_current_page' );
|
||||
|
||||
if ( !$current_page ) {
|
||||
$current_page = 1;
|
||||
\S::set_session( 'products_list_current_page', $current_page );
|
||||
}
|
||||
|
||||
$query = \S::get_session( 'products_list_query' );
|
||||
if ( $query ) {
|
||||
$query_array = [];
|
||||
parse_str( $query, $query_array );
|
||||
}
|
||||
|
||||
if ( \S::get( 'show_xml_data' ) === 'true' )
|
||||
{
|
||||
\S::set_session( 'show_xml_data', true );
|
||||
}
|
||||
else if ( \S::get( 'show_xml_data' ) === 'false' )
|
||||
{
|
||||
\S::set_session( 'show_xml_data', false );
|
||||
}
|
||||
|
||||
return \Tpl::view( 'shop-product/products-list', [
|
||||
'current_page' => $current_page,
|
||||
'query_array' => $query_array,
|
||||
'pagination_max' => ceil( \admin\factory\ShopProduct::count_product() / 10 ),
|
||||
'baselinker_enabled' => \admin\factory\Integrations::baselinker_settings( 'enabled' ),
|
||||
'apilo_enabled' => \admin\factory\Integrations::apilo_settings( 'enabled' ),
|
||||
'sellasist_enabled' => \admin\factory\Integrations::sellasist_settings( 'enabled' ),
|
||||
'show_xml_data' => \S::get_session( 'show_xml_data' ),
|
||||
'shoppro_enabled' => \admin\factory\Integrations::shoppro_settings( 'enabled' )
|
||||
] );
|
||||
}
|
||||
|
||||
//
|
||||
// KOMBINACJE PRODUKTU
|
||||
//
|
||||
|
||||
// zapisanie możliwości zakupu przy stanie 0 w kombinacji produktu
|
||||
static public function product_combination_stock_0_buy_save()
|
||||
{
|
||||
\admin\factory\ShopProduct::product_combination_stock_0_buy_save( (int)\S::get( 'product_id' ), \S::get( 'stock_0_buy' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapisanie sku w kombinacji produktu
|
||||
static public function product_combination_sku_save()
|
||||
{
|
||||
\admin\factory\ShopProduct::product_combination_sku_save( (int)\S::get( 'product_id' ), \S::get( 'sku' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapisanie ilości w kombinacji produktu
|
||||
static public function product_combination_quantity_save()
|
||||
{
|
||||
\admin\factory\ShopProduct::product_combination_quantity_save( (int)\S::get( 'product_id' ), \S::get( 'quantity' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapisanie ceny w kombinacji produktu
|
||||
static public function product_combination_price_save()
|
||||
{
|
||||
\admin\factory\ShopProduct::product_combination_price_save( (int)\S::get( 'product_id' ), \S::get( 'price' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
//wyświetlenie kombinacji produktu
|
||||
static public function product_combination()
|
||||
{
|
||||
return \Tpl::view( 'shop-product/product-combination', [
|
||||
'product' => \admin\factory\ShopProduct::product_details( (int) \S::get( 'product_id' ) ),
|
||||
'attributes' => \admin\factory\ShopAttribute::get_attributes_list(),
|
||||
'default_language' => \front\factory\Languages::default_language(),
|
||||
'product_permutations' => \admin\factory\ShopProduct::get_product_permutations( (int) \S::get( 'product_id' ) )
|
||||
] );
|
||||
}
|
||||
|
||||
// generate_sku_code
|
||||
static public function generate_sku_code() {
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas generowania kodu sku wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( $sku = \shop\Product::generate_sku_code( \S::get( 'product_id' ) ) )
|
||||
$response = [ 'status' => 'ok', 'sku' => $sku ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// product_xml_name_save
|
||||
static public function product_xml_name_save() {
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania nazwy produktu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \shop\Product::product_xml_name_save( \S::get( 'product_id' ), \S::get( 'product_xml_name' ), \S::get( 'lang_id' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// product_custom_label_suggestions
|
||||
static public function product_custom_label_suggestions() {
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas pobierania sugestii dla custom label wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( $suggestions = \shop\Product::product_custom_label_suggestions( \S::get( 'custom_label' ), \S::get( 'label_type' ) ) )
|
||||
$response = [ 'status' => 'ok', 'suggestions' => $suggestions ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// product_custom_label_save
|
||||
static public function product_custom_label_save() {
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania custom label wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
|
||||
if ( \shop\Product::product_custom_label_save( \S::get( 'product_id' ), \S::get( 'custom_label' ), \S::get( 'label_type' ) ) )
|
||||
$response = [ 'status' => 'ok' ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
43
autoload/admin/controls/class.ShopProductSets.php
Normal file
43
autoload/admin/controls/class.ShopProductSets.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopProductSets
|
||||
{
|
||||
|
||||
static public function set_delete()
|
||||
{
|
||||
if ( \shop\ProductSet::set_delete( \S::get( 'id' ) ) )
|
||||
\S::set_message( 'Komplet produktów usunięty.' );
|
||||
else
|
||||
\S::alert( 'Podczas usuwania kompletu produktów wystąpił błąd. Proszę spróbować ponownie' );
|
||||
header( 'Location: /admin/shop_product_sets/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania kompletu produktów wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopProductSet::save(
|
||||
(int)$values['id'], $values['name'], (string) $values['status'], $values['set_products_id']
|
||||
) ) {
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Komplet produktów został zapisany.', 'id' => $id ];
|
||||
}
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
static public function set_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-product-sets/set-edit', [
|
||||
'set' => new \shop\ProductSet( (int) \S::get( 'id' ) ),
|
||||
'products' => \admin\factory\ShopProduct::products_list()
|
||||
] );
|
||||
}
|
||||
|
||||
static public function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-product-sets/view-list' );
|
||||
}
|
||||
}
|
||||
59
autoload/admin/controls/class.ShopPromotion.php
Normal file
59
autoload/admin/controls/class.ShopPromotion.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopPromotion
|
||||
{
|
||||
// usunięcie promocji
|
||||
static public function promotion_delete()
|
||||
{
|
||||
$promotion = \R::load( 'pp_shop_promotion', (int)\S::get( 'id' ) );
|
||||
if ( \R::trash( $promotion ) )
|
||||
\S::alert( 'Promocja została usunięta' );
|
||||
|
||||
header( 'Location: /admin/shop_promotion/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
// zapisanie promocji
|
||||
static public function save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania promocji wystąpił błąd. Proszę spróbować ponownie' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopPromotion::save(
|
||||
$values['id'],
|
||||
$values['name'],
|
||||
$values['status'] == 'on' ? 1 : 0,
|
||||
$values['condition_type'],
|
||||
$values['discount_type'],
|
||||
$values['amount'],
|
||||
$values['date_to'],
|
||||
$values['categories'],
|
||||
$values['condition_categories'],
|
||||
$values['include_coupon'] == 'on' ? 1 : 0,
|
||||
$values['include_product_promo'] == 'on' ? 1 : 0,
|
||||
$values['min_product_count'],
|
||||
$values['price_cheapest_product']
|
||||
) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Promocja została zapisana', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// edycja promocji
|
||||
static public function edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-promotion/promotion-edit', [
|
||||
'promotion' => \admin\factory\ShopPromotion::promotion_details( (int)\S::get( 'id' ) ),
|
||||
'categories' => \admin\factory\ShopCategory::subcategories( null ),
|
||||
'dlang' => \front\factory\Languages::default_language()
|
||||
] );
|
||||
}
|
||||
|
||||
// lista promocji
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-promotion/view-list' );
|
||||
}
|
||||
|
||||
}
|
||||
38
autoload/admin/controls/class.ShopStatuses.php
Normal file
38
autoload/admin/controls/class.ShopStatuses.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?
|
||||
namespace admin\controls;
|
||||
|
||||
class ShopStatuses {
|
||||
|
||||
// status_save
|
||||
public static function status_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania statusu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopStatuses::status_save( $values['id'], $values['color'], $values['apilo_status_id'], $values['sellasist_status_id'], $values['baselinker_status_id'] ) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Status został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
// status_edit
|
||||
public static function status_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-statuses/status-edit', [
|
||||
'status' => \admin\factory\ShopStatuses::get_status( \S::get( 'id' ) ),
|
||||
'apilo_order_status_list' => unserialize( \admin\factory\Integrations::apilo_settings( 'status-types-list' ) ),
|
||||
'sellasist_order_status_list' => unserialize( \admin\factory\Integrations::sellasist_settings( 'status_types_list' ) ),
|
||||
'baselinker_order_status_list' => unserialize( \admin\factory\Integrations::baselinker_settings( 'order_status_list' ) ),
|
||||
] );
|
||||
}
|
||||
|
||||
static public function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-statuses/view-list', [
|
||||
'apilo_order_status_list' => unserialize( \admin\factory\Integrations::apilo_settings( 'status-types-list' ) ),
|
||||
'sellasist_order_status_list' => unserialize( \admin\factory\Integrations::sellasist_settings( 'status_types_list' ) ),
|
||||
'baselinker_order_status_list' => unserialize( \admin\factory\Integrations::baselinker_settings( 'order_status_list' ) ),
|
||||
] );
|
||||
}
|
||||
}
|
||||
36
autoload/admin/controls/class.ShopTransport.php
Normal file
36
autoload/admin/controls/class.ShopTransport.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopTransport
|
||||
{
|
||||
public static function transport_save()
|
||||
{
|
||||
$response = [ 'status' => 'error', 'msg' => 'Podczas zapisywania rodzaju transportu wystąpił błąd. Proszę spróbować ponownie.' ];
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
|
||||
if ( $id = \admin\factory\ShopTransport::transport_save(
|
||||
$values['id'], $values['name'], $values['name_visible'], $values['description'], $values['status'], $values['cost'], $values['payment_methods'], $values['max_wp'], $values['default'], $values['apilo_carrier_account_id'], $values['sellasist_shipment_method_id'], $values['delivery_free']
|
||||
) )
|
||||
$response = [ 'status' => 'ok', 'msg' => 'Rodzaj transportu został zapisany.', 'id' => $id ];
|
||||
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function transport_edit()
|
||||
{
|
||||
return \Tpl::view( 'shop-transport/transport-edit', [
|
||||
'transport_details' => \admin\factory\ShopTransport::transport_details( \S::get( 'id' ) ),
|
||||
'payments_list' => \admin\factory\ShopPaymentMethod::payments_list(),
|
||||
'apilo_carrier_account_list' => unserialize( \admin\factory\Integrations::apilo_settings( 'carrier-account-list' ) ),
|
||||
'sellasist_shipments_methods' => unserialize( \admin\factory\Integrations::sellasist_settings( 'shipments_methods' ) ),
|
||||
] );
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \Tpl::view( 'shop-transport/view-list', [
|
||||
'apilo_carrier_account_list' => unserialize( \admin\factory\Integrations::apilo_settings( 'carrier-account-list' ) ),
|
||||
'sellasist_shipments_methods' => unserialize( \admin\factory\Integrations::sellasist_settings( 'shipments_methods' ) ),
|
||||
] );
|
||||
}
|
||||
}
|
||||
29
autoload/admin/controls/class.Update.php
Normal file
29
autoload/admin/controls/class.Update.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Update
|
||||
{
|
||||
public static function update()
|
||||
{
|
||||
if ( !\admin\factory\Update::update() )
|
||||
\S::alert( 'W trakcie aktualizacji systemu wystąpił błąd. Proszę spróbować ponownie.' );
|
||||
else
|
||||
\S::set_message( 'Aktualizacja przebiegła pomyślnie.' );
|
||||
|
||||
header( 'Location: /admin/update/main_view/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function updateAll()
|
||||
{
|
||||
$response['status'] = \admin\factory\Update::update();
|
||||
$response['version'] = number_format( \S::get('version_current') + 0.001, 3, '.', '' );
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function main_view()
|
||||
{
|
||||
return \admin\view\Update::main_view();
|
||||
}
|
||||
}
|
||||
36
autoload/admin/controls/class.Users.php
Normal file
36
autoload/admin/controls/class.Users.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
|
||||
class Users
|
||||
{
|
||||
public static function user_delete()
|
||||
{
|
||||
if ( \admin\factory\Users::user_delete( \S::get( 'id' ) ) )
|
||||
\S::alert( 'Użytkownik został usunięty.' );
|
||||
header( 'Location: /admin/users/view_list/' );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function user_save()
|
||||
{
|
||||
$values = json_decode( \S::get( 'values' ), true );
|
||||
$response = \admin\factory\Users::user_save( $values['id'], $values['login'], $values['status'], $values['password'], $values['password_re'], $values['admin'] );
|
||||
echo json_encode( $response );
|
||||
exit;
|
||||
}
|
||||
|
||||
public static function user_edit()
|
||||
{
|
||||
return \admin\view\Users::user_edit(
|
||||
\admin\factory\Users::user_details(
|
||||
\S::get( 'id' )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public static function view_list()
|
||||
{
|
||||
return \admin\view\Users::users_list();
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user