<?php
/**
* 2023 Anvanto
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
*
*  @author    Anvanto <anvantoco@gmail.com>
*  @copyright 2023 Anvanto
*  @license   http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*/

if (!defined('_PS_VERSION_')) {
    exit;
}

function upgrade_module_3_1_7($object)
{

    $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_productextratabs_tpl_content` (
        `id_content` int(10) unsigned NOT NULL AUTO_INCREMENT,
        `content_active` tinyint(1) unsigned NOT NULL DEFAULT 1,
        `content_combinations` tinyint(1) unsigned NOT NULL DEFAULT 0,
        `content_contactform` tinyint(1) unsigned NOT NULL DEFAULT 0,
        `id_product` int(10) NOT NULL,
        `id_template` int(10) NOT NULL,
        PRIMARY KEY(`id_content`)
    ) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';
    
    $sql[] = 'CREATE TABLE IF NOT EXISTS `' . _DB_PREFIX_ . 'an_productextratabs_tpl_content_lang` (
        `id_content` int(10) unsigned NOT NULL,
        `content_name` varchar(255) NOT NULL,
        `content_content` text NOT NULL,
        `id_lang` varchar(255) NOT NULL,
        PRIMARY KEY(`id_content`, `id_lang`)
    ) ENGINE = ' . _MYSQL_ENGINE_ . ' DEFAULT CHARSET = utf8';


    $return = true;
    foreach ($sql as $_sql) {
        $return = Db::getInstance()->Execute($_sql);
        if (!$return){
            return false;
        }
    }

    return true;
}