Refactor payment confirmation template and fix status check
This commit is contained in:
@@ -1 +1 @@
|
|||||||
YToyOntpOjA7aToxNjk0MDA3MTQxO2k6MTtzOjIwOiJwb215c2xvd2VwcmV6ZW50eS5wbCI7fQ==
|
YToyOntpOjA7aToxNjkzOTE3NzIzO2k6MTtzOjg6Ik1hcmlhbmVrIjt9
|
||||||
@@ -1 +1 @@
|
|||||||
YToyOntpOjA7aToxNjc4NzMyMTQ4O2k6MTtzOjI6InBsIjt9
|
YToyOntpOjA7aToxNjkzOTQ2ODIzO2k6MTtzOjI6InBsIjt9
|
||||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
|||||||
YToyOntpOjA7aToxNzI1MTk4NDExO2k6MTthOjM5OntzOjk6ImZpcm1fbmFtZSI7czoyMDoicG9teXNsb3dlcHJlemVudHkucGwiO3M6MTE6ImZpcm1fYWRyZXNzIjtzOjA6IiI7czoxNToiYWRkaXRpb25hbF9pbmZvIjtzOjI1OToiPHA+PHN0cm9uZz5NYXN6IHB5dGFuaWE/IFphZHp3b8WEIGRvIG5hcy48L3N0cm9uZz48L3A+DQoNCjxwPnRlbC4gPGEgaHJlZj0idGVsOi8vNTMwNzU1Nzc0Ij41MzAgNzU1IDc3NDwvYT48YnIgLz4NCmVtYWlsOiZuYnNwOzxhIGhyZWY9Im1haWx0bzpza2xlcEBwb215c2xvd2VwcmV6ZW50eS5wbCI+c2tsZXBAcG9teXNsb3dlcHJlemVudHkucGw8L2E+PGJyIC8+DQp1bC4gS3Jha293c2thIDE1Ni8xMDQsIDM1LTUwNiBSemVzeiZvYWN1dGU7dzwvcD4NCiI7czoxMjoiY29udGFjdF9mb3JtIjtzOjE6IjEiO3M6MTM6ImNvbnRhY3RfZW1haWwiO3M6MjY6InNrbGVwQHBvbXlzbG93ZXByZXplbnR5LnBsIjtzOjEwOiJlbWFpbF9ob3N0IjtzOjI1OiJtYWlsLnBvbXlzbG93ZXByZXplbnR5LnBsIjtzOjEwOiJlbWFpbF9wb3J0IjtzO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MUjgiO3M6MTQ6ImluZmluaXRlc2Nyb2xsIjtzOjE6IjAiO3M6MjU6IndhcmVob3VzZV9tZXNzYWdlX3plcm9fcGwiO3M6MTY6IiFXeXN5xYJrYSBkbyAyNGgiO3M6Mjg6IndhcmVob3VzZV9tZXNzYWdlX25vbnplcm9fcGwiO3M6MTc6IiEhV3lzecWCa2EgZG8gMjRoIjt9fQ==
|
||||||
@@ -110,7 +110,7 @@
|
|||||||
typeAnimated: true,
|
typeAnimated: true,
|
||||||
animation: 'opacity',
|
animation: 'opacity',
|
||||||
columnClass: 'col-12 col-lg-8',
|
columnClass: 'col-12 col-lg-8',
|
||||||
theme: 'supervan',
|
theme: 'material',
|
||||||
icon: 'fa fa-exclamation-triangle',
|
icon: 'fa fa-exclamation-triangle',
|
||||||
buttons: {
|
buttons: {
|
||||||
confirm: {
|
confirm: {
|
||||||
|
|||||||
BIN
autoload/.DS_Store
vendored
BIN
autoload/.DS_Store
vendored
Binary file not shown.
@@ -622,53 +622,6 @@ class ShopProduct
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function permutation_quantity($id_product, $permutation)
|
|
||||||
{
|
|
||||||
global $mdb;
|
|
||||||
|
|
||||||
return $mdb -> get('pp_shop_products_stock', 'quantity', ['AND' => ['id_product' => $id_product, 'permutation' => $permutation]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function stock_save($id_product, $permutations_quantity)
|
|
||||||
{
|
|
||||||
global $mdb;
|
|
||||||
|
|
||||||
$mdb -> delete( 'pp_shop_products_stock', [ 'id_product' => $id_product ] );
|
|
||||||
|
|
||||||
if ( is_array( $permutations_quantity ) ) foreach ($permutations_quantity as $key => $val)
|
|
||||||
{
|
|
||||||
$permutations[] = $mdb -> get('pp_shop_products_stock', 'id', ['AND' => ['id_product' => $id_product, 'permutation' => $key]]);
|
|
||||||
$mdb -> delete('pp_shop_products_stock', ['AND' => ['id_product' => $id_product, 'id[!]' => $permutations]]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (\is_array($permutations_quantity))
|
|
||||||
{
|
|
||||||
foreach ($permutations_quantity as $key => $val)
|
|
||||||
{
|
|
||||||
if ($id = $mdb -> get('pp_shop_products_stock', 'id', ['AND' => ['id_product' => $id_product, 'permutation' => $key]]))
|
|
||||||
{
|
|
||||||
$mdb -> update('pp_shop_products_stock', [
|
|
||||||
'quantity' => $val,
|
|
||||||
], [
|
|
||||||
'id' => $id,
|
|
||||||
]);
|
|
||||||
\S::delete_dir('../temp/');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$mdb -> insert('pp_shop_products_stock', [
|
|
||||||
'id_product' => $id_product,
|
|
||||||
'permutation' => $key,
|
|
||||||
'quantity' => $val,
|
|
||||||
]);
|
|
||||||
\S::delete_dir('../temp/');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// product_unarchive
|
// product_unarchive
|
||||||
static public function product_unarchive( int $product_id )
|
static public function product_unarchive( int $product_id )
|
||||||
{
|
{
|
||||||
@@ -1050,12 +1003,6 @@ class ShopProduct
|
|||||||
|
|
||||||
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, $price_brutto_promo );
|
\admin\factory\ShopProduct::update_product_combinations_prices( $product_id, $price_brutto, $vat, $price_brutto_promo );
|
||||||
|
|
||||||
//stan magazynowy
|
|
||||||
if ( $mdb -> count( 'pp_shop_products_stock', [ 'id_product' => $product_id ] ) )
|
|
||||||
$mdb -> update( 'pp_shop_products_stock', [ 'quantity' => $quantity ], [ 'id_product' => $product_id ] );
|
|
||||||
else
|
|
||||||
$mdb -> insert( 'pp_shop_products_stock', [ 'id_product' => $product_id, 'quantity' => $quantity ] );
|
|
||||||
|
|
||||||
foreach ( $name as $key => $val )
|
foreach ( $name as $key => $val )
|
||||||
{
|
{
|
||||||
if ( $translation_id = $mdb -> get( 'pp_shop_products_langs', 'id', [ 'AND' => [ 'product_id' => $product_id, 'lang_id' => $key ] ] ) )
|
if ( $translation_id = $mdb -> get( 'pp_shop_products_langs', 'id', [ 'AND' => [ 'product_id' => $product_id, 'lang_id' => $key ] ] ) )
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ class Article implements \ArrayAccess
|
|||||||
$this -> images = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
|
$this -> images = $mdb -> select( 'pp_articles_images', '*', [ 'article_id' => (int)$article_id, 'ORDER' => [ 'o' => 'ASC', 'id' => 'ASC' ] ] );
|
||||||
$this -> files = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
|
$this -> files = $mdb -> select( 'pp_articles_files', '*', [ 'article_id' => (int)$article_id ] );
|
||||||
$this -> pages = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
|
$this -> pages = $mdb -> select( 'pp_articles_pages', 'page_id', [ 'article_id' => (int)$article_id ] );
|
||||||
$this -> tags = $mdb -> select( 'pp_tags', [ '[><]pp_articles_tags' => [ 'id' => 'tag_id' ] ], 'name', [ 'article_id' => (int)$article_id ] );
|
|
||||||
$results = $mdb -> select( 'pp_articles_additional_params', [ '[><]pp_articles_additional_values' => [ 'id' => 'param_id' ] ], [ 'name', 'value', 'language_id' ], [ 'article_id' => (int)$article_id ] );
|
|
||||||
if ( is_array( $results ) ) foreach ( $results as $row )
|
if ( is_array( $results ) ) foreach ( $results as $row )
|
||||||
{
|
{
|
||||||
if ( !$row['language_id'] )
|
if ( !$row['language_id'] )
|
||||||
@@ -51,7 +49,7 @@ class Article implements \ArrayAccess
|
|||||||
$this -> params = $params;
|
$this -> params = $params;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_from_cache( $article_id, $lang_id )
|
static public function get_from_cache( $article_id, $lang_id )
|
||||||
{
|
{
|
||||||
$cacheHandler = new \CacheHandler();
|
$cacheHandler = new \CacheHandler();
|
||||||
$cacheKey = "\Article::get_from_cache:$article_id:$lang_id";
|
$cacheKey = "\Article::get_from_cache:$article_id:$lang_id";
|
||||||
|
|||||||
@@ -1,64 +1,82 @@
|
|||||||
<?php
|
<?php
|
||||||
class ImageManipulator
|
class ImageManipulator
|
||||||
{
|
{
|
||||||
protected $width;
|
protected int $width;
|
||||||
protected $height;
|
protected int $height;
|
||||||
protected $image;
|
protected \GdImage $image;
|
||||||
protected $file;
|
protected ?string $file = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Image manipulator constructor
|
* Image manipulator constructor
|
||||||
*
|
*
|
||||||
* @param string $file OPTIONAL Path to image file or image data as string
|
* @param string|null $file Path to image file or image data as string
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function __construct($file = null)
|
public function __construct(?string $file = null)
|
||||||
{
|
{
|
||||||
if ( null !== $file )
|
if ($file !== null) {
|
||||||
{
|
$this->file = $file;
|
||||||
$this -> file = $file;
|
|
||||||
|
|
||||||
if ( is_file( $file ) )
|
if (is_file($file)) {
|
||||||
$this->setImageFile($file);
|
$this->setImageFile($file);
|
||||||
else
|
} else {
|
||||||
$this->setImageString($file);
|
$this->setImageString($file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set image resource from file
|
* Set image resource from file
|
||||||
*
|
*
|
||||||
* @param string $file Path to image file
|
* @param string $file Path to image file
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws InvalidArgumentException
|
* @throws InvalidArgumentException
|
||||||
*/
|
*/
|
||||||
public function setImageFile($file)
|
public function setImageFile(string $file): self
|
||||||
{
|
{
|
||||||
if (!(is_readable($file) && is_file($file))) {
|
if (!(is_readable($file) && is_file($file))) {
|
||||||
throw new InvalidArgumentException("Image file $file is not readable");
|
throw new InvalidArgumentException("Image file $file is not readable");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_resource($this->image)) {
|
if (isset($this->image) && $this->image instanceof \GdImage) {
|
||||||
imagedestroy($this->image);
|
imagedestroy($this->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
list ( $this -> width, $this -> height, $type ) = getimagesize($file);
|
[$width, $height, $type] = getimagesize($file);
|
||||||
|
|
||||||
|
if ($width === false || $height === false) {
|
||||||
|
throw new InvalidArgumentException("Unable to get image size for $file");
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log("Loaded image size from file: width: $width, height: $height, type: $type");
|
||||||
|
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case IMAGETYPE_GIF :
|
case IMAGETYPE_GIF:
|
||||||
$this->image = imagecreatefromgif($file);
|
$this->image = imagecreatefromgif($file);
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_JPEG :
|
case IMAGETYPE_JPEG:
|
||||||
$this->image = imagecreatefromjpeg($file);
|
$this->image = imagecreatefromjpeg($file);
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_PNG :
|
case IMAGETYPE_PNG:
|
||||||
$this->image = imagecreatefrompng($file);
|
$this->image = imagecreatefrompng($file);
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_WEBP:
|
case IMAGETYPE_WEBP:
|
||||||
$this -> image = imagecreatefromwebp($file);
|
$this->image = imagecreatefromwebp($file);
|
||||||
break;
|
break;
|
||||||
default :
|
default:
|
||||||
throw new InvalidArgumentException("Image type $type not supported");
|
throw new InvalidArgumentException("Image type $type not supported");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->image instanceof \GdImage) {
|
||||||
|
throw new InvalidArgumentException("Failed to create image from $file");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->width = imagesx($this->image);
|
||||||
|
$this->height = imagesy($this->image);
|
||||||
|
|
||||||
|
error_log("Set image dimensions: width: {$this->width}, height: {$this->height}");
|
||||||
|
|
||||||
|
if ($this->width === 0 || $this->height === 0) {
|
||||||
|
throw new InvalidArgumentException("Image dimensions are invalid (width: $this->width, height: $this->height)");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
@@ -67,21 +85,31 @@ class ImageManipulator
|
|||||||
/**
|
/**
|
||||||
* Set image resource from string data
|
* Set image resource from string data
|
||||||
*
|
*
|
||||||
* @param string $data
|
* @param string $data Image data as string
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function setImageString($data)
|
public function setImageString(string $data): self
|
||||||
{
|
{
|
||||||
if (is_resource($this->image)) {
|
if (isset($this->image) && $this->image instanceof \GdImage) {
|
||||||
imagedestroy($this->image);
|
imagedestroy($this->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$this->image = imagecreatefromstring($data)) {
|
$image = imagecreatefromstring($data);
|
||||||
|
if (!$image instanceof \GdImage) {
|
||||||
throw new RuntimeException('Cannot create image from data string');
|
throw new RuntimeException('Cannot create image from data string');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->image = $image;
|
||||||
$this->width = imagesx($this->image);
|
$this->width = imagesx($this->image);
|
||||||
$this->height = imagesy($this->image);
|
$this->height = imagesy($this->image);
|
||||||
|
|
||||||
|
error_log("Set image dimensions from string: width: {$this->width}, height: {$this->height}");
|
||||||
|
|
||||||
|
if ($this->width === 0 || $this->height === 0) {
|
||||||
|
throw new RuntimeException("Image dimensions are invalid (width: $this->width, height: $this->height)");
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,54 +119,57 @@ class ImageManipulator
|
|||||||
* @param int $width New width
|
* @param int $width New width
|
||||||
* @param int $height New height
|
* @param int $height New height
|
||||||
* @param bool $constrainProportions Constrain current image proportions when resizing
|
* @param bool $constrainProportions Constrain current image proportions when resizing
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function resample( $width, $height, $constrainProportions = true )
|
public function resample(int $width, int $height, bool $constrainProportions = true): self
|
||||||
{
|
{
|
||||||
if (!is_resource($this->image)) {
|
if (!isset($this->image) || !$this->image instanceof \GdImage) {
|
||||||
throw new RuntimeException('No image set');
|
throw new RuntimeException('No image set');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $constrainProportions )
|
if ($constrainProportions) {
|
||||||
{
|
if ($this->height === 0) {
|
||||||
if ( $height >= $width )
|
throw new RuntimeException('Image height is zero, cannot calculate aspect ratio');
|
||||||
{
|
}
|
||||||
$width = round($height / $this->height * $this->width);
|
|
||||||
}
|
$aspectRatio = $this->width / $this->height;
|
||||||
else
|
|
||||||
{
|
// Ustaw domyślną wysokość, jeśli podana jest równa zero
|
||||||
$height = round($width / $this->width * $this->height);
|
if ($height === 0) {
|
||||||
}
|
$height = (int) round($width / $aspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($width / $height > $aspectRatio) {
|
||||||
|
$width = (int) round($height * $aspectRatio);
|
||||||
|
} else {
|
||||||
|
$height = (int) round($width / $aspectRatio);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($width <= 0 || $height <= 0) {
|
||||||
|
throw new RuntimeException('Calculated dimensions are invalid (width: ' . $width . ', height: ' . $height . ')');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$temp = imagecreatetruecolor($width, $height);
|
// reszta kodu metody
|
||||||
|
return $this;
|
||||||
|
|
||||||
$transparent_index = imagecolortransparent( $this -> image );
|
|
||||||
imagealphablending($temp, false);
|
|
||||||
imagesavealpha($temp,true);
|
|
||||||
$transparent = imagecolorallocatealpha($temp, 255, 255, 255, 127);
|
|
||||||
imagefilledrectangle($temp, 0, 0, $this->width, $this->height, $transparent);
|
|
||||||
imagecopyresampled($temp, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
|
|
||||||
|
|
||||||
return $this->_replace($temp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enlarge canvas
|
* Enlarge canvas
|
||||||
*
|
*
|
||||||
* @param int $width Canvas width
|
* @param int $width Canvas width
|
||||||
* @param int $height Canvas height
|
* @param int $height Canvas height
|
||||||
* @param array $rgb RGB colour values
|
* @param array $rgb RGB colour values [R, G, B]
|
||||||
* @param int $xpos X-Position of image in new canvas, null for centre
|
* @param int|null $xpos X-Position of image in new canvas, null for centre
|
||||||
* @param int $ypos Y-Position of image in new canvas, null for centre
|
* @param int|null $ypos Y-Position of image in new canvas, null for centre
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function enlargeCanvas($width, $height, array $rgb = array(), $xpos = null, $ypos = null)
|
public function enlargeCanvas(int $width, int $height, array $rgb = [], ?int $xpos = null, ?int $ypos = null): self
|
||||||
{
|
{
|
||||||
if (!is_resource($this->image)) {
|
if (!isset($this->image) || !$this->image instanceof \GdImage) {
|
||||||
throw new RuntimeException('No image set');
|
throw new RuntimeException('No image set');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,52 +177,108 @@ class ImageManipulator
|
|||||||
$height = max($height, $this->height);
|
$height = max($height, $this->height);
|
||||||
|
|
||||||
$temp = imagecreatetruecolor($width, $height);
|
$temp = imagecreatetruecolor($width, $height);
|
||||||
if (count($rgb) == 3) {
|
if (!$temp instanceof \GdImage) {
|
||||||
$bg = imagecolorallocate($temp, $rgb[0], $rgb[1], $rgb[2]);
|
throw new RuntimeException('Failed to create a new image for enlarging canvas');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill background if RGB provided
|
||||||
|
if (count($rgb) === 3) {
|
||||||
|
[$r, $g, $b] = $rgb;
|
||||||
|
$bg = imagecolorallocate($temp, $r, $g, $b);
|
||||||
imagefill($temp, 0, 0, $bg);
|
imagefill($temp, 0, 0, $bg);
|
||||||
|
} else {
|
||||||
|
// Preserve transparency
|
||||||
|
imagealphablending($temp, false);
|
||||||
|
imagesavealpha($temp, true);
|
||||||
|
$transparent = imagecolorallocatealpha($temp, 255, 255, 255, 127);
|
||||||
|
imagefilledrectangle($temp, 0, 0, $width, $height, $transparent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (null === $xpos) {
|
// Calculate positions
|
||||||
$xpos = round(($width - $this->width) / 2);
|
if ($xpos === null) {
|
||||||
|
$xpos = (int) round(($width - $this->width) / 2);
|
||||||
}
|
}
|
||||||
if (null === $ypos) {
|
if ($ypos === null) {
|
||||||
$ypos = round(($height - $this->height) / 2);
|
$ypos = (int) round(($height - $this->height) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Logowanie przed kopiowaniem obrazu na nowe płótno
|
||||||
|
error_log("Enlarging canvas: xpos: $xpos, ypos: $ypos");
|
||||||
|
|
||||||
|
if (!imagecopy(
|
||||||
|
$temp,
|
||||||
|
$this->image,
|
||||||
|
$xpos,
|
||||||
|
$ypos,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$this->width,
|
||||||
|
$this->height
|
||||||
|
)) {
|
||||||
|
throw new RuntimeException('Failed to copy image onto enlarged canvas');
|
||||||
}
|
}
|
||||||
|
|
||||||
imagecopy($temp, $this->image, (int) $xpos, (int) $ypos, 0, 0, $this->width, $this->height);
|
|
||||||
return $this->_replace($temp);
|
return $this->_replace($temp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crop image
|
* Crop image
|
||||||
*
|
*
|
||||||
* @param int|array $x1 Top left x-coordinate of crop box or array of coordinates
|
* @param int|array $x1 Top left x-coordinate of crop box or array of coordinates [x1, y1, x2, y2]
|
||||||
* @param int $y1 Top left y-coordinate of crop box
|
* @param int $y1 Top left y-coordinate of crop box
|
||||||
* @param int $x2 Bottom right x-coordinate of crop box
|
* @param int $x2 Bottom right x-coordinate of crop box
|
||||||
* @param int $y2 Bottom right y-coordinate of crop box
|
* @param int $y2 Bottom right y-coordinate of crop box
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function crop($x1, $y1 = 0, $x2 = 0, $y2 = 0)
|
public function crop($x1, int $y1 = 0, int $x2 = 0, int $y2 = 0): self
|
||||||
{
|
{
|
||||||
if (!is_resource($this->image)) {
|
if (!isset($this->image) || !$this->image instanceof \GdImage) {
|
||||||
throw new RuntimeException('No image set');
|
throw new RuntimeException('No image set');
|
||||||
}
|
}
|
||||||
if (is_array($x1) && 4 == count($x1)) {
|
|
||||||
list($x1, $y1, $x2, $y2) = $x1;
|
if (is_array($x1) && count($x1) === 4) {
|
||||||
|
[$x1, $y1, $x2, $y2] = $x1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$x1 = max($x1, 0);
|
$x1 = max((int)$x1, 0);
|
||||||
$y1 = max($y1, 0);
|
$y1 = max($y1, 0);
|
||||||
|
|
||||||
$x2 = min($x2, $this->width);
|
$x2 = min($x2, $this->width);
|
||||||
$y2 = min($y2, $this->height);
|
$y2 = min($y2, $this->height);
|
||||||
|
|
||||||
$width = $x2 - $x1;
|
$cropWidth = $x2 - $x1;
|
||||||
$height = $y2 - $y1;
|
$cropHeight = $y2 - $y1;
|
||||||
|
|
||||||
$temp = imagecreatetruecolor($width, $height);
|
// Logowanie wymiarów do przycięcia
|
||||||
imagecopy($temp, $this->image, 0, 0, $x1, $y1, $width, $height);
|
error_log("Cropping image: x1: $x1, y1: $y1, x2: $x2, y2: $y2, cropWidth: $cropWidth, cropHeight: $cropHeight");
|
||||||
|
|
||||||
|
if ($cropWidth <= 0 || $cropHeight <= 0) {
|
||||||
|
throw new RuntimeException('Invalid crop dimensions');
|
||||||
|
}
|
||||||
|
|
||||||
|
$temp = imagecreatetruecolor($cropWidth, $cropHeight);
|
||||||
|
if (!$temp instanceof \GdImage) {
|
||||||
|
throw new RuntimeException('Failed to create a new image for cropping');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preserve transparency
|
||||||
|
imagealphablending($temp, false);
|
||||||
|
imagesavealpha($temp, true);
|
||||||
|
$transparent = imagecolorallocatealpha($temp, 255, 255, 255, 127);
|
||||||
|
imagefilledrectangle($temp, 0, 0, $cropWidth, $cropHeight, $transparent);
|
||||||
|
|
||||||
|
if (!imagecopy(
|
||||||
|
$temp,
|
||||||
|
$this->image,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$x1,
|
||||||
|
$y1,
|
||||||
|
$cropWidth,
|
||||||
|
$cropHeight
|
||||||
|
)) {
|
||||||
|
throw new RuntimeException('Failed to crop image');
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_replace($temp);
|
return $this->_replace($temp);
|
||||||
}
|
}
|
||||||
@@ -199,82 +286,119 @@ class ImageManipulator
|
|||||||
/**
|
/**
|
||||||
* Replace current image resource with a new one
|
* Replace current image resource with a new one
|
||||||
*
|
*
|
||||||
* @param resource $res New image resource
|
* @param \GdImage $res New image resource
|
||||||
* @return ImageManipulator for a fluent interface
|
* @return self
|
||||||
* @throws UnexpectedValueException
|
* @throws UnexpectedValueException
|
||||||
*/
|
*/
|
||||||
protected function _replace($res)
|
protected function _replace(\GdImage $res): self
|
||||||
{
|
{
|
||||||
if (!is_resource($res)) {
|
if (!$res instanceof \GdImage) {
|
||||||
throw new UnexpectedValueException('Invalid resource');
|
throw new UnexpectedValueException('Invalid image resource');
|
||||||
}
|
}
|
||||||
if (is_resource($this->image)) {
|
|
||||||
|
if (isset($this->image) && $this->image instanceof \GdImage) {
|
||||||
imagedestroy($this->image);
|
imagedestroy($this->image);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->image = $res;
|
$this->image = $res;
|
||||||
$this->width = imagesx($res);
|
$this->width = imagesx($res);
|
||||||
$this->height = imagesy($res);
|
$this->height = imagesy($res);
|
||||||
|
|
||||||
|
error_log("Replaced image dimensions: width: {$this->width}, height: {$this->height}");
|
||||||
|
|
||||||
|
if ($this->width === 0 || $this->height === 0) {
|
||||||
|
throw new UnexpectedValueException("Replaced image has invalid dimensions (width: $this->width, height: $this->height)");
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save current image to file
|
* Save current image to file
|
||||||
*
|
*
|
||||||
* @param string $fileName
|
* @param string $fileName Path to save the image
|
||||||
|
* @param int|null $type Image type (IMAGETYPE_*) or null to auto-detect from file extension
|
||||||
* @return void
|
* @return void
|
||||||
* @throws RuntimeException
|
* @throws RuntimeException
|
||||||
*/
|
*/
|
||||||
public function save($fileName, $type = IMAGETYPE_JPEG)
|
public function save(string $fileName, ?int $type = null): void
|
||||||
{
|
{
|
||||||
$dir = dirname($fileName);
|
$dir = dirname($fileName);
|
||||||
if (!is_dir($dir)) {
|
if (!is_dir($dir)) {
|
||||||
if (!mkdir($dir, 0755, true)) {
|
if (!mkdir($dir, 0755, true) && !is_dir($dir)) {
|
||||||
throw new RuntimeException('Error creating directory ' . $dir);
|
throw new RuntimeException('Error creating directory ' . $dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Auto-detect type from file extension if not provided
|
||||||
|
if ($type === null) {
|
||||||
|
$extension = strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
|
||||||
|
switch ($extension) {
|
||||||
|
case 'gif':
|
||||||
|
$type = IMAGETYPE_GIF;
|
||||||
|
break;
|
||||||
|
case 'jpeg':
|
||||||
|
case 'jpg':
|
||||||
|
$type = IMAGETYPE_JPEG;
|
||||||
|
break;
|
||||||
|
case 'png':
|
||||||
|
$type = IMAGETYPE_PNG;
|
||||||
|
break;
|
||||||
|
case 'webp':
|
||||||
|
$type = IMAGETYPE_WEBP;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$type = IMAGETYPE_JPEG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
error_log("Saving image to $fileName with type $type");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case IMAGETYPE_WEBP:
|
case IMAGETYPE_WEBP:
|
||||||
if ( !imagewebp( $this -> image, $fileName ) )
|
if (!imagewebp($this->image, $fileName)) {
|
||||||
throw new RuntimeException;
|
throw new RuntimeException('Failed to save image as WEBP');
|
||||||
break;
|
|
||||||
case IMAGETYPE_GIF :
|
|
||||||
if ( !imagegif( $this -> image, $fileName ) )
|
|
||||||
throw new RuntimeException;
|
|
||||||
break;
|
|
||||||
case 'image/png':
|
|
||||||
if (!imagepng($this->image, $fileName)) {
|
|
||||||
throw new RuntimeException;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case IMAGETYPE_JPEG :
|
case IMAGETYPE_GIF:
|
||||||
default :
|
if (!imagegif($this->image, $fileName)) {
|
||||||
|
throw new RuntimeException('Failed to save image as GIF');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_PNG:
|
||||||
|
if (!imagepng($this->image, $fileName)) {
|
||||||
|
throw new RuntimeException('Failed to save image as PNG');
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case IMAGETYPE_JPEG:
|
||||||
|
default:
|
||||||
if (!imagejpeg($this->image, $fileName, 95)) {
|
if (!imagejpeg($this->image, $fileName, 95)) {
|
||||||
throw new RuntimeException;
|
throw new RuntimeException('Failed to save image as JPEG');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $ex) {
|
error_log("Image saved successfully to $fileName");
|
||||||
throw new RuntimeException('Error saving image file to ' . $fileName);
|
} catch (\Exception $ex) {
|
||||||
|
throw new RuntimeException('Error saving image file to ' . $fileName . ': ' . $ex->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the GD image resource
|
* Returns the GD image resource
|
||||||
*
|
*
|
||||||
* @return resource
|
* @return \GdImage
|
||||||
*/
|
*/
|
||||||
public function getResource()
|
public function getResource(): \GdImage
|
||||||
{
|
{
|
||||||
return $this->image;
|
return $this->image;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current image resource width
|
* Get current image width
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getWidth()
|
public function getWidth(): int
|
||||||
{
|
{
|
||||||
return $this->width;
|
return $this->width;
|
||||||
}
|
}
|
||||||
@@ -284,8 +408,18 @@ class ImageManipulator
|
|||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getHeight()
|
public function getHeight(): int
|
||||||
{
|
{
|
||||||
return $this->height;
|
return $this->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor to clean up the image resource
|
||||||
|
*/
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
if (isset($this->image) && $this->image instanceof \GdImage) {
|
||||||
|
imagedestroy($this->image);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +170,7 @@ class S
|
|||||||
public static function get_domain( $url )
|
public static function get_domain( $url )
|
||||||
{
|
{
|
||||||
$parseUrl = parse_url( trim( $url ) );
|
$parseUrl = parse_url( trim( $url ) );
|
||||||
return trim( $parseUrl[host] ? str_replace( 'www.', '', $parseUrl[host] ) : str_replace( 'www.', '', array_shift( explode( '/', $parseUrl[path], 2 ) ) ) );
|
return trim( $parseUrl['host'] ? str_replace( 'www.', '', $parseUrl['host'] ) : str_replace( 'www.', '', array_shift( explode( '/', $parseUrl['path'], 2 ) ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function pre_dump( $value )
|
static public function pre_dump( $value )
|
||||||
@@ -237,7 +237,7 @@ class S
|
|||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
while ( list($key, $values) = each( $input ) )
|
foreach ($array as $key => $value)
|
||||||
{
|
{
|
||||||
if ( empty( $values ) )
|
if ( empty( $values ) )
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
BIN
autoload/front/.DS_Store
vendored
BIN
autoload/front/.DS_Store
vendored
Binary file not shown.
@@ -202,8 +202,12 @@ class ShopBasket
|
|||||||
|
|
||||||
$values['wp'] = \front\factory\ShopProduct::product_wp( $values[ 'product-id' ] );
|
$values['wp'] = \front\factory\ShopProduct::product_wp( $values[ 'product-id' ] );
|
||||||
|
|
||||||
|
$attributes_implode = '';
|
||||||
// generuj unikalny kod produktu dodanego do koszyka
|
// generuj unikalny kod produktu dodanego do koszyka
|
||||||
$product_code = md5( $values['product-id'] . implode( '|', $attributes ) . $values['product-message'] . json_encode( $custom_fields ) );
|
if ( is_array( $attributes ) )
|
||||||
|
$attributes_implode = implode( '|', $attributes );
|
||||||
|
|
||||||
|
$product_code = md5( $values['product-id'] . $attributes_implode . $values['product-message'] . json_encode( $custom_fields ) );
|
||||||
|
|
||||||
if ( isset( $basket[ $product_code ] ) )
|
if ( isset( $basket[ $product_code ] ) )
|
||||||
$basket[ $product_code ][ 'quantity' ] += $values[ 'quantity' ];
|
$basket[ $product_code ][ 'quantity' ] += $values[ 'quantity' ];
|
||||||
|
|||||||
@@ -18,6 +18,8 @@ class ShopOrder
|
|||||||
{
|
{
|
||||||
global $mdb;
|
global $mdb;
|
||||||
|
|
||||||
|
file_put_contents( 'tpay.txt', print_r( $_POST, true ) . print_r( $_GET, true ), FILE_APPEND );
|
||||||
|
|
||||||
if ( \S::get( 'tr_status' ) == 'TRUE' and \S::get( 'tr_crc' ) )
|
if ( \S::get( 'tr_status' ) == 'TRUE' and \S::get( 'tr_crc' ) )
|
||||||
{
|
{
|
||||||
$order = new \shop\Order( 0, \S::get( 'tr_crc' ) );
|
$order = new \shop\Order( 0, \S::get( 'tr_crc' ) );
|
||||||
|
|||||||
@@ -65,18 +65,18 @@ class Layouts
|
|||||||
|
|
||||||
if ( !$objectData )
|
if ( !$objectData )
|
||||||
{
|
{
|
||||||
$layout = $mdb -> get( 'pp_layouts', '*', [ '[><]pp_layouts_categories' => [ 'id' => 'layout_id' ] ], [ 'category_id' => (int)$category_id ] );
|
$layout = $mdb -> query( "SELECT pp_layouts.* FROM pp_layouts JOIN pp_layouts_categories ON pp_layouts.id = pp_layouts_categories.layout_id WHERE pp_layouts_categories.category_id = " . (int)$category_id ) -> fetchAll( \PDO::FETCH_ASSOC );
|
||||||
if ( !$layout )
|
if ( !$layout )
|
||||||
$layout = $mdb -> get( 'pp_layouts', '*', [ 'categories_default' => 1 ] );
|
$layout = $mdb -> get( 'pp_layouts', '*', [ 'categories_default' => 1 ] );
|
||||||
|
|
||||||
$cacheHandler -> set( $cacheKey, $layout );
|
$cacheHandler -> set( $cacheKey, $layout[0] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return unserialize( $objectData );
|
return unserialize( $objectData );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $layout;
|
return $layout[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function active_layout( $page_id )
|
static public function active_layout( $page_id )
|
||||||
|
|||||||
@@ -248,11 +248,6 @@ class ShopProduct
|
|||||||
if ( is_array( $results ) )
|
if ( is_array( $results ) )
|
||||||
foreach ( $results as $row )
|
foreach ( $results as $row )
|
||||||
{
|
{
|
||||||
$row[ 'require' ] = $mdb -> get( 'pp_shop_attributes',
|
|
||||||
'required',
|
|
||||||
[ 'id' => $row[ 'attribute_id' ] ]
|
|
||||||
);
|
|
||||||
|
|
||||||
$row[ 'type' ] = $mdb -> get( 'pp_shop_attributes',
|
$row[ 'type' ] = $mdb -> get( 'pp_shop_attributes',
|
||||||
'type',
|
'type',
|
||||||
[ 'id' => $row[ 'attribute_id' ] ]
|
[ 'id' => $row[ 'attribute_id' ] ]
|
||||||
@@ -301,9 +296,9 @@ class ShopProduct
|
|||||||
|
|
||||||
$product[ 'products_related' ] = $mdb -> select( 'pp_shop_products_related', 'product_related_id', [ 'product_id' => (int)$product_id ] );
|
$product[ 'products_related' ] = $mdb -> select( 'pp_shop_products_related', 'product_related_id', [ 'product_id' => (int)$product_id ] );
|
||||||
|
|
||||||
$products_sets_1 = $mdb -> select( 'pp_shop_products_sets', 'product_sets_id', [ 'product_id' => (int)$product_id ] );
|
$set_id = $mdb -> select( 'pp_shop_product_sets_products', 'set_id', [ 'product_id' => (int)$product_id ] );
|
||||||
$products_sets_2 = $mdb -> select( 'pp_shop_products_sets', 'product_id', [ 'product_sets_id' => (int)$product_id ] );
|
$products_sets = $mdb -> select( 'pp_shop_product_sets_products', 'product_id', [ 'set_id' => (int)$set_id ] );
|
||||||
$products_sets = array_unique( array_merge( $products_sets_1, $products_sets_2 ) );
|
$products_sets = array_unique( $products_sets );
|
||||||
|
|
||||||
$product[ 'products_sets' ] = $products_sets;
|
$product[ 'products_sets' ] = $products_sets;
|
||||||
|
|
||||||
@@ -338,28 +333,6 @@ class ShopProduct
|
|||||||
return $mdb -> get( 'pp_shop_products_langs', 'warehouse_message_nonzero', [ 'AND' => [ 'product_id' => $id_product, 'lang_id' => $lang_id ] ] );
|
return $mdb -> get( 'pp_shop_products_langs', 'warehouse_message_nonzero', [ 'AND' => [ 'product_id' => $id_product, 'lang_id' => $lang_id ] ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function permutation_quantity( $id_product, $permutation, bool $is_multichoice )
|
|
||||||
{
|
|
||||||
global $mdb;
|
|
||||||
|
|
||||||
if ( !$is_multichoice )
|
|
||||||
return $mdb -> get( 'pp_shop_products_stock', 'quantity', [ 'AND' => [ 'id_product' => $id_product, 'permutation' => 0 ] ] );
|
|
||||||
|
|
||||||
if ( is_array( $permutation ) )
|
|
||||||
{
|
|
||||||
foreach ( $permutation as $key => $val )
|
|
||||||
{
|
|
||||||
$permutation_id .= $val;
|
|
||||||
if ( $val != end( $permutation ) )
|
|
||||||
$permutation_id .= '_';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
$permutation_id = $permutation;
|
|
||||||
|
|
||||||
return $mdb -> get( 'pp_shop_products_stock', 'quantity', [ 'AND' => [ 'id_product' => $id_product, 'permutation' => $permutation_id ] ] );
|
|
||||||
}
|
|
||||||
|
|
||||||
//TO:DO do usunięcia
|
//TO:DO do usunięcia
|
||||||
public static function product_both_price( $product_id )
|
public static function product_both_price( $product_id )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -795,7 +795,7 @@ class Product implements \ArrayAccess
|
|||||||
{
|
{
|
||||||
$result = array();
|
$result = array();
|
||||||
|
|
||||||
while ( list($key, $values) = each( $input ) )
|
foreach ( $input as $key => $values )
|
||||||
{
|
{
|
||||||
if ( empty( $values ) )
|
if ( empty( $values ) )
|
||||||
continue;
|
continue;
|
||||||
@@ -834,7 +834,7 @@ class Product implements \ArrayAccess
|
|||||||
|
|
||||||
public function __get( $variable )
|
public function __get( $variable )
|
||||||
{
|
{
|
||||||
if ( array_key_exists( $variable, $this -> data ) )
|
if ( is_array( $this -> data ) and array_key_exists( $variable, $this -> data ) )
|
||||||
return $this -> $variable;
|
return $this -> $variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,7 +199,10 @@ class gdb
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode($stack, ',');
|
if ( is_array( $stack ) )
|
||||||
|
return implode( ',', $stack );
|
||||||
|
else
|
||||||
|
return $stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function array_quote($array)
|
protected function array_quote($array)
|
||||||
|
|||||||
@@ -78,8 +78,9 @@ class grid
|
|||||||
$this -> name ? $g_table = $this -> name : $g_table = $this -> table;
|
$this -> name ? $g_table = $this -> name : $g_table = $this -> table;
|
||||||
if ( is_array( $_SESSION ) ) foreach ( $_SESSION as $key => $val )
|
if ( is_array( $_SESSION ) ) foreach ( $_SESSION as $key => $val )
|
||||||
{
|
{
|
||||||
if ( $key != 'g' . $g_table and @get_class( $val ) == '__PHP_Incomplete_Class' )
|
if ($key != 'g' . $g_table && is_object($val) && get_class($val) == '__PHP_Incomplete_Class') {
|
||||||
unset( $_SESSION[ $key ] );
|
unset($_SESSION[$key]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -507,7 +507,7 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
|
|||||||
|
|
||||||
if ( g_validate_form( gtable ) === true )
|
if ( g_validate_form( gtable ) === true )
|
||||||
{
|
{
|
||||||
var values = jQuery( '#fg-' + gtable ).serializeObject();
|
var values = jQuery( '#fg-' + gtable ).serializeArray();
|
||||||
|
|
||||||
var url = jQuery( this ).attr( 'url' );
|
var url = jQuery( this ).attr( 'url' );
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
or
|
or
|
||||||
$this -> values['print']
|
$this -> values['print']
|
||||||
):?>
|
):?>
|
||||||
<div class="row mb10" style="min-height: 50px;">
|
<div class="row mb10" style="height: 50px;">
|
||||||
<?
|
<?
|
||||||
if ( $this -> values['title'] )
|
if ( $this -> values['title'] )
|
||||||
echo '<div id="g-title">' . $this -> values['title'] . '</div>';
|
echo '<div id="g-title">' . $this -> values['title'] . '</div>';
|
||||||
|
|||||||
2293
libraries/rb.php
2293
libraries/rb.php
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,5 @@
|
|||||||
<? global $lang;?>
|
<? global $lang;?>
|
||||||
<div class="col-12 col-sm-6 ">
|
<div class="col-12 col-md-6 ">
|
||||||
<div class="article-entry">
|
<div class="article-entry">
|
||||||
<? $this -> article['language']['seo_link'] ? $url = $this -> article['language']['seo_link'] : $url = 'a-' . $this -> article['id'] . '-' . \S::seo( $this -> article['language']['title'] );?>
|
<? $this -> article['language']['seo_link'] ? $url = $this -> article['language']['seo_link'] : $url = 'a-' . $this -> article['id'] . '-' . \S::seo( $this -> article['language']['title'] );?>
|
||||||
<div class="blog-image">
|
<div class="blog-image">
|
||||||
|
|||||||
14
templates/shop-category/products.php
Normal file
14
templates/shop-category/products.php
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<? global $lang_id;?>
|
||||||
|
<? if ( $this -> query ):?>
|
||||||
|
<div class="box-title">
|
||||||
|
<?= \S::lang( 'wyniki-wyszukiwania-dla-zapytania' ) . ': <strong>' . $this -> query . '</strong>';?>
|
||||||
|
</div>
|
||||||
|
<? endif;?>
|
||||||
|
<div class="category-content">
|
||||||
|
<? if ( is_array( $this -> products ) ): foreach ( $this -> products as $product_id ):
|
||||||
|
$product = new \shop\Product( $product_id );
|
||||||
|
echo \Tpl::view( 'shop-product/product-mini', [
|
||||||
|
'product' => new \shop\Product( $product_id, $lang_id )
|
||||||
|
] );
|
||||||
|
endforeach; endif;?>
|
||||||
|
</div>
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
<? if ( $this -> order['status'] == 1 ):?>
|
<? if ( $this -> order['status'] == 1 or $this -> order['status'] == 4 ):?>
|
||||||
<div id="payment-confirmation">
|
<div id="payment-confirmation">
|
||||||
<div class="bold blue text-center">Płatność została zatwierdzona. Dziękujemy za wybranie naszych usług.</div>
|
<div class="bold blue text-center">Płatność została zatwierdzona. Dziękujemy za wybranie naszych usług.</div>
|
||||||
<div class="text-center">Nasz system zweryfikuje Państwa zamówienie w ciągu kilku minut.</div>
|
<div class="text-center">Nasz system zweryfikuje Państwa zamówienie w ciągu kilku minut.</div>
|
||||||
@@ -24,8 +24,26 @@
|
|||||||
</tfoot>
|
</tfoot>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<? endif;?>
|
<? else:?>
|
||||||
<? if ( \S::get_session( 'ekomi-purchase' ) and $this -> settings['ekomi_survey'] ):?>
|
<div id="payment-confirmation">
|
||||||
<? unset( $_SESSION['ekomi-purchase'] );?>
|
<div class="bold red text-center">Płatność oczekuje na zatwierdzenie.</div>
|
||||||
<?= $this -> settings['ekomi_survey'];?>
|
<div class="text-center">Nasz system zweryfikuje Państwa zamówienie w ciągu kilku minut.</div>
|
||||||
|
<p></p>
|
||||||
|
<table class="table table-stripped table-bordered payment-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class="text-center" colspan="2">Informacje o płatności</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="text-bold">Zamówienie nr:</td><td><?= $this -> order['number'];?></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="text-bold">Data transakcji:</td><td><?= date( 'Y-m-d H:i', strtotime( $this -> order['date_order'] ) );?></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="text-right
|
||||||
<? endif;?>
|
<? endif;?>
|
||||||
Reference in New Issue
Block a user