From 2184e285b105ce1d93453861d7d15c43005803d4 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Tue, 11 Mar 2025 23:56:31 +0100 Subject: [PATCH] =?UTF-8?q?Dodanie=20obs=C5=82ugi=20kupon=C3=B3w=20rabatow?= =?UTF-8?q?ych=20w=20szczeg=C3=B3=C5=82ach=20zam=C3=B3wienia=20oraz=20aktu?= =?UTF-8?q?alizacja=20adres=C3=B3w=20URL=20do=20zasob=C3=B3w=20aktualizacj?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/templates/update/main-view.php | 2 +- autoload/.DS_Store | Bin 0 -> 6148 bytes autoload/admin/controls/class.ShopOrder.php | 14 +- autoload/admin/factory/class.Update.php | 12 +- autoload/class.Log.php | 1 + autoload/class.S.php | 157 ++++++++++---------- autoload/front/.DS_Store | Bin 0 -> 6148 bytes autoload/front/controls/class.ShopOrder.php | 9 +- autoload/front/factory/class.ShopOrder.php | 11 +- autoload/shop/class.Order.php | 4 +- templates/.DS_Store | Bin 0 -> 6148 bytes templates/shop-order/mail-summary.php | 7 + templates/shop-order/order-details.php | 1 + templates/shop-order/order-simple.php | 5 + templates_user/shop-order/order-details.php | 1 + 15 files changed, 126 insertions(+), 98 deletions(-) create mode 100644 autoload/.DS_Store create mode 100644 autoload/front/.DS_Store create mode 100644 templates/.DS_Store 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(); ?> Y-~&(R-f8*YM`WC-UYuKZ=V1!Glzp zf#jQHX7ckbn`DTH7Y~~`(Ts>X6hRiHA=2G69l7%a$U4UT_GZ4iD#NZZ%wcxP+E3`3 z_EhMOTI>I09ZKJ?w`Gl(?&9_F<>~zSY#cw7%{Lyq+dsz8VScw*RWJ|?1Ovgq&l$j- zEz(U5qYegwfneZ+0XZKMiePrEhI(|M(i8wF&uA6sl1oTTa?Fm^5EckqD9}RLQw+9n z^e6Yrj@8h@i9PvXpZPs`VVxc0Cv_*zhEWFt!N8b-V{6Xj{$JvkX(svOkZ1)1!N5Ob zfG7Q`Utm*yw|?24+_eei5=BJ(swfcXqelQ5a*mv;(d 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 46f5790..948f55c 100644 --- a/autoload/class.S.php +++ b/autoload/class.S.php @@ -117,96 +117,97 @@ class S static public function generate_webp_image($file, $compression_quality = 85) { - if (strpos($file, 'thumb/') !== false) { - $file_tmp = explode('/', $file); + if ( strpos( $file, 'thumb/' ) !== false ) + { + $file_tmp = explode( '/', $file ); - $width = $file_tmp[1] ?? 500; - $height = $file_tmp[2] ?? 500; + $width = $file_tmp[1]; + if ( empty( $width ) and $width !== '0' ) + $width = 500; - for ($i = 0; $i <= 2; $i++) { - unset($file_tmp[$i]); - } + $height = $file_tmp[2]; + if ( empty( $height ) and $height !== '0' ) + $height = 500; - $img_src = implode('/', $file_tmp); - $crop_w = $_GET['c_w'] ?? 0; - $crop_h = $_GET['c_h'] ?? 0; + for ( $i = 0; $i <= 2; $i++ ) + unset( $file_tmp[$i] ); - $img_md5 = md5($img_src . $height . $width . $crop_h . $crop_w); - $file = 'thumbs/' . $img_md5[0] . '/' . $img_md5[1] . '/' . $img_md5[2] . '/' . $img_md5; - } + $img_src = implode( '/', $file_tmp ); - if (!file_exists($file)) { + $crop_w = $_GET['c_w']; + $crop_h = $_GET['c_h']; + + $img_md5 = md5( $img_src . $height . $width . $crop_h . $crop_w ); + $file = 'thumbs/' . $img_md5[0] . '/' . $img_md5[1] . '/' . $img_md5[2] . '/' . $img_md5; + } + + if ( !file_exists( $file ) ) + return false; + + $output_file = 'cache/' . $file . '.webp'; + if ( file_exists( $output_file ) ) + return $output_file; + + $file_type = mime_content_type( $file ); + + if ( function_exists( 'imagewebp' ) ) + { + switch ( $file_type ) + { + case 'image/jpeg': + $image = imagecreatefromjpeg($file); + break; + + case 'image/png': + $image = imagecreatefrompng($file); + imagepalettetotruecolor($image); + imagealphablending($image, true); + imagesavealpha($image, true); + break; + + case 'image/gif': + $image = imagecreatefromgif($file); + break; + + default: return false; } - $output_file = 'cache/' . $file . '.webp'; - if (file_exists($output_file)) { - return $output_file; + $dir = dirname($output_file); + if (!is_dir($dir)) + mkdir($dir, 0755, true); + + $result = imagewebp($image, $output_file, $compression_quality); + if (false === $result) + return false; + + imagedestroy($image); + + return $output_file; + } + elseif (class_exists('Imagick')) + { + $dir = dirname($output_file); + if (!is_dir($dir)) + mkdir($dir, 0755, true); + + $image = new \Imagick(); + $image->readImage($file); + + if ($file_type === 'png') + { + $image->setImageFormat('webp'); + $image->setImageCompressionQuality($compression_quality); + $image->setOption('webp:lossless', 'true'); } - $file_type = mime_content_type($file); + $image->writeImage($output_file); + return $output_file; + } - if (function_exists('imagewebp')) { - switch ($file_type) { - case 'image/jpeg': - $image = imagecreatefromjpeg($file); - break; - case 'image/png': - $image = imagecreatefrompng($file); - if (!$image) { - return false; // Jeśli nie udało się wczytać obrazu, zwróć false - } - imagepalettetotruecolor($image); - imagealphablending($image, true); - imagesavealpha($image, true); - break; - case 'image/gif': - $image = imagecreatefromgif($file); - break; - default: - return false; - } - - if (!$image) { - return false; // Zapobiega błędowi jeśli wczytanie obrazu się nie powiedzie - } - - $dir = dirname($output_file); - if (!is_dir($dir)) { - mkdir($dir, 0755, true); - } - - $result = imagewebp($image, $output_file, $compression_quality); - imagedestroy($image); - - return $result ? $output_file : false; - } elseif (class_exists('Imagick')) { - $dir = dirname($output_file); - if (!is_dir($dir)) { - mkdir($dir, 0755, true); - } - - $image = new \Imagick(); - try { - $image->readImage($file); - } catch (Exception $e) { - return false; - } - - if ($file_type === 'image/png') { - $image->setImageFormat('webp'); - $image->setImageCompressionQuality($compression_quality); - $image->setOption('webp:lossless', 'true'); - } - - $image->writeImage($output_file); - return $output_file; - } - - return false; + return false; } - public static function is_array_fix( $value ) { if ( is_array( $value ) and count( $value ) ) @@ -394,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 new file mode 100644 index 0000000000000000000000000000000000000000..7285fd13b00a087a6417494eb5c700e132b02819 GIT binary patch literal 6148 zcmeHKy-veG47N)IK`b2^Z)5Hogep8iC1z;LpVa6o)PmTu@mMgi_iY&Ye72&51c?cu z%9ecJ#b@8ocTpS@5l^?v3DKB{a;V_w7|nplxM)vCW|2Wob3}Tim(|^5wun7%H~dEi zmab_*8*1HOwQge!$xjr$bq1UPXP{v~z7GK^ zSQyrd>C=HGl>opD<|OD#Eg><%urRC@F#=%?1!^c;iNP8UdoaJkuvXM?Vk-3~NPLApRqeXz<1v_)`YH0K&6M2mk;8 literal 0 HcmV?d00001 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/templates/.DS_Store b/templates/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..96797d4292e50044254a7be6c0d61b9e1f76789e GIT binary patch literal 6148 zcmeHKu};H44E2=`fr8Yr3)1lc4BZ(*6uzKrEKq`|M5Bue?D+-w0(K-mgYV+`Y?VZ5 zidayEY{`BX$G$l4+W3x$T=rZ{iN-{fKp6-7FdKyLvvy>l9=_?~9H%s=8+xP%y6Z%n zV;33VwHsl@78IzW=K4J?@29idP*zg*@mqgn8S;F-40A*zua_S$+1cm$w&>y)(bb|^ zg~zmX(5N@iiVFPNR_$t!PWs}SwN4JN-nG_^bC%(|(w}16b@Kno#27FJjDekH06m)} z83~#-28;n?V9fx3A3T&XRjdW$rvoM)0f0leqhK8OK0wb7V5(RP!UJ)V3Y1i*M+_(F z@OzC*6>C9BCl{ZLdGyInPbf}zUe3pGa;czMW55__Gq5L@WA6VK{pbI7l3f`C#=yT~ zzzy?Rp5c|Ww{~8Rd##6FLs>Yk7F?%b5L+=~xfM^KQQ-GH0H%tyAUqJ;2t*pp7z2OG Fz!x5GRMh|g literal 0 HcmV?d00001 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/templates_user/shop-order/order-details.php b/templates_user/shop-order/order-details.php index 055f3d6..c3c6790 100644 --- a/templates_user/shop-order/order-details.php +++ b/templates_user/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 ):?>