<?php

include_once("Operations.php");

$numVersion  = 0;
$currentVersion = 43;

function getDatetimeNowMysql()
{
    $tz_object = new DateTimeZone('America/Santo_Domingo');
    $datetime = new DateTime();
    $datetime->setTimezone($tz_object);
    return $datetime->format('Y\-m\-d\ H:i:s');
}

$currDateTime = getDatetimeNowMysql();

try {

    $db = Databases::connect();
    $statement = $db->prepare("SELECT * FROM version ORDER BY ID DESC");
    $statement->execute();
    $item = $statement->fetch();
    $numVersion = $item['NUMBER'];
    updateVersion($numVersion, $currentVersion);
} catch (Exception $e) {

    $db = Databases::connect();

    $statement = $db->prepare(
        "CREATE TABLE version (
        `ID` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
        `NUMBER` INTEGER UNSIGNED,
        `OBSERVATION` LONGTEXT CHARACTER SET utf8 COLLATE utf8_spanish_ci NULL DEFAULT NULL,
        `SQL_QUERY` LONGTEXT CHARACTER SET utf8 COLLATE utf8_spanish_ci NULL DEFAULT NULL,
        PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_spanish_ci COMMENT = 'TABLE OF VERSION';"
    );
    $statement->execute();
    $db = Databases::connect();
    $statement = $db->prepare(
        "INSERT INTO version
        (ID,NUMBER,OBSERVATION,SQL_QUERY) 
        VALUES 
        (1,0,'INSTALLATION','{$currDateTime}');"
    );

    $statement->execute();
    $db = Databases::connect();
    $statement = $db->prepare("SELECT * FROM  version ORDER BY ID DESC");
    $statement->execute();
    $item = $statement->fetch();
    $numVersion  = $item['NUMBER'];
    updateVersion($numVersion, $currentVersion);
}


function updateVersion($version, $currentVersion)
{

    $currDateTime = getDatetimeNowMysql();
    $version++;

    for ($i = $version; $i <= $currentVersion; $i++) {
        $sql = versionQuery($i);
        if (!empty(trim((string) $sql))) {
            try {
                $db = Databases::connect();
                $statement = $db->prepare($sql);
                $statement->execute();
            } catch (Exception $e) {
                $sql = $e . " " . $sql;
            }
            $sql = str_replace("'", "`", $sql);
        }

        $db = Databases::connect();

        $statement = $db->prepare(
            "INSERT INTO version (NUMBER,OBSERVATION,SQL_QUERY) VALUES ('{$i}','{$sql}','{$currDateTime}');"
        );

        $statement->execute();
    }
}


function versionQuery($q_version)
{

    if ($q_version == 1) {

        return "CREATE TABLE `tb_enterprises` (
        `ent_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `ent_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_document` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_document_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_country` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_state` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_timezone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'America/Santo_Domingo',
        `ent_address` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_phone2` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_url` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_logo` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `ent_cancel_password` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_discount_password` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_statistic_password` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_ticket_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `ent_access` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `ent_notification_text` varchar(5000) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ent_show_notification` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'No',
        `ent_created_by` bigint unsigned DEFAULT NULL,
        `ent_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`ent_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 2) {

        return "CREATE TABLE `tb_pos` (
        `pos_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pos_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_ent_id` bigint unsigned DEFAULT NULL,
        `pos_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_business_category` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_currency` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_country` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_state` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_city` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_timezone` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'America/Santo_Domingo',
        `pos_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_phone2` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pos_discount_format` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Percentage',
        `pos_usd_exchange_rate` decimal(17,2) DEFAULT '0.00',
        `pos_tax` decimal(17,2) DEFAULT '0.00',
        `pos_tax_law` decimal(17,2) DEFAULT '0.00',
        `pos_card_tax` decimal(17,2) DEFAULT '0.00',
        `pos_party_mode` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Off',
        `pos_ticket_footer` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `pos_lang` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'en',
        `pos_access` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `pos_created_by` bigint unsigned DEFAULT NULL,
        `pos_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`pos_id`) USING BTREE,
        KEY `pos_ent_id` (`pos_ent_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 3) {

        return "CREATE TABLE `tb_customers` (
        `cus_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `cus_ent_id` bigint unsigned DEFAULT NULL,
        `cus_pos_id` bigint unsigned DEFAULT NULL,
        `cus_full_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `cus_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `cus_email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `cus_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `cus_fiscal_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `cus_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Active',
        `cus_created_by` bigint unsigned DEFAULT NULL,
        `cus_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`cus_id`) USING BTREE,
        KEY `cus_ent_id` (`cus_ent_id`) USING BTREE,
        KEY `cus_pos_id` (`cus_pos_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 4) {

        return "CREATE TABLE `tb_categories` (
        `cat_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `cat_ent_id` bigint unsigned DEFAULT NULL,
        `cat_pos_id` bigint unsigned DEFAULT NULL,
        `cat_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `cat_description` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL,
        `cat_image` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `cat_access` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Enable',
        `cat_created_by` bigint unsigned DEFAULT NULL,
        `cat_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`cat_id`) USING BTREE,
        KEY `cat_ent_id` (`cat_ent_id`) USING BTREE,
        KEY `cat_pos_id` (`cat_pos_id`) USING BTREE,
        KEY `cat_created_by` (`cat_created_by`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 5) {

        return "CREATE TABLE `tb_products` (
        `pro_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pro_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pro_ent_id` bigint unsigned DEFAULT NULL,
        `pro_pos_id` bigint unsigned DEFAULT NULL,
        `pro_cat_id` bigint unsigned DEFAULT NULL,
        `pro_description` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pro_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Product',
        `pro_cost` decimal(17,2) DEFAULT '0.00',
        `pro_price` decimal(17,2) DEFAULT '0.00',
        `pro_price_party` decimal(17,2) NOT NULL DEFAULT '0.00',
        `pro_discount` decimal(17,2) DEFAULT '0.00',
        `pro_image` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT '600x600.png',
        `pro_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `pro_created_by` bigint unsigned DEFAULT NULL,
        `pro_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`pro_id`) USING BTREE,
        KEY `pro_ent_id` (`pro_ent_id`) USING BTREE,
        KEY `pro_pos_id` (`pro_pos_id`) USING BTREE,
        KEY `pro_code` (`pro_code`) USING BTREE,
        KEY `pro_description` (`pro_description`) USING BTREE,
        KEY `pro_cat_id` (`pro_cat_id`) USING BTREE,
        KEY `pro_type` (`pro_type`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 6) {

        return "CREATE TABLE `tb_purchases` (
        `pur_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pur_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pur_ent_id` bigint unsigned DEFAULT NULL,
        `pur_pos_id` bigint unsigned DEFAULT NULL,
        `pur_date` datetime DEFAULT NULL,
        `pur_cost` decimal(17,2) DEFAULT '0.00',
        `pur_shipping` decimal(17,2) DEFAULT '0.00',
        `pur_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `pur_cancel_reason` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pur_canceled_by` bigint DEFAULT NULL,
        `pur_canceled_at` datetime DEFAULT NULL,
        `pur_created_by` bigint unsigned DEFAULT NULL,
        `pur_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`pur_id`) USING BTREE,
        KEY `pur_date` (`pur_date`) USING BTREE,
        KEY `pur_ent_id` (`pur_ent_id`) USING BTREE,
        KEY `pur_pos_id` (`pur_pos_id`) USING BTREE,
        KEY `pur_created_by` (`pur_created_by`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 7) {

        return "CREATE TABLE `tb_purchases_details` (
        `pur_det_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pur_det_ent_id` bigint unsigned DEFAULT NULL,
        `pur_det_pos_id` bigint unsigned DEFAULT NULL,
        `pur_det_pur_id` bigint unsigned DEFAULT NULL,
        `pur_det_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pur_det_pur_date` datetime DEFAULT NULL,
        `pur_det_pro_id` bigint unsigned DEFAULT NULL,
        `pur_det_cat_id` bigint unsigned DEFAULT NULL,
        `pur_det_pro_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pur_det_pro_cost` decimal(17,2) DEFAULT '0.00',
        `pur_det_pro_price` decimal(17,2) DEFAULT '0.00',
        `pur_det_pro_qty` int DEFAULT NULL,
        `pur_cur_total` decimal(17,2) DEFAULT '0.00',
        `pur_det_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        PRIMARY KEY (`pur_det_id`) USING BTREE,
        KEY `FK_purchases_details_1` (`pur_det_pur_id`) USING BTREE,
        KEY `pur_det_ent_id` (`pur_det_ent_id`) USING BTREE,
        KEY `pur_det_pos_id` (`pur_det_pos_id`) USING BTREE,
        KEY `pur_det_pro_id` (`pur_det_pro_id`) USING BTREE,
        CONSTRAINT `FK_purchases_details_1` FOREIGN KEY (`pur_det_pur_id`) REFERENCES `tb_purchases` (`pur_id`) ON DELETE CASCADE ON UPDATE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 8) {

        return "CREATE TABLE `tb_expenses` (
        `exp_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `exp_ent_id` bigint unsigned DEFAULT NULL,
        `exp_pos_id` bigint unsigned DEFAULT NULL,
        `exp_date` datetime DEFAULT NULL,
        `exp_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `exp_total` decimal(17,2) DEFAULT '0.00',
        `exp_shipping` decimal(15,2) DEFAULT '0.00',
        `exp_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Active',
        `exp_cancel_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `exp_canceled_by` bigint DEFAULT NULL,
        `exp_canceled_at` datetime DEFAULT NULL,
        `exp_created_by` bigint unsigned DEFAULT NULL,
        `exp_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        `exp_edited_at` datetime DEFAULT NULL,
        `exp_edited_by` bigint unsigned DEFAULT NULL,
        PRIMARY KEY (`exp_id`) USING BTREE,
        KEY `exp_date` (`exp_date`) USING BTREE,
        KEY `exp_ent_id` (`exp_ent_id`) USING BTREE,
        KEY `exp_created_by` (`exp_created_by`) USING BTREE,
        KEY `exp_pos_id` (`exp_pos_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 9) {

        return "CREATE TABLE `tb_expenses_details` (
        `exp_det_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `exp_det_exp_id` bigint unsigned DEFAULT NULL,
        `exp_det_ent_id` bigint unsigned DEFAULT NULL,
        `exp_det_pos_id` bigint unsigned DEFAULT NULL,
        `exp_det_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `exp_det_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `exp_det_cost` decimal(17,2) DEFAULT '0.00',
        `exp_det_exp_date` datetime DEFAULT NULL,
        `exp_det_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        PRIMARY KEY (`exp_det_id`) USING BTREE,
        KEY `FK_expenses_details_1` (`exp_det_exp_id`) USING BTREE,
        CONSTRAINT `FK_expenses_details_1` FOREIGN KEY (`exp_det_exp_id`) REFERENCES `tb_expenses` (`exp_id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 10) {
        return "CREATE TABLE `tb_fiscal_receipt_list` (
        `fis_rec_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `fis_rec_ent_id` bigint unsigned DEFAULT NULL,
        `fis_rec_type` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fis_rec_description` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fis_rec_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Active',
        `fis_rec_created_by` bigint DEFAULT NULL,
        `fis_rec_added_date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`fis_rec_id`) USING BTREE,
        KEY `fis_rec_created_by` (`fis_rec_created_by`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        INSERT INTO `tb_fiscal_receipt_list` VALUES (1, 1, 'B01', 'CRÉDITO FISCAL', 'Active', 1);
        INSERT INTO `tb_fiscal_receipt_list` VALUES (2, 1, 'B02', 'CONSUMIDOR FINAL', 'Active', 1);
        ";
    }

    if ($q_version == 11) {
        return "CREATE TABLE `tb_fiscal_receipt_entry` (
        `fiscal_entry_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `fiscal_entry_fis_rec_id` bigint unsigned DEFAULT NULL,
        `fiscal_entry_ent_id` bigint unsigned DEFAULT NULL,
        `fiscal_entry_type` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fiscal_entry_description` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fiscal_entry_approved` int DEFAULT NULL,
        `fiscal_entry_expire_date` date DEFAULT NULL,
        `fiscal_entry_status` varchar(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Active',
        `fiscal_entry_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`fiscal_entry_id`) USING BTREE,
        KEY `fiscal_entry_ent_id` (`fiscal_entry_ent_id`) USING BTREE,
        KEY `fiscal_entry_type` (`fiscal_entry_type`) USING BTREE,
        KEY `FK_fiscal_details_1` (`fiscal_entry_fis_rec_id`) USING BTREE,
        CONSTRAINT `FK_fiscal_details_1` FOREIGN KEY (`fiscal_entry_fis_rec_id`) REFERENCES `tb_fiscal_receipt_list` (`fis_rec_id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 12) {
        return "CREATE TABLE `tb_fiscal_receipt_transactions` (
        `fiscal_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `fiscal_ent_id` bigint unsigned DEFAULT NULL,
        `fiscal_type` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fiscal_number` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fiscal_from` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `fiscal_from_id` bigint unsigned DEFAULT NULL,
        `fiscal_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `fiscal_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`fiscal_id`) USING BTREE,
        KEY `fiscal_ent_id` (`fiscal_ent_id`) USING BTREE,
        KEY `fiscal_type` (`fiscal_type`) USING BTREE,
        KEY `fiscal_from` (`fiscal_from`) USING BTREE,
        KEY `fiscal_from_id` (`fiscal_from_id`) USING BTREE,
        KEY `fiscal_access` (`fiscal_status`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 13) {

        return "CREATE TABLE `tb_logs` (
        `log_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `log_ent_id` bigint unsigned DEFAULT NULL,
        `log_pos_id` bigint unsigned DEFAULT NULL,
        `log_user_id` bigint unsigned DEFAULT NULL,
        `log_datetime` datetime DEFAULT NULL,
        `log_description` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `log_ip` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_country_code` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_country` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_regio_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_timezone` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `log_user_datetime` datetime DEFAULT NULL,
        PRIMARY KEY (`log_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 14) {

        return "CREATE TABLE `tb_sales` (
        `sale_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `sale_ent_id` bigint unsigned DEFAULT NULL,
        `sale_pos_id` bigint unsigned DEFAULT NULL,
        `sale_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_date` datetime DEFAULT NULL,
        `sale_date_close` datetime DEFAULT NULL,
        `sale_ncf_type` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_ncf_number` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_type` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_cus_id` bigint unsigned DEFAULT NULL,
        `sale_table_id` bigint unsigned DEFAULT NULL,
        `sale_sub_total` decimal(17,2) DEFAULT '0.00',
        `sale_tax_percent` decimal(17,2) NOT NULL DEFAULT '0.00',
        `sale_tax_value` decimal(17,2) NOT NULL DEFAULT '0.00',
        `sale_tax_law_percent` decimal(17,2) NOT NULL DEFAULT '0.00',
        `sale_tax_law_value` decimal(17,2) NOT NULL DEFAULT '0.00',
        `sale_discount_percent` decimal(17,2) DEFAULT '0.00',
        `sale_discount_value` decimal(17,2) DEFAULT '0.00',
        `sale_cost_delivery` decimal(17,2) DEFAULT '0.00',
        `sale_amount_final` decimal(17,2) DEFAULT '0.00',
        `sale_debt` decimal(17,2) DEFAULT '0.00',
        `sale_debt_status` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'On',
        `sale_debt_reset_reason` varchar(300) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_debt_reset_by` bigint unsigned DEFAULT NULL,
        `sale_debt_reset_at` datetime DEFAULT NULL,
        `sale_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `sale_cancel_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `sale_canceled_by` bigint DEFAULT NULL,
        `sale_canceled_at` datetime DEFAULT NULL,
        `sale_created_by` bigint unsigned DEFAULT NULL,
        `sale_created_at` datetime DEFAULT NULL,
        `sale_edited_by` bigint unsigned DEFAULT NULL,
        `sale_edited_at` datetime DEFAULT NULL,
        PRIMARY KEY (`sale_id`) USING BTREE,
        KEY `sale_date` (`sale_date`) USING BTREE,
        KEY `sale_cus_id` (`sale_cus_id`) USING BTREE,
        KEY `sale_ent_id` (`sale_ent_id`) USING BTREE,
        KEY `sale_pos_id` (`sale_pos_id`) USING BTREE,
        KEY `sale_debt` (`sale_debt`) USING BTREE,
        KEY `sale_status` (`sale_status`) USING BTREE,
        KEY `sale_type` (`sale_type`) USING BTREE,
        KEY `sale_created_by` (`sale_created_by`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 15) {

        return "CREATE TABLE `tb_sales_details` (
        `sale_det_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `sale_det_ent_id` bigint unsigned DEFAULT NULL,
        `sale_det_pos_id` bigint unsigned DEFAULT NULL,
        `sale_det_sale_id` bigint unsigned DEFAULT NULL,
        `sale_det_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_det_sale_date` datetime DEFAULT NULL,
        `sale_det_ord_det_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_det_pro_id` bigint unsigned DEFAULT NULL,
        `sale_det_pro_price` decimal(17,2) DEFAULT '0.00',
        `sale_det_pro_qty` int DEFAULT NULL,
        `sale_det_created_by` bigint DEFAULT NULL,
        `sale_det_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        PRIMARY KEY (`sale_det_id`) USING BTREE,
        KEY `FK_sales_details_1` (`sale_det_sale_id`) USING BTREE,
        KEY `sale_det_pro_id` (`sale_det_pro_id`) USING BTREE,
        KEY `sale_det_ent_id` (`sale_det_ent_id`) USING BTREE,
        KEY `sale_det_pos_id` (`sale_det_pos_id`) USING BTREE,
        KEY `sale_det_created_by` (`sale_det_created_by`) USING BTREE,
        CONSTRAINT `FK_sales_details_1` FOREIGN KEY (`sale_det_sale_id`) REFERENCES `tb_sales` (`sale_id`) ON DELETE CASCADE ON UPDATE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 16) {

        return "CREATE TABLE `tb_orders_request` (
        `ord_det_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `ord_det_ent_id` bigint unsigned DEFAULT NULL,
        `ord_det_pos_id` bigint unsigned DEFAULT NULL,
        `ord_det_number` int DEFAULT NULL,
        `ord_det_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ord_det_sale_id` bigint unsigned DEFAULT NULL,
        `ord_det_sale_code` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ord_det_sale_type` varchar(12) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `ord_sale_table_id` bigint unsigned DEFAULT NULL,
        `ord_det_sale_date` datetime DEFAULT NULL,
        `ord_det_cus_id` bigint unsigned DEFAULT NULL,
        `ord_det_emp_id` bigint unsigned DEFAULT NULL,
        `ord_det_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Pending',
        `ord_det_cancel_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `ord_det_created_by` bigint unsigned DEFAULT NULL,
        `ord_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`ord_det_id`) USING BTREE,
        KEY `ord_det_ent_id` (`ord_det_ent_id`) USING BTREE,
        KEY `ord_det_pos_id` (`ord_det_pos_id`) USING BTREE,
        KEY `ord_det_sale_id` (`ord_det_sale_id`) USING BTREE,
        KEY `ord_det_code` (`ord_det_code`) USING BTREE,
        KEY `ord_det_created_by` (`ord_det_created_by`) USING BTREE,
        KEY `FK_clients_orders_1` (`ord_det_sale_id`) USING BTREE,
        CONSTRAINT `FK_clients_orders_1` FOREIGN KEY (`ord_det_sale_id`) REFERENCES `tb_sales` (`sale_id`) ON DELETE CASCADE ON UPDATE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }


    if ($q_version == 17) {

        return "CREATE TABLE `tb_payments_details` (
        `pay_det_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pay_det_ent_id` bigint unsigned DEFAULT NULL,
        `pay_det_pos_id` bigint unsigned DEFAULT NULL,
        `pay_det_sale_id` bigint unsigned DEFAULT NULL,
        `pay_det_cus_id` bigint unsigned DEFAULT NULL,
        `sale_det_sale_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_det_sale_type` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_det_sale_date` datetime DEFAULT NULL,
        `pay_det_date` datetime DEFAULT NULL,
        `pay_det_sale_close` datetime DEFAULT NULL,
        `pay_det_payment_type` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_det_value` decimal(17,2) DEFAULT '0.00',
        `pay_det_income` decimal(17,2) NOT NULL DEFAULT '0.00',
        `pay_det_card_tax` decimal(17,2) NOT NULL DEFAULT '0.00',
        `pay_det_change` decimal(17,2) NOT NULL DEFAULT '0.00',
        `pay_det_created_by` bigint unsigned DEFAULT NULL,
        `pay_det_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        PRIMARY KEY (`pay_det_id`) USING BTREE,
        KEY `FK_sales_payments_details_1` (`pay_det_sale_id`) USING BTREE,
        KEY `pay_det_date` (`pay_det_date`) USING BTREE,
        KEY `pay_det_pos_id` (`pay_det_pos_id`) USING BTREE,
        KEY `pay_det_status` (`pay_det_status`) USING BTREE,
        KEY `pay_det_created_by` (`pay_det_created_by`) USING BTREE,
        KEY `pay_det_sale_date` (`pay_det_sale_date`) USING BTREE,
        CONSTRAINT `FK_sales_payments_details_1` FOREIGN KEY (`pay_det_sale_id`) REFERENCES `tb_sales` (`sale_id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 18) {

        return "CREATE TABLE `tb_tables` (
        `table_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `table_ent_id` bigint unsigned DEFAULT NULL,
        `table_pos_id` bigint unsigned DEFAULT NULL,
        `table_description` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `table_access` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `table_created_by` bigint unsigned DEFAULT NULL,
        `table_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`table_id`) USING BTREE,
        KEY `table_ent_id` (`table_ent_id`) USING BTREE,
        KEY `table_pos_id` (`table_pos_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        
        INSERT INTO `tb_tables` (`table_id`, `table_ent_id`, `table_pos_id`, `table_description`, `table_access`, `table_created_by`, `table_created_at`) VALUES (1, 1, 1, 'Table 01', 'Active', 1, '2022-08-12 21:08:31'),(2, 1, 1, 'Table 02', 'Active', 1, '2022-08-12 21:08:31'),(3, 1, 1, 'Table 03', 'Active', 1, '2022-08-12 21:08:31'),(4, 1, 1, 'Table 04', 'Active', 1, '2022-08-12 21:08:31'),(5, 1, 1, 'Table 05', 'Active', 1, '2022-08-12 21:08:31'),(6, 1, 1, 'Table 06', 'Active', 1, '2022-08-12 21:08:31'),(7, 1, 1, 'Table 07', 'Active', 1, '2022-08-12 21:08:31'),(8, 1, 1, 'Table 08', 'Active', 1, '2022-08-12 21:08:31'),(9, 1, 1, 'Table 09', 'Active', 1, '2022-08-12 21:08:31'),(10, 1, 1, 'Table 10', 'Active', 1, '2022-08-12 21:08:31'),(11, 1, 1, 'Table 11', 'Active', 1, '2022-08-12 21:08:31'),(12, 1, 1, 'Table 12', 'Active', 1, '2022-08-12 21:08:31'),(13, 1, 1, 'Table 13', 'Active', 1, '2022-08-12 21:08:31'),(14, 1, 1, 'Table 14', 'Active', 1, '2022-08-12 21:08:31'),(15, 1, 1, 'Table 15', 'Active', 1, '2022-08-12 21:08:31'),(16, 1, 1, 'Table 16', 'Active', 1, '2022-08-12 21:08:31'),(17, 1, 1, 'Table 17', 'Active', 1, '2022-08-12 21:08:31'),(18, 1, 1, 'Table 18', 'Active', 1, '2022-08-12 21:08:31'),(19, 1, 1, 'Table 19', 'Active', 1, '2022-08-12 21:08:31'),(20, 1, 1, 'Table 20', 'Active', 1, '2022-08-12 21:08:31'),(21, 1, 1, 'Table 21', 'Active', 1, '2022-08-12 21:08:31'),(22, 1, 1, 'Table 22', 'Active', 1, '2022-08-12 21:08:31'),(23, 1, 1, 'Table 23', 'Active', 1, '2022-08-12 21:08:31'),(24, 1, 1, 'Table 24', 'Active', 1, '2022-08-12 21:08:31'),(25, 1, 1, 'Table 25', 'Active', 1, '2022-08-12 21:08:31'),(26, 1, 1, 'Table 26', 'Active', 1, '2022-08-12 21:08:31'),(27, 1, 1, 'Table 27', 'Active', 1, '2022-08-12 21:08:31'),(28, 1, 1, 'Table 28', 'Active', 1, '2022-08-12 21:08:31'),(29, 1, 1, 'Table 29', 'Active', 1, '2022-08-12 21:08:31'),(30, 1, 1, 'Table 30', 'Active', 1, '2022-08-12 21:08:31'),(31, 1, 1, 'Table 31', 'Active', 1, '2022-08-12 21:08:31'),(32, 1, 1, 'Table 32', 'Active', 1, '2022-08-12 21:08:31'),(33, 1, 1, 'Table 33', 'Active', 1, '2022-08-12 21:08:31'),(34, 1, 1, 'Table 34', 'Active', 1, '2022-08-12 21:08:31'),(35, 1, 1, 'Table 35', 'Active', 1, '2022-08-12 21:08:31'),(36, 1, 1, 'Table 36', 'Active', 1, '2022-08-12 21:08:31'),(37, 1, 1, 'Table 37', 'Active', 1, '2022-08-12 21:08:31'),(38, 1, 1, 'Table 38', 'Active', 1, '2022-08-12 21:08:31'),(39, 1, 1, 'Table 39', 'Active', 1, '2022-08-12 21:08:31'),(40, 1, 1, 'Table 40', 'Active', 1, '2022-08-12 21:08:31'),(41, 1, 1, 'Table 41', 'Active', 1, '2022-08-12 21:08:31'),(42, 1, 1, 'Table 42', 'Active', 1, '2022-08-12 21:08:31'),(43, 1, 1, 'Table 43', 'Active', 1, '2022-08-12 21:08:31'),(44, 1, 1, 'Table 44', 'Active', 1, '2022-08-12 21:08:31'),(45, 1, 1, 'Table 45', 'Active', 1, '2022-08-12 21:08:31'),(46, 1, 1, 'Table 46', 'Active', 1, '2022-08-12 21:08:31'),(47, 1, 1, 'Table 47', 'Active', 1, '2022-08-12 21:08:31'),(48, 1, 1, 'Table 48', 'Active', 1, '2022-08-12 21:08:31'),(49, 1, 1, 'Table 49', 'Active', 1, '2022-08-12 21:08:31'),(50, 1, 1, 'Table 50', 'Active', 1, '2022-08-12 21:08:31');
        ";
    }

    if ($q_version == 19) {

        return "CREATE TABLE `tb_users` (
        `user_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `user_ent_id` bigint unsigned DEFAULT NULL,
        `user_pos_id` bigint unsigned DEFAULT NULL,
        `user_firstname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_lastname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_document` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_document_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_birthday` date DEFAULT NULL,
        `user_name` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_country` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_state` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_city` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_image` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_profile` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_last_activity` datetime DEFAULT NULL,
        `user_last_login` datetime DEFAULT NULL,
        `user_access` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        `user_language` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'es',
        `user_theme` varchar(25) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `user_created_by` bigint unsigned DEFAULT NULL,
        `user_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        `user_edited_by` bigint unsigned DEFAULT NULL,
        `user_edited_at` datetime DEFAULT NULL,
        PRIMARY KEY (`user_id`) USING BTREE,
        KEY `user_ent_id` (`user_ent_id`) USING BTREE,
        KEY `user_pos_id` (`user_pos_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;";
    }

    if ($q_version == 20) {
        return "CREATE TABLE `tb_stock_adjustments` (
        `adjust_id` int NOT NULL AUTO_INCREMENT,
        `adjust_ent_id` int DEFAULT NULL,
        `adjust_pos_id` int DEFAULT NULL,
        `adjust_user_id` int DEFAULT NULL,
        `adjust_type` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `adjust_product_id` int DEFAULT NULL,
        `adjust_current_stock` int DEFAULT NULL,
        `adjust_quantity` int DEFAULT NULL,
        `adjust_reason` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `adjust_datetime` datetime DEFAULT NULL,
        `adjust_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Active',
        PRIMARY KEY (`adjust_id`) USING BTREE,
        KEY `adjust_ent_id` (`adjust_ent_id`) USING BTREE,
        KEY `adjust_pos_id` (`adjust_pos_id`) USING BTREE,
        KEY `adjust_user_id` (`adjust_user_id`) USING BTREE,
        KEY `adjust_product_id` (`adjust_product_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        ";
    }

    if ($q_version == 21) {
        return "CREATE TABLE `tb_payments_type` (
        `pay_type_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pay_type_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_type_description` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_type_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Enable',
        PRIMARY KEY (`pay_type_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;

        INSERT INTO `tb_payments_type` (`pay_type_id`, `pay_type_name`, `pay_type_description`, `pay_type_status`) VALUES (1, 'CASH', 'CASH', 'Enable'),(2, 'CARD', 'CREDIT CARD', 'Enable'),(3, 'CASHAPP', 'CASHAPP', 'Enable'),(4, 'ZELLE', 'ZELLE', 'Enable'),(5, 'BANK DEPOSIT', 'BANK DEPOSIT', 'Enable'),(6, 'MONCASH', 'MONCASH', 'Enable');

        ALTER TABLE `tb_enterprises` ADD `ent_notification_text` VARCHAR(5000) CHARACTER SET utf8 COLLATE utf8_spanish_ci NULL DEFAULT NULL AFTER `ent_access`, ADD `ent_show_notification` VARCHAR(5) CHARACTER SET utf8 COLLATE utf8_spanish_ci NOT NULL DEFAULT 'No' AFTER `ent_notification_text`;

        ALTER TABLE `tb_pos` ADD `pos_business_category` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL AFTER `pos_name`;
        ALTER TABLE `tb_pos` ADD `pos_lang` VARCHAR(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'en' AFTER `pos_ticket_footer`;
        ALTER TABLE `tb_pos` CHANGE `pos_discount_config` `pos_discount_format` VARCHAR(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Percentage', CHANGE `pos_usd_change_rate` `pos_usd_exchange_rate` DECIMAL(17,2) NULL DEFAULT '0.00';
        ALTER TABLE `tb_pos` ADD `pos_tax` DECIMAL(17,2) NULL DEFAULT '0.00' AFTER `pos_usd_exchange_rate`, ADD `pos_tax_law` DECIMAL(17,2) NULL DEFAULT '0.00' AFTER `pos_tax`, ADD `pos_card_tax` DECIMAL(17,2) NULL DEFAULT '0.00' AFTER `pos_tax_law`;

        ALTER TABLE `tb_orders_request` ADD `ord_det_number` INT NULL AFTER `ord_det_pos_id`;
        UPDATE `tb_stock_adjustments` SET adjust_type = 'Decrease' WHERE adjust_type = 'Disminuir';
        UPDATE `tb_stock_adjustments` SET adjust_type = 'Increase' WHERE adjust_type = 'Incrementar';
        UPDATE tb_sales SET sale_type = 'Take away' WHERE sale_type = 'Take Out';
        UPDATE tb_payments_details SET pay_det_sale_type = 'Take away' WHERE pay_det_sale_type = 'Take Out';
        UPDATE tb_orders_request SET ord_det_sale_type = 'Take away' WHERE ord_det_sale_type = 'Take Out';
        ";
    }

    if ($q_version == 22) {
        return "CREATE TABLE `tb_countries` (
        `country_id` bigint NOT NULL AUTO_INCREMENT,
        `country_code` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `country_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        PRIMARY KEY (`country_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        
        INSERT INTO `tb_countries` (`country_id`, `country_code`, `country_name`) VALUES
        (1, 'US', 'United States'),(2, 'DO', 'Dominican Republic'),(3, 'HT', 'Haiti'),(4, 'AF', 'Afghanistan'),(5, 'AX', 'Åland Islands'),(6, 'AL', 'Albania'),(7, 'DZ', 'Algeria'),(8, 'AS', 'American Samoa'),(9, 'AD', 'Andorra'),(10, 'AO', 'Angola'),(11, 'AI', 'Anguilla'),(12, 'AQ', 'Antarctica'),(13, 'AG', 'Antigua and Barbuda'),(14, 'AR', 'Argentina'),(15, 'AM', 'Armenia'),(16, 'AW', 'Aruba'),(17, 'AU', 'Australia'),(18, 'AT', 'Austria'),(19, 'AZ', 'Azerbaijan'),(20, 'BS', 'Bahamas'),(21, 'BH', 'Bahrain'),(22, 'BD', 'Bangladesh'),(23, 'BB', 'Barbados'),(24, 'BY', 'Belarus'),(25, 'BE', 'Belgium'),(26, 'BZ', 'Belize'),(27, 'BJ', 'Benin'),(28, 'BM', 'Bermuda'),(29, 'BT', 'Bhutan'),(30, 'BO', 'Bolivia, Plurinational State of'),(31, 'BQ', 'Bonaire, Sint Eustatius and Saba'),(32, 'BA', 'Bosnia and Herzegovina'),(33, 'BW', 'Botswana'),(34, 'BV', 'Bouvet Island'),(35, 'BR', 'Brazil'),(36, 'IO', 'British Indian Ocean Territory'),(37, 'BN', 'Brunei Darussalam'),(38, 'BG', 'Bulgaria'),(39, 'BF', 'Burkina Faso'),(40, 'BI', 'Burundi'),(41, 'KH', 'Cambodia'),(42, 'CM', 'Cameroon'),(43, 'CA', 'Canada'),(44, 'CV', 'Cape Verde'),(45, 'KY', 'Cayman Islands'),(46, 'CF', 'Central African Republic'),(47, 'TD', 'Chad'),(48, 'CL', 'Chile'),(49, 'CN', 'China'),(50, 'CX', 'Christmas Island'),(51, 'CC', 'Cocos (Keeling) Islands'),(52, 'CO', 'Colombia'),(53, 'KM', 'Comoros'),(54, 'CG', 'Congo'),(55, 'CD', 'Congo, the Democratic Republic of the'),(56, 'CK', 'Cook Islands'),(57, 'CR', 'Costa Rica'),(58, 'CI', 'Côte d\'Ivoire'),(59, 'HR', 'Croatia'),(60, 'CU', 'Cuba'),(61, 'CW', 'Curaçao'),(62, 'CY', 'Cyprus'),(63, 'CZ', 'Czech Republic'),(64, 'DK', 'Denmark'),(65, 'DJ', 'Djibouti'),(66, 'DM', 'Dominica'),(67, 'EC', 'Ecuador'),(68, 'EG', 'Egypt'),(69, 'SV', 'El Salvador'),(70, 'GQ', 'Equatorial Guinea'),(71, 'ER', 'Eritrea'),(72, 'EE', 'Estonia'),(73, 'ET', 'Ethiopia'),(74, 'FK', 'Falkland Islands (Malvinas)'),(75, 'FO', 'Faroe Islands'),(76, 'FJ', 'Fiji'),(77, 'FI', 'Finland'),(78, 'FR', 'France'),(79, 'GF', 'French Guiana'),(80, 'PF', 'French Polynesia'),(81, 'TF', 'French Southern Territories'),(82, 'GA', 'Gabon'),(83, 'GM', 'Gambia'),(84, 'GE', 'Georgia'),(85, 'DE', 'Germany'),(86, 'GH', 'Ghana'),(87, 'GI', 'Gibraltar'),(88, 'GR', 'Greece'),(89, 'GL', 'Greenland'),(90, 'GD', 'Grenada'),(91, 'GP', 'Guadeloupe'),(92, 'GU', 'Guam'),(93, 'GT', 'Guatemala'),(94, 'GG', 'Guernsey'),(95, 'GN', 'Guinea'),(96, 'GW', 'Guinea-Bissau'),(97, 'GY', 'Guyana'),(98, 'HM', 'Heard Island and McDonald Islands'),(99, 'VA', 'Holy See (Vatican City State)'),(100, 'HN', 'Honduras'),(101, 'HK', 'Hong Kong'),(102, 'HU', 'Hungary'),(103, 'IS', 'Iceland'),(104, 'IN', 'India'),(105, 'ID', 'Indonesia'),(106, 'IR', 'Iran, Islamic Republic of'),(107, 'IQ', 'Iraq'),(108, 'IE', 'Ireland'),(109, 'IM', 'Isle of Man'),(110, 'IL', 'Israel'),(111, 'IT', 'Italy'),(112, 'JM', 'Jamaica'),(113, 'JP', 'Japan'),(114, 'JE', 'Jersey'),(115, 'JO', 'Jordan'),(116, 'KZ', 'Kazakhstan'),(117, 'KE', 'Kenya'),(118, 'KI', 'Kiribati'),(119, 'KP', 'Korea, Democratic People\'s Republic of'),(120, 'KR', 'Korea, Republic of'),(121, 'KW', 'Kuwait'),(122, 'KG', 'Kyrgyzstan'),(123, 'LA', 'Lao People\'s Democratic Republic'),(124, 'LV', 'Latvia'),(125, 'LB', 'Lebanon'),(126, 'LS', 'Lesotho'),(127, 'LR', 'Liberia'),(128, 'LY', 'Libya'),(129, 'LI', 'Liechtenstein'),(130, 'LT', 'Lithuania'),(131, 'LU', 'Luxembourg'),(132, 'MO', 'Macao'),(133, 'MK', 'Macedonia, the former Yugoslav Republic of'),(134, 'MG', 'Madagascar'),(135, 'MW', 'Malawi'),(136, 'MY', 'Malaysia'),(137, 'MV', 'Maldives'),(138, 'ML', 'Mali'),(139, 'MT', 'Malta'),(140, 'MH', 'Marshall Islands'),(141, 'MQ', 'Martinique'),(142, 'MR', 'Mauritania'),(143, 'MU', 'Mauritius'),(144, 'YT', 'Mayotte'),(145, 'MX', 'Mexico'),(146, 'FM', 'Micronesia, Federated States of'),(147, 'MD', 'Moldova, Republic of'),(148, 'MC', 'Monaco'),(149, 'MN', 'Mongolia'),(150, 'ME', 'Montenegro'),(151, 'MS', 'Montserrat'),(152, 'MA', 'Morocco'),(153, 'MZ', 'Mozambique'),(154, 'MM', 'Myanmar'),(155, 'NA', 'Namibia'),(156, 'NR', 'Nauru'),(157, 'NP', 'Nepal'),(158, 'NL', 'Netherlands'),(159, 'NC', 'New Caledonia'),(160, 'NZ', 'New Zealand'),(161, 'NI', 'Nicaragua'),(162, 'NE', 'Niger'),(163, 'NG', 'Nigeria'),(164, 'NU', 'Niue'),(165, 'NF', 'Norfolk Island'),(166, 'MP', 'Northern Mariana Islands'),(167, 'NO', 'Norway'),(168, 'OM', 'Oman'),(169, 'PK', 'Pakistan'),(170, 'PW', 'Palau'),(171, 'PS', 'Palestinian Territory, Occupied'),(172, 'PA', 'Panama'),(173, 'PG', 'Papua New Guinea'),(174, 'PY', 'Paraguay'),(175, 'PE', 'Peru'),(176, 'PH', 'Philippines'),(177, 'PN', 'Pitcairn'),(178, 'PL', 'Poland'),(179, 'PT', 'Portugal'),(180, 'PR', 'Puerto Rico'),(181, 'QA', 'Qatar'),(182, 'RE', 'Réunion'),(183, 'RO', 'Romania'),(184, 'RU', 'Russian Federation'),(185, 'RW', 'Rwanda'),(186, 'BL', 'Saint Barthélemy'),(187, 'SH', 'Saint Helena, Ascension and Tristan da Cunha'),(188, 'KN', 'Saint Kitts and Nevis'),(189, 'LC', 'Saint Lucia'),(190, 'MF', 'Saint Martin (French part)'),(191, 'PM', 'Saint Pierre and Miquelon'),(192, 'VC', 'Saint Vincent and the Grenadines'),(193, 'WS', 'Samoa'),(194, 'SM', 'San Marino'),(195, 'ST', 'Sao Tome and Principe'),(196, 'SA', 'Saudi Arabia'),(197, 'SN', 'Senegal'),(198, 'RS', 'Serbia'),(199, 'SC', 'Seychelles'),(200, 'SL', 'Sierra Leone'),(201, 'SG', 'Singapore'),(202, 'SX', 'Sint Maarten (Dutch part)'),(203, 'SK', 'Slovakia'),(204, 'SI', 'Slovenia'),(205, 'SB', 'Solomon Islands'),(206, 'SO', 'Somalia'),(207, 'ZA', 'South Africa'),(208, 'GS', 'South Georgia and the South Sandwich Islands'),(209, 'SS', 'South Sudan'),(210, 'ES', 'Spain'),(211, 'LK', 'Sri Lanka'),(212, 'SD', 'Sudan'),(213, 'SR', 'Suriname'),(214, 'SJ', 'Svalbard and Jan Mayen'),(215, 'SZ', 'Swaziland'),(216, 'SE', 'Sweden'),(217, 'CH', 'Switzerland'),(218, 'SY', 'Syrian Arab Republic'),(219, 'TW', 'Taiwan, Province of China'),(220, 'TJ', 'Tajikistan'),(221, 'TZ', 'Tanzania, United Republic of'),(222, 'TH', 'Thailand'),(223, 'TL', 'Timor-Leste'),(224, 'TG', 'Togo'),(225, 'TK', 'Tokelau'),(226, 'TO', 'Tonga'),(227, 'TT', 'Trinidad and Tobago'),(228, 'TN', 'Tunisia'),(229, 'TR', 'Turkey'),(230, 'TM', 'Turkmenistan'),(231, 'TC', 'Turks and Caicos Islands'),(232, 'TV', 'Tuvalu'),(233, 'UG', 'Uganda'),(234, 'UA', 'Ukraine'),(235, 'AE', 'United Arab Emirates'),(236, 'GB', 'United Kingdom'),(237, 'UM', 'United States Minor Outlying Islands'),(238, 'UY', 'Uruguay'),(239, 'UZ', 'Uzbekistan'),(240, 'VU', 'Vanuatu'),(241, 'VE', 'Venezuela, Bolivarian Republic of'),(242, 'VN', 'Viet Nam'),(243, 'VG', 'Virgin Islands, British'),(244, 'VI', 'Virgin Islands, U.S.'),(245, 'WF', 'Wallis and Futuna'),(246, 'EH', 'Western Sahara'),(247, 'YE', 'Yemen'),(248, 'ZM', 'Zambia'),(249, 'ZW', 'Zimbabwe');

        CREATE TABLE `tb_timezones` (
        `timezone_id` bigint NOT NULL AUTO_INCREMENT,
        `timezone_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        PRIMARY KEY (`timezone_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;

        INSERT INTO `tb_timezones` (`timezone_id`, `timezone_name`) VALUES
        (1, 'Africa/Abidjan'),(2, 'Africa/Accra'),(3, 'Africa/Addis_Ababa'),(4, 'Africa/Algiers'),(5, 'Africa/Asmara'),(6, 'Africa/Bamako'),(7, 'Africa/Bangui'),(8, 'Africa/Banjul'),(9, 'Africa/Bissau'),(10, 'Africa/Blantyre'),(11, 'Africa/Brazzaville'),(12, 'Africa/Bujumbura'),(13, 'Africa/Cairo'),(14, 'Africa/Casablanca'),(15, 'Africa/Ceuta'),(16, 'Africa/Conakry'),(17, 'Africa/Dakar'),(18, 'Africa/Dar_es_Salaam'),(19, 'Africa/Djibouti'),(20, 'Africa/Douala'),(21, 'Africa/El_Aaiun'),(22, 'Africa/Freetown'),(23, 'Africa/Gaborone'),(24, 'Africa/Harare'),(25, 'Africa/Johannesburg'),(26, 'Africa/Juba'),(27, 'Africa/Kampala'),(28, 'Africa/Khartoum'),(29, 'Africa/Kigali'),(30, 'Africa/Kinshasa'),(31, 'Africa/Lagos'),(32, 'Africa/Libreville'),(33, 'Africa/Lome'),(34, 'Africa/Luanda'),(35, 'Africa/Lubumbashi'),(36, 'Africa/Lusaka'),(37, 'Africa/Malabo'),(38, 'Africa/Maputo'),(39, 'Africa/Maseru'),(40, 'Africa/Mbabane'),(41, 'Africa/Mogadishu'),(42, 'Africa/Monrovia'),(43, 'Africa/Nairobi'),(44, 'Africa/Ndjamena'),(45, 'Africa/Niamey'),(46, 'Africa/Nouakchott'),(47, 'Africa/Ouagadougou'),(48, 'Africa/Porto'),(49, 'Africa/Sao_Tome'),(50, 'Africa/Tripoli'),(51, 'Africa/Tunis'),(52, 'Africa/Windhoek'),(53, 'America/Adak'),(54, 'America/Anchorage'),(55, 'America/Anguilla'),(56, 'America/Antigua'),(57, 'America/Araguaina'),(58, 'America/Argentina/Buenos_Aires'),(59, 'America/Argentina/Catamarca'),(60, 'America/Argentina/Cordoba'),(61, 'America/Argentina/Jujuy'),(62, 'America/Argentina/La_Rioja'),(63, 'America/Argentina/Mendoza'),(64, 'America/Argentina/Rio_Gallegos'),(65, 'America/Argentina/Salta'),(66, 'America/Argentina/San_Juan'),(67, 'America/Argentina/San_Luis'),(68, 'America/Argentina/Tucuman'),(69, 'America/Argentina/Ushuaia'),(70, 'America/Aruba'),(71, 'America/Asuncion'),(72, 'America/Atikokan'),(73, 'America/Bahia'),(74, 'America/Bahia_Banderas'),(75, 'America/Barbados'),(76, 'America/Belem'),(77, 'America/Belize'),(78, 'America/Blanc'),(79, 'America/Boa_Vista'),(80, 'America/Bogota'),(81, 'America/Boise'),(82, 'America/Cambridge_Bay'),(83, 'America/Campo_Grande'),(84, 'America/Cancun'),(85, 'America/Caracas'),(86, 'America/Cayenne'),(87, 'America/Cayman'),(88, 'America/Chicago'),(89, 'America/Chihuahua'),(90, 'America/Costa_Rica'),(91, 'America/Creston'),(92, 'America/Cuiaba'),(93, 'America/Curacao'),(94, 'America/Danmarkshavn'),(95, 'America/Dawson'),(96, 'America/Dawson_Creek'),(97, 'America/Denver'),(98, 'America/Detroit'),(99, 'America/Dominica'),(100, 'America/Edmonton'),(101, 'America/Eirunepe'),(102, 'America/El_Salvador'),(103, 'America/Fort_Nelson'),(104, 'America/Fortaleza'),(105, 'America/Glace_Bay'),(106, 'America/Goose_Bay'),(107, 'America/Grand_Turk'),(108, 'America/Grenada'),(109, 'America/Guadeloupe'),(110, 'America/Guatemala'),(111, 'America/Guayaquil'),(112, 'America/Guyana'),(113, 'America/Halifax'),(114, 'America/Havana'),(115, 'America/Hermosillo'),(116, 'America/Indiana/Indianapolis'),(117, 'America/Indiana/Knox'),(118, 'America/Indiana/Marengo'),(119, 'America/Indiana/Petersburg'),(120, 'America/Indiana/Tell_City'),(121, 'America/Indiana/Vevay'),(122, 'America/Indiana/Vincennes'),(123, 'America/Indiana/Winamac'),(124, 'America/Inuvik'),(125, 'America/Iqaluit'),(126, 'America/Jamaica'),(127, 'America/Juneau'),(128, 'America/Kentucky/Louisville'),(129, 'America/Kentucky/Monticello'),(130, 'America/Kralendijk'),(131, 'America/La_Paz'),(132, 'America/Lima'),(133, 'America/Los_Angeles'),(134, 'America/Lower_Princes'),(135, 'America/Maceio'),(136, 'America/Managua'),(137, 'America/Manaus'),(138, 'America/Marigot'),(139, 'America/Martinique'),(140, 'America/Matamoros'),(141, 'America/Mazatlan'),(142, 'America/Menominee'),(143, 'America/Merida'),(144, 'America/Metlakatla'),(145, 'America/Mexico_City'),(146, 'America/Miquelon'),(147, 'America/Moncton'),(148, 'America/Monterrey'),(149, 'America/Montevideo'),(150, 'America/Montserrat'),(151, 'America/Nassau'),(152, 'America/New_York'),(153, 'America/Nipigon'),(154, 'America/Nome'),(155, 'America/Noronha'),(156, 'America/North_Dakota/Beulah'),(157, 'America/North_Dakota/Center'),(158, 'America/North_Dakota/New_Salem'),(159, 'America/Nuuk'),(160, 'America/Ojinaga'),(161, 'America/Panama'),(162, 'America/Pangnirtung'),(163, 'America/Paramaribo'),(164, 'America/Phoenix'),(165, 'America/Port'),(166, 'America/Port_of_Spain'),(167, 'America/Porto_Velho'),(168, 'America/Puerto_Rico'),(169, 'America/Punta_Arenas'),(170, 'America/Rainy_River'),(171, 'America/Rankin_Inlet'),(172, 'America/Recife'),(173, 'America/Regina'),(174, 'America/Resolute'),(175, 'America/Rio_Branco'),(176, 'America/Santarem'),(177, 'America/Santiago'),(178, 'America/Santo_Domingo'),(179, 'America/Sao_Paulo'),(180, 'America/Scoresbysund'),(181, 'America/Sitka'),(182, 'America/St_Barthelemy'),(183, 'America/St_Johns'),(184, 'America/St_Kitts'),(185, 'America/St_Lucia'),(186, 'America/St_Thomas'),(187, 'America/St_Vincent'),(188, 'America/Swift_Current'),(189, 'America/Tegucigalpa'),(190, 'America/Thule'),(191, 'America/Thunder_Bay'),(192, 'America/Tijuana'),(193, 'America/Toronto'),(194, 'America/Tortola'),(195, 'America/Vancouver'),(196, 'America/Whitehorse'),(197, 'America/Winnipeg'),(198, 'America/Yakutat'),(199, 'America/Yellowknife'),(200, 'Antarctica/Casey'),(201, 'Antarctica/Davis'),(202, 'Antarctica/DumontDUrville'),(203, 'Antarctica/Macquarie'),(204, 'Antarctica/Mawson'),(205, 'Antarctica/McMurdo'),(206, 'Antarctica/Palmer'),(207, 'Antarctica/Rothera'),(208, 'Antarctica/Syowa'),(209, 'Antarctica/Troll'),(210, 'Antarctica/Vostok'),(211, 'Arctic/Longyearbyen'),(212, 'Asia/Aden'),(213, 'Asia/Almaty'),(214, 'Asia/Amman'),(215, 'Asia/Anadyr'),(216, 'Asia/Aqtau'),(217, 'Asia/Aqtobe'),(218, 'Asia/Ashgabat'),(219, 'Asia/Atyrau'),(220, 'Asia/Baghdad'),(221, 'Asia/Bahrain'),(222, 'Asia/Baku'),(223, 'Asia/Bangkok'),(224, 'Asia/Barnaul'),(225, 'Asia/Beirut'),(226, 'Asia/Bishkek'),(227, 'Asia/Brunei'),(228, 'Asia/Chita'),(229, 'Asia/Choibalsan'),(230, 'Asia/Colombo'),(231, 'Asia/Damascus'),(232, 'Asia/Dhaka'),(233, 'Asia/Dili'),(234, 'Asia/Dubai'),(235, 'Asia/Dushanbe'),(236, 'Asia/Famagusta'),(237, 'Asia/Gaza'),(238, 'Asia/Hebron'),(239, 'Asia/Ho_Chi_Minh'),(240, 'Asia/Hong_Kong'),(241, 'Asia/Hovd'),(242, 'Asia/Irkutsk'),(243, 'Asia/Jakarta'),(244, 'Asia/Jayapura'),(245, 'Asia/Jerusalem'),(246, 'Asia/Kabul'),(247, 'Asia/Kamchatka'),(248, 'Asia/Karachi'),(249, 'Asia/Kathmandu'),(250, 'Asia/Khandyga'),(251, 'Asia/Kolkata'),(252, 'Asia/Krasnoyarsk'),(253, 'Asia/Kuala_Lumpur'),(254, 'Asia/Kuching'),(255, 'Asia/Kuwait'),(256, 'Asia/Macau'),(257, 'Asia/Magadan'),(258, 'Asia/Makassar'),(259, 'Asia/Manila'),(260, 'Asia/Muscat'),(261, 'Asia/Nicosia'),(262, 'Asia/Novokuznetsk'),(263, 'Asia/Novosibirsk'),(264, 'Asia/Omsk'),(265, 'Asia/Oral'),(266, 'Asia/Phnom_Penh'),(267, 'Asia/Pontianak'),(268, 'Asia/Pyongyang'),(269, 'Asia/Qatar'),(270, 'Asia/Qostanay'),(271, 'Asia/Qyzylorda'),(272, 'Asia/Riyadh'),(273, 'Asia/Sakhalin'),(274, 'Asia/Samarkand'),(275, 'Asia/Seoul'),(276, 'Asia/Shanghai'),(277, 'Asia/Singapore'),(278, 'Asia/Srednekolymsk'),(279, 'Asia/Taipei'),(280, 'Asia/Tashkent'),(281, 'Asia/Tbilisi'),(282, 'Asia/Tehran'),(283, 'Asia/Thimphu'),(284, 'Asia/Tokyo'),(285, 'Asia/Tomsk'),(286, 'Asia/Ulaanbaatar'),(287, 'Asia/Urumqi'),(288, 'Asia/Ust'),(289, 'Asia/Vientiane'),(290, 'Asia/Vladivostok'),(291, 'Asia/Yakutsk'),(292, 'Asia/Yangon'),(293, 'Asia/Yekaterinburg'),(294, 'Asia/Yerevan'),(295, 'Atlantic/Azores'),(296, 'Atlantic/Bermuda'),(297, 'Atlantic/Canary'),(298, 'Atlantic/Cape_Verde'),(299, 'Atlantic/Faroe'),(300, 'Atlantic/Madeira'),(301, 'Atlantic/Reykjavik'),(302, 'Atlantic/South_Georgia'),(303, 'Atlantic/St_Helena'),(304, 'Atlantic/Stanley'),(305, 'Australia/Adelaide'),(306, 'Australia/Brisbane'),(307, 'Australia/Broken_Hill'),(308, 'Australia/Darwin'),(309, 'Australia/Eucla'),(310, 'Australia/Hobart'),(311, 'Australia/Lindeman'),(312, 'Australia/Lord_Howe'),(313, 'Australia/Melbourne'),(314, 'Australia/Perth'),(315, 'Australia/Sydney'),(316, 'Europe/Amsterdam'),(317, 'Europe/Andorra'),(318, 'Europe/Astrakhan'),(319, 'Europe/Athens'),(320, 'Europe/Belgrade'),(321, 'Europe/Berlin'),(322, 'Europe/Bratislava'),(323, 'Europe/Brussels'),(324, 'Europe/Bucharest'),(325, 'Europe/Budapest'),(326, 'Europe/Busingen'),(327, 'Europe/Chisinau'),(328, 'Europe/Copenhagen'),(329, 'Europe/Dublin'),(330, 'Europe/Gibraltar'),(331, 'Europe/Guernsey'),(332, 'Europe/Helsinki'),(333, 'Europe/Isle_of_Man'),(334, 'Europe/Istanbul'),(335, 'Europe/Jersey'),(336, 'Europe/Kaliningrad'),(337, 'Europe/Kiev'),(338, 'Europe/Kirov'),(339, 'Europe/Lisbon'),(340, 'Europe/Ljubljana'),(341, 'Europe/London'),(342, 'Europe/Luxembourg'),(343, 'Europe/Madrid'),(344, 'Europe/Malta'),(345, 'Europe/Mariehamn'),(346, 'Europe/Minsk'),(347, 'Europe/Monaco'),(348, 'Europe/Moscow'),(349, 'Europe/Oslo'),(350, 'Europe/Paris'),(351, 'Europe/Podgorica'),(352, 'Europe/Prague'),(353, 'Europe/Riga'),(354, 'Europe/Rome'),(355, 'Europe/Samara'),(356, 'Europe/San_Marino'),(357, 'Europe/Sarajevo'),(358, 'Europe/Saratov'),(359, 'Europe/Simferopol'),(360, 'Europe/Skopje'),(361, 'Europe/Sofia'),(362, 'Europe/Stockholm'),(363, 'Europe/Tallinn'),(364, 'Europe/Tirane'),(365, 'Europe/Ulyanovsk'),(366, 'Europe/Uzhgorod'),(367, 'Europe/Vaduz'),(368, 'Europe/Vatican'),(369, 'Europe/Vienna'),(370, 'Europe/Vilnius'),(371, 'Europe/Volgograd'),(372, 'Europe/Warsaw'),(373, 'Europe/Zagreb'),(374, 'Europe/Zaporozhye'),(375, 'Europe/Zurich'),(376, 'Indian/Antananarivo'),(377, 'Indian/Chagos'),(378, 'Indian/Christmas'),(379, 'Indian/Cocos'),(380, 'Indian/Comoro'),(381, 'Indian/Kerguelen'),(382, 'Indian/Mahe'),(383, 'Indian/Maldives'),(384, 'Indian/Mauritius'),(385, 'Indian/Mayotte'),(386, 'Indian/Reunion'),(387, 'Pacific/Apia'),(388, 'Pacific/Auckland'),(389, 'Pacific/Bougainville'),(390, 'Pacific/Chatham'),(391, 'Pacific/Chuuk'),(392, 'Pacific/Easter'),(393, 'Pacific/Efate'),(394, 'Pacific/Fakaofo'),(395, 'Pacific/Fiji'),(396, 'Pacific/Funafuti'),(397, 'Pacific/Galapagos'),(398, 'Pacific/Gambier'),(399, 'Pacific/Guadalcanal'),(400, 'Pacific/Guam'),(401, 'Pacific/Honolulu'),(402, 'Pacific/Kanton'),(403, 'Pacific/Kiritimati'),(404, 'Pacific/Kosrae'),(405, 'Pacific/Kwajalein'),(406, 'Pacific/Majuro'),(407, 'Pacific/Marquesas'),(408, 'Pacific/Midway'),(409, 'Pacific/Nauru'),(410, 'Pacific/Niue'),(411, 'Pacific/Norfolk'),(412, 'Pacific/Noumea'),(413, 'Pacific/Pago_Pago'),(414, 'Pacific/Palau'),(415, 'Pacific/Pitcairn'),(416, 'Pacific/Pohnpei'),(417, 'Pacific/Port_Moresby'),(418, 'Pacific/Rarotonga'),(419, 'Pacific/Saipan'),(420, 'Pacific/Tahiti'),(421, 'Pacific/Tarawa'),(422, 'Pacific/Tongatapu'),(423, 'Pacific/Wake'),(424, 'Pacific/Wallis'),(425, 'UTC');
        ";
    }

    if ($q_version == 23) {
        return "";
    }

    if ($q_version == 24) {
        return "ALTER TABLE `tb_pos` CHANGE `pos_currency` `pos_currency` VARCHAR(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'USD';
        
        CREATE TABLE `tb_currency` (
        `currency_id` bigint NOT NULL AUTO_INCREMENT,
        `currency_code` varchar(3) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `currency_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        PRIMARY KEY (`currency_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;

        INSERT INTO `tb_currency` (`currency_code`, `currency_name`) VALUES
        ('USD', 'USD - United States dollar'),
        ('DOP', 'DOP - Dominican peso'),
        ('HTG', 'HTG - Haitian gourde'),
        ('EUR', 'EUR - Euro'),
        ('AED', 'AED - United Arab Emirates dirham'),
        ('AFN', 'AFN - Afghan afghani'),
        ('ALL', 'ALL - Albanian lek'),
        ('AMD', 'AMD - Armenian dram'),
        ('ANG', 'ANG - Netherlands Antillean guilder'),
        ('AOA', 'AOA - Angolan kwanza'),
        ('ARS', 'ARS - Argentine peso'),
        ('AUD', 'AUD - Australian dollar'),
        ('AWG', 'AWG - Aruban florin'),
        ('AZN', 'AZN - Azerbaijani manat'),
        ('BAM', 'BAM - Bosnia and Herzegovina convertible mark'),
        ('BBD', 'BBD - Barbadian dollar'),
        ('BDT', 'BDT - Bangladeshi taka'),
        ('BGN', 'BGN - Bulgarian lev'),
        ('BHD', 'BHD - Bahraini dinar'),
        ('BIF', 'BIF - Burundian franc'),
        ('BMD', 'BMD - Bermudian dollar'),
        ('BND', 'BND - Brunei dollar'),
        ('BOB', 'BOB - Bolivian boliviano'),
        ('BRL', 'BRL - Brazilian real'),
        ('BSD', 'BSD - Bahamian dollar'),
        ('BTN', 'BTN - Bhutanese ngultrum'),
        ('BWP', 'BWP - Botswana pula'),
        ('BYN', 'BYN - Belarusian ruble'),
        ('BZD', 'BZD - Belize dollar'),
        ('CAD', 'CAD - Canadian dollar'),
        ('CDF', 'CDF - Congolese franc'),
        ('CHF', 'CHF - Swiss franc'),
        ('CLP', 'CLP - Chilean peso'),
        ('CNY', 'CNY - Chinese yuan'),
        ('COP', 'COP - Colombian peso'),
        ('CRC', 'CRC - Costa Rican colón'),
        ('CUC', 'CUC - Cuban convertible peso'),
        ('CUP', 'CUP - Cuban peso'),
        ('CVE', 'CVE - Cape Verdean escudo'),
        ('CZK', 'CZK - Czech koruna'),
        ('DJF', 'DJF - Djiboutian franc'),
        ('DKK', 'DKK - Danish krone'),
        ('DZD', 'DZD - Algerian dinar'),
        ('EGP', 'EGP - Egyptian pound'),
        ('ERN', 'ERN - Eritrean nakfa'),
        ('ETB', 'ETB - Ethiopian birr'),
        ('FJD', 'FJD - Fijian dollar'),
        ('FKP', 'FKP - Falkland Islands pound'),
        ('GBP', 'GBP - British pound'),
        ('GEL', 'GEL - Georgian lari'),
        ('GGP', 'GGP - Guernsey pound'),
        ('GHS', 'GHS - Ghanaian cedi'),
        ('GIP', 'GIP - Gibraltar pound'),
        ('GMD', 'GMD - Gambian dalasi'),
        ('GNF', 'GNF - Guinean franc'),
        ('GTQ', 'GTQ - Guatemalan quetzal'),
        ('GYD', 'GYD - Guyanese dollar'),
        ('HKD', 'HKD - Hong Kong dollar'),
        ('HNL', 'HNL - Honduran lempira'),
        ('HRK', 'HRK - Croatian kuna'),
        ('HUF', 'HUF - Hungarian forint'),
        ('IDR', 'IDR - Indonesian rupiah'),
        ('ILS', 'ILS - Israeli new shekel'),
        ('IMP', 'IMP - Manx pound'),
        ('INR', 'INR - Indian rupee'),
        ('IQD', 'IQD - Iraqi dinar'),
        ('IRR', 'IRR - Iranian rial'),
        ('ISK', 'ISK - Icelandic króna'),
        ('JEP', 'JEP - Jersey pound'),
        ('JMD', 'JMD - Jamaican dollar'),
        ('JOD', 'JOD - Jordanian dinar'),
        ('JPY', 'JPY - Japanese yen'),
        ('KES', 'KES - Kenyan shilling'),
        ('KGS', 'KGS - Kyrgyzstani som'),
        ('KHR', 'KHR - Cambodian riel'),
        ('KID', 'KID - Kiribati dollar'),
        ('KMF', 'KMF - Comorian franc'),
        ('KPW', 'KPW - North Korean won'),
        ('KRW', 'KRW - South Korean won'),
        ('KWD', 'KWD - Kuwaiti dinar'),
        ('KYD', 'KYD - Cayman Islands dollar'),
        ('KZT', 'KZT - Kazakhstani tenge'),
        ('LAK', 'LAK - Lao kip'),
        ('LBP', 'LBP - Lebanese pound'),
        ('LKR', 'LKR - Sri Lankan rupee'),
        ('LRD', 'LRD - Liberian dollar'),
        ('LSL', 'LSL - Lesotho loti'),
        ('LYD', 'LYD - Libyan dinar'),
        ('MAD', 'MAD - Moroccan dirham'),
        ('MDL', 'MDL - Moldovan leu'),
        ('MGA', 'MGA - Malagasy ariary'),
        ('MKD', 'MKD - Macedonian denar'),
        ('MMK', 'MMK - Burmese kyat'),
        ('MNT', 'MNT - Mongolian tögrög'),
        ('MOP', 'MOP - Macanese pataca'),
        ('MRU', 'MRU - Mauritanian ouguiya'),
        ('MUR', 'MUR - Mauritian rupee'),
        ('MVR', 'MVR - Maldivian rufiyaa'),
        ('MWK', 'MWK - Malawian kwacha'),
        ('MXN', 'MXN - Mexican peso'),
        ('MYR', 'MYR - Malaysian ringgit'),
        ('MZN', 'MZN - Mozambican metical'),
        ('NAD', 'NAD - Namibian dollar'),
        ('NGN', 'NGN - Nigerian naira'),
        ('NIO', 'NIO - Nicaraguan córdoba'),
        ('NOK', 'NOK - Norwegian krone'),
        ('NPR', 'NPR - Nepalese rupee'),
        ('NZD', 'NZD - New Zealand dollar'),
        ('OMR', 'OMR - Omani rial'),
        ('PAB', 'PAB - Panamanian balboa'),
        ('PEN', 'PEN - Peruvian sol'),
        ('PGK', 'PGK - Papua New Guinean'),
        ('PHP', 'PHP - Philippine peso'),
        ('PKR', 'PKR - Pakistani rupee'),
        ('PLN', 'PLN - Polish złoty'),
        ('PRB', 'PRB - Transnistrian ruble'),
        ('PYG', 'PYG - Paraguayan guaraní'),
        ('QAR', 'QAR - Qatari riyal'),
        ('RON', 'RON - Romanian leu'),
        ('RSD', 'RSD - Serbian dinar'),
        ('RUB', 'RUB - Russian ruble'),
        ('RWF', 'RWF - Rwandan franc'),
        ('SAR', 'SAR - Saudi riyal'),
        ('SEK', 'SEK - Swedish krona'),
        ('SGD', 'SGD - Singapore dollar'),
        ('SHP', 'SHP - Saint Helena pound'),
        ('SLL', 'SLL - Sierra Leonean leone'),
        ('SLS', 'SLS - Somaliland shilling'),
        ('SOS', 'SOS - Somali shilling'),
        ('SRD', 'SRD - Surinamese dollar'),
        ('SSP', 'SSP - South Sudanese pound'),
        ('STN', 'STN - São Tomé and Príncipe'),
        ('SYP', 'SYP - Syrian pound'),
        ('SZL', 'SZL - Swazi lilangeni'),
        ('THB', 'THB - Thai baht'),
        ('TJS', 'TJS - Tajikistani somoni'),
        ('TMT', 'TMT - Turkmenistan manat'),
        ('TND', 'TND - Tunisian dinar'),
        ('TOP', 'TOP - Tongan paʻanga'),
        ('TRY', 'TRY - Turkish lira'),
        ('TTD', 'TTD - Trinidad and Tobago dollar'),
        ('TVD', 'TVD - Tuvaluan dollar'),
        ('TWD', 'TWD - New Taiwan dollar'),
        ('TZS', 'TZS - Tanzanian shilling'),
        ('UAH', 'UAH - Ukrainian hryvnia'),
        ('UGX', 'UGX - Ugandan shilling'),
        ('UYU', 'UYU - Uruguayan peso'),
        ('UZS', 'UZS - Uzbekistani soʻm'),
        ('VES', 'VES - Venezuelan bolívar soberano'),
        ('VND', 'VND - Vietnamese đồng'),
        ('VUV', 'VUV - Vanuatu vatu'),
        ('WST', 'WST - Samoan tālā'),
        ('XAF', 'XAF - Central African CFA franc'),
        ('XCD', 'XCD - Eastern Caribbean dollar'),
        ('XOF', 'XOF - West African CFA franc'),
        ('XPF', 'XPF - CFP franc'),
        ('ZAR', 'ZAR - South African rand'),
        ('ZMW', 'ZMW - Zambian kwacha'),
        ('ZWB', 'ZWB - Zimbabwean bonds');
        ";
    }

    if ($q_version == 25) {
        return "ALTER TABLE `tb_payments_details` ADD `pay_det_previous_debt` DECIMAL(17,2) NOT NULL DEFAULT '0.00' AFTER `pay_det_payment_type`;";
    }

    if ($q_version == 26) {
        return "ALTER TABLE `tb_pos` CHANGE `pos_code` `pos_code` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_pos` ADD `pos_show_menu_usd_amount` VARCHAR(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Off' AFTER `pos_party_mode`;
        ALTER TABLE `tb_pos` ADD `pos_show_stock_menu` VARCHAR(5) NOT NULL DEFAULT 'Off' AFTER `pos_show_menu_usd_amount`;
        ALTER TABLE `tb_pos` ADD `pos_menu_access` VARCHAR(5) NOT NULL DEFAULT 'Off' AFTER `pos_lang`;";
    }

    if ($q_version == 27) {
        return "ALTER TABLE `tb_sales_details` CHANGE `sale_det_pro_qty` `sale_det_pro_qty` DECIMAL(17,2) NULL DEFAULT NULL;ALTER TABLE `tb_purchases_details` CHANGE `pur_det_pro_qty` `pur_det_pro_qty` DECIMAL(17,2) NULL DEFAULT NULL;ALTER TABLE `tb_stock_adjustments` CHANGE `adjust_quantity` `adjust_quantity` DECIMAL(17,2) NULL DEFAULT NULL;ALTER TABLE `tb_products` ADD `pro_sale_measure` VARCHAR(15) NOT NULL DEFAULT 'Unit' AFTER `pro_type`;";
    }

    if ($q_version == 28) {
        return "ALTER TABLE `tb_products` CHANGE `pro_code` `pro_code` VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL;";
    }

    if ($q_version == 29) {
        return "ALTER TABLE `tb_enterprises` ADD `ent_folder_name` VARCHAR(100) NULL DEFAULT NULL AFTER `ent_show_notification`;";
    }

    if ($q_version == 30) {
        return "ALTER TABLE `tb_sales` ADD `sale_type_tax_percent` DECIMAL(17,2) NOT NULL DEFAULT '0.00' AFTER `sale_cost_delivery`, ADD `sale_type_tax_value` DECIMAL(17,2) NOT NULL DEFAULT '0.00' AFTER `sale_type_tax_percent`;        
        CREATE TABLE `tb_sale_type` (
        `sale_type_id` int NOT NULL AUTO_INCREMENT,
        `sale_type_ent_id` int DEFAULT NULL,
        `sale_type_pos_id` int DEFAULT NULL,
        `sale_type_created_by` int DEFAULT NULL,
        `sale_type_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `sale_type_tax` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Yes',
        `sale_type_tax_law` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'No',
        `sale_type_add_tax` decimal(17,2) DEFAULT '0.00',
        `sale_type_status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Enable',
        `sale_type_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`sale_type_id`) USING BTREE,
        KEY `sale_type_ent_id` (`sale_type_ent_id`) USING BTREE,
        KEY `sale_type_pos_id` (`sale_type_pos_id`) USING BTREE,
        KEY `sale_type_name` (`sale_type_name`) USING BTREE,
        KEY `sale_type_created_by` (`sale_type_created_by`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        ";
    }

    if ($q_version == 31) {
        return "ALTER TABLE `tb_enterprises`
        DROP `ent_country`,
        DROP `ent_state`,
        DROP `ent_city`,
        DROP `ent_timezone`,
        DROP `ent_address`,
        DROP `ent_phone`,
        DROP `ent_phone2`,
        DROP `ent_discount_type`,
        DROP `ent_usd_exchange_rate`,
        DROP `ent_tax`,
        DROP `ent_tax_law`,
        DROP `ent_card_tax`,
        DROP `ent_ticket_footer`;
        ";
    }

    if ($q_version == 32) {
        return "ALTER TABLE `tb_pos` ADD `pos_cash_back_status` VARCHAR(5) NULL DEFAULT 'Off' AFTER `pos_menu_access`, ADD `pos_cash_back_percentage` DECIMAL(17,2) NULL DEFAULT '0.00' AFTER `pos_cash_back_status`;
        ALTER TABLE `tb_pos` ADD INDEX `pos_cash_back_status` (`pos_cash_back_status`);
        ALTER TABLE `tb_payments_details` ADD `pay_det_cashback` DECIMAL(17,2) NULL DEFAULT '0.00' AFTER `pay_det_change`, ADD `pay_det_cashback_status` VARCHAR(15) NULL DEFAULT NULL AFTER `pay_det_cashback`;
        INSERT INTO `tb_payments_type` (`pay_type_id`, `pay_type_name`, `pay_type_description`, `pay_type_status`) VALUES ('CASHBACK', 'CASHBACK', 'Enable');
        ALTER TABLE `tb_enterprises` ADD `ent_contract_status` VARCHAR(15) NULL DEFAULT 'Active' AFTER `ent_access`;
        ALTER TABLE `tb_pos` ADD `pos_cash_back_availability_days` INT NULL DEFAULT '8' AFTER `pos_cash_back_percentage`, ADD `pos_cash_back_expiration_days` INT NULL DEFAULT '180' AFTER `pos_cash_back_availability_days`;";
    }

    if ($q_version == 33) {
        return "ALTER TABLE `tb_enterprises` CHANGE `ent_access` `ent_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_enterprises` CHANGE `ent_url` `ent_website_url` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_enterprises` CHANGE `ent_contract_status` `ent_contract_status` VARCHAR(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_pos` CHANGE `pos_access` `pos_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';ALTER TABLE `tb_stock_adjustments` CHANGE `adjust_status` `adjust_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_purchases` CHANGE `pur_status` `pur_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_purchases_details` CHANGE `pur_det_status` `pur_det_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_sales` CHANGE `sale_status` `sale_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_sales_details` CHANGE `sale_det_status` `sale_det_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';ALTER TABLE `tb_users` CHANGE `user_access` `user_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_products` CHANGE `pro_status` `pro_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_categories` CHANGE `cat_access` `cat_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_customers` CHANGE `cus_status` `cus_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_expenses` CHANGE `exp_status` `exp_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';   
        ALTER TABLE `tb_expenses_details` CHANGE `exp_det_status` `exp_det_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_fiscal_receipt_list` CHANGE `fis_rec_status` `fis_rec_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_fiscal_receipt_entry` CHANGE `fiscal_entry_status` `fiscal_entry_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_fiscal_receipt_transactions` CHANGE `fiscal_status` `fiscal_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_orders_request` CHANGE `ord_det_cancel_status` `ord_det_cancel_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_payments_details` CHANGE `pay_det_status` `pay_det_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_tables` CHANGE `table_access` `table_status` VARCHAR(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'Enabled';

        ALTER TABLE `tb_pos` ADD `pos_zip_code` VARCHAR(15) NULL DEFAULT NULL AFTER `pos_state`;
        ALTER TABLE `tb_pos` CHANGE `pos_party_mode` `pos_festive_mode` VARCHAR(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Off';
        ALTER TABLE `tb_pos` CHANGE `pos_timezone` `pos_time_zone` VARCHAR(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'America/New_York';
        ALTER TABLE `tb_pos` CHANGE `pos_tax_law` `pos_legal_tipping` DECIMAL(17,2) NULL DEFAULT '0.00';
        ALTER TABLE `tb_users` CHANGE `user_language` `user_language` VARCHAR(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT 'en';
        ALTER TABLE `tb_users` CHANGE `user_image` `user_image` TEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL;
        RENAME TABLE `tb_currency` TO `tb_currencies`;
        ALTER TABLE `tb_fiscal_receipt_entry` ADD `fiscal_entry_from` INT NULL DEFAULT '0' AFTER `fiscal_entry_description`, ADD `fiscal_entry_to` INT NULL DEFAULT '0' AFTER `fiscal_entry_from`;
        ALTER TABLE `tb_fiscal_receipt_transactions` ADD `fiscal_fis_rec_id` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `fiscal_ent_id`;
        ALTER TABLE `tb_fiscal_receipt_transactions` ADD INDEX `fiscal_fis_rec_id` (`fiscal_fis_rec_id`);
        ALTER TABLE `tb_products` ADD INDEX `pro_status` (`pro_status`);
        UPDATE tb_fiscal_receipt_transactions SET fiscal_fis_rec_id = 1 WHERE fiscal_ent_id = 1 and fiscal_type = 'B01';
        UPDATE tb_fiscal_receipt_transactions SET fiscal_fis_rec_id = 2 WHERE fiscal_ent_id = 1 and fiscal_type = 'B02';
        UPDATE tb_fiscal_receipt_transactions SET fiscal_fis_rec_id = 4 WHERE fiscal_ent_id = 8 and fiscal_type = 'B01';
        UPDATE tb_fiscal_receipt_transactions SET fiscal_fis_rec_id = 5 WHERE fiscal_ent_id = 8 and fiscal_type = 'B02';
        ALTER TABLE `tb_categories` CHANGE `cat_description` `cat_name` VARCHAR(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NOT NULL;
        ALTER TABLE `tb_stock_adjustments` CHANGE `adjust_datetime` `adjust_datetime` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP;
        
        UPDATE `tb_enterprises` SET `ent_contract_status` = 'Enabled' WHERE `ent_contract_status` = 'Active';
        UPDATE `tb_enterprises` SET `ent_status` = 'Enabled' WHERE `ent_status` = 'Active';
        UPDATE `tb_pos` SET `pos_status` = 'Enabled' WHERE `pos_status` = 'Active';
        UPDATE `tb_users` SET `user_status` = 'Enabled' WHERE `user_status` = 'Active';
        UPDATE `tb_users` SET user_profile = 'Cashier' WHERE user_profile = 'Inventory Manager';
        UPDATE tb_products SET pro_status = 'Enabled' WHERE pro_status = 'Active';
        UPDATE tb_stock_adjustments SET adjust_status = 'Enabled' WHERE adjust_status = 'Active';
        UPDATE tb_purchases SET pur_status = 'Enabled' WHERE pur_status = 'Active';
        UPDATE tb_purchases_details SET pur_det_status = 'Enabled' WHERE pur_det_status = 'Active';
        UPDATE tb_sales SET sale_status = 'Enabled' WHERE sale_status = 'Active';
        UPDATE tb_sales_details SET sale_det_status = 'Enabled' WHERE sale_det_status = 'Active';
        UPDATE tb_customers SET cus_status = 'Enabled' WHERE cus_status = 'Active';
        UPDATE tb_expenses SET exp_status = 'Enabled' WHERE exp_status = 'Active';
        UPDATE tb_expenses_details SET exp_det_status = 'Enabled' WHERE exp_det_status = 'Active';
        UPDATE tb_fiscal_receipt_list SET fis_rec_status = 'Enabled' WHERE fis_rec_status = 'Active';
        UPDATE tb_fiscal_receipt_entry SET fiscal_entry_status = 'Enabled' WHERE fiscal_entry_status = 'Active';
        UPDATE tb_fiscal_receipt_transactions SET fiscal_status = 'Enabled' WHERE fiscal_status = 'Active';
        UPDATE tb_orders_request SET ord_det_cancel_status = 'Enabled' WHERE ord_det_cancel_status = 'Active';
        UPDATE tb_payments_details SET pay_det_status = 'Enabled' WHERE pay_det_status = 'Active';
        UPDATE tb_tables SET table_status = 'Enabled' WHERE table_status = 'Active';
        UPDATE tb_payments_type SET pay_type_status = 'Enabled' WHERE pay_type_status = 'Enable';
        UPDATE tb_sale_type SET sale_type_status = 'Enabled' WHERE sale_type_status = 'Enable';
        UPDATE tb_categories SET cat_status = 'Enabled' WHERE cat_status = 'Enable';
        ";
    }

    if ($q_version == 34) {
        return "ALTER TABLE `tb_currencies` ADD `currency_symbol` VARCHAR(10) NULL DEFAULT NULL AFTER `currency_code`;
        TRUNCATE TABLE `tb_currencies`;
        INSERT INTO `tb_currencies` (`currency_code`, `currency_symbol`, `currency_name`) VALUES 
        ('USD', '$', 'United States dollar'),
        ('DOP', 'RD$', 'Dominican peso'),
        ('HTG', 'G', 'Haitian gourde'),
        ('AED', 'د.إ', 'United Arab Emirates dirham'),
        ('AFN', 'Afs', 'Afghan afghani'),
        ('ALL', 'L', 'Albanian lek'),
        ('AMD', 'դր.', 'Armenian dram'),
        ('ANG', 'ƒ', 'Netherlands Antillean guilder'),
        ('AOA', 'Kz', 'Angolan kwanza'),
        ('ARS', '$', 'Argentine peso'),
        ('AUD', '$', 'Australian dollar'),
        ('AWG', 'Afl.', 'Aruban florin'),
        ('AZN', 'm', 'Azerbaijani manat'),
        ('BAM', 'KM', 'Bosnia and Herzegovina convertible mark'),
        ('BBD', 'Bds$', 'Barbados dollar'),
        ('BDT', '৳', 'Bangladeshi taka'),
        ('BGN', 'лв', 'Bulgarian lev'),
        ('BHD', 'BD', 'Bahraini dinar'),
        ('BIF', 'FBu', 'Burundian franc'),
        ('BMD', 'BD$', 'Bermudian dollar'),
        ('BND', '$', 'Brunei dollar'),
        ('BOB', 'Bs.', 'Boliviano'),
        ('BRL', 'R$', 'Brazilian real'),
        ('BSD', 'B$', 'Bahamian dollar'),
        ('BTN', 'Nu.', 'Bhutanese ngultrum'),
        ('BWP', 'P', 'Botswana pula'),
        ('BYN', 'Br', 'Belarusian ruble'),
        ('BYR', 'BR', 'Belarusian ruble'),
        ('BZD', 'BZ$', 'Belize dollar'),
        ('CAD', '$', 'Canadian dollar'),
        ('CDF', 'Fr', 'Congolese franc'),
        ('CHF', 'CHF', 'Swiss franc'),
        ('CLF', '$', 'Unidad de Fomento'),
        ('CLP', '$', 'Chilean peso'),
        ('CNH', '¥', 'Chinese yuan - Offshore'),
        ('CNY', '¥', 'Chinese yuan'),
        ('COP', '$', 'Colombian peso'),
        ('COU', '$', 'Unidad de Valor Real'),
        ('CRC', '₡', 'Costa Rican colón'),
        ('CUC', '$', 'Cuban convertible peso'),
        ('CUP', '$', 'Cuban peso'),
        ('CVE', '$', 'Cape Verdean escudo'),
        ('CZK', 'Kč', 'Czech koruna'),
        ('DJF', 'Fdj', 'Djiboutian franc'),
        ('DKK', 'kr', 'Danish krone'),
        ('DZD', 'DA', 'Algerian dinar'),
        ('EGP', 'LE', 'Egyptian pound'),
        ('ERN', 'Nfk', 'Eritrean nakfa'),
        ('ETB', 'Br', 'Ethiopian birr'),
        ('EUR', '€', 'Euro'),
        ('FJD', 'FJ$', 'Fiji dollar'),
        ('FKP', '£', 'Falkland Islands pound'),
        ('GBP', '£', 'Pound sterling'),
        ('GEL', 'ლ', 'Georgian lari'),
        ('GHS', 'GH¢', 'Ghanaian cedi'),
        ('GIP', '£', 'Gibraltar pound'),
        ('GMD', 'D', 'Gambian dalasi'),
        ('GNF', 'FG', 'Guinean franc'),
        ('GTQ', 'Q', 'Guatemalan quetzal'),
        ('GYD', '$', 'Guyanese dollar'),
        ('HKD', '$', 'Hong Kong dollar'),
        ('HNL', 'L', 'Honduran lempira'),
        ('HRK', 'kn', 'Croatian kuna'),
        ('HUF', 'Ft', 'Hungarian forint'),
        ('IDR', 'Rp', 'Indonesian rupiah'),
        ('ILS', '₪', 'Israeli new shekel'),
        ('INR', '₹', 'Indian rupee'),
        ('IQD', 'ع.د', 'Iraqi dinar'),
        ('IRR', '﷼', 'Iranian rial'),
        ('ISK', 'kr', 'Icelandic króna'),
        ('JMD', '$', 'Jamaican dollar'),
        ('JOD', 'د.ا', 'Jordanian dinar'),
        ('JPY', '¥', 'Japanese yen'),
        ('KES', 'KSh', 'Kenyan shilling'),
        ('KGS', 'лв', 'Kyrgyzstani som'),
        ('KHR', '៛', 'Cambodian riel'),
        ('KMF', 'CF', 'Comorian franc'),
        ('KPW', '₩', 'North Korean won'),
        ('KRW', '₩', 'South Korean won'),
        ('KWD', 'د.ك', 'Kuwaiti dinar'),
        ('KYD', '$', 'Cayman Islands dollar'),
        ('KZT', '₸', 'Kazakhstani tenge'),
        ('LAK', '₭', 'Lao kip'),
        ('LBP', 'ل.ل', 'Lebanese pound'),
        ('LKR', 'Rs', 'Sri Lankan rupee'),
        ('LRD', 'L$', 'Liberian dollar'),
        ('LSL', 'M', 'Lesotho loti'),
        ('LTL', 'Lt', 'Lithuanian litas'),
        ('LVL', 'Ls', 'Latvian lats'),
        ('LYD', 'ل.د', 'Libyan dinar'),
        ('MAD', 'DH', 'Moroccan dirham'),
        ('MDL', 'L', 'Moldovan leu'),
        ('MGA', 'Ar', 'Malagasy ariary'),
        ('MKD', 'ден', 'Macedonian denar'),
        ('MMK', 'K', 'Myanmar kyat'),
        ('MNT', '₮', 'Mongolian tögrög'),
        ('MOP', 'MOP$', 'Macanese pataca'),
        ('MRO', 'UM', 'Mauritanian ouguiya (old)'),
        ('MRU', 'UM', 'Mauritanian ouguiya'),
        ('MUR', 'Rs', 'Mauritian rupee'),
        ('MVR', '.ރ', 'Maldivian rufiyaa'),
        ('MWK', 'MK', 'Malawian kwacha'),
        ('MXN', '$', 'Mexican peso'),
        ('MYR', 'RM', 'Malaysian ringgit'),
        ('MZN', 'MT', 'Mozambican metical'),
        ('NAD', '$', 'Namibian dollar'),
        ('NGN', '₦', 'Nigerian naira'),
        ('NIO', 'C$', 'Nicaraguan córdoba'),
        ('NOK', 'kr', 'Norwegian krone'),
        ('NPR', '₨', 'Nepalese rupee'),
        ('NZD', '$', 'New Zealand dollar'),
        ('OMR', 'ر.ع.', 'Omani rial'),
        ('PAB', 'B/.', 'Panamanian balboa'),
        ('PEN', 'S/', 'Peruvian sol'),
        ('PGK', 'K', 'Papua New Guinean kina'),
        ('PHP', '₱', 'Philippine peso'),
        ('PKR', 'Rs.', 'Pakistani rupee'),
        ('PLN', 'zł', 'Polish złoty'),
        ('PYG', '₲', 'Paraguayan guaraní'),
        ('QAR', 'QR', 'Qatari riyal'),
        ('RON', 'lei', 'Romanian leu'),
        ('RSD', 'din.', 'Serbian dinar'),
        ('RUB', 'руб', 'Russian ruble'),
        ('RWF', 'RF', 'Rwandan franc'),
        ('SAR', 'SR', 'Saudi riyal'),
        ('SBD', 'SI$', 'Solomon Islands dollar'),
        ('SCR', 'SR', 'Seychellois rupee'),
        ('SDG', 'ج.س.', 'Sudanese pound'),
        ('SEK', 'kr', 'Swedish krona'),
        ('SGD', 'S$', 'Singapore dollar'),
        ('SHP', '£', 'Saint Helena pound'),
        ('SLE', 'Le', 'Sierra Leonean leone'),
        ('SLL', 'Le', 'Sierra Leonean leone'),
        ('SOS', 'Sh.', 'Somali shilling'),
        ('SRD', '$', 'Surinamese dollar'),
        ('SSP', '£', 'South Sudanese pound'),
        ('STD', 'Db', 'São Tomé and Príncipe dobra'),
        ('STN', 'Db', 'São Tomé and Príncipe dobra'),
        ('SVC', '¢', 'Salvadoran Colon'),
        ('SYP', '£', 'Syrian pound'),
        ('SZL', 'E', 'Swazi lilangeni'),
        ('THB', '฿', 'Thai baht'),
        ('TJS', 'TJS', 'Tajikistani somoni'),
        ('TMT', 'T', 'Turkmenistan manat'),
        ('TND', 'DT', 'Tunisian dinar'),
        ('TOP', 'T$', 'Tongan paʻanga'),
        ('TRY', '₺', 'Turkish lira'),
        ('TTD', '$', 'Trinidad and Tobago dollar'),
        ('TWD', 'NT$', 'New Taiwan dollar'),
        ('TZS', 'TSh', 'Tanzanian shilling'),
        ('UAH', '₴', 'Ukraine hryvnia'),
        ('UGX', 'USh', 'Ugandan shilling'),
        ('USD', '$', 'United States dollar'),
        ('UYI', '$', 'Uruguay Peso en Unidades Indexadas'),
        ('UYU', '$', 'Uruguayan peso'),
        ('UYW', '$', 'Unidad previsional'),
        ('UZS', 'лв', 'Uzbekistan som'),
        ('VEF', 'Bs.F', 'Venezuelan bolívar fuerte'),
        ('VES', 'Bs', 'Venezuelan bolívar soberano'),
        ('VND', '₫', 'Vietnamese đồng'),
        ('VUV', 'VT', 'Vanuatu vatu'),
        ('WST', 'WS$', 'Samoan tālā'),
        ('XAF', 'FCFA', 'CFA franc BEAC'),
        ('XCD', '$', 'East Caribbean dollar'),
        ('XOF', 'CFA', 'CFA franc BCEAO'),
        ('XPF', 'XPF', 'CFP franc'),
        ('YER', '﷼', 'Yemeni rial'),
        ('ZAR', 'R', 'South African rand'),
        ('ZIG', 'ZiG', 'Zimbabwe Gold'),
        ('ZMW', 'ZK', 'Zambian kwacha');
        UPDATE `tb_currencies` SET currency_name = CONCAT(currency_code,' - ',currency_name);
        ";
    }

    if ($q_version == 35) {
        return "CREATE TABLE `tb_providers` (
        `prov_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `prov_ent_id` bigint unsigned DEFAULT NULL,
        `prov_pos_id` bigint unsigned DEFAULT NULL,
        `prov_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_address` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci,
        `prov_city` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_state` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_zip_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_country` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_phone` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_phone2` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_email` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_fiscal_number` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `prov_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NOT NULL DEFAULT 'Enabled',
        `prov_created_by` bigint unsigned DEFAULT NULL,
        `prov_created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`prov_id`) USING BTREE,
        KEY `prov_ent_id` (`prov_ent_id`) USING BTREE,
        KEY `prov_pos_id` (`prov_pos_id`) USING BTREE,
        KEY `prov_status` (`prov_status`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        ALTER TABLE `tb_purchases` ADD `pur_provider_id` BIGINT NULL DEFAULT NULL AFTER `pur_pos_id`, ADD INDEX `pur_provider_id` (`pur_provider_id`);
        ALTER TABLE `tb_purchases` ADD `pur_edited_by` BIGINT NOT NULL AFTER `pur_created_at`, ADD `pur_edited_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `pur_edited_by`, ADD INDEX `pur_edited_by` (`pur_edited_by`);
        ALTER TABLE `tb_purchases_details` CHANGE `pur_cur_total` `pur_det_total` DECIMAL(17,2) NULL DEFAULT '0.00';
        ALTER TABLE `tb_stock_adjustments` ADD INDEX `adjust_status` (`adjust_status`);
        ALTER TABLE `tb_stock_adjustments` ADD INDEX `adjust_type` (`adjust_type`);
        ALTER TABLE `tb_sales_details` ADD INDEX `sale_det_status` (`sale_det_status`);
        ALTER TABLE `tb_purchases_details` ADD INDEX `pur_det_status` (`pur_det_status`);
        ALTER TABLE `tb_payments_details` ADD INDEX `pay_det_cus_id` (`pay_det_cus_id`);
        ALTER TABLE `tb_sales` CHANGE `sale_debt_reset_reason` `sale_debt_reset_reason` TEXT CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        UPDATE tb_purchases SET pur_provider_id = 1;
        ALTER TABLE `tb_pos` ADD `pos_day_start_time` TIME NOT NULL DEFAULT '07:00:00' AFTER `pos_cash_back_expiration_days`, ADD `pos_day_end_time` TIME NOT NULL DEFAULT '06:59:59' AFTER `pos_day_start_time`;
        UPDATE `tb_purchases` SET pur_status = 'Disabled' WHERE pur_status = 'Canceled';
        UPDATE `tb_sales` SET sale_status = 'Disabled' WHERE sale_status = 'Canceled';
        UPDATE `tb_sales_details` SET sale_det_status = 'Disabled' WHERE sale_det_status = 'Canceled';
        UPDATE `tb_orders_request` SET ord_det_status = 'Disabled' WHERE ord_det_status = 'Canceled';
        UPDATE `tb_payments_details` SET pay_det_status = 'Disabled' WHERE pay_det_status = 'Canceled';
        UPDATE `tb_fiscal_receipt_transactions` SET fiscal_status = 'Disabled' WHERE fiscal_status = 'Canceled';
        ALTER TABLE `tb_users` ADD `user_branch_access` JSON NULL DEFAULT NULL AFTER `user_profile`, ADD `user_system_access` JSON NULL DEFAULT NULL AFTER `user_branch_access`;
        UPDATE `tb_users` SET user_branch_access = '{}', user_system_access = '{}' WHERE user_branch_access IS NULL;
        ALTER TABLE `tb_pos` DROP `pos_discount_format`;
        UPDATE tb_pos SET pos_business_category = 'Nightclub' WHERE pos_business_category = 'Bar/Lounge/Club';
        UPDATE tb_payments_type SET pay_type_name = 'CREDIT CARD' WHERE pay_type_name = 'CARD';
        UPDATE tb_payments_details SET pay_det_payment_type = 'CREDIT CARD' WHERE pay_det_payment_type = 'CARD';
        ALTER TABLE `tb_payments_type` DROP `pay_type_description`;
        ALTER TABLE `tb_payments_type` ADD `pay_type_ent_id` INT NULL DEFAULT NULL AFTER `pay_type_id`, ADD `pay_type_pos_id` INT NULL DEFAULT NULL AFTER `pay_type_ent_id`, ADD `pay_type_created_by` INT NULL DEFAULT NULL AFTER `pay_type_pos_id`, ADD INDEX `pay_type_ent_id` (`pay_type_ent_id`), ADD INDEX `pay_type_pos_id` (`pay_type_pos_id`), ADD INDEX `pay_type_created_by` (`pay_type_created_by`), ADD INDEX `pay_type_status` (`pay_type_status`);
        ALTER TABLE `tb_payments_type` CHANGE `pay_type_status` `pay_type_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_payments_type` ADD `pay_type_created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER `pay_type_status`;
        TRUNCATE TABLE `tb_payments_type`;
        ALTER TABLE `tb_payments_details` ADD INDEX `pay_det_ent_id` (`pay_det_ent_id`);
        ALTER TABLE `tb_users` CHANGE `user_phone` `user_phone` VARCHAR(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_providers` CHANGE `prov_phone` `prov_phone` VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL, CHANGE `prov_phone2` `prov_phone2` VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_pos` CHANGE `pos_phone` `pos_phone` VARCHAR(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL, CHANGE `pos_phone2` `pos_phone2` VARCHAR(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_customers` CHANGE `cus_phone` `cus_phone` VARCHAR(30) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        ALTER TABLE `tb_pos` ADD `pos_show` VARCHAR(5) NOT NULL DEFAULT 'On' AFTER `pos_status`, ADD INDEX `pos_show` (`pos_show`);
        ALTER TABLE `tb_payments_details` ADD `pay_det_note` LONGTEXT NULL DEFAULT NULL AFTER `pay_det_cashback_status`;        
        UPDATE tb_users SET user_profile = 'Owner' WHERE user_profile = 'Super Admin';
        UPDATE tb_users SET user_profile = 'Manager' WHERE user_profile = 'Admin';
        ALTER TABLE `tb_sale_type` CHANGE `sale_type_status` `sale_type_status` VARCHAR(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ";
    }

    // if ($q_version == 36) {
    //     return "CREATE TABLE `tb_user_permissions` (
    //     `perm_id` bigint unsigned NOT NULL AUTO_INCREMENT,
    //     `perm_user_id` bigint unsigned DEFAULT NULL,
    //     `perm_name` VARCHAR(100) NOT NULL,
    //     `perm_create` BOOLEAN DEFAULT FALSE,
    //     `perm_edit` BOOLEAN DEFAULT FALSE,
    //     `perm_list` BOOLEAN DEFAULT FALSE,
    //     `perm_status` BOOLEAN DEFAULT FALSE,
    //     `perm_cancel_delete` BOOLEAN DEFAULT FALSE,
    //     `perm_print` BOOLEAN DEFAULT FALSE,
    //     `perm_pos_festive` BOOLEAN DEFAULT FALSE,
    //     `perm_add_request_tax_receipt` BOOLEAN DEFAULT FALSE,
    //     `perm_view_logs_history` BOOLEAN DEFAULT FALSE,
    //     `perm_reset` BOOLEAN DEFAULT FALSE,
    //     PRIMARY KEY (`perm_id`) USING BTREE,
    //     KEY `perm_user_id` (`perm_user_id`) USING BTREE
    //     ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
    //     ";
    // }

    if ($q_version == 36) {
        return "CREATE TABLE `tb_invoices` (
        `inv_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `inv_ent_id` bigint unsigned DEFAULT NULL,
        `inv_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `inv_date` date DEFAULT NULL,
        `inv_due_date` date DEFAULT NULL,
        `inv_subtotal` DECIMAL(17,2) DEFAULT '0.00',
        `inv_discount_percent` DECIMAL(17,2) DEFAULT '0.00',
        `inv_discount_amount` DECIMAL(17,2) DEFAULT '0.00',
        `inv_amount` DECIMAL(17,2) DEFAULT '0.00',
        `inv_tax_percent` DECIMAL(17,2) DEFAULT '0.00',
        `inv_tax_amount` DECIMAL(17,2) DEFAULT '0.00',
        `inv_total_amount` DECIMAL(17,2) DEFAULT '0.00',
        `inv_debt` DECIMAL(17,2) DEFAULT '0.00',
        `inv_note` text DEFAULT NULL,
        `inv_terms` text DEFAULT NULL,
        `inv_status` ENUM('Pending', 'Paid', 'Overdue', 'Cancelled') DEFAULT 'Pending',
        `inv_created_by` bigint unsigned DEFAULT NULL,
        `inv_created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
        `inv_updated_by` bigint unsigned DEFAULT NULL,
        `inv_updated_at` timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        PRIMARY KEY (`inv_id`) USING BTREE,
        KEY `inv_ent_id` (`inv_ent_id`) USING BTREE,
        KEY `inv_code` (`inv_code`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        CREATE TABLE `tb_invoices_items` (
        `inv_item_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `inv_item_inv_id` bigint unsigned DEFAULT NULL,
        `inv_item_ent_id` bigint unsigned DEFAULT NULL,
        `inv_item_inv_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `inv_item_description` text DEFAULT NULL,
        `inv_item_quantity` INT NOT NULL,
        `inv_item_unit_price` DECIMAL(17,2) DEFAULT '0.00',
        `inv_item_total` DECIMAL(17,2) DEFAULT '0.00',
        PRIMARY KEY (`inv_item_id`) USING BTREE,
        KEY `inv_item_inv_id` (`inv_item_inv_id`) USING BTREE,
        KEY `inv_item_ent_id` (`inv_item_ent_id`) USING BTREE,
        KEY `inv_item_inv_code` (`inv_item_inv_code`) USING BTREE,
        CONSTRAINT `FK_invoices_details_1` FOREIGN KEY (`inv_item_inv_id`) REFERENCES `tb_invoices` (`inv_id`) ON DELETE CASCADE ON UPDATE RESTRICT
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        CREATE TABLE `tb_invoices_payments` (
        `pay_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `pay_inv_id` bigint unsigned DEFAULT NULL,
        `pay_inv_ent_id` bigint unsigned DEFAULT NULL,
        `pay_inv_code` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `pay_inv_date` date DEFAULT NULL,
        `pay_inv_method` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Cash',
        `pay_inv_amount` DECIMAL(17,2) DEFAULT '0.00',
        `pay_inv_note` text DEFAULT NULL,
        `pay_inv_status` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Enabled',
        `pay_inv_created_by` bigint unsigned DEFAULT NULL,
        `pay_inv_created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`pay_id`) USING BTREE,
        KEY `pay_inv_id` (`pay_inv_id`) USING BTREE,
        KEY `pay_inv_ent_id` (`pay_inv_ent_id`) USING BTREE,
        KEY `pay_inv_code` (`pay_inv_code`) USING BTREE,
        KEY `pay_inv_date` (`pay_inv_date`) USING BTREE,
        KEY `pay_inv_method` (`pay_inv_method`) USING BTREE,
        KEY `pay_inv_status` (`pay_inv_status`) USING BTREE,
        KEY `pay_inv_created_by` (`pay_inv_created_by`) USING BTREE,
        CONSTRAINT `FK_invoices_payments_invails_1` FOREIGN KEY (`pay_inv_id`) REFERENCES `tb_invoices` (`inv_id`) ON DELETE CASCADE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        ";
    }

    if ($q_version == 37) {
        return "UPDATE `tb_sale_type` SET sale_type_name = 'Take Away' WHERE sale_type_name in ('Takeaway', 'Take away');
        ALTER TABLE `tb_enterprises` ADD `ent_online_billing_status` VARCHAR(15) NULL DEFAULT 'Disabled' AFTER `ent_folder_name`, ADD `ent_online_subscription_status` VARCHAR(15) NULL DEFAULT 'Disabled' AFTER `ent_online_billing_status`, ADD `ent_online_subscription_plan` VARCHAR(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT 'Standard' AFTER `ent_online_subscription_status`;
        ";
    }

    if ($q_version == 38) {
        return "CREATE TABLE `tb_stripe_plans` (
        `plan_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `plan_product_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_product_price_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_price` DECIMAL(17,2) DEFAULT '0.00',
        `plan_recurring` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_interval` enum('none','day','week','month','year') NOT NULL DEFAULT 'month',
        `plan_interval_count` INT NOT NULL DEFAULT '1',
        `plan_description` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_features` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `plan_created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`plan_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        INSERT INTO `tb_stripe_plans` (`plan_id`, `plan_product_id`, `plan_product_price_id`, `plan_name`, `plan_description`, `plan_price`, `plan_recurring`, `plan_interval`, `plan_interval_count`, `plan_features`) VALUES (NULL, 'prod_SOE2dBIfExKEwY', 'price_1RTRaSKaWzEqPgeUqvGjdJGL', 'Basic', 'All Basic features', '40.00', 'Yes', 'month', '1', 'All Basic Access'), (NULL, 'prod_SbHg8vAIavyrFi', 'price_1Rg57BKaWzEqPgeUkyfZnjZ4', 'Starter', 'All Starter Featues', '50.00', 'Yes', 'month', '1', 'All Starter Access'), (NULL, 'prod_SNqfQUAiU6SL0e', 'price_1RT4xxKaWzEqPgeUIJCb5E96', 'Standard', 'All Standard Featues', '70.00', 'Yes', 'month', '1', 'All Standard Access'), (NULL, 'prod_SOEpoIQZNoj9M7', 'price_1RTSLoKaWzEqPgeUkr2HtZuf', 'Premium', 'All Premium Featues', '80.00', 'Yes', 'month', '1', 'All Premium Access'), (NULL, 'prod_SOE7pMmGaAj8Ar', 'price_1RTRfAKaWzEqPgeUj4hAM6Q5', 'Ultimate', 'All Ultimate Featues', '100.00', 'Yes', 'month', '1', 'All Ultimate Access');
        ALTER TABLE `tb_enterprises` ADD `ent_plan_id` BIGINT UNSIGNED NULL DEFAULT NULL AFTER `ent_folder_name`, ADD `ent_stripe_customer_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL AFTER `ent_online_subscription_status`, ADD `ent_stripe_subscription_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL AFTER `ent_stripe_customer_id`;
        UPDATE `tb_enterprises` SET ent_plan_id = (SELECT plan_id FROM tb_stripe_plans WHERE plan_name = ent_online_subscription_plan);
        ALTER TABLE `tb_enterprises` DROP `ent_online_subscription_plan`;
        UPDATE `tb_enterprises` SET ent_online_subscription_status = 'Active' WHERE ent_online_subscription_status = 'Enabled';
        CREATE TABLE `tb_stripe_subscriptions` (
        `subs_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `subs_session_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_subscription_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_customer_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_customer_account_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_enterprise_id` bigint unsigned DEFAULT NULL,
        `subs_customer_email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_customer_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_amount` DECIMAL(17,2) DEFAULT '0.00',
        `subs_currency` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_payment_status` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_session_status` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subscription_status` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `subs_trial_end` datetime DEFAULT NULL,
        `subs_created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`subs_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        ";
    }

    if ($q_version == 39) {
        return "CREATE TABLE tb_stripe_invoices (
        inv_id bigint unsigned NOT NULL AUTO_INCREMENT,
        inv_stripe_invoice_id text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_subscription_id text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_customer_id text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_customer_account_id text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_enterprise_id bigint unsigned DEFAULT NULL,
        inv_customer_email text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_customer_name text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_customer_phone varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_amount_due DECIMAL(17,2) DEFAULT '0.00',
        inv_amount_paid DECIMAL(17,2) DEFAULT '0.00',
        inv_amount_remaining DECIMAL(17,2) DEFAULT '0.00',
        inv_currency varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_hosted_url text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        inv_date datetime DEFAULT NULL,
        inv_period_start date DEFAULT NULL,
        inv_period_end date DEFAULT NULL,
        inv_status varchar(50),
        inv_created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`inv_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        INSERT INTO tb_stripe_subscriptions (subs_session_id, subs_subscription_id, subs_enterprise_id, subs_customer_id, subs_customer_account_id, subs_customer_name, subs_customer_email, subs_amount, subs_currency, subs_payment_status, subs_session_status, subscription_status, subs_trial_end, subs_created_at) VALUES ('cs_live_a1VotrJhh7xYQ3MAWM0ss2wzwJ7cpi4a9dhI2mfI9i2HjDRT9YBqV9F14M', 'sub_1RgBdIKaWzEqPgeUIX9Utg5V', '9', 'cus_SbOQfINDokkXcv', NULL, 'Samuel Darguin','sdarguin1906@gmail.com', '200.00', 'usd', 'paid', 'complete', 'active', NULL, '2025-07-01 5:22:29'),('cs_live_a1VyXsOUnAeV95VCZn0ZzS8CDBvlSc9LXSYLufZNLCCd9kO3N1Q55fZDPK', 'sub_1RYEI0KaWzEqPgeUUz1W7CkO', '7', 'cus_STAc1blBR47ro7', NULL, 'Jacob Payen','milokanbotanica7@gmail.com', '160.00', 'usd', 'paid', 'complete', 'active', NULL, '2025-06-09 6:35:39'),('cs_live_a1g6q00RLsx6TGSBfTbMiP2PUmoj7EpIJnnbv8PMPjVP3figWMAJ5DQacN', 'sub_1S2hkfKaWzEqPgeUNqmvKk3w', '14', 'cus_Syf44GswO9h3eO', NULL, 'Darby edyna Dessaint','darbydessaint04@gmail.com', '140.00', 'usd', 'paid', 'complete', 'active', NULL, '2025-09-01 8:07:12'),('cs_live_a1aOqNgSwLYRFPapXNiYAxNKxT6UzAW1ngAxoLhf7BUyYjl6zaKKYPEKKA', 'sub_1SFcGwKaWzEqPgeU8DBOSTAB', '12', 'cus_TC0HHuaKb4GS3H', NULL, 'Rood-Michel Amisial','aroodmichel29@gmail.com', '70.00', 'usd', 'paid', 'complete', 'canceled', NULL, '2025-10-07 10:53:53');
        UPDATE tb_enterprises SET ent_online_subscription_status = 'active' WHERE ent_online_subscription_status = 'Active';
        UPDATE tb_enterprises SET ent_online_subscription_status = 'canceled' WHERE ent_online_subscription_status = 'Disabled';
        UPDATE tb_enterprises SET ent_stripe_customer_id = (select subs_customer_id from tb_stripe_subscriptions where subs_enterprise_id = ent_id) WHERE ent_id = (select subs_enterprise_id from tb_stripe_subscriptions where subs_enterprise_id = ent_id);
        UPDATE tb_enterprises SET ent_stripe_subscription_id = (select subs_subscription_id from tb_stripe_subscriptions where subs_enterprise_id = ent_id) WHERE ent_id = (select subs_enterprise_id from tb_stripe_subscriptions where subs_enterprise_id = ent_id);
        ";
    }

    if ($q_version == 40) {
        return "CREATE TABLE `tb_stripe_customers` (
        `cus_id` bigint unsigned NOT NULL AUTO_INCREMENT,
        `customer_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_account_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_enterprise_id` bigint unsigned DEFAULT NULL,
        `customer_email` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_name` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_phone` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_city` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_country` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_line1` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_line2` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_postal_code` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_state` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_language` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_app_source` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_balance` DECIMAL(17,2) DEFAULT '0.00',
        `customer_created_at` datetime DEFAULT NULL,
        `customer_image` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_password` varchar(5) CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL,
        `customer_user_last_activity` datetime DEFAULT NULL,
        `customer_user_last_login` datetime DEFAULT NULL,
        `created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
        PRIMARY KEY (`cus_id`) USING BTREE
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_spanish_ci ROW_FORMAT=DYNAMIC;
        INSERT INTO tb_stripe_customers (customer_id, customer_account_id, customer_enterprise_id, customer_email, customer_name, customer_phone, customer_city, customer_country, customer_line1, customer_line2, customer_postal_code, customer_state, customer_language, customer_app_source, customer_balance, customer_created_at) VALUES 
        ('cus_SbOQfINDokkXcv', NULL, '9', 'sdarguin1906@gmail.com', 'Samuel Darguin', '+17188790167', 'Queens', 'US', '214-15 113th Avenue', NULL, '11429', 'NY', 'en-US', 'evosyspos', '0', '2025-07-01 5:22:29'),
        ('cus_STAc1blBR47ro7', NULL, '7', 'milokanbotanica7@gmail.com', 'Jacob Payen', '+17722401884', 'Springfield', 'US', '1 East John Street', NULL, '45506', 'OH', 'en-US', 'evosyspos', '0', '2025-06-09 6:35:39'),
        ('cus_Syf44GswO9h3eO', NULL, '14', 'darbydessaint04@gmail.com', 'Darby Edyna Dessaint', '+18095103517', NULL, 'DO', NULL, NULL, NULL, NULL, 'fr-FR', 'evosyspos', '0', '2025-09-01 8:07:12'),
        ('cus_TC0HHuaKb4GS3H', NULL, '12', 'aroodmichel29@gmail.com', 'Rood-Michel Amisial', '+50934985454', NULL, 'HT', NULL, NULL, NULL, NULL, 'en-US', 'evosyspos', '0', '2025-10-07 10:53:53');
        ";
    }

    if ($q_version == 41) {
        return "ALTER TABLE `tb_stripe_subscriptions` CHANGE `subs_amount` `subs_amount_total` DECIMAL(17,2) NULL DEFAULT '0.00', ADD `subs_price_id` text CHARACTER SET utf8mb4 COLLATE utf8mb4_spanish_ci DEFAULT NULL AFTER `subs_subscription_id`, ADD `subs_quantity` INT NULL DEFAULT '1' AFTER `subs_customer_name`, ADD `subs_amount_unit` DECIMAL(17,2) NOT NULL DEFAULT '0.00' AFTER `subs_quantity`, ADD `subs_interval` enum('none','day','week','month','year') NOT NULL DEFAULT 'month' AFTER `subs_currency`, ADD `subs_interval_count` INT NOT NULL DEFAULT '1' AFTER `subs_interval`, ADD `subs_created` DATETIME NULL DEFAULT NULL AFTER `subscription_status`, ADD `subs_current_period_start` DATETIME NULL DEFAULT NULL AFTER `subs_created`, ADD `subs_current_period_end` DATETIME NULL DEFAULT NULL AFTER `subs_current_period_start`;
        ALTER TABLE `tb_stripe_customers` ADD INDEX `customer_account_id` (`customer_account_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_customers` ADD INDEX `customer_enterprise_id` (`customer_enterprise_id`) USING BTREE;
        ALTER TABLE `tb_stripe_invoices` ADD INDEX `inv_enterprise_id` (`inv_enterprise_id`) USING BTREE;
        ALTER TABLE `tb_stripe_invoices` ADD INDEX `inv_stripe_invoice_id` (`inv_stripe_invoice_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_invoices` ADD INDEX `inv_subscription_id` (`inv_subscription_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_invoices` ADD INDEX `inv_customer_id` (`inv_customer_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_invoices` ADD INDEX `inv_customer_account_id` (`inv_customer_account_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_plans` ADD INDEX `plan_product_id` (`plan_product_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_plans` ADD INDEX `plan_product_price_id` (`plan_product_price_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_session_id` (`subs_session_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_subscription_id` (`subs_subscription_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_price_id` (`subs_price_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_customer_id` (`subs_customer_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_customer_account_id` (`subs_customer_account_id`(200)) USING BTREE;
        ALTER TABLE `tb_stripe_subscriptions` ADD INDEX `subs_enterprise_id` (`subs_enterprise_id`) USING BTREE;
        ALTER TABLE `tb_enterprises` CHANGE `ent_online_subscription_status` `ent_stripe_subscription_status` VARCHAR(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        ";
    }

    if ($q_version == 42) {
        return "ALTER TABLE `tb_enterprises` CHANGE `ent_plan_id` `ent_plan_id` BIGINT UNSIGNED NULL DEFAULT '3';
        ALTER TABLE `tb_enterprises` CHANGE `ent_online_billing_status` `ent_online_billing_status` VARCHAR(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'Enabled';
        ALTER TABLE `tb_enterprises` CHANGE `ent_stripe_subscription_status` `ent_stripe_subscription_status` VARCHAR(15) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT 'local-payment';
        ALTER TABLE tb_stripe_subscriptions ADD subs_canceled_at DATETIME NULL DEFAULT NULL AFTER subs_trial_end;
        UPDATE tb_enterprises SET ent_stripe_subscription_status = 'local-payment' WHERE ent_id NOT IN (7,9,10,12,17);
        UPDATE tb_enterprises SET ent_stripe_subscription_status = 'canceled' WHERE ent_id = 14;
        UPDATE tb_enterprises SET ent_plan_id = 2 WHERE ent_id = 9;
        UPDATE tb_pos SET pos_day_start_time = '07:00:00', pos_day_end_time = '06:59:59';
        UPDATE tb_enterprises SET ent_stripe_customer_id = 'cus_STAc1blBR47ro7', ent_stripe_subscription_id = 'sub_1RYEI0KaWzEqPgeUUz1W7CkO' WHERE ent_id = 17;
        UPDATE tb_stripe_subscriptions SET subs_enterprise_id = 17 WHERE subs_id = 2;
        UPDATE tb_stripe_customers SET customer_enterprise_id = 17 WHERE cus_id = 2;
        ALTER TABLE `tb_users` ADD `user_email_report` VARCHAR(15) NULL DEFAULT 'Disabled' AFTER `user_email`;
        ALTER TABLE `tb_enterprises` ADD `ent_email_report` VARCHAR(15) NULL DEFAULT 'Disabled' AFTER `ent_show_notification`;
        ";
    }

    if ($q_version == 43) {
        return "ALTER TABLE `tb_stripe_subscriptions`
        DROP `subs_session_id`,
        DROP `subs_customer_email`,
        DROP `subs_customer_name`,
        DROP `subs_amount_total`,
        DROP `subs_payment_status`,
        DROP `subs_session_status`;
        ALTER TABLE `tb_stripe_customers` ADD INDEX `customer_id` (`customer_id`(200)) USING BTREE;
        ALTER TABLE `tb_products` CHANGE `pro_image` `pro_image` VARCHAR(200) CHARACTER SET utf8mb3 COLLATE utf8mb3_spanish_ci NULL DEFAULT NULL;
        ";
    }

    // Sepecial Sale Offers: so,sop,sos
    if ($q_version == 44) {
        return "CREATE TABLE tb_special_sale_offers (
        offer_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        offer_ent_id BIGINT UNSIGNED NOT NULL,
        offer_pos_id BIGINT UNSIGNED NOT NULL,
        offer_name VARCHAR(100) NOT NULL,
        offer_description TEXT NULL,
        offer_status ENUM('Enabled','Disabled') NOT NULL DEFAULT 'Enabled',
        offer_availability_type ENUM('ALWAYS','LIMITED') NOT NULL DEFAULT 'ALWAYS',
        offer_start_date DATE NULL,
        offer_end_date DATE NULL,
        offer_created_by BIGINT UNSIGNED NULL,
        offer_updated_by BIGINT UNSIGNED NULL,
        offer_created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
        offer_updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        INDEX idx_ent (offer_ent_id),
        INDEX idx_pos (offer_pos_id),
        INDEX idx_status (offer_status)
        INDEX idx_start_date (offer_start_date)
        INDEX idx_end_date (offer_end_date)
        ) ENGINE=InnoDB 
        DEFAULT CHARSET=utf8mb3 
        COLLATE=utf8mb3_spanish_ci 
        COMMENT='TABLE OF SPECIAL SALE OFFERS';

        CREATE TABLE tb_special_sale_offer_products (
        offer_product_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        offer_id BIGINT UNSIGNED NOT NULL,
        product_id BIGINT UNSIGNED NOT NULL,
        offer_price DECIMAL(10,2) NOT NULL,
        offer_quantity DECIMAL(10,2) NOT NULL,
        offer_discount DECIMAL(10,2) NOT NULL,
        created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
        UNIQUE KEY unique_offer_product (offer_id, product_id),
        INDEX idx_offer (offer_id),
        INDEX idx_product (product_id),
        CONSTRAINT fk_offer_products_offer
            FOREIGN KEY (offer_id)
            REFERENCES tb_special_sale_offers(offer_id)
            ON DELETE CASCADE
        ) ENGINE=InnoDB 
        DEFAULT CHARSET=utf8mb3 
        COLLATE=utf8mb3_spanish_ci 
        COMMENT='TABLE OF SPECIAL SALE OFFER PRODUCTS';

        CREATE TABLE tb_special_sale_offer_schedule (
        schedule_id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
        offer_id BIGINT UNSIGNED NOT NULL,
        day_of_week TINYINT NOT NULL COMMENT '1=Mon ... 7=Sun',
        start_time TIME NOT NULL,
        end_time TIME NOT NULL,
        created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
        INDEX idx_offer (offer_id),
        INDEX idx_day (day_of_week),
        CONSTRAINT fk_offer_schedule
            FOREIGN KEY (offer_id)
            REFERENCES tb_special_sale_offers(offer_id)
            ON DELETE CASCADE

        ) ENGINE=InnoDB 
        DEFAULT CHARSET=utf8mb3 
        COLLATE=utf8mb3_spanish_ci 
        COMMENT='TABLE OF SPECIAL SALE OFFER SCHEDULE';
        ";
    }
}

// ✅ This structure supports:
// Buy X Get Y
// Buy X Get Y Free
// Buy X Get Y % Discount
// Buy X Get Y Fixed Price
// Mix product combos


// 1️⃣ Insert 20 Offers
// INSERT INTO tb_special_sale_offers
// (offer_ent_id, offer_pos_id, offer_name, offer_description, offer_status, offer_availability_type, offer_start_date, offer_end_date, offer_created_by)
// VALUES
// (1,1,'Pizza Weekend Combo','Special pizza weekend combo','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Burger Lunch Deal','Lunch burger special','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Friday Beer Deal','Friday beer discount','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Family Chicken Pack','Chicken combo for families','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Happy Hour Nachos','Nachos happy hour','Enabled','ALWAYS',NULL,NULL,1),

// (1,1,'Summer Special Combo','Limited summer combo','Enabled','LIMITED','2026-06-01','2026-08-31',1),
// (1,1,'Black Friday Deal','Black Friday mega discount','Enabled','LIMITED','2026-11-25','2026-11-30',1),
// (1,1,'Christmas Combo','Holiday meal combo','Enabled','LIMITED','2026-12-20','2026-12-31',1),
// (1,1,'New Year Pizza Offer','New year pizza deal','Enabled','LIMITED','2026-12-31','2027-01-02',1),
// (1,1,'Valentine Dinner Deal','Valentine special dinner','Enabled','LIMITED','2026-02-10','2026-02-15',1),

// (1,1,'Taco Tuesday','Tuesday taco deal','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Steak Night','Premium steak night','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Kids Meal Combo','Kids meal special','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Coffee Morning Deal','Morning coffee and pastry','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Dessert Lovers','Dessert promotion','Enabled','ALWAYS',NULL,NULL,1),

// (1,1,'Weekend BBQ','Weekend BBQ pack','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Pizza + Soda Deal','Pizza and soda combo','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Double Burger Deal','Two burgers discount','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Pasta Lovers Combo','Pasta special combo','Enabled','ALWAYS',NULL,NULL,1),
// (1,1,'Late Night Snack','Late night snacks deal','Enabled','ALWAYS',NULL,NULL,1);

// 2️⃣ Insert Offer Products
// (Some offers have 1 product, some 2, some 3)
// INSERT INTO tb_special_sale_offer_products
// (offer_id, product_id, offer_price, offer_quantity, offer_discount)
// VALUES
// (1,101,12.99,1,0),
// (1,102,2.00,1,0),

// (2,103,5.99,1,1),
// (2,104,1.50,1,0),

// (3,105,3.99,1,1),

// (4,106,15.99,1,2),
// (4,107,3.99,1,0),
// (4,108,2.99,1,0),

// (5,109,4.99,1,1),

// (6,110,10.99,1,2),
// (6,111,2.50,1,0),

// (7,112,8.99,1,3),

// (8,113,18.99,1,4),
// (8,114,5.00,1,0),
// (8,115,4.00,1,0),

// (9,116,9.99,1,2),

// (10,117,20.99,1,5),
// (10,118,6.00,1,0),

// (11,119,3.99,2,1),

// (12,120,21.99,1,4),

// (13,121,4.99,1,1),
// (13,122,1.99,1,0),

// (14,123,2.50,1,0),
// (14,124,1.50,1,0),

// (15,125,3.99,1,1),

// (16,126,25.99,1,3),
// (16,127,5.00,1,0),

// (17,128,11.99,1,2),
// (17,129,2.00,1,0),

// (18,130,9.99,2,3),

// (19,131,14.99,1,2),
// (19,132,4.50,1,0),

// (20,133,5.99,1,1);

// 3️⃣ Insert Offer Schedules
// Different schedules:
// weekday lunch
// weekend
// evening
// morning
// late night

// INSERT INTO tb_special_sale_offer_schedule
// (offer_id, day_of_week, start_time, end_time)
// VALUES

// -- Weekend offers
// (1,6,'10:00:00','22:00:00'),
// (1,7,'10:00:00','22:00:00'),

// (16,6,'12:00:00','23:00:00'),
// (16,7,'12:00:00','23:00:00'),

// -- Lunch deals Monday-Friday
// (2,1,'11:00:00','15:00:00'),
// (2,2,'11:00:00','15:00:00'),
// (2,3,'11:00:00','15:00:00'),
// (2,4,'11:00:00','15:00:00'),
// (2,5,'11:00:00','15:00:00'),

// -- Friday special
// (3,5,'16:00:00','23:00:00'),

// -- Happy hour
// (5,1,'16:00:00','19:00:00'),
// (5,2,'16:00:00','19:00:00'),
// (5,3,'16:00:00','19:00:00'),
// (5,4,'16:00:00','19:00:00'),
// (5,5,'16:00:00','19:00:00'),

// -- Taco Tuesday
// (11,2,'12:00:00','22:00:00'),

// -- Steak night Saturday
// (12,6,'17:00:00','23:00:00'),

// -- Morning coffee
// (14,1,'06:00:00','11:00:00'),
// (14,2,'06:00:00','11:00:00'),
// (14,3,'06:00:00','11:00:00'),
// (14,4,'06:00:00','11:00:00'),
// (14,5,'06:00:00','11:00:00'),

// -- Late night snack
// (20,5,'22:00:00','02:00:00'),
// (20,6,'22:00:00','02:00:00');


// SELECT 
//     o.offer_id,
//     o.offer_name,
//     o.offer_description,

//     p.product_id,
//     p.offer_price,
//     p.offer_quantity,
//     p.offer_discount,

//     s.day_of_week,
//     s.start_time,
//     s.end_time

// FROM tb_special_sale_offers o

// JOIN tb_special_sale_offer_products p
//     ON o.offer_id = p.offer_id

// LEFT JOIN tb_special_sale_offer_schedule s
//     ON o.offer_id = s.offer_id

// WHERE o.offer_status = 'Enabled'

// AND (
//         o.offer_availability_type = 'ALWAYS'
//         OR (
//             o.offer_availability_type = 'LIMITED'
//             AND CURDATE() BETWEEN o.offer_start_date AND o.offer_end_date
//         )
// )

// AND (
//         s.day_of_week = WEEKDAY(CURDATE()) + 1
// )

// AND (
//         CURTIME() BETWEEN s.start_time AND s.end_time
// );



// SELECT 
//     op.product_id,

//     o.offer_id,
//     o.offer_name,
//     o.offer_description,

//     op.offer_price,
//     op.offer_quantity,
//     op.offer_discount,

//     CASE
//         WHEN op.offer_discount > 0 
//             THEN op.offer_discount
//         ELSE 0
//     END AS calculated_discount,

//     o.offer_availability_type,
//     o.offer_start_date,
//     o.offer_end_date,

//     s.day_of_week,
//     s.start_time,
//     s.end_time

// FROM tb_special_sale_offer_products op

// JOIN tb_special_sale_offers o
//     ON op.offer_id = o.offer_id

// LEFT JOIN tb_special_sale_offer_schedule s
//     ON o.offer_id = s.offer_id

// WHERE

//     /* Offer must be enabled */
//     o.offer_status = 'Enabled'

//     /* Date validation */
//     AND (
//         o.offer_availability_type = 'ALWAYS'
//         OR (
//             o.offer_availability_type = 'LIMITED'
//             AND CURDATE() BETWEEN o.offer_start_date AND o.offer_end_date
//         )
//     )

//     /* Day validation */
//     AND (
//         s.day_of_week IS NULL
//         OR s.day_of_week = DAYOFWEEK(CURDATE())
//     )

//     /* Time validation */
//     AND (
//         s.start_time IS NULL
//         OR CURTIME() BETWEEN s.start_time AND s.end_time
//     )

// ORDER BY
//     op.product_id,
//     op.offer_discount DESC;