<?php /*
    header("Content-Type:application/json");
    include("connection.php");
    include("utils.php");
    
    $out = new stdClass();
    
    // Vamos a consultar los colegios 
    $sql = "SELECT * FROM schools";
    if (!$rs=$db->query($sql))
        badEnd("500", array("msg"=>$db->error.$sql));
    
    // recorremos los colegios
    while($row = $rs->fetch_assoc()){
        // Obtenemos la cantidad total de estimada
        $sql = "SELECT SUM(qty) AS qty FROM estimatedpupils WHERE schoolid = ".$row['id'];
        if (!$res=$db->query($sql))
            badEnd("500", array("msg"=>$db->error.$sql));
            
        $rowSum = $res->fetch_assoc();
        
        $out->test [] = $rowSum;
        
        //Actualizamos la cantidad
        $sql = "UPDATE schools SET ".
        "       pupilqty = ".($row['qty'] == null ? 0 : $row['qty']).
        "       WHERE id = ".$row['id'];
        if (!$db->query($sql))
            badEnd("500", array("msg"=>$db->error.$sql));
    }
    
    header("HTTP/1.1 200");
    echo (json_encode($out));
    die();*/
?>