<?php

/**

 * Data Migration Module Configuration

 */



// Prevent direct access

if (!defined('MIGRATION_ACCESS')) {

    die('Direct access not permitted');

}



// Fix path to include main config

require_once __DIR__ . '/../config.php';



// Migration settings

define('MAX_UPLOAD_SIZE', 50 * 1024 * 1024); // 50MB

define('BATCH_SIZE', 100); // Records per batch

define('TEMPLATES_PATH', __DIR__ . '/templates/');

define('LOGS_PATH', __DIR__ . '/logs/');

define('ALLOWED_EXTENSIONS', ['csv', 'xlsx', 'xls', 'txt']);



// Database tables mapping

$table_mapping = [

    'students' => 'students',

    'staff' => 'staff',

    'fees' => 'fee_structures',

    'payments' => 'payments',

    'subjects' => 'subjects',

    'class_subjects' => 'class_subjects',

    'scores' => 'scores',

    'grade_boundaries' => 'grade_boundaries',

    'expenses' => 'expenses',
    'staff_pay' => 'payroll_staff_pay',
    'student_health' => 'student_health',
    'student_leadership' => 'student_leadership',
    'student_activities' => 'student_activities',
    'biometric_enroll' => 'biometric_enrollments'

];



// Field mappings for different sources

$field_mappings = [

    'gesmis' => [

        'student_id' => 'GESMIS_ID',

        'first_name' => 'FIRST_NAME',

        'last_name' => 'SURNAME',

        'class' => 'CLASS_CODE',

        'date_of_birth' => 'DOB',

        'gender' => 'GENDER',

        'father_name' => 'FATHER_NAME',

        'father_phone' => 'FATHER_TEL',

        'mother_name' => 'MOTHER_NAME',

        'mother_phone' => 'MOTHER_TEL'

    ],

    'oneroster' => [

        'student_id' => 'sourcedId',

        'first_name' => 'givenName',

        'last_name' => 'familyName',

        'class' => 'class',

        'email' => 'email',

        'phone' => 'phone'

    ]

];



// Validation rules

$validation_rules = require_once __DIR__ . '/validation/rules.php';



// Create logs directory if not exists

if (!file_exists(LOGS_PATH)) {

    mkdir(LOGS_PATH, 0755, true);

}



// Logging function

function logMigration($message, $type = 'INFO') {

    $logFile = LOGS_PATH . 'migration_' . date('Y-m-d') . '.log';

    $timestamp = date('Y-m-d H:i:s');

    file_put_contents($logFile, "[$timestamp] [$type] $message\n", FILE_APPEND);

}

?>