Dodanie obsługi kuponów rabatowych w szczegółach zamówienia oraz aktualizacja adresów URL do zasobów aktualizacji

This commit is contained in:
2025-03-11 23:56:31 +01:00
parent 8adeb8eb10
commit 2184e285b1
15 changed files with 126 additions and 98 deletions

View File

@@ -64,7 +64,7 @@ echo $grid -> draw();
?> ?>
<? <?
ob_start(); ob_start();
echo $versions = file_get_contents( 'http://www.shoppro.project-dc.pl/updates/changelog.php' ); echo $versions = file_get_contents( 'https://shoppro.project-dc.pl/updates/changelog.php' );
$out = ob_get_clean(); $out = ob_get_clean();
$grid = new \gridEdit; $grid = new \gridEdit;

BIN
autoload/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -51,8 +51,12 @@ class ShopOrder
public static function order_details() public static function order_details()
{ {
$order = new \shop\Order( (int)\S::get( 'order_id' ) );
$coupon = new \shop\Coupon( $order -> coupon_id );
return \Tpl::view( 'shop-order/order-details', [ return \Tpl::view( 'shop-order/order-details', [
'order' => new \shop\Order( (int)\S::get( 'order_id' ) ), 'order' => $order,
'coupon' => $coupon,
'order_statuses' => \shop\Order::order_statuses(), 'order_statuses' => \shop\Order::order_statuses(),
'next_order_id' => \admin\factory\ShopOrder::next_order_id( (int)\S::get( 'order_id' ) ), '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' ) ), 'prev_order_id' => \admin\factory\ShopOrder::prev_order_id( (int)\S::get( 'order_id' ) ),

View File

@@ -9,7 +9,7 @@ class Update
\S::delete_session( 'new-version' ); \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 ); $versions = explode( PHP_EOL, $versions );
foreach ( $versions as $ver ) foreach ( $versions as $ver )
@@ -22,7 +22,7 @@ class Update
else else
$dir = substr( $ver, 0, strlen( $ver ) - 1 ) . 0; $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' ); $dlHandler = fopen( 'update.zip' , 'w' );
if ( !fwrite( $dlHandler, $file ) ) if ( !fwrite( $dlHandler, $file ) )
@@ -34,10 +34,10 @@ class Update
else else
{ {
/* aktualizacja bazy danych */ /* 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 ); $ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_HEADER, false );
$response = curl_exec( $ch ); $response = curl_exec( $ch );
$content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE ); $content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE );
@@ -53,10 +53,10 @@ class Update
} }
/* usuwanie zbędnych plików */ /* 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 ); $ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $ch, CURLOPT_HEADER, true ); curl_setopt( $ch, CURLOPT_HEADER, false );
$response = curl_exec( $ch ); $response = curl_exec( $ch );
$content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE ); $content_type = curl_getinfo( $ch, CURLINFO_CONTENT_TYPE );

View File

@@ -4,6 +4,7 @@ class Log
static public function save_log( $message, $user_id = null ) static public function save_log( $message, $user_id = null )
{ {
global $mdb; global $mdb;
$mdb -> insert( 'pp_log', [ $mdb -> insert( 'pp_log', [
'message' => $message, 'message' => $message,
'user_id' => $user_id ? $user_id : null, 'user_id' => $user_id ? $user_id : null,

View File

@@ -117,83 +117,85 @@ class S
static public function generate_webp_image($file, $compression_quality = 85) static public function generate_webp_image($file, $compression_quality = 85)
{ {
if (strpos($file, 'thumb/') !== false) { if ( strpos( $file, 'thumb/' ) !== false )
$file_tmp = explode('/', $file); {
$file_tmp = explode( '/', $file );
$width = $file_tmp[1] ?? 500; $width = $file_tmp[1];
$height = $file_tmp[2] ?? 500; if ( empty( $width ) and $width !== '0' )
$width = 500;
for ($i = 0; $i <= 2; $i++) { $height = $file_tmp[2];
unset($file_tmp[$i]); if ( empty( $height ) and $height !== '0' )
} $height = 500;
$img_src = implode('/', $file_tmp); for ( $i = 0; $i <= 2; $i++ )
$crop_w = $_GET['c_w'] ?? 0; unset( $file_tmp[$i] );
$crop_h = $_GET['c_h'] ?? 0;
$img_md5 = md5($img_src . $height . $width . $crop_h . $crop_w); $img_src = implode( '/', $file_tmp );
$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; $file = 'thumbs/' . $img_md5[0] . '/' . $img_md5[1] . '/' . $img_md5[2] . '/' . $img_md5;
} }
if (!file_exists($file)) { if ( !file_exists( $file ) )
return false; return false;
}
$output_file = 'cache/' . $file . '.webp'; $output_file = 'cache/' . $file . '.webp';
if (file_exists($output_file)) { if ( file_exists( $output_file ) )
return $output_file; return $output_file;
}
$file_type = mime_content_type($file); $file_type = mime_content_type( $file );
if (function_exists('imagewebp')) { if ( function_exists( 'imagewebp' ) )
switch ($file_type) { {
switch ( $file_type )
{
case 'image/jpeg': case 'image/jpeg':
$image = imagecreatefromjpeg($file); $image = imagecreatefromjpeg($file);
break; break;
case 'image/png': case 'image/png':
$image = imagecreatefrompng($file); $image = imagecreatefrompng($file);
if (!$image) {
return false; // Jeśli nie udało się wczytać obrazu, zwróć false
}
imagepalettetotruecolor($image); imagepalettetotruecolor($image);
imagealphablending($image, true); imagealphablending($image, true);
imagesavealpha($image, true); imagesavealpha($image, true);
break; break;
case 'image/gif': case 'image/gif':
$image = imagecreatefromgif($file); $image = imagecreatefromgif($file);
break; break;
default: default:
return false; return false;
} }
if (!$image) {
return false; // Zapobiega błędowi jeśli wczytanie obrazu się nie powiedzie
}
$dir = dirname($output_file); $dir = dirname($output_file);
if (!is_dir($dir)) { if (!is_dir($dir))
mkdir($dir, 0755, true); mkdir($dir, 0755, true);
}
$result = imagewebp($image, $output_file, $compression_quality); $result = imagewebp($image, $output_file, $compression_quality);
if (false === $result)
return false;
imagedestroy($image); imagedestroy($image);
return $result ? $output_file : false; return $output_file;
} elseif (class_exists('Imagick')) {
$dir = dirname($output_file);
if (!is_dir($dir)) {
mkdir($dir, 0755, true);
} }
elseif (class_exists('Imagick'))
{
$dir = dirname($output_file);
if (!is_dir($dir))
mkdir($dir, 0755, true);
$image = new \Imagick(); $image = new \Imagick();
try {
$image->readImage($file); $image->readImage($file);
} catch (Exception $e) {
return false;
}
if ($file_type === 'image/png') { if ($file_type === 'png')
{
$image->setImageFormat('webp'); $image->setImageFormat('webp');
$image->setImageCompressionQuality($compression_quality); $image->setImageCompressionQuality($compression_quality);
$image->setOption('webp:lossless', 'true'); $image->setOption('webp:lossless', 'true');
@@ -206,7 +208,6 @@ class S
return false; return false;
} }
public static function is_array_fix( $value ) public static function is_array_fix( $value )
{ {
if ( is_array( $value ) and count( $value ) ) if ( is_array( $value ) and count( $value ) )
@@ -394,7 +395,7 @@ class S
return $version; return $version;
$version = 0; $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 ); $versions = explode( PHP_EOL, $versions );
foreach ( $versions as $key => $version_tmp ) foreach ( $versions as $key => $version_tmp )
{ {

BIN
autoload/front/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -142,11 +142,14 @@ class ShopOrder
global $page, $settings; global $page, $settings;
$page['language']['meta_title'] = \S::lang( 'meta-title-szczegoly-zamowienia' ) . ' | ' . $settings['firm_name']; $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', [ return \Tpl::view( 'shop-order/order-details', [
'order' => \front\factory\ShopOrder::order_details( 'order' => $order,
\front\factory\ShopOrder::order_id( \S::get( 'order_hash' ) ) 'coupon' => $coupon,
),
'client' => \S::get_session( 'client' ), 'client' => \S::get_session( 'client' ),
'settings' => $settings 'settings' => $settings
] ); ] );

View File

@@ -140,12 +140,14 @@ class ShopOrder
'apilo_order_status_date' => date( 'Y-m-d H:i:s' ), 'apilo_order_status_date' => date( 'Y-m-d H:i:s' ),
'sellasist_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(); $order_id = $mdb -> id();
if ( !$order_id ) if ( !$order_id )
return false; 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 // ustawienie statusu zamówienia
$mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order_id, 'status_id' => 0, 'mail' => 1 ] ); $mdb -> insert( 'pp_shop_order_statuses', [ 'order_id' => $order_id, 'status_id' => 0, 'mail' => 1 ] );
@@ -218,7 +220,8 @@ class ShopOrder
$mail_order = \Tpl::view( 'shop-order/mail-summary', [ $mail_order = \Tpl::view( 'shop-order/mail-summary', [
'settings' => $settings, 'settings' => $settings,
'order' => $order 'order' => $order,
'coupon' => $coupon,
] ); ] );
$settings[ 'ssl' ] ? $base = 'https' : $base = 'http'; $settings[ 'ssl' ] ? $base = 'https' : $base = 'http';

View File

@@ -328,10 +328,12 @@ class Order implements \ArrayAccess
global $settings; global $settings;
$order = \front\factory\ShopOrder::order_details( $this -> id ); $order = \front\factory\ShopOrder::order_details( $this -> id );
$coupon = new \shop\Coupon( $order['coupon_id'] );
$mail_order = \Tpl::view( 'shop-order/mail-summary', [ $mail_order = \Tpl::view( 'shop-order/mail-summary', [
'settings' => $settings, 'settings' => $settings,
'order' => $order 'order' => $order,
'coupon' => $coupon,
] ); ] );
$settings[ 'ssl' ] ? $base = 'https' : $base = 'http'; $settings[ 'ssl' ] ? $base = 'https' : $base = 'http';

BIN
templates/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -136,6 +136,13 @@ echo $this -> settings['newsletter_header'];
</td> </td>
</tr> </tr>
<? endif;?> <? endif;?>
<? if ( $this -> coupon ):?>
<tr>
<td style="text-align: right; font-weight: 600; padding-top: 10px;" colspan="4">
Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon -> name;?> - <?= $this -> coupon -> amount;?> <?= $this -> coupon -> type == 1 ? '%' : 'zł';?></span>
</td>
</tr>
<? endif;?>
<tr> <tr>
<td style="text-align: right; font-weight: 600; padding-top: 10px;" colspan="4"><?= $this -> order['payment_method'];?></td> <td style="text-align: right; font-weight: 600; padding-top: 10px;" colspan="4"><?= $this -> order['payment_method'];?></td>
</tr> </tr>

View File

@@ -5,6 +5,7 @@
</div> </div>
<?= \Tpl::view( 'shop-order/order-simple', [ <?= \Tpl::view( 'shop-order/order-simple', [
'order' => $this -> order, 'order' => $this -> order,
'coupon' => $this -> coupon,
'statuses' => \shop\Order::order_statuses() 'statuses' => \shop\Order::order_statuses()
] );?> ] );?>
<? if ( $this -> order['status'] == 0 or $this -> order['status'] == 2 ):?> <? if ( $this -> order['status'] == 0 or $this -> order['status'] == 2 ):?>

View File

@@ -88,6 +88,11 @@
Rabat <span class="text-danger"><?= \S::decimal( $discount );?> zł</span> Rabat <span class="text-danger"><?= \S::decimal( $discount );?> zł</span>
</div> </div>
<? endif;?> <? endif;?>
<? if ( $this -> coupon ):?>
<div class="basket-summary">
Kod rabatowy: <span style="color: #cc0000;"><?= $this -> coupon -> name;?> - <?= $this -> coupon -> amount;?> <?= $this -> coupon -> type == 1 ? '%' : 'zł';?></span>
</div>
<? endif;?>
<div class="basket-summary"> <div class="basket-summary">
<?= $this -> order['transport'];?> <span><?= \S::decimal( $this -> order['transport_cost'] );?> zł</span> <?= $this -> order['transport'];?> <span><?= \S::decimal( $this -> order['transport_cost'] );?> zł</span>
</div> </div>

View File

@@ -5,6 +5,7 @@
</div> </div>
<?= \Tpl::view( 'shop-order/order-simple', [ <?= \Tpl::view( 'shop-order/order-simple', [
'order' => $this -> order, 'order' => $this -> order,
'coupon' => $this -> coupon,
'statuses' => \shop\Order::order_statuses() 'statuses' => \shop\Order::order_statuses()
] );?> ] );?>
<? if ( $this -> order['status'] == 0 or $this -> order['status'] == 2 ):?> <? if ( $this -> order['status'] == 0 or $this -> order['status'] == 2 ):?>