<?php
/********************************************************************************
 * (c)1337 aheadware.com - All rights reserved
 ********************************************************************************/

require_once __DIR__ . '/../../src/server/server/config/boot_global.php';
require_once __DIR__ . '/../../src/server/server/config/boot_local.php';


function patch_addGeneralCourseCategoryToTeam()
{
    return NULL;

    /*
    // Set DB configuration for live teamdata access
    Francis_Utils_Config::set( 'db.tbteamdata.host', 'v034011.kasserver.com' );
    Francis_Utils_Config::set( 'db.tbteamdata.name', 'd02e620f' );
    Francis_Utils_Config::set( 'db.tbteamdata.user', 'd02e620f' );
    Francis_Utils_Config::set( 'db.tbteamdata.pass', 'NT7uSbtaebV9Gedq' );
*/
    $sql = 'SELECT * FROM ' . TB_Shared_Ent_TeamData_Team::getTable();
    $teams = TB_Shared_Ent_TeamData_Team::findMany( $sql );

    /** @var TB_Shared_Ent_TeamData_Team $team */
    foreach ( $teams as $team )
    {
        $generalCategoryId = $team->id . '-0';
        $generalCategory = $team->getCourseCategoryDataById( $generalCategoryId );
        if ( is_null( $generalCategory ) )
        {
            $team->addCourseCategory( [ 'id' => $generalCategoryId, 'name' => 'Allgemein' ] );
            $team->save();
        }

        unset( $team );
    }

    echo "DONE...";
}

patch_addGeneralCourseCategoryToTeam();
