Files
2019-11-17 19:14:07 +01:00

83 lines
3.4 KiB
PHP

<?php
/**
* Module made by Nukium
*
* @author Nukium
* @copyright 2017 Nukium SAS
* @license All rights reserved
*
* ███ ██ ██ ██ ██ ██ ██ ██ ██ ███ ███
* ████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ████
* ██ ██ ██ ██ ██ █████ ██ ██ ██ ██ ████ ██
* ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
* ██ ████ ██████ ██ ██ ██ ██████ ██ ██
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class GlsLogClass extends ObjectModel
{
/** @var int */
public $id_shop_group;
/** @var */
public $id_employee;
/** @var string $message */
public $message;
/** @var string Object creation date */
public $date_add;
public static $definition = array(
'table' => 'gls_log',
'primary' => 'id_gls_log',
'fields' => array(
'id_shop_group' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'message' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'required' => true, 'size' => 16777216),
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
)
);
public static function createDbTable()
{
return Db::getInstance()->Execute('CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'gls_log` (
`id_gls_log` int(10) unsigned NOT NULL AUTO_INCREMENT,
`id_shop_group` int(11) UNSIGNED NOT NULL DEFAULT \'1\',
`id_shop` int(11) UNSIGNED NOT NULL DEFAULT \'1\',
`id_employee` int(10) UNSIGNED DEFAULT NULL,
`message` text NOT NULL,
`date_add` datetime NOT NULL,
PRIMARY KEY (`id_gls_log`),
KEY `id_shop_group` (`id_shop_group`),
KEY `id_shop` (`id_shop`)
) ENGINE=' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET=utf8;');
}
public static function removeDbTable()
{
return Db::getInstance()->Execute('DROP TABLE IF EXISTS `'._DB_PREFIX_.'gls_log`');
}
public function log($message, $autoDate = true, $nullValues = false)
{
if (!empty($message)) {
$this->message = $message;
$this->id_shop = ($this->id_shop) ? $this->id_shop : Context::getContext()->shop->id;
$this->id_shop_group = ($this->id_shop_group) ? $this->id_shop_group : Context::getContext()->shop->id_shop_group;
$this->id_employee = ($this->id_employee) ? $this->id_employee : Context::getContext()->employee->id;
$return = parent::add($autoDate, $nullValues);
return $return;
}
}
}