diff --git a/admin/templates/shop-coupon/view-list.php b/admin/templates/shop-coupon/view-list.php index 0cfed6d..08b5493 100644 --- a/admin/templates/shop-coupon/view-list.php +++ b/admin/templates/shop-coupon/view-list.php @@ -12,11 +12,11 @@ $grid -> search = [ [ 'name' => 'Wysłany', 'db' => 'send', 'type' => 'select', 'replace' => [ 'array' => [ 0 => 'nie', 1 => 'tak' ] ] ] ]; $grid -> columns_view = [ - [ + [ 'name' => 'Lp.', 'th' => [ 'class' => 'g-lp' ], 'td' => [ 'class' => 'g-center' ], - 'autoincrement' => true + 'autoincrement' => true ], [ 'name' => 'Aktywny', 'db' => 'status', @@ -24,6 +24,11 @@ $grid -> columns_view = [ 'td' => [ 'class' => 'g-center' ], 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ], 'sort' => true + ], [ + 'name' => 'Użyto X razy', + 'db' => 'used_count', + 'td' => [ 'class' => 'g-center' ], + 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ], ], [ 'name' => 'Nazwa', 'db' => 'name', @@ -60,22 +65,22 @@ $grid -> columns_view = [ 'db' => 'date_used', 'td' => [ 'class' => 'g-center' ], 'th' => [ 'class' => 'g-center', 'style' => 'width: 150px;' ] - ], [ - 'name' => 'Edytuj', - 'action' => [ 'type' => 'edit', 'url' => '/admin/shop_coupon/coupon_edit/id=[id]' ], + ], [ + 'name' => 'Edytuj', + 'action' => [ 'type' => 'edit', 'url' => '/admin/shop_coupon/coupon_edit/id=[id]' ], 'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ], 'td' => [ 'class' => 'g-center' ] - ], [ - 'name' => 'Usuń', - 'action' => [ 'type' => 'delete', 'url' => '/admin/shop_coupon/coupon_delete/id=[id]' ], + ], [ + 'name' => 'Usuń', + 'action' => [ 'type' => 'delete', 'url' => '/admin/shop_coupon/coupon_delete/id=[id]' ], 'th' => [ 'class' => 'g-center', 'style' => 'width: 70px;' ], 'td' => [ 'class' => 'g-center' ] ] ]; $grid -> buttons = [ - [ - 'label' => 'Dodaj kupon', - 'url' => '/admin/shop_coupon/coupon_edit/', + [ + 'label' => 'Dodaj kupon', + 'url' => '/admin/shop_coupon/coupon_edit/', 'icon' => 'fa-plus-circle', 'class' => 'btn-success' ] diff --git a/admin/templates/shop-order/order-details.php b/admin/templates/shop-order/order-details.php index a082ffe..6b40dea 100644 --- a/admin/templates/shop-order/order-details.php +++ b/admin/templates/shop-order/order-details.php @@ -44,6 +44,9 @@ ob_start();
Kwota zamówienia order[ 'summary' ];?> zł
+ coupon ):?> +
Kod rabatowy: coupon -> name;?> - coupon -> amount;?> coupon -> type == 1 ? '%' : 'zł';?>
+
order[ 'transport' ] );?>: order[ 'transport_cost' ];?> zł
order['transport_id'] == 2 and $this -> order[ 'inpost_paczkomat' ] ):?> diff --git a/admin/templates/update/main-view.php b/admin/templates/update/main-view.php index af81a3c..d22a1db 100644 --- a/admin/templates/update/main-view.php +++ b/admin/templates/update/main-view.php @@ -64,7 +64,7 @@ echo $grid -> draw(); ?> coupon_id ); + 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' ) ), - ] ); + '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() diff --git a/autoload/admin/factory/class.Update.php b/autoload/admin/factory/class.Update.php index c215123..5996d2c 100644 --- a/autoload/admin/factory/class.Update.php +++ b/autoload/admin/factory/class.Update.php @@ -9,7 +9,7 @@ class Update \S::delete_session( 'new-version' ); - $versions = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] ); + $versions = file_get_contents( 'https://shoppro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] ); $versions = explode( PHP_EOL, $versions ); foreach ( $versions as $ver ) @@ -22,7 +22,7 @@ class Update else $dir = substr( $ver, 0, strlen( $ver ) - 1 ) . 0; - $file = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '.zip' ); + $file = file_get_contents( 'https://shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '.zip' ); $dlHandler = fopen( 'update.zip' , 'w' ); if ( !fwrite( $dlHandler, $file ) ) @@ -34,10 +34,10 @@ class Update else { /* aktualizacja bazy danych */ - $url = 'http://www.shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_sql.txt'; + $url = 'https://shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_sql.txt'; $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $ch, CURLOPT_HEADER, true ); + curl_setopt( $ch, CURLOPT_HEADER, false ); $response = curl_exec( $ch ); $content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE ); @@ -53,10 +53,10 @@ class Update } /* usuwanie zbędnych plików */ - $url = 'http://www.shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_files.txt'; + $url = 'https://shoppro.project-dc.pl/updates/' . $dir . '/ver_' . $ver . '_files.txt'; $ch = curl_init( $url ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); - curl_setopt( $ch, CURLOPT_HEADER, true ); + curl_setopt( $ch, CURLOPT_HEADER, false ); $response = curl_exec( $ch ); $content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE ); diff --git a/autoload/class.Log.php b/autoload/class.Log.php index 1fb80a4..0afc67e 100644 --- a/autoload/class.Log.php +++ b/autoload/class.Log.php @@ -4,6 +4,7 @@ class Log static public function save_log( $message, $user_id = null ) { global $mdb; + $mdb -> insert( 'pp_log', [ 'message' => $message, 'user_id' => $user_id ? $user_id : null, diff --git a/autoload/class.S.php b/autoload/class.S.php index 8f5bf77..948f55c 100644 --- a/autoload/class.S.php +++ b/autoload/class.S.php @@ -395,7 +395,7 @@ class S return $version; $version = 0; - $versions = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] ); + $versions = file_get_contents( 'https://shoppro.project-dc.pl/updates/versions.php?key=' . $settings['update_key'] ); $versions = explode( PHP_EOL, $versions ); foreach ( $versions as $key => $version_tmp ) { diff --git a/autoload/front/.DS_Store b/autoload/front/.DS_Store deleted file mode 100644 index 7285fd1..0000000 Binary files a/autoload/front/.DS_Store and /dev/null differ diff --git a/autoload/front/controls/class.ShopOrder.php b/autoload/front/controls/class.ShopOrder.php index 170b66a..ac40287 100644 --- a/autoload/front/controls/class.ShopOrder.php +++ b/autoload/front/controls/class.ShopOrder.php @@ -142,11 +142,14 @@ class ShopOrder global $page, $settings; $page['language']['meta_title'] = \S::lang( 'meta-title-szczegoly-zamowienia' ) . ' | ' . $settings['firm_name']; + $order = \front\factory\ShopOrder::order_details( + \front\factory\ShopOrder::order_id( \S::get( 'order_hash' ) ) + ); + $coupon = new \shop\Coupon( $order['coupon_id'] ); return \Tpl::view( 'shop-order/order-details', [ - 'order' => \front\factory\ShopOrder::order_details( - \front\factory\ShopOrder::order_id( \S::get( 'order_hash' ) ) - ), + 'order' => $order, + 'coupon' => $coupon, 'client' => \S::get_session( 'client' ), 'settings' => $settings ] ); diff --git a/autoload/front/factory/class.ShopOrder.php b/autoload/front/factory/class.ShopOrder.php index 072eaf7..3ec5313 100644 --- a/autoload/front/factory/class.ShopOrder.php +++ b/autoload/front/factory/class.ShopOrder.php @@ -140,12 +140,14 @@ class ShopOrder 'apilo_order_status_date' => date( 'Y-m-d H:i:s' ), 'sellasist_order_status_date' => date( 'Y-m-d H:i:s' ), ] ); + $order_id = $mdb -> id(); if ( !$order_id ) return false; - \Log::save_log( 'Złożono nowe zamówienie | NR: ' . $order_id ); + if ( $coupon ) + $mdb -> update( 'pp_shop_coupon', [ 'used_count[+]' => 1 ], [ 'id' => $coupon -> id ] ); // ustawienie statusu zamówienia $mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order_id, 'status_id' => 0, 'mail' => 1 ] ); @@ -217,9 +219,10 @@ class ShopOrder $order = \front\factory\ShopOrder::order_details( $order_id ); $mail_order = \Tpl::view( 'shop-order/mail-summary', [ - 'settings' => $settings, - 'order' => $order - ] ); + 'settings' => $settings, + 'order' => $order, + 'coupon' => $coupon, + ] ); $settings[ 'ssl' ] ? $base = 'https' : $base = 'http'; diff --git a/autoload/shop/class.Order.php b/autoload/shop/class.Order.php index 28f94e8..c74b545 100644 --- a/autoload/shop/class.Order.php +++ b/autoload/shop/class.Order.php @@ -328,10 +328,12 @@ class Order implements \ArrayAccess global $settings; $order = \front\factory\ShopOrder::order_details( $this -> id ); + $coupon = new \shop\Coupon( $order['coupon_id'] ); $mail_order = \Tpl::view( 'shop-order/mail-summary', [ 'settings' => $settings, - 'order' => $order + 'order' => $order, + 'coupon' => $coupon, ] ); $settings[ 'ssl' ] ? $base = 'https' : $base = 'http'; diff --git a/config.php b/config.php index f3e9f2f..c684fdd 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ diff --git a/templates/shop-order/mail-summary.php b/templates/shop-order/mail-summary.php index c598010..1320239 100644 --- a/templates/shop-order/mail-summary.php +++ b/templates/shop-order/mail-summary.php @@ -136,6 +136,13 @@ echo $this -> settings['newsletter_header']; + coupon ):?> + + + Kod rabatowy: coupon -> name;?> - coupon -> amount;?> coupon -> type == 1 ? '%' : 'zł';?> + + + order['payment_method'];?> diff --git a/templates/shop-order/order-details.php b/templates/shop-order/order-details.php index dcf2c67..c5ef684 100644 --- a/templates/shop-order/order-details.php +++ b/templates/shop-order/order-details.php @@ -5,6 +5,7 @@
$this -> order, + 'coupon' => $this -> coupon, 'statuses' => \shop\Order::order_statuses() ] );?> order['status'] == 0 or $this -> order['status'] == 2 ):?> diff --git a/templates/shop-order/order-simple.php b/templates/shop-order/order-simple.php index 9f0f5ba..e05ea45 100644 --- a/templates/shop-order/order-simple.php +++ b/templates/shop-order/order-simple.php @@ -88,6 +88,11 @@ Rabat
+ coupon ):?> +
+ Kod rabatowy: coupon -> name;?> - coupon -> amount;?> coupon -> type == 1 ? '%' : 'zł';?> +
+
order['transport'];?> order['transport_cost'] );?> zł
diff --git a/updates/0.20/ver_0.227.zip b/updates/0.20/ver_0.227.zip new file mode 100644 index 0000000..d52540d Binary files /dev/null and b/updates/0.20/ver_0.227.zip differ diff --git a/updates/0.20/ver_0.227_sql.txt b/updates/0.20/ver_0.227_sql.txt new file mode 100644 index 0000000..87dfcd5 --- /dev/null +++ b/updates/0.20/ver_0.227_sql.txt @@ -0,0 +1 @@ +ALTER TABLE `pp_shop_coupon` ADD COLUMN `used_count` INT NULL DEFAULT '0' AFTER `categories`; \ No newline at end of file diff --git a/updates/changelog.php b/updates/changelog.php index 6019ef0..37a84e8 100644 --- a/updates/changelog.php +++ b/updates/changelog.php @@ -1,3 +1,6 @@ +ver. 0.227
+- NEW - historia kodów rabatowych +
ver. 0.226
- NEW - dodanie opcji faktury do zamówienia
diff --git a/updates/install.php b/updates/install.php index 711df2a..edaa4f6 100644 --- a/updates/install.php +++ b/updates/install.php @@ -15,14 +15,14 @@ if ( $_POST['action'] == 'install' ) $mysqli = new mysqli( $_POST['host'], $_POST['user'], $_POST['password'], $_POST['name'] ); $mysqli -> set_charset( 'utf8' ); - $file_sql = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/shopPRO_sql.txt' ); + $file_sql = file_get_contents( 'https://shoppro.project-dc.pl/updates/shopPRO_sql.txt' ); $sql_commands = explode( ';', $file_sql ); for ( $i = 0; $i < count( $sql_commands ) - 1; $i++ ) $result = $mysqli -> query( $sql_commands[$i] ); mysqli_close( $mysqli ); - $file = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/shopPRO.zip' ); + $file = file_get_contents( 'https://shoppro.project-dc.pl/updates/shopPRO.zip' ); $dlHandler = fopen( 'update.zip', 'w' ); if ( !fwrite( $dlHandler, $file ) ) @@ -206,7 +206,7 @@ if ( $_POST['action'] == 'install' )
-
+

Instalacja

@@ -225,7 +225,7 @@ if ( $_POST['action'] == 'install' )
- +