Files
2025-06-24 14:14:35 +02:00

122 lines
3.9 KiB
PHP

<?php
/**
* NOTICE OF LICENSE
*
* This file is licenced under the Software License Agreement.
* With the purchase or the installation of the software in your application
* you accept the licence agreement.
*
* You must not modify, adapt or create derivative works of this source code
*
* @author PrestaHelp.com
* @copyright 2019 PrestaHelp
* @license LICENSE.txt
*/
class InpostPoint
{
/**
* Pobranie liczby punktów w bazie
* @return int count of point list
*/
public static function getCountBasePoints()
{
return count(Db::getInstance()->executeS('SELECT * FROM `'._DB_PREFIX_.'inpostship_points` ORDER BY `id_point` ASC'));
}
/**
* Pobieranie listy punktów paczkomatowych
* @param null - string $search
* @return array of points list
*/
public static function getAllPoints($search = null, $cod = 1)
{
if ($search) {
if ($cod == 0) {
return Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'inpostship_points`
WHERE (`point_code` LIKE "%'.$search.'%" OR `point_address1` LIKE "%'.$search.'%"
OR `point_address2` LIKE "%'.$search.'%") ORDER BY `point_code` ASC');
} else {
return Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'inpostship_points`
WHERE (`point_code` LIKE "%'.$search.'%" OR `point_address1` LIKE "%'.$search.'%"
OR `point_address2` LIKE "%'.$search.'%") AND `point_cod` = 1 ORDER BY `point_code` ASC');
}
} else {
if ($cod == 0) {
return Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'inpostship_points`
ORDER BY `point_code` ASC');
} else {
return Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'inpostship_points`
WHERE `point_cod` = 1 ORDER BY `point_code` ASC');
}
}
}
/**
* Pobieranie listy punktów paczkomatowych wg. typu
* @param $type - string of type
* @return array of points list
*/
public static function getPointOfType($type)
{
return Db::getInstance()->executeS('SELECT * FROM ' . _DB_PREFIX_ . 'inpostship_points '.
'WHERE point_type LIKE "%'.$type.'%" ORDER BY point_code ASC');
}
/**
* Pobieranie informacji o danym paczkomacie
* @param $point - string of point code
* @return array of point info
*/
public static function getPointInfo($point)
{
return Db::getInstance()->getRow('SELECT * FROM ' . _DB_PREFIX_ . 'inpostship_points '.
'WHERE `point_code` = "'.$point.'"');
}
/**
* Sprawdzanie czy dany punkt paczkomatowy istnieje w bazie
* @param $name - string of point code
* @return bool true/false exist point in DB
*/
public static function checkPoint($name)
{
$value = (int)Db::getInstance()->getValue('SELECT `id_point` FROM `'._DB_PREFIX_.'inpostship_points` '.
'WHERE point_code = "'.$name.'"');
if (!empty($value) && $value > 0) {
return true;
}
return false;
}
/***
POP POINTS
***/
/**
* Lista punktów POP
* @return mixed
*/
public static function getPopPointsAll()
{
return Db::getInstance()->executeS('SELECT * FROM `' . _DB_PREFIX_ . 'inpostship_points_pop` ORDER BY `point_code` ASC');
}
/**
* Sprawdzanie czy dany POP istnieje w bazie
* @param $name - string of point code
* @return bool true/false exist point in DB
*/
public static function checkPointPop($name)
{
$value = (int)Db::getInstance()->getValue('SELECT `id_point` FROM `'._DB_PREFIX_.'inpostship_points_pop` '.
'WHERE `point_code` = "'.$name.'"');
if (!empty($value) && $value > 0) {
return true;
}
return false;
}
}