<?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: GET, POST');
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization");
include '../../../config/index.php';
$data = array();
// $sql_10P = "SELECT * FROM parents    ";
// $result_10P = mysqli_query($conn, $sql_10P);
// if (mysqli_num_rows($result_10P) > 0) {
//     while ($row_10P = mysqli_fetch_assoc($result_10P)) {
//         $sql_np = "INSERT INTO new_parents VALUES (NULL,
//             '" . $row_10P['p_name'] . "',
//             '" . $row_10P['p_last_name'] . "',
//             '" . $row_10P["p_email"] . "',
//             '" . $row_10P["p_phone"] . "', 
//             '" . $row_10P["p_image"] . "', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '" . $row_10P["p_password"] . "', 
//             '" . $row_10P["password_reset"] . "', 
//             '" . $row_10P["flag_1"] . "', 
//             '" . $row_10P["flag_2"] . "', 
//             '" . $row_10P["flag_3"] . "', 
//             now())";
//         if (mysqli_query($conn, $sql_np)) {
//         }
//     }
// }

// $sql_10P = "SELECT * FROM new_parents    ";
// $result_10P = mysqli_query($conn, $sql_10P);
// if (mysqli_num_rows($result_10P) > 0) {
//     while ($row_10P = mysqli_fetch_assoc($result_10P)) {
//         $sql_np = "INSERT INTO parents VALUES (NULL,
//             '" . $row_10P['p_name'] . "',
//             '" . $row_10P['p_last_name'] . "',
//             '" . $row_10P["p_email"] . "',
//             '" . $row_10P["p_phone"] . "', 
//             '" . $row_10P["p_image"] . "', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '', 
//             '" . $row_10P["p_password"] . "', 
//             '" . $row_10P["password_reset"] . "', 
//             '" . $row_10P["flag_1"] . "', 
//             '" . $row_10P["flag_2"] . "', 
//             '" . $row_10P["flag_3"] . "', 
//             now())";
//         if (mysqli_query($conn, $sql_np)) {
//         }
//     }
// }
$sql1 = "SELECT * FROM curriculumClasses WHERE curriculum_id='4' ";
$result1 = mysqli_query($conn, $sql1);
if (mysqli_num_rows($result1) > 0) {
    while ($row1 = mysqli_fetch_assoc($result1)) {
        $sql_cc = 'INSERT INTO centerClasses VALUES(NULL,
            "' . $row1["curriculumClasses_id"] . '",
            "' . $row1["curriculumEnrollment_id"] . '",
            "",
            "47",
            "' . $row1["class_id"] . '",
            NOW())';
        if (mysqli_query($conn, $sql_cc)) {
            $centerClasses_id = mysqli_insert_id($conn);
            $sql10 = "SELECT * FROM curriculumCourses WHERE  curriculumClasses_id='" . $row1["curriculumClasses_id"] . "' ";
            $result10 = mysqli_query($conn, $sql10);
            if (mysqli_num_rows($result10) > 0) {
                while ($row10 = mysqli_fetch_assoc($result10)) {
                    $sql_we10 = 'INSERT INTO centerCourse VALUES(NULL,
                        "47",
                        "' . $row10["curriculumCourses_id"] . '",
                        "' . $centerClasses_id . '",
                        "' . $row10["course_id"] . '",
                        "' . $row10["curriculumSession_id"] . '",
                        NOW())';
                    if (mysqli_query($conn, $sql_we10)) {
                    }
                }
            }
        }
    }
}
 
// $sql_10P = "SELECT * FROM students    ";
// $result_10P = mysqli_query($conn, $sql_10P);
// if (mysqli_num_rows($result_10P) > 0) {
//     while ($row_10P = mysqli_fetch_assoc($result_10P)) {
//         $sql_ps = "INSERT INTO ParentStudents VALUES (NULL,
//             '" . $row_10P['parent_id'] . "',
//             '" . $row_10P['student_id'] . "',
//             '" . $row_10P['center_id'] . "',
//             'false', 
//             'false', 
//             now())";
//         if (mysqli_query($conn, $sql_ps)) {
//             $ParentStudents_id = mysqli_insert_id($conn);
//             $sql_ns = "INSERT INTO new_students VALUES (NULL,
//                 '" . $ParentStudents_id . "',
//                 '" . $row_10P['center_id'] . "',
//                 '" . $row_10P["centerClasses_id"] . "',
//                 '" . $row_10P["learner_name"] . "', 
//                 '" . $row_10P["learner_last_name"] . "', 
//                 '', 
//                 '', 
//                 '', 
//                 '', 
//                 '" . $row_10P["learner_age"] . "', 
//                 '" . $row_10P["learner_image"] . "', 
//                 '" . $row_10P["status"] . "', 
//                 '" . $row_10P["homeschool"] . "', 
//                 '" . $row_10P["username"] . "', 
//                 '" . $row_10P["password"] . "', 
//                 '" . $row_10P["reset"] . "', 
//                 '" . $row_10P["flag_1"] . "', 
//                 '" . $row_10P["flag_2"] . "', 
//                 '" . $row_10P["flag_3"] . "', 
//                 '" . $row_10P["flag_4"] . "', 
//                 '" . $row_10P["flag_5"] . "', 
//                 now())";
//             if (mysqli_query($conn, $sql_ns)) {
//             }
//         }
//     }
// }

// $sql_10P = "SELECT * FROM students    ";
// $result_10P = mysqli_query($conn, $sql_10P);
// if (mysqli_num_rows($result_10P) > 0) {
//     while ($row_10P = mysqli_fetch_assoc($result_10P)) {

//         $ParentStudents_id = mysqli_insert_id($conn);
//         $sql_ns = "INSERT INTO new_students VALUES (NULL,
//                 '" . $row_10P['ParentStudents_id'] . "',
//                 '" . $row_10P['center_id'] . "',
//                 '" . $row_10P["centerClasses_id"] . "',
//                 '" . $row_10P["learner_name"] . "', 
//                 '" . $row_10P["learner_last_name"] . "', 
//                 '', 
//                 '', 
//                 '', 
//                 '', 
//                 '" . $row_10P["learner_age"] . "', 
//                 '" . $row_10P["learner_image"] . "', 
//                 '" . $row_10P["status"] . "', 
//                 '" . $row_10P["homeschool"] . "', 
//                 '" . $row_10P["username"] . "', 
//                 '" . $row_10P["password"] . "', 
//                 '" . $row_10P["reset"] . "', 
//                 '" . $row_10P["flag_1"] . "', 
//                 '" . $row_10P["flag_2"] . "', 
//                 '" . $row_10P["flag_3"] . "', 
//                 '" . $row_10P["flag_4"] . "', 
//                 '" . $row_10P["flag_5"] . "', 
//                 now())";
//         if (mysqli_query($conn, $sql_ns)) {
//         }
//     }
// }

// $sql_10P = "SELECT * FROM new_students    ";
// $result_10P = mysqli_query($conn, $sql_10P);
// if (mysqli_num_rows($result_10P) > 0) {
//     while ($row_10P = mysqli_fetch_assoc($result_10P)) {
//         $sql_ns = "INSERT INTO students VALUES (NULL,
//                 '" . $row_10P['ParentStudents_id'] . "',
//                 '" . $row_10P['center_id'] . "',
//                 '" . $row_10P["centerClasses_id"] . "',
//                 '" . $row_10P["learner_name"] . "', 
//                 '" . $row_10P["learner_last_name"] . "', 
//                 '" . $row_10P["learner_age"] . "', 
//                 '" . $row_10P["learner_image"] . "', 
//                 '" . $row_10P["status"] . "', 
//                 '" . $row_10P["homeschool"] . "', 
//                 '" . $row_10P["username"] . "', 
//                 '" . $row_10P["password"] . "', 
//                 '" . $row_10P["reset"] . "', 
//                 '" . $row_10P["flag_1"] . "', 
//                 '" . $row_10P["flag_2"] . "', 
//                 '" . $row_10P["flag_3"] . "', 
//                 '" . $row_10P["flag_4"] . "', 
//                 '" . $row_10P["flag_5"] . "', 
//                 now())";
//                 echo  $sql_ns;
//         if (mysqli_query($conn, $sql_ns)) {
//         }
//     }
// }

$sql_10P = "SELECT * FROM new_teachers    ";
$result_10P = mysqli_query($conn, $sql_10P);
if (mysqli_num_rows($result_10P) > 0) {
    while ($row_10P = mysqli_fetch_assoc($result_10P)) {
        $sql_ns = "INSERT INTO teachers VALUES (NULL,
                '" . $row_10P['TeacherFirstName'] . "',
                '" . $row_10P['TeacherLastName'] . "',
                '" . $row_10P["TeacherEmail"] . "',
                '" . $row_10P["TeacherImage"] . "', 
                '" . $row_10P["TeacherPhone"] . "', 
                '" . $row_10P["DateOfBirth"] . "', 
                '" . $row_10P["Gender"] . "', 
                '" . $row_10P["DisabilityStatus"] . "', 
                '" . $row_10P["RefugeeStatus"] . "', 
                '" . $row_10P["TeacherPassword"] . "', 
                '" . $row_10P["center_id"] . "', 
                '" . $row_10P["center_branch_id"] . "', 
                '" . $row_10P["Deleted"] . "', 
                '" . $row_10P["Location"] . "', 
                '" . $row_10P["External"] . "', 
                '" . $row_10P["Lat"] . "', 
                '" . $row_10P["long"] . "', 
                '" . $row_10P["flag_1"] . "', 
                '" . $row_10P["flag_2"] . "', 
                now())"; 
        if (mysqli_query($conn, $sql_ns)) {
        }
    }
}
echo json_encode($data);
