include "../lib/start.php"; check_session(); check_permission(ADM_PERM); header("Content-type: text/plain"); $sel_classi = "SELECT id_classe FROM classi ORDER BY id_classe"; try { $res_classi = $db->executeQuery($sel_classi); } catch (MySQLException $ex) { print "ko;" . $ex->getQuery() . ";" . $ex->getMessage(); exit; } $sel_anno = "SELECT * FROM anni ORDER BY id_anno DESC LIMIT 1"; $res_anno = $db->executeQuery($sel_anno); $year = new AnnoScolastico($res_anno->fetch_assoc()); $anno = $year->get_ID(); while ($classe = $res_classi->fetch_assoc()) { $sel_materie = "SELECT id_materia FROM materie WHERE id_materia != 999 AND (id_materia < 12 OR id_materia > 20) ORDER BY id_materia"; $res_materie = $db->executeQuery($sel_materie); while ($mat = $res_materie->fetch_assoc()) { $ins = "INSERT INTO cdc (id_anno, id_classe, id_docente, id_materia) VALUES ({$anno}, " . $classe['id_classe'] . ", NULL, " . $mat['id_materia'] . ")"; try { $rs = $db->executeUpdate($ins); } catch (MySQLException $ex) { print "ko;" . $ex->getQuery() . ";" . $ex->getMessage(); exit; } } } print "ok;"; exit;
$res_classi = $db->execute($sel_classi); $classi = array(); while ($_classi = $res_classi->fetch_assoc()) { array_push($classi, $_classi['id_classe']); } $days = 0; $current_day = format_date($anno->get_data_inizio_lezioni(), IT_DATE_STYLE, SQL_DATE_STYLE, "-"); // contatore delle queries eseguite $i = 0; print "<script>\$('t_msg').innerHTML = 'Caricamento dei dati in corso: ';</script>"; while (strtotime($current_day) < strtotime($last_day)) { if (date("w", strtotime($current_day)) == "0") { // do nothing } else { foreach ($classi as $id_classe) { $insert = "INSERT INTO reg_classi (id_classe, id_anno, data) VALUES ({$id_classe}, " . $anno->get_ID() . ",'{$current_day}')"; $res = $db->executeUpdate($insert); if ($i % $fattore_avanzamento == 0) { print "<script>\$('progress').style.width = '" . $i / $fattore_avanzamento . "%';\t\$('msg').innerHTML = '" . intval($i / $fattore_avanzamento, 10) . "%'</script>"; flush(); } } } $days++; //print("$insert -> Inserito record per $current_day</br>"); $current_day = date("Y-m-d", strtotime("{$current_day} +1 days")); $i++; //print $i."<br />"; } //print "Inserimento giornate terminato: $days giorni<br /><br />Avvio inserimento alunni"; $sel_classi = "SELECT id_classe, anno_corso, sezione FROM classi";