Refactor payment confirmation template and fix status check

This commit is contained in:
2024-10-29 11:25:46 +01:00
parent 082feb6f2a
commit fbb0231089
25 changed files with 1595 additions and 1928 deletions

View File

@@ -1 +1 @@
YToyOntpOjA7aToxNjk0MDA3MTQxO2k6MTtzOjIwOiJwb215c2xvd2VwcmV6ZW50eS5wbCI7fQ== YToyOntpOjA7aToxNjkzOTE3NzIzO2k6MTtzOjg6Ik1hcmlhbmVrIjt9

View File

@@ -1 +1 @@
YToyOntpOjA7aToxNjc4NzMyMTQ4O2k6MTtzOjI6InBsIjt9 YToyOntpOjA7aToxNjkzOTQ2ODIzO2k6MTtzOjI6InBsIjt9

File diff suppressed because one or more lines are too long

View File

@@ -1 +1 @@
YToyOntpOjA7aToxNzI1MTk4NDExO2k6MTthOjM5OntzOjk6ImZpcm1fbmFtZSI7czoyMDoicG9teXNsb3dlcHJlemVudHkucGwiO3M6MTE6ImZpcm1fYWRyZXNzIjtzOjA6IiI7czoxNToiYWRkaXRpb25hbF9pbmZvIjtzOjI1OToiPHA+PHN0cm9uZz5NYXN6IHB5dGFuaWE/IFphZHp3b8WEIGRvIG5hcy48L3N0cm9uZz48L3A+DQoNCjxwPnRlbC4gPGEgaHJlZj0idGVsOi8vNTMwNzU1Nzc0Ij41MzAgNzU1IDc3NDwvYT48YnIgLz4NCmVtYWlsOiZuYnNwOzxhIGhyZWY9Im1haWx0bzpza2xlcEBwb215c2xvd2VwcmV6ZW50eS5wbCI+c2tsZXBAcG9teXNsb3dlcHJlemVudHkucGw8L2E+PGJyIC8+DQp1bC4gS3Jha293c2thIDE1Ni8xMDQsIDM1LTUwNiBSemVzeiZvYWN1dGU7dzwvcD4NCiI7czoxMjoiY29udGFjdF9mb3JtIjtzOjE6IjEiO3M6MTM6ImNvbnRhY3RfZW1haWwiO3M6MjY6InNrbGVwQHBvbXlzbG93ZXByZXplbnR5LnBsIjtzOjEwOiJlbWFpbF9ob3N0IjtzOjI1OiJtYWlsLnBvbXlzbG93ZXByZXplbnR5LnB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yX2lkIjtzOjEyOiJHVE0tUE03WjNMUjgiO3M6MTQ6ImluZmluaXRlc2Nyb2xsIjtzOjE6IjAiO3M6MjU6IndhcmVob3VzZV9tZXNzYWdlX3plcm9fcGwiO3M6MTY6IiFXeXN5xYJrYSBkbyAyNGgiO3M6Mjg6IndhcmVob3VzZV9tZXNzYWdlX25vbnplcm9fcGwiO3M6MTc6IiEhV3lzecWCa2EgZG8gMjRoIjt9fQ==

View File

@@ -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

Binary file not shown.

View File

@@ -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 ] ] ) )

View File

@@ -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";

View File

@@ -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);
}
}
}

View File

@@ -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;

Binary file not shown.

View File

@@ -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' ];

View File

@@ -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' ) );

View File

@@ -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 )

View File

@@ -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 )
{ {

View File

@@ -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;
} }

View File

@@ -3,7 +3,7 @@
* Medoo database framework * Medoo database framework
* http://medoo.in * http://medoo.in
* Version 0.9.7 * Version 0.9.7
* *
* Copyright 2014, Angel Lai * Copyright 2014, Angel Lai
* Released under the MIT license * Released under the MIT license
*/ */
@@ -33,7 +33,7 @@ class gdb
protected $option = array(); protected $option = array();
// Variable // Variable
protected $logs = array(); protected $logs = array();
public function __construct($options = null) public function __construct($options = null)
@@ -131,7 +131,7 @@ class gdb
} }
$this->pdo = new PDO( $this->pdo = new PDO(
$dsn, $dsn,
$this->username, $this->username,
$this->password, $this->password,
$this->option $this->option
@@ -148,14 +148,14 @@ class gdb
} }
public function query($query) public function query($query)
{ {
array_push($this->logs, $query); array_push($this->logs, $query);
return $this->pdo->query($query); return $this->pdo->query($query);
} }
public function exec($query) public function exec($query)
{ {
array_push($this->logs, $query); array_push($this->logs, $query);
return $this->pdo->exec($query); return $this->pdo->exec($query);
@@ -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)
@@ -318,11 +321,11 @@ class gdb
} }
$value = '%' . $value . '%'; $value = '%' . $value . '%';
$wheres[] = $column . ' LIKE ' . $this->fn_quote($key, $value); $wheres[] = $column . ' LIKE ' . $this->fn_quote($key, $value);
} }
} }
if (in_array($operator, array('>', '>=', '<', '<='))) if (in_array($operator, array('>', '>=', '<', '<=')))
{ {
if (is_numeric($value)) if (is_numeric($value))
@@ -835,7 +838,7 @@ class gdb
if (isset($data[0])) if (isset($data[0]))
{ {
$column = $where == null ? $join : $column; $column = $where == null ? $join : $column;
if (is_string($column) && $column != '*') if (is_string($column) && $column != '*')
{ {
return $data[ 0 ][ $column ]; return $data[ 0 ][ $column ];

View File

@@ -1,29 +1,29 @@
<?php <?php
class grid class grid
{ {
protected $table; protected $table;
protected $name; protected $name;
protected $dir; protected $dir;
public $order; public $order;
public $search; public $search;
public $filters; public $filters;
public $columns_view; public $columns_view;
public $hidden_columns; public $hidden_columns;
public $columns_edit; public $columns_edit;
public $summary; public $summary;
public $clear_cache = true; public $clear_cache = true;
public $print = false; public $print = false;
public $hide_columns = true; public $hide_columns = true;
public $show_paging = true; public $show_paging = true;
public $title = null; public $title = null;
public $src = null; public $src = null;
public $src_filtered = null; public $src_filtered = null;
public $id = 'id'; public $id = 'id';
public $columns = '*'; public $columns = '*';
public $cp = 1; public $cp = 1;
@@ -32,13 +32,13 @@ class grid
public $where = array(); public $where = array();
public $join = null; public $join = null;
public $condensed = false; public $condensed = false;
public $sql = null; public $sql = null;
public $sql_count = null; public $sql_count = null;
public $include_plugins = true; public $include_plugins = true;
public $gdb_opt = array( public $gdb_opt = array(
'database_type' => 'mysql', 'database_type' => 'mysql',
'database_name' => 'db_name', 'database_name' => 'db_name',
'server' => 'db_host', 'server' => 'db_host',
@@ -46,96 +46,97 @@ class grid
'password' => 'db_pass', 'password' => 'db_pass',
'port' => 'db_port' 'port' => 'db_port'
); );
public $empty_txt = 'Brak danych w tabeli.'; public $empty_txt = 'Brak danych w tabeli.';
public $multiselect = null; public $multiselect = null;
public $multidelete_url = null; public $multidelete_url = null;
public $buttons = null; public $buttons = null;
public $actions = array( 'delete' => false, 'delete_url' => null, 'add' => false, 'add_url' => null, 'edit' => false ); public $actions = array( 'delete' => false, 'delete_url' => null, 'add' => false, 'add_url' => null, 'edit' => false );
function __construct( $table, $name = '' ) function __construct( $table, $name = '' )
{ {
$this -> table = $table; $this -> table = $table;
$this -> name = $name; $this -> name = $name;
$this -> dir = dirname( __FILE__ ); $this -> dir = dirname( __FILE__ );
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
if ( !empty( $_SESSION[ 'g' . $g_table . 'filters' ] ) ) if ( !empty( $_SESSION[ 'g' . $g_table . 'filters' ] ) )
$this -> filters = $_SESSION[ 'g' . $g_table . 'filters' ]; $this -> filters = $_SESSION[ 'g' . $g_table . 'filters' ];
if ( !empty( $_SESSION[ 'g' . $g_table . 'limit' ] ) ) if ( !empty( $_SESSION[ 'g' . $g_table . 'limit' ] ) )
$this -> limit = $_SESSION[ 'g' . $g_table . 'limit' ]; $this -> limit = $_SESSION[ 'g' . $g_table . 'limit' ];
if ( !empty( $_SESSION[ 'g' . $g_table . 'order' ] ) ) if ( !empty( $_SESSION[ 'g' . $g_table . 'order' ] ) )
$this -> order = $_SESSION[ 'g' . $g_table . 'order' ]; $this -> order = $_SESSION[ 'g' . $g_table . 'order' ];
if ( $this -> clear_cache ) if ( $this -> clear_cache )
{ {
$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]);
}
} }
} }
} }
public function hide_column( $column, $hidden ) public function hide_column( $column, $hidden )
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$db = $this -> connectToDb(); $db = $this -> connectToDb();
$results = $db -> get( 'grid_settings', 'settings', [ 'name' => $g_table ] ); $results = $db -> get( 'grid_settings', 'settings', [ 'name' => $g_table ] );
$results = unserialize( $results ); $results = unserialize( $results );
$results['hidden_columns'][ $column ] = $hidden; $results['hidden_columns'][ $column ] = $hidden;
if ( $db -> count( 'grid_settings', [ 'name' => $g_table ] ) ) if ( $db -> count( 'grid_settings', [ 'name' => $g_table ] ) )
$db -> update( 'grid_settings', [ 'settings' => serialize( $results ) ], [ 'name' => $g_table ] ); $db -> update( 'grid_settings', [ 'settings' => serialize( $results ) ], [ 'name' => $g_table ] );
else else
$db -> insert( 'grid_settings', [ 'settings' => serialize( $results ), 'name' => $g_table ] ); $db -> insert( 'grid_settings', [ 'settings' => serialize( $results ), 'name' => $g_table ] );
} }
public function drawEdit( $id ) public function drawEdit( $id )
{ {
$values = get_object_vars( $this ); $values = get_object_vars( $this );
$view = new gridView( $this -> dir . '/templates/' ); $view = new gridView( $this -> dir . '/templates/' );
$view -> values = $values; $view -> values = $values;
$view -> element = $this -> getElement( $id ); $view -> element = $this -> getElement( $id );
return $view -> render( 'edit' ); return $view -> render( 'edit' );
} }
public function draw() public function draw()
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$db = $this -> connectToDb(); $db = $this -> connectToDb();
$results = $db -> get( 'grid_settings', 'settings', [ 'name' => $g_table ] ); $results = $db -> get( 'grid_settings', 'settings', [ 'name' => $g_table ] );
$results = unserialize( $results ); $results = unserialize( $results );
$this -> hidden_columns = $results['hidden_columns']; $this -> hidden_columns = $results['hidden_columns'];
(int)$_SESSION[ 'g' . $g_table . 'cp' ] ? $this -> cp = (int)$_SESSION[ 'g' . $g_table . 'cp' ] : $this -> cp = 1; (int)$_SESSION[ 'g' . $g_table . 'cp' ] ? $this -> cp = (int)$_SESSION[ 'g' . $g_table . 'cp' ] : $this -> cp = 1;
$_SESSION[ 'g' . $g_table ] = $this; $_SESSION[ 'g' . $g_table ] = $this;
$values = get_object_vars( $this ); $values = get_object_vars( $this );
$values['content'] = $this -> drawResults(); $values['content'] = $this -> drawResults();
$view = new gridView( $this -> dir . '/templates/' ); $view = new gridView( $this -> dir . '/templates/' );
$view -> values = $values; $view -> values = $values;
return $view -> render( 'container' ); return $view -> render( 'container' );
} }
public function connectToDb() public function connectToDb()
{ {
return new gdb( [ return new gdb( [
@@ -148,14 +149,14 @@ class grid
'charset' => 'utf8' 'charset' => 'utf8'
] ); ] );
} }
public function getCSV() public function getCSV()
{ {
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
$results = $this -> getDataSrc(); $results = $this -> getDataSrc();
else else
$results = $this -> getData( true ); $results = $this -> getData( true );
if ( is_array( $this -> columns_view ) ) foreach ( $this -> columns_view as $column ) if ( is_array( $this -> columns_view ) ) foreach ( $this -> columns_view as $column )
{ {
$array_row = array(); $array_row = array();
@@ -164,7 +165,7 @@ class grid
$headers[] = $column['name']; $headers[] = $column['name'];
} }
} }
if ( is_array( $results ) ) foreach ( $results as $row ) if ( is_array( $results ) ) foreach ( $results as $row )
{ {
$array_row = array(); $array_row = array();
@@ -208,15 +209,15 @@ class grid
} }
$array[] = $array_row; $array[] = $array_row;
} }
$now = gmdate( "D, d M Y H:i:s" ); $now = gmdate( "D, d M Y H:i:s" );
header( 'Content-Encoding: UTF-8' ); header( 'Content-Encoding: UTF-8' );
header( "Expires: Tue, 03 Jul 2001 06:00:00 GMT" ); header( "Expires: Tue, 03 Jul 2001 06:00:00 GMT" );
header( "Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate" ); header( "Cache-Control: max-age=0, no-cache, must-revalidate, proxy-revalidate" );
header( "Last-Modified: {$now} GMT" ); header( "Last-Modified: {$now} GMT" );
// force download // force download
header( "Content-Type: application/force-download" ); header( "Content-Type: application/force-download" );
header( "Content-Type: application/octet-stream" ); header( "Content-Type: application/octet-stream" );
header( "Content-Type: application/download" ); header( "Content-Type: application/download" );
@@ -233,11 +234,11 @@ class grid
fclose( $df ); fclose( $df );
return ob_get_clean(); return ob_get_clean();
} }
public function printResults() public function printResults()
{ {
$values = get_object_vars( $this ); $values = get_object_vars( $this );
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
{ {
$values['count'] = $this -> getDataCountSrc(); $values['count'] = $this -> getDataCountSrc();
@@ -247,30 +248,30 @@ class grid
$values['count'] = $this -> getDataCount(); $values['count'] = $this -> getDataCount();
$values['summary'] = $this -> getDataSummary(); $values['summary'] = $this -> getDataSummary();
} }
$this -> cp = 1; $this -> cp = 1;
$this -> limit = $values['count']; $this -> limit = $values['count'];
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
$values['results'] = $this -> getDataSrc(); $values['results'] = $this -> getDataSrc();
else else
$values['results'] = $this -> getData(); $values['results'] = $this -> getData();
$view = new gridView( $this -> dir . '/templates/' ); $view = new gridView( $this -> dir . '/templates/' );
$view -> values = $values; $view -> values = $values;
return $view -> render( 'print' ); return $view -> render( 'print' );
} }
public function get_data_count_sql() public function get_data_count_sql()
{ {
$db = $this ->connectToDb(); $db = $this ->connectToDb();
$where = $this -> getWhereCondition(); $where = $this -> getWhereCondition();
$where = $db -> where_clause( $where ); $where = $db -> where_clause( $where );
if ( strpos( $this -> sql_count, 'WHERE' ) !== false and !empty( $where ) ) if ( strpos( $this -> sql_count, 'WHERE' ) !== false and !empty( $where ) )
$where = str_replace( 'WHERE', 'AND', $where ); $where = str_replace( 'WHERE', 'AND', $where );
$this -> sql_tmp = str_replace( '[where]', $where, $this -> sql_count ); $this -> sql_tmp = str_replace( '[where]', $where, $this -> sql_count );
$query = $db -> query( $this -> sql_tmp ); $query = $db -> query( $this -> sql_tmp );
@@ -289,14 +290,14 @@ class grid
return 0; return 0;
} }
} }
public function get_data_sql( $print = false ) public function get_data_sql( $print = false )
{ {
$db = $this -> connectToDb(); $db = $this -> connectToDb();
$where = $this -> getWhereCondition(); $where = $this -> getWhereCondition();
$where = $db -> where_clause( $where ); $where = $db -> where_clause( $where );
if ( strpos( $this -> sql, 'WHERE' ) !== false and !empty( $where ) ) if ( strpos( $this -> sql, 'WHERE' ) !== false and !empty( $where ) )
$where = str_replace( 'WHERE', 'AND', $where ); $where = str_replace( 'WHERE', 'AND', $where );
@@ -304,10 +305,10 @@ class grid
$this -> sql_tmp = $this -> sql . ' LIMIT ' . $this -> limit . ' OFFSET ' . ( $this -> cp - 1 ) * $this -> limit; $this -> sql_tmp = $this -> sql . ' LIMIT ' . $this -> limit . ' OFFSET ' . ( $this -> cp - 1 ) * $this -> limit;
else else
$this -> sql_tmp = $this -> sql; $this -> sql_tmp = $this -> sql;
$this -> sql_tmp = str_replace( '[where]', $where, $this -> sql_tmp ); $this -> sql_tmp = str_replace( '[where]', $where, $this -> sql_tmp );
$this -> sql_tmp = str_replace( '[order_p1]', $this -> order['column'], $this -> sql_tmp ); $this -> sql_tmp = str_replace( '[order_p1]', $this -> order['column'], $this -> sql_tmp );
$this -> sql_tmp = str_replace( '[order_p2]', $this -> order['type'], $this -> sql_tmp ); $this -> sql_tmp = str_replace( '[order_p2]', $this -> order['type'], $this -> sql_tmp );
$query = $db -> query( $this -> sql_tmp ); $query = $db -> query( $this -> sql_tmp );
if ( $query ) if ( $query )
{ {
@@ -324,11 +325,11 @@ class grid
return null; return null;
} }
} }
public function drawResults() public function drawResults()
{ {
$values = get_object_vars( $this ); $values = get_object_vars( $this );
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
$values['count'] = $this -> getDataCountSrc(); $values['count'] = $this -> getDataCountSrc();
else if ( isset( $this -> sql ) and isset( $this -> sql_count ) ) else if ( isset( $this -> sql ) and isset( $this -> sql_count ) )
@@ -338,51 +339,51 @@ class grid
$values['count'] = $this -> getDataCount(); $values['count'] = $this -> getDataCount();
$values['summary'] = $this -> getDataSummary(); $values['summary'] = $this -> getDataSummary();
} }
$ls = ceil( $values['count'] / $this -> limit ); $ls = ceil( $values['count'] / $this -> limit );
if ( !(int)$ls ) if ( !(int)$ls )
$ls = 1; $ls = 1;
if ( $this -> cp > $ls ) if ( $this -> cp > $ls )
{ {
$this -> cp = $ls; $this -> cp = $ls;
$values['cp'] = $ls; $values['cp'] = $ls;
} }
if ( is_array( $this -> src ) ) if ( is_array( $this -> src ) )
$values['results'] = $this -> getDataSrc(); $values['results'] = $this -> getDataSrc();
else if ( isset( $this -> sql ) and isset( $this -> sql_count ) ) else if ( isset( $this -> sql ) and isset( $this -> sql_count ) )
$values['results'] = $this -> get_data_sql(); $values['results'] = $this -> get_data_sql();
else else
$values['results'] = $this -> getData(); $values['results'] = $this -> getData();
$view = new gridView( $this -> dir . '/templates/' ); $view = new gridView( $this -> dir . '/templates/' );
$view -> values = $values; $view -> values = $values;
return $view -> render( 'results' ); return $view -> render( 'results' );
} }
public function delete( $id ) public function delete( $id )
{ {
return $this -> connectToDb() -> delete( $this -> table, [ $this -> id => $id ] ); return $this -> connectToDb() -> delete( $this -> table, [ $this -> id => $id ] );
} }
public function getWhereCondition() public function getWhereCondition()
{ {
$where = array(); $where = array();
$where['AND'] = $this -> where; $where['AND'] = $this -> where;
if ( $this -> filters ) if ( $this -> filters )
{ {
foreach ( $this -> filters as $key => $val ) foreach ( $this -> filters as $key => $val )
{ {
if ( $val['type'] == 'like' ) if ( $val['type'] == 'like' )
$where['AND'] = array_merge( $where['AND'], [ $key . '[~]' => $val['value'] ] ); $where['AND'] = array_merge( $where['AND'], [ $key . '[~]' => $val['value'] ] );
if ( $val['type'] == 'equal' ) if ( $val['type'] == 'equal' )
$where['AND'] = array_merge( $where['AND'], [ $key => $val['value'] ] ); $where['AND'] = array_merge( $where['AND'], [ $key => $val['value'] ] );
if ( $val['type'] == 'date_range' ) if ( $val['type'] == 'date_range' )
{ {
$dates = explode( ' - ', $val['value'] ); $dates = explode( ' - ', $val['value'] );
@@ -391,13 +392,13 @@ class grid
} }
} }
} }
if ( count( $where['AND'] ) ) if ( count( $where['AND'] ) )
return $where; return $where;
else else
return array(); return array();
} }
public static function searchSrc( $array, $column, $value, $type = 'equal' ) public static function searchSrc( $array, $column, $value, $type = 'equal' )
{ {
if ( is_array( $array ) ) foreach ( $array as $key => $val ) if ( is_array( $array ) ) foreach ( $array as $key => $val )
@@ -407,7 +408,7 @@ class grid
if ( $val[ $column ] == $value ) if ( $val[ $column ] == $value )
$array_tmp[] = $val; $array_tmp[] = $val;
} }
if ( $type == 'like' ) if ( $type == 'like' )
{ {
if ( strpos( mb_strtolower( $val[ $column ], 'UTF-8' ), mb_strtolower( $value, 'UTF-8' ) ) !== false ) if ( strpos( mb_strtolower( $val[ $column ], 'UTF-8' ), mb_strtolower( $value, 'UTF-8' ) ) !== false )
@@ -416,28 +417,28 @@ class grid
} }
return $array_tmp; return $array_tmp;
} }
public function filtrDataSrc() public function filtrDataSrc()
{ {
$this -> src_filtered = $this -> src; $this -> src_filtered = $this -> src;
if ( $this -> filters ) if ( $this -> filters )
{ {
foreach ( $this -> filters as $key => $val ) foreach ( $this -> filters as $key => $val )
{ {
if ( $val['type'] == 'like' ) if ( $val['type'] == 'like' )
$this -> src_filtered = $this -> searchSrc( $this -> src_filtered, $key, $val['value'], 'like' ); $this -> src_filtered = $this -> searchSrc( $this -> src_filtered, $key, $val['value'], 'like' );
if ( $val['type'] == 'equal' ) if ( $val['type'] == 'equal' )
$this -> src_filtered = $this -> searchSrc( $this -> src_filtered, $key, $val['value'], 'equal' ); $this -> src_filtered = $this -> searchSrc( $this -> src_filtered, $key, $val['value'], 'equal' );
} }
} }
} }
public function getDataSummary() public function getDataSummary()
{ {
$where = self::getWhereCondition(); $where = self::getWhereCondition();
if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key ) if ( is_array( $this -> summary ) ) foreach ( $this -> summary as $key )
{ {
if ( $this -> join ) if ( $this -> join )
@@ -447,48 +448,48 @@ class grid
} }
return $summary; return $summary;
} }
public function getDataCountSrc() public function getDataCountSrc()
{ {
$this -> filtrDataSrc(); $this -> filtrDataSrc();
return count( $this -> src_filtered ); return count( $this -> src_filtered );
} }
public function getDataCount() public function getDataCount()
{ {
$where = self::getWhereCondition(); $where = self::getWhereCondition();
if ( $this -> join ) if ( $this -> join )
$results = $this -> connectToDb() -> count( $this -> table, $this -> join, '*', $where ); $results = $this -> connectToDb() -> count( $this -> table, $this -> join, '*', $where );
else else
$results = $this -> connectToDb() -> count( $this -> table, $where ); $results = $this -> connectToDb() -> count( $this -> table, $where );
if ( $results ) if ( $results )
return $results; return $results;
else else
return false; return false;
} }
public function getDataSrc() public function getDataSrc()
{ {
if ( $this -> order ) if ( $this -> order )
$this -> src_filtered = $this -> sortByColumn( $this -> src_filtered, $this -> order['column'], $this -> order['type'] ); $this -> src_filtered = $this -> sortByColumn( $this -> src_filtered, $this -> order['column'], $this -> order['type'] );
$array_tmp = $this -> src_filtered; $array_tmp = $this -> src_filtered;
if ( is_array( $array_tmp ) ) if ( is_array( $array_tmp ) )
return array_splice( $array_tmp, ( $this -> cp - 1 ) * $this -> limit, $this -> limit ); return array_splice( $array_tmp, ( $this -> cp - 1 ) * $this -> limit, $this -> limit );
else else
return false; return false;
} }
public function getData( $csv = false ) public function getData( $csv = false )
{ {
$where = self::getWhereCondition(); $where = self::getWhereCondition();
if ( $this -> order ) if ( $this -> order )
$where = array_merge( $where, [ 'ORDER' => $this -> order['column'] . ' ' . $this -> order['type'] ] ); $where = array_merge( $where, [ 'ORDER' => $this -> order['column'] . ' ' . $this -> order['type'] ] );
if ( $this -> limit and $this -> show_paging === true and !$csv ) if ( $this -> limit and $this -> show_paging === true and !$csv )
$where = array_merge( $where, [ 'LIMIT' => [ ( $this -> cp - 1 ) * $this -> limit, $this -> limit ] ] ); $where = array_merge( $where, [ 'LIMIT' => [ ( $this -> cp - 1 ) * $this -> limit, $this -> limit ] ] );
@@ -496,18 +497,18 @@ class grid
$results = $this -> connectToDb() -> select( $this -> table, $this -> join, $this -> columns, $where ); $results = $this -> connectToDb() -> select( $this -> table, $this -> join, $this -> columns, $where );
else else
$results = $this -> connectToDb() -> select( $this -> table, $this -> columns, $where ); $results = $this -> connectToDb() -> select( $this -> table, $this -> columns, $where );
if ( $results ) if ( $results )
return $results; return $results;
else else
return false; return false;
} }
public function getElement( $id ) public function getElement( $id )
{ {
return $this -> connectToDb() -> get( $this -> table, '*', [ $this -> id => $id ] ); return $this -> connectToDb() -> get( $this -> table, '*', [ $this -> id => $id ] );
} }
public function saveElement( $values ) public function saveElement( $values )
{ {
if ( !$values[ $this -> id ] ) if ( !$values[ $this -> id ] )
@@ -518,12 +519,12 @@ class grid
else else
return $this -> connectToDb() -> update( $this -> table, $values, [ $this -> id => $values[ $this -> id ] ] ); return $this -> connectToDb() -> update( $this -> table, $values, [ $this -> id => $values[ $this -> id ] ] );
} }
public static function sortByColumn( &$arr, $col, $sort ) public static function sortByColumn( &$arr, $col, $sort )
{ {
setlocale( LC_COLLATE, 'pl_PL.utf-8' ); setlocale( LC_COLLATE, 'pl_PL.utf-8' );
$sort == 'ASC' ? $dir = SORT_ASC : $dir = SORT_DESC; $sort == 'ASC' ? $dir = SORT_ASC : $dir = SORT_DESC;
$sort_col = array(); $sort_col = array();
if ( is_array( $arr ) ) if ( is_array( $arr ) )
{ {
@@ -534,46 +535,46 @@ class grid
} }
return $arr; return $arr;
} }
public static function validateDate( $date ) public static function validateDate( $date )
{ {
if ( date( 'Y-m-d', strtotime( $date ) ) != '1970-01-01' ) if ( date( 'Y-m-d', strtotime( $date ) ) != '1970-01-01' )
return true; return true;
} }
public function save_limit( $limit ) public function save_limit( $limit )
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$_SESSION[ 'g' . $g_table . 'limit' ] = $limit; $_SESSION[ 'g' . $g_table . 'limit' ] = $limit;
} }
public function save_order() public function save_order()
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$_SESSION[ 'g' . $g_table . 'order' ] = $this -> order; $_SESSION[ 'g' . $g_table . 'order' ] = $this -> order;
} }
public function save_filters() public function save_filters()
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$_SESSION[ 'g' . $g_table . 'filters' ] = $this -> filters; $_SESSION[ 'g' . $g_table . 'filters' ] = $this -> filters;
} }
public function set_cp( $cp ) public function set_cp( $cp )
{ {
$this -> name ? $g_table = $this -> name : $g_table = $this -> table; $this -> name ? $g_table = $this -> name : $g_table = $this -> table;
$_SESSION[ 'g' . $g_table . 'cp'] = $cp; $_SESSION[ 'g' . $g_table . 'cp'] = $cp;
$this -> cp = $cp; $this -> cp = $cp;
} }
public function getParams( $string ) public function getParams( $string )
{ {
$params = array(); $params = array();
preg_match_all( '/\[[a-zA-Z0-9_]*\]/', $string, $results_tmp1 ); preg_match_all( '/\[[a-zA-Z0-9_]*\]/', $string, $results_tmp1 );
if ( is_array( $results_tmp1[0] ) ) foreach ( $results_tmp1[0] as $row_tmp1 ) if ( is_array( $results_tmp1[0] ) ) foreach ( $results_tmp1[0] as $row_tmp1 )
{ {
@@ -584,7 +585,7 @@ class grid
} }
return $params; return $params;
} }
public function convertString( $string, $row ) public function convertString( $string, $row )
{ {
$out = $string; $out = $string;
@@ -599,11 +600,11 @@ class grid
} }
return $out; return $out;
} }
public function convertStringJS( $string ) public function convertStringJS( $string )
{ {
$out = 'var out = "' . addslashes( $string ) . '";' . chr( 13 ); $out = 'var out = "' . addslashes( $string ) . '";' . chr( 13 );
preg_match_all( '/\[[a-zA-Z0-9_]*\]/', $string, $results_tmp1 ); preg_match_all( '/\[[a-zA-Z0-9_]*\]/', $string, $results_tmp1 );
if ( is_array( $results_tmp1[0] ) ) foreach ( $results_tmp1[0] as $row_tmp1 ) if ( is_array( $results_tmp1[0] ) ) foreach ( $results_tmp1[0] as $row_tmp1 )
{ {

View File

@@ -1,7 +1,7 @@
function g_validate_form( id ) function g_validate_form( id )
{ {
var submit = true; var submit = true;
jQuery( '#fg-' + id ).find( "input[type=text], input[type=password], select, textarea" ).each( function() jQuery( '#fg-' + id ).find( "input[type=text], input[type=password], select, textarea" ).each( function()
{ {
var min = parseInt( jQuery( this ).attr( 'min' ) ); var min = parseInt( jQuery( this ).attr( 'min' ) );
var equal = jQuery( this ).attr( 'equal' ); var equal = jQuery( this ).attr( 'equal' );
@@ -34,7 +34,7 @@ function g_validate_form( id )
else if ( fun !== undefined ) else if ( fun !== undefined )
{ {
var response = window[fun](); var response = window[fun]();
if ( response['status'] === 'error' ) if ( response['status'] === 'error' )
{ {
submit = false; submit = false;
@@ -56,7 +56,7 @@ function g_validate_form( id )
return submit; return submit;
} }
function number_format( number, decimals, dec_point, thousands_sep ) function number_format( number, decimals, dec_point, thousands_sep )
{ {
number = ( number + '' ).replace( /[^0-9+\-Ee.]/g, '' ); number = ( number + '' ).replace( /[^0-9+\-Ee.]/g, '' );
var n = !isFinite(+number) ? 0 : +number, var n = !isFinite(+number) ? 0 : +number,
@@ -102,7 +102,7 @@ function hide_error() {
}, 3000 ); }, 3000 );
} }
function create_message( text ) function create_message( text )
{ {
hide_message(); hide_message();
jQuery( '#content' ).prepend( '<div class="row">' + jQuery( '#content' ).prepend( '<div class="row">' +
@@ -134,15 +134,15 @@ jQuery( 'body' ).on( 'click', '#g-message, #g-alert', function() {
jQuery( 'body' ).on( 'change', '.g-double', function() { jQuery( 'body' ).on( 'change', '.g-double', function() {
var value = jQuery( this ).val(); var value = jQuery( this ).val();
value = parseFloat( value.replace( ',', '.' ) * 1 ); value = parseFloat( value.replace( ',', '.' ) * 1 );
if ( isNaN( value ) ) if ( isNaN( value ) )
value = 0; value = 0;
if ( jQuery( this ).hasClass( 'g-plus' ) ) if ( jQuery( this ).hasClass( 'g-plus' ) )
value = Math.abs( value ); value = Math.abs( value );
value = number_format( value , 2 , '.' , '' ); value = number_format( value , 2 , '.' , '' );
jQuery( this ).val( value ); jQuery( this ).val( value );
}); });
@@ -176,13 +176,13 @@ jQuery.datepicker.regional['pl'] = {
jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ 'pl' ] ); jQuery.datepicker.setDefaults( jQuery.datepicker.regional[ 'pl' ] );
jQuery( 'body' ).on( 'focus', '.g-date', function() { jQuery( 'body' ).on( 'focus', '.g-date', function() {
jQuery( this ).datepicker( { jQuery( this ).datepicker( {
dateFormat: 'yy-mm-dd', dateFormat: 'yy-mm-dd',
changeMonth: true, changeMonth: true,
changeYear: true changeYear: true
} ); } );
}); });
jQuery( 'body' ).on( 'click', 'a.g-expand', function() { jQuery( 'body' ).on( 'click', 'a.g-expand', function() {
jQuery( this ).parents( '.g-form-edit' ).children( '.g-content' ).slideDown( 'fast' ); jQuery( this ).parents( '.g-form-edit' ).children( '.g-content' ).slideDown( 'fast' );
jQuery( this ).children( 'i' ).removeClass( 'fa-chevron-down' ).addClass( 'fa-chevron-up' ); jQuery( this ).children( 'i' ).removeClass( 'fa-chevron-down' ).addClass( 'fa-chevron-up' );
@@ -195,34 +195,34 @@ jQuery( 'body' ).on( 'click', '.g-collapse', function() {
jQuery( this ).removeClass( 'g-collapse' ).addClass( 'g-expand' ); jQuery( this ).removeClass( 'g-collapse' ).addClass( 'g-expand' );
}); });
jQuery( 'body' ).on( 'click', '#g-columns-list-close', function() jQuery( 'body' ).on( 'click', '#g-columns-list-close', function()
{ {
jQuery( '#g-select-columns' ).show(); jQuery( '#g-select-columns' ).show();
jQuery( "#g-columns-list-close" ).hide(); jQuery( "#g-columns-list-close" ).hide();
return false; return false;
}); });
jQuery( 'body' ).on( 'click', '#g-select-columns', function() jQuery( 'body' ).on( 'click', '#g-select-columns', function()
{ {
jQuery( '#g-select-columns' ).hide(); jQuery( '#g-select-columns' ).hide();
jQuery( "#g-columns-list-close" ).show(); jQuery( "#g-columns-list-close" ).show();
jQuery( '#g-columns-list' ).show(); jQuery( '#g-columns-list' ).show();
return false; return false;
}); });
jQuery( '.g-column-toggle' ).on( 'ifToggled', function() jQuery( '.g-column-toggle' ).on( 'ifToggled', function()
{ {
var data = jQuery( this ).parents( '#g-columns-list' ).attr( 'data' ); var data = jQuery( this ).parents( '#g-columns-list' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
for ( index = 0; index < data.length; ++index ) for ( index = 0; index < data.length; ++index )
{ {
var vars = data[ index ].split( ':') ; var vars = data[ index ].split( ':') ;
if ( vars[0] === 'table' ) if ( vars[0] === 'table' )
var gtable = vars[1]; var gtable = vars[1];
} }
var i = jQuery( this ).parents( 'li' ).attr( 'i' ); var i = jQuery( this ).parents( 'li' ).attr( 'i' );
jQuery.ajax( jQuery.ajax(
@@ -236,27 +236,27 @@ jQuery( '.g-column-toggle' ).on( 'ifToggled', function()
hidden: !jQuery( this ).prop( 'checked' ), hidden: !jQuery( this ).prop( 'checked' ),
a: 'gdraw' a: 'gdraw'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); response = jQuery.parseJSON( data );
jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( response.msg !== null ) if ( response.msg !== null )
create_message( response.msg ); create_message( response.msg );
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -264,7 +264,7 @@ jQuery( '.g-column-toggle' ).on( 'ifToggled', function()
}); });
}); });
jQuery( 'body' ).on( 'click', '#g-columns-list span', function() { jQuery( 'body' ).on( 'click', '#g-columns-list span', function() {
var input = jQuery( this ).attr( 'input' ); var input = jQuery( this ).attr( 'input' );
jQuery( '#' + input ).iCheck( 'toggle' ); jQuery( '#' + input ).iCheck( 'toggle' );
}); });
@@ -295,33 +295,33 @@ jQuery( 'body' ).on( 'click', '.g-print', function() {
window.open( dir + '/print.php?gtable=' + gtable, 'Drukowanie', "height=400,width=600" ); window.open( dir + '/print.php?gtable=' + gtable, 'Drukowanie', "height=400,width=600" );
}); });
jQuery( 'body' ).on( 'click', '#g-multidelete', function() jQuery( 'body' ).on( 'click', '#g-multidelete', function()
{ {
var url = jQuery( this ).attr( 'url' ); var url = jQuery( this ).attr( 'url' );
if ( typeof url === 'undefined' ) if ( typeof url === 'undefined' )
url = ''; url = '';
var data = jQuery( this ).parents( '.g-container' ).attr( 'data' ); var data = jQuery( this ).parents( '.g-container' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
for ( index = 0; index < data.length; ++index ) for ( index = 0; index < data.length; ++index )
{ {
var vars = data[ index ].split( ':') ; var vars = data[ index ].split( ':') ;
if ( vars[0] === 'table' ) if ( vars[0] === 'table' )
var gtable = vars[1]; var gtable = vars[1];
} }
jQuery.prompt( 'Na pewno chcesz usunąć wybrane elementy?', jQuery.prompt( 'Na pewno chcesz usunąć wybrane elementy?',
{ {
title: 'Potwierdź?', title: 'Potwierdź?',
submit: function(e,v,m,f) submit: function(e,v,m,f)
{ {
if ( v === true ) if ( v === true )
{ {
var checkedVals = getCheckedIds( gtable ); var checkedVals = getCheckedIds( gtable );
if ( url !== '' ) if ( url !== '' )
{ {
jQuery.ajax( jQuery.ajax(
@@ -329,62 +329,62 @@ jQuery( 'body' ).on( 'click', '#g-multidelete', function()
type: 'POST', type: 'POST',
cache: false, cache: false,
url: url, url: url,
data: data:
{ {
gdelete_multi: checkedVals gdelete_multi: checkedVals
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); response = jQuery.parseJSON( data );
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( response.msg !== null ) if ( response.msg !== null )
create_message( response.msg ); create_message( response.msg );
jQuery.ajax( jQuery.ajax(
{ {
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
a: 'gdraw' a: 'gdraw'
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); response = jQuery.parseJSON( data );
jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( response.msg !== null ) if ( response.msg !== null )
create_message( response.msg ); create_message( response.msg );
jQuery( '#g-multidelete' ).hide(); jQuery( '#g-multidelete' ).hide();
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
} }
}); });
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -398,19 +398,19 @@ jQuery( 'body' ).on( 'click', '#g-multidelete', function()
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
gdelete_multi: checkedVals, gdelete_multi: checkedVals,
a: 'gdraw' a: 'gdraw'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); response = jQuery.parseJSON( data );
jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
@@ -419,12 +419,12 @@ jQuery( 'body' ).on( 'click', '#g-multidelete', function()
create_message( response.msg ); create_message( response.msg );
jQuery( '#g-multidelete' ).hide(); jQuery( '#g-multidelete' ).hide();
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -432,18 +432,18 @@ jQuery( 'body' ).on( 'click', '#g-multidelete', function()
}); });
} }
} }
}, },
buttons: { buttons: {
'tak': true, 'tak': true,
'nie': false 'nie': false
}, },
focus: 1 focus: 1
}); });
return false; return false;
}); });
jQuery( 'body' ).on( 'click', '#g-cancel', function() { jQuery( 'body' ).on( 'click', '#g-cancel', function() {
var data = jQuery( this ).parents( '.g-container' ).attr( 'data' ); var data = jQuery( this ).parents( '.g-container' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
@@ -467,17 +467,17 @@ jQuery( 'body' ).on( 'click', '#g-cancel', function() {
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-add, #g-search, .g-button, #g-select-columns' ).show(); jQuery( '#g-add, #g-search, .g-button, #g-select-columns' ).show();
jQuery( '#g-cancel, #g-save' ).hide(); jQuery( '#g-cancel, #g-save' ).hide();
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -485,46 +485,46 @@ jQuery( 'body' ).on( 'click', '#g-cancel', function() {
}); });
}); });
jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function() jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
{ {
var back_url = jQuery( this ).attr( 'back_url' ); var back_url = jQuery( this ).attr( 'back_url' );
var persist_edit = jQuery( this ).attr( 'persist_edit' ); var persist_edit = jQuery( this ).attr( 'persist_edit' );
var id_param = jQuery( this ).attr( 'id_param' ); var id_param = jQuery( this ).attr( 'id_param' );
if ( typeof back_url === 'undefined' ) if ( typeof back_url === 'undefined' )
back_url = ''; back_url = '';
var data = jQuery( this ).parents( '.g-container' ).attr( 'data' ); var data = jQuery( this ).parents( '.g-container' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
for ( index = 0; index < data.length; ++index ) for ( index = 0; index < data.length; ++index )
{ {
var vars = data[ index ].split( ':') ; var vars = data[ index ].split( ':') ;
if ( vars[0] === 'table' ) if ( vars[0] === 'table' )
var gtable = vars[1]; var gtable = vars[1];
} }
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' );
if ( url !== '' ) if ( url !== '' )
{ {
jQuery.ajax( jQuery.ajax(
{ {
type: 'POST', type: 'POST',
cache: false, cache: false,
url: url, url: url,
data: data:
{ {
gtable: gtable, gtable: gtable,
values: JSON.stringify( values ), values: JSON.stringify( values ),
a: 'gsave' a: 'gsave'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
jQuery( '#overlay' ).show(); jQuery( '#overlay' ).show();
@@ -533,7 +533,7 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
{ {
jQuery( '#overlay' ).hide(); jQuery( '#overlay' ).hide();
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( back_url !== '' && persist_edit == 0 ) if ( back_url !== '' && persist_edit == 0 )
document.location.href = back_url; document.location.href = back_url;
@@ -547,16 +547,16 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
a: 'gdraw' a: 'gdraw'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
@@ -564,12 +564,12 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
jQuery( '#g-add, #g-search, .g-button' ).show(); jQuery( '#g-add, #g-search, .g-button' ).show();
jQuery( '#g-cancel, #g-save' ).hide(); jQuery( '#g-cancel, #g-save' ).hide();
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -580,49 +580,49 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
{ {
if ( response.msg !== null ) if ( response.msg !== null )
create_message( response.msg ); create_message( response.msg );
if ( id_param != '' ) if ( id_param != '' )
jQuery( '#' + id_param ).val( response.id ); jQuery( '#' + id_param ).val( response.id );
} }
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
} }
}); });
} }
else else
{ {
jQuery.ajax( jQuery.ajax(
{ {
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
values: JSON.stringify( values ), values: JSON.stringify( values ),
a: 'gsave' a: 'gsave'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( back_url !== '' ) if ( back_url !== '' )
{ {
document.location.href=back_url; document.location.href=back_url;
} }
else else
{ {
if ( response.msg !== null ) if ( response.msg !== null )
@@ -632,12 +632,12 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
jQuery( '#g-cancel, #g-save' ).hide(); jQuery( '#g-cancel, #g-save' ).hide();
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -646,9 +646,9 @@ jQuery( 'body' ).on( 'click', '#g-save, #g-edit-save', function()
} }
}; };
}); });
jQuery( 'body' ).on( 'click', '#g-add, .g-edit', function() { jQuery( 'body' ).on( 'click', '#g-add, .g-edit', function() {
var data = jQuery( this ).parents( '.g-container' ).attr( 'data' ); var data = jQuery( this ).parents( '.g-container' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
@@ -658,9 +658,9 @@ jQuery( 'body' ).on( 'click', '#g-add, .g-edit', function() {
if ( vars[0] === 'table' ) if ( vars[0] === 'table' )
var gtable = vars[1]; var gtable = vars[1];
} }
var gedit = jQuery( this ).attr( 'element-id' ); var gedit = jQuery( this ).attr( 'element-id' );
jQuery.ajax({ jQuery.ajax({
type: 'POST', type: 'POST',
cache: false, cache: false,
@@ -675,17 +675,17 @@ jQuery( 'body' ).on( 'click', '#g-add, .g-edit', function() {
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-add, #g-search, .g-button, #g-select-columns' ).hide(); jQuery( '#g-add, #g-search, .g-button, #g-select-columns' ).hide();
jQuery( '#g-cancel, #g-save' ).css( 'display', 'inline-block' ); jQuery( '#g-cancel, #g-save' ).css( 'display', 'inline-block' );
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -693,7 +693,7 @@ jQuery( 'body' ).on( 'click', '#g-add, .g-edit', function() {
}); });
}); });
jQuery( 'body' ).on( 'click', '.g-delete', function() jQuery( 'body' ).on( 'click', '.g-delete', function()
{ {
jQuery( this ).blur(); jQuery( this ).blur();
@@ -711,35 +711,35 @@ jQuery( 'body' ).on( 'click', '.g-delete', function()
var back_url = jQuery( this ).attr( 'back-url' ); var back_url = jQuery( this ).attr( 'back-url' );
var url = jQuery( this ).attr( 'url' ).replace( '[ID]', gdelete ); var url = jQuery( this ).attr( 'url' ).replace( '[ID]', gdelete );
jQuery.prompt( 'Na pewno chcesz usunąć wybrany element?', jQuery.prompt( 'Na pewno chcesz usunąć wybrany element?',
{ {
title: 'Potwierdź?', title: 'Potwierdź?',
submit: function(e,v,m,f) submit: function(e,v,m,f)
{ {
if ( v === true ) if ( v === true )
{ {
if ( url !== '' ) if ( url !== '' )
{ {
jQuery.ajax( jQuery.ajax(
{ {
type: 'POST', type: 'POST',
cache: false, cache: false,
url: url, url: url,
data: data:
{ {
gdelete: gdelete, gdelete: gdelete,
a: 'gdelete' a: 'gdelete'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( back_url !== '' ) if ( back_url !== '' )
{ {
document.location.href=back_url; document.location.href=back_url;
} }
@@ -762,71 +762,71 @@ jQuery( 'body' ).on( 'click', '.g-delete', function()
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
} }
}); });
} }
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
} }
}); });
} }
else else
{ {
jQuery.ajax( jQuery.ajax(
{ {
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
gdelete: gdelete, gdelete: gdelete,
a: 'gdraw' a: 'gdraw'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) success: function( data )
{ {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
if ( back_url !== '' ) if ( back_url !== '' )
{ {
document.location.href=back_url; document.location.href=back_url;
} }
else else
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
if ( response.msg !== null ) if ( response.msg !== null )
create_message( response.msg ); create_message( response.msg );
} }
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -834,22 +834,22 @@ jQuery( 'body' ).on( 'click', '.g-delete', function()
}); });
} }
} }
}, },
buttons: buttons:
{ {
'tak': true, 'tak': true,
'nie': false 'nie': false
} }
}); });
return false; return false;
}); });
jQuery( 'body' ).on( 'change', '.g-search-input, .g-search-select', function() jQuery( 'body' ).on( 'change', '.g-search-input, .g-search-select', function()
{ {
var data = jQuery( this ).attr( 'data' ); var data = jQuery( this ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
for ( index = 0; index < data.length; ++index ) for ( index = 0; index < data.length; ++index )
{ {
var vars = data[ index ].split( ':') ; var vars = data[ index ].split( ':') ;
@@ -863,7 +863,7 @@ jQuery( 'body' ).on( 'change', '.g-search-input, .g-search-select', function()
var data = jQuery( this ).parents( '.g-container' ).attr( 'data' ); var data = jQuery( this ).parents( '.g-container' ).attr( 'data' );
data = data.split( ";" ); data = data.split( ";" );
for ( index = 0; index < data.length; ++index ) for ( index = 0; index < data.length; ++index )
{ {
var vars = data[ index ].split( ':') ; var vars = data[ index ].split( ':') ;
@@ -877,7 +877,7 @@ jQuery( 'body' ).on( 'change', '.g-search-input, .g-search-select', function()
type: 'POST', type: 'POST',
cache: false, cache: false,
url: dir + '/ajax.php', url: dir + '/ajax.php',
data: data:
{ {
gtable: gtable, gtable: gtable,
gsearch_column: gsearch_column, gsearch_column: gsearch_column,
@@ -885,22 +885,22 @@ jQuery( 'body' ).on( 'change', '.g-search-input, .g-search-select', function()
gsearch_type: gsearch_type, gsearch_type: gsearch_type,
a: 'gdraw' a: 'gdraw'
}, },
beforeSend: function() beforeSend: function()
{ {
jQuery( '#g-' + gtable ).find( '#g-loader' ).show(); jQuery( '#g-' + gtable ).find( '#g-loader' ).show();
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
jQuery( 'input[name="' + gsearch_column + '"]' ).focus().val( jQuery( 'input[name="' + gsearch_column + '"]' ).val() ); jQuery( 'input[name="' + gsearch_column + '"]' ).focus().val( jQuery( 'input[name="' + gsearch_column + '"]' ).val() );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -948,15 +948,15 @@ jQuery( 'body' ).on( 'click', '.g-sort', function() {
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -991,15 +991,15 @@ jQuery( 'body' ).on( 'change', '#g-row-limit', function() {
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }
@@ -1012,7 +1012,7 @@ jQuery( 'body' ).on( 'click', '.date-range-icon', function()
$( this ).parents( '.input-group' ).children( 'input' ).trigger( 'click' ); $( this ).parents( '.input-group' ).children( 'input' ).trigger( 'click' );
}); });
jQuery( 'body' ).on( 'click', '.g-next, .g-last, .g-first, .g-previous, .g-page', function(e) jQuery( 'body' ).on( 'click', '.g-next, .g-last, .g-first, .g-previous, .g-page', function(e)
{ {
e.preventDefault(); e.preventDefault();
@@ -1042,15 +1042,15 @@ jQuery( 'body' ).on( 'click', '.g-next, .g-last, .g-first, .g-previous, .g-page'
}, },
success: function( data ) { success: function( data ) {
response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide(); response = jQuery.parseJSON( data ); jQuery( '#g-' + gtable ).find( '#g-loader' ).hide();
if ( response.status === 'ok' ) if ( response.status === 'ok' )
{ {
jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output ); jQuery( '#g-' + gtable ).find( '#g-results' ).empty().html( response.output );
} }
else else
{ {
if ( response.msg ) if ( response.msg )
var msg = response.msg; var msg = response.msg;
else else
var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie."; var msg = "Przepraszamy. Podczas wczytywania danych wystąpił błąd. Prosimy spróbować ponownie.";
create_error( msg ); create_error( msg );
} }

View File

@@ -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>';

File diff suppressed because it is too large Load Diff

View File

@@ -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">

View 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>

View File

@@ -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;?>

8
tpay.txt Normal file
View File

@@ -0,0 +1,8 @@
Array
(
)
Array
(
[module] => shop_order
[action] => payment_status_tpay
)