<?php

       require_once '../app/model/db.class.php';

        $obj = new database();
        $obj->conectar(); $obj->consulta("set names 'utf8'");

          $reg = $obj->consulta("select * from  boletin");

          while($row = $obj->fetch_assoc($reg)){

                $reg1 = $obj->consulta("SELECT avg(definitiva) as promedio FROM detalleboletin WHERE boletin ='".$row['numero']."'");

                $row1 = $obj->fetch_assoc($reg1);

                if ($row1['promedio']==0){

                     $obj->consulta("INSERT INTO boletin_blancos VALUES ('".$row['numero']."','".$row['anolectivo']."','".$row['asignatura']."','".$row['periodo']."','".$row['jornada']."','".$row['grado']."','".$row['curso']."',".$row['secuencial'].")");

                }                   
          }


         $obj->disconnect();

         echo "<script languaje='javascript'>alert('PROCESO TERMINADO')</script>";
         echo "<script languaje='javascript'>document.location.href='../menu.php';</script>";
?>
