ver. 0.276: ShopOrder migration, Integrations cleanup, global admin search
This commit is contained in:
@@ -4,9 +4,13 @@ class Dashboard
|
||||
{
|
||||
static public function main_view()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$statusesRepository = new \Domain\ShopStatus\ShopStatusRepository( $mdb );
|
||||
|
||||
return \Tpl::view( 'dashboard/main-view', [
|
||||
'last_orders' => \shop\Dashboard::last_orders(),
|
||||
'order_statuses' => \shop\Order::order_statuses(),
|
||||
'order_statuses' => $statusesRepository -> allStatuses(),
|
||||
'sales' => \shop\Dashboard::last_24_months_sales(),
|
||||
'best_sales_products' => \shop\Dashboard::best_sales_products(),
|
||||
'most_view_products' => \shop\Dashboard::most_view_products(),
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
<?php
|
||||
namespace admin\controls;
|
||||
class ShopOrder
|
||||
{
|
||||
static public function send_order_to_apilo()
|
||||
{
|
||||
$order_id = \S::get( 'order_id' );
|
||||
if ( \admin\factory\ShopOrder::send_order_to_apilo( $order_id ) ) {
|
||||
\S::alert( 'Zamówienie zostanie wysłane ponownie do apilo.com' );
|
||||
} else {
|
||||
\S::alert( 'Wystąpił błąd podczas wysyłania zamówienia do apilo.com' );
|
||||
}
|
||||
header( 'Location: /admin/shop_order/order_details/order_id=' . $order_id );
|
||||
exit;
|
||||
}
|
||||
|
||||
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_street' ), \S::get( 'client_postal_code' ), \S::get( 'client_city' ), \S::get( 'client_email' ), \S::get( 'firm_name' ), \S::get( 'firm_street' ), \S::get( 'firm_postal_code' ), \S::get( 'firm_city' ), \S::get( 'firm_nip' ), \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()
|
||||
{
|
||||
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
|
||||
$coupon = $order -> coupon_id ? new \shop\Coupon( $order -> coupon_id ) : null;
|
||||
|
||||
return \Tpl::view( 'shop-order/order-details', [
|
||||
'order' => $order,
|
||||
'coupon' => $coupon,
|
||||
'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;
|
||||
}
|
||||
|
||||
// toggle_trustmate_send
|
||||
public static function toggle_trustmate_send()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$order_id = (int)\S::get( 'order_id' );
|
||||
$order = $mdb -> get( 'pp_shop_orders', [ 'trustmate_send' ], [ 'id' => $order_id ] );
|
||||
|
||||
$new_value = $order['trustmate_send'] ? 0 : 1;
|
||||
$mdb -> update( 'pp_shop_orders', [ 'trustmate_send' => $new_value ], [ 'id' => $order_id ] );
|
||||
|
||||
echo json_encode( [ 'result' => true, 'trustmate_send' => $new_value ] );
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@@ -229,6 +229,10 @@ class ShopProduct
|
||||
// ajax_load_products
|
||||
static public function ajax_load_products() {
|
||||
|
||||
global $mdb;
|
||||
|
||||
$integrationsRepository = new \Domain\Integrations\IntegrationsRepository( $mdb );
|
||||
|
||||
$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' ) );
|
||||
@@ -241,7 +245,7 @@ class ShopProduct
|
||||
'html' => \Tpl::view( 'shop-product/products-list-table', [
|
||||
'products' => $products['products'],
|
||||
'current_page' => \S::get( 'current_page' ),
|
||||
'apilo_enabled' => \admin\factory\Integrations::apilo_settings( 'enabled' ),
|
||||
'apilo_enabled' => $integrationsRepository -> getSetting( 'apilo', 'enabled' ),
|
||||
'show_xml_data' => \S::get_session( 'show_xml_data' )
|
||||
] )
|
||||
];
|
||||
@@ -253,6 +257,10 @@ class ShopProduct
|
||||
|
||||
static public function view_list()
|
||||
{
|
||||
global $mdb;
|
||||
|
||||
$integrationsRepository = new \Domain\Integrations\IntegrationsRepository( $mdb );
|
||||
|
||||
$current_page = \S::get_session( 'products_list_current_page' );
|
||||
|
||||
if ( !$current_page ) {
|
||||
@@ -276,9 +284,9 @@ class ShopProduct
|
||||
'current_page' => $current_page,
|
||||
'query_array' => $query_array,
|
||||
'pagination_max' => ceil( \admin\factory\ShopProduct::count_product() / 10 ),
|
||||
'apilo_enabled' => \admin\factory\Integrations::apilo_settings( 'enabled' ),
|
||||
'apilo_enabled' => $integrationsRepository -> getSetting( 'apilo', 'enabled' ),
|
||||
'show_xml_data' => \S::get_session( 'show_xml_data' ),
|
||||
'shoppro_enabled' => \admin\factory\Integrations::shoppro_settings( 'enabled' )
|
||||
'shoppro_enabled' => $integrationsRepository -> getSetting( 'shoppro', 'enabled' )
|
||||
] );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user