
<?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();
    
    $sql1="SELECT * FROM digicenters WHERE center_id='".$_GET["center_id"]."' ";
    // echo  $sql1;
    $result1 = mysqli_query($conn, $sql1); 
    if (mysqli_num_rows($result1) > 0) {
        while($row1 = mysqli_fetch_assoc($result1)) {
            $userDigicenter_id;
            $FullName;
            $SignUpRole;
            $curriculum_id;
            $package_id;
            $branches;
            $curriculumEnrollment_id;
            $PackageName;
            $Price;
            $Currency; $PriceDuration; $PriceTarget; $MinStudents;
            $MaxStudents; $Status; $BillingTarget; $LmsAccess;
            $CodingRoboticsCurriculum; $QaVisits; $SchoolBranches; 
            $AccountManager;  $Support;  $TeachersTrained;
            $AdminAccounts;  $AdminAccounts; 
            $ModuleName;  $ModuleTarget;  $ModuleDescription;
            $CurriculumName;  $SessionName;  $NoSessions;
            $sql10="SELECT * FROM userDigicenter WHERE center_id='".$row1["center_id"]."' ";
            $result10 = mysqli_query($conn, $sql10); 
            if (mysqli_num_rows($result10) > 0) {
                while($row10 = mysqli_fetch_assoc($result10)) {
                    $userDigicenter_id=$row10["userDigicenter_id"];
                    $FullName=$row10["FullName"];
                    $SignUpRole=$row10["SignUpRole"];
                }
            }
            $sql10="SELECT * FROM centerSettings WHERE center_id='".$row1["center_id"]."' ";
            $result10 = mysqli_query($conn, $sql10); 
            if (mysqli_num_rows($result10) > 0) {
                while($row10 = mysqli_fetch_assoc($result10)) {
                    $curriculum_id=$row10["curriculum_id"];
                    $package_id=$row10["package_id"];
                    $branches=$row10["branches"];
                    $curriculumEnrollment_id=$row10["curriculumEnrollment_id"];
                    $sql_pckg="SELECT * FROM curriculum WHERE curriculum_id='".$row10["curriculum_id"]."' ";
                    $result_pckg = mysqli_query($conn, $sql_pckg); 
                    if (mysqli_num_rows($result_pckg) > 0) {
                        while($row_pckg = mysqli_fetch_assoc($result_pckg)) {
                            $CurriculumName=$row_pckg["CurriculumName"];
                            $SessionName=$row_pckg["SessionName"];
                            $NoSessions=$row_pckg["NoSessions"];
                        }
                    }
                    $sql_pckg="SELECT * FROM packages WHERE package_id='".$row10["package_id"]."' ";
                    $result_pckg = mysqli_query($conn, $sql_pckg); 
                    if (mysqli_num_rows($result_pckg) > 0) {
                        while($row_pckg = mysqli_fetch_assoc($result_pckg)) {
                            $PackageName=$row_pckg["PackageName"];
                            $Price=$row_pckg["Price"];
                            $Currency=$row_pckg["Currency"];
                            $PriceDuration=$row_pckg["PriceDuration"];
                            $PriceTarget=$row_pckg["PriceTarget"];
                            $MinStudents=$row_pckg["MinStudents"];
                            $MaxStudents=$row_pckg["MaxStudents"];
                            $Status=$row_pckg["Status"];
                            $BillingTarget=$row_pckg["BillingTarget"];
                            $LmsAccess=$row_pckg["LmsAccess"];
                            $CodingRoboticsCurriculum=$row_pckg["CodingRoboticsCurriculum"];
                            $QaVisits=$row_pckg["QaVisits"];
                            $SchoolBranches=$row_pckg["SchoolBranches"];
                            $AccountManager=$row_pckg["AccountManager"];
                            $Support=$row_pckg["Support"];
                            $TeachersTrained=$row_pckg["TeachersTrained"];
                            $AdminAccounts=$row_pckg["AdminAccounts"];
                            $AdminAccounts=$row_pckg["ModuleDescription"];
                            $sql_mdl="SELECT * FROM modules WHERE module_id='".$row_pckg["module_id"]."' ";
                            $result_mdl = mysqli_query($conn, $sql_mdl); 
                            if (mysqli_num_rows($result_mdl) > 0) {
                                while($row_mdl = mysqli_fetch_assoc($result_mdl)) {
                                    $ModuleName=$row_mdl["ModuleName"];
                                    $ModuleTarget=$row_mdl["ModuleTarget"];
                                    $ModuleDescription=$row_mdl["ModuleDescription"];
                             
                                }
                            }
                        }
                    }
                }    
            }
            $curl_post_data = array(
                'center_id' => $row1["center_id"],
                'center_name' => $row1["center_name"],
                'center_email' => $row1["center_email"],
                'center_phone' => $row1["center_phone"],
                'center_location' => $row1["center_location"],
                'center_lat' => $row1["center_lat"],
                'center_long' => $row1["center_long"],
                'center_description' => $row1["center_description"],
                'center_image' => $row1["center_image"],
                'center_physical' => $row1["center_physical"],
                'transport' => $row1["transport "],
                'approved' => $row1["approved"],
                'flag_1' => $row1["flag_1"],
                'flag_2' => $row1["flag_2"],
                'CurriculumName' => $CurriculumName,
                'SessionName' => $SessionName,
                'NoSessions' => $NoSessions,
                'userDigicenter_id' => $userDigicenter_id,
                'FullName' => $FullName,
                'SignUpRole' => $SignUpRole,
                'curriculum_id' => $curriculum_id,
                'package_id' => $package_id,
                'branches' => $branches,
                'curriculumEnrollment_id' => $curriculumEnrollment_id,
                'PackageName' => $PackageName,
                'Price' => $Price,
                'Currency' => $Currency,
                'PriceDuration' => $PriceDuration,
                'PriceTarget' => $PriceTarget,
                'MinStudents' => $MinStudents,
                'MaxStudents' => $MaxStudents,
                'Status' => $Status,
                'BillingTarget' => $BillingTarget,
                'LmsAccess' => $LmsAccess,
                'CodingRoboticsCurriculum' => $CodingRoboticsCurriculum,
                'QaVisits' => $QaVisits,
                'SchoolBranches' => $SchoolBranches,
                'AccountManager' => $AccountManager,
                'Support' => $Support,
                'TeachersTrained' => $TeachersTrained,
                'AdminAccounts' => $AdminAccounts,
                'ModuleName' => $ModuleName,
                'ModuleTarget' => $ModuleTarget,
                'ModuleDescription' => $ModuleDescription,
                'userDigicenter_id' => $userDigicenter_id,
            );
          
            echo json_encode($curl_post_data);
        }
    }
   
?>