<?php
require_once "../models/Operations.php";

$sql = "SELECT pos_id,pos_ent_id FROM tb_pos;";
$posInfo = executePDOFetchAll($sql);

$sqlCategoryValue = "";

foreach ($posInfo as $pos) {

    // IF EXISTE MORE DATA TO SAVE ADD A COMA TO THE SECOND ROW
    if (!empty(trim((string) $sqlCategoryValue))) {
        $sqlCategoryValue .= ", ";
    }

    $cat_code = createTokenNumber('tb_categories', 'cat_code', '6');

    $sqlCategoryValue .= "('{$pos['pos_ent_id']}', '{$pos['pos_id']}', '$cat_code', 'General')";
}

$sqlBulkCategory = "INSERT INTO tb_categories (
    cat_ent_id
    ,cat_pos_id
    ,cat_code
    ,cat_name )
VALUES
" . $sqlCategoryValue;

$answer = executeQueryPDOApi($sqlBulkCategory, "Saved", "BULK CATEGORIES");
var_dump($answer);

// After update, Execute: 
// https://evosyspos.dev/update/create-payment-type.php
// https://evosyspos.dev/update/create-users-access.php
// https://evosyspos.dev/update/create-categories.php
// https://evosyspos.dev/update/create-fix-product-categories.php