'ets_rv_mail_log', 'primary' => 'id_ets_rv_mail_log', 'fields' => [ 'id_ets_rv_email_queue' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_lang' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true), 'id_shop' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), 'employee' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedInt'), 'template' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255), 'to_mail' => array('type' => self::TYPE_STRING, 'validate' => 'isEmail', 'size' => 255), 'to_name' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName', 'size' => 255), 'template_vars' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000), 'subject' => array('type' => self::TYPE_STRING, 'validate' => 'isCleanHtml', 'size' => 500), 'content' => array('type' => self::TYPE_HTML, 'validate' => 'isCleanHtml', 'size' => 65000), 'sent_time' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'), 'status' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'), ] ]; public static function writeLog($queue, $status) { if ((int)Configuration::getGlobalValue('ETS_RV_CRONJOB_MAIL_LOG') < 1) return true; if (empty($queue) || !in_array($status, [EtsRVMailLog::SEND_MAIL_DELIVERED, EtsRVMailLog::SEND_MAIL_FAILED, EtsRVMailLog::SEND_MAIL_TIMEOUT])) return false; if ($queue instanceof EtsRVEmailQueue) { $queue = (array)$queue; } $query = ' INSERT INTO `' . _DB_PREFIX_ . 'ets_rv_mail_log`(`id_ets_rv_email_queue` , `id_lang` , `id_shop` , `id_customer` , `employee` , `template` , `to_email` , `to_name` , `template_vars` , `subject` , `content` , `sent_time` , `status` ) VALUES (' . (int)(isset($queue['id']) ? $queue['id'] : $queue['id_ets_rv_email_queue']) . ' , ' . (int)$queue['id_lang'] . ' , ' . (int)$queue['id_shop'] . ' , ' . (int)$queue['id_customer'] . ' , ' . (int)$queue['employee'] . ' , "' . pSQL($queue['template']) . '" , "' . pSQL($queue['to_email']) . '" , "' . pSQL($queue['to_name']) . '" , "' . pSQL((is_array($queue['template_vars']) ? json_encode($queue['template_vars']) : $queue['template_vars']), true) . '" , "' . pSQL($queue['subject']) . '" , "' . pSQL($queue['content']) . '" , "' . pSQL(date('Y-m-d H:i:s')) . '" , ' . (int)$status . ' ) ON DUPLICATE KEY UPDATE `sent_time`="' . pSQL(date('Y-m-d H:i:s')) . '", `status` = ' . (int)$status . ' '; return Db::getInstance()->execute($query); } public static function getLog($id_ets_rv_email_queue) { if (!$id_ets_rv_email_queue || !Validate::isUnsignedInt($id_ets_rv_email_queue)) return false; return Db::getInstance()->getRow('SELECT * FROM `' . _DB_PREFIX_ . 'ets_rv_mail_log` WHERE `id_ets_rv_mail_log`=' . (int)$id_ets_rv_email_queue); } public static function cleanLog() { return Db::getInstance()->execute('TRUNCATE TABLE `' . _DB_PREFIX_ . 'ets_rv_mail_log`'); } }