<?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';
    $sql1="SELECT * FROM curriculum WHERE curriculum_id='".$_GET['curriculum_id']."' AND DefaultStatus='false'";
    $result1 = mysqli_query($conn, $sql1); 
    if (mysqli_num_rows($result1) > 0) {
        while($row1 = mysqli_fetch_assoc($result1)) {
            $sql10="SELECT * FROM curriculum WHERE DefaultStatus='true' AND curriculum_id!='".$row1['curriculum_id']."'";
            $result10 = mysqli_query($conn, $sql10); 
            if (mysqli_num_rows($result10) > 0) {
                while($row10 = mysqli_fetch_assoc($result10)) {
                    $sql_C = "UPDATE curriculum SET
                        DefaultStatus='false'
                        WHERE curriculum_id=".$row10["curriculum_id"];
                    if (mysqli_query($conn, $sql_C)) {
                    }
                }
            }
            $sql_C = "UPDATE curriculum SET
                DefaultStatus='true'
                WHERE curriculum_id=".$row1["curriculum_id"];
            if (mysqli_query($conn, $sql_C)) {
                $curl_post_data = array(
                    'Success' => 'true',
                    'curriculum_id' => $row1["curriculum_id"] ,
                );
                echo json_encode($curl_post_data); 
            }else{

                $curl_post_data = array(
                    'Success' => 'false',
                    'curriculum_id' => '', 
                );
                echo json_encode($curl_post_data);  
            }
        }

    }

    
?>