//$fp=fopen($dbf_file['tmp_name'],"r"); $fp = fopen("../temp/{$tempdir}/f_men.csv", "r"); // On lit une ligne pour passer la ligne d'entête: $ligne = fgets($fp, 4096); //========================= $nb_reg_no = 0; for ($k = 1; $k < $nblignes + 1; $k++) { //$ligne = dbase_get_record($fp,$k); if (!feof($fp)) { $ligne = fgets($fp, 4096); if (trim($ligne) != "") { $tabligne = explode(";", $ligne); for ($i = 0; $i < count($tabchamps); $i++) { //$affiche[$i] = dbase_filter(trim($ligne[$tabindice[$i]])); //affiche_debug("\$affiche[$i]=dbase_filter(trim(\$ligne[$tabindice[$i]]))=$affiche[$i]<br />\n"); $affiche[$i] = dbase_filter(trim($tabligne[$tabindice[$i]])); affiche_debug("\$affiche[{$i}]=dbase_filter(trim(\$tabligne[" . $tabindice[$i] . "]))=" . $affiche[$i] . "<br />\n"); } affiche_debug("==========================<br />\n"); $req = mysqli_query($GLOBALS["mysqli"], "select col1 from tempo2 where col2 = '{$affiche['1']}'"); affiche_debug("On recherche si un prof assure le cours correspondant au groupe: select col1 from tempo2 where col2 = '{$affiche['1']}'<br />\n"); $login_prof = @old_mysql_result($req, 0, 'col1'); // A REVOIR... IL FAUDRAIT PEUT-ETRE CREER QUAND MEME LE GROUPE POUR L'ASSOCIATION groupe/matiere/classe même si il n'y a pas encore de prof (dans le F_MEN) if ($login_prof != '') { // On relie les profs aux matières affiche_debug("Un (au moins) prof trouvé: {$login_prof}<br />\n"); $verif = mysqli_query($GLOBALS["mysqli"], "select id_professeur from j_professeurs_matieres where (id_matiere='{$affiche['0']}' and id_professeur='{$login_prof}')"); affiche_debug("select id_professeur from j_professeurs_matieres where (id_matiere='{$affiche['0']}' and id_professeur='{$login_prof}')<br />\n"); $resverif = mysqli_num_rows($verif); if ($resverif == 0) { // On arrive jusque là.
$nb_reg_no = 0; while(!feof($fp)){ $temoin_erreur="non"; $tmp_lig=fgets($fp,4096); if(trim($tmp_lig)!=""){ $ligne=explode(";",$tmp_lig); $affiche[0]=traitement_magic_quotes(corriger_caracteres(dbase_filter(trim($ligne[0])))); if((mb_strlen(preg_replace("/[A-Za-z0-9_ &]/","",strtr($affiche[0],"-","_")))!=0)&&($affiche[0]!="")){ $temoin_erreur="oui"; //echo "<!-- -->\n"; $msg.="Le nom <font color='red'>$affiche[0]</font> ne convient pas.<br />\n"; $nb_reg_no++; } $affiche[1]=traitement_magic_quotes(corriger_caracteres(dbase_filter(trim($ligne[1])))); if((mb_strlen(preg_replace("/[A-Za-zÀÄÂÉÈÊËÎÏÔÖÙÛÜÇçàäâéèêëîïôöùûü0-9_ &]/","",strtr($affiche[1],"-","_")))!=0)&&($affiche[1]!="")){ $temoin_erreur="oui"; //echo "<!-- -->\n"; $msg.="Le nom <font color='red'>$affiche[1]</font> ne convient pas.<br />\n"; $nb_reg_no++; } if(($affiche[0]!="")&&($affiche[1]!="")&&($temoin_erreur!="oui")){ $alt=$alt*(-1); $verif = mysqli_query($GLOBALS["mysqli"], "select matiere, nom_complet from matieres where matiere='$affiche[0]'"); $resverif = mysqli_num_rows($verif); if($resverif == 0) { $req = mysqli_query($GLOBALS["mysqli"], "insert into matieres set matiere='$affiche[0]', nom_complet='$affiche[1]', priority='0',matiere_aid='n',matiere_atelier='n'"); if(!$req) {
echo "</tr>\n"; $alt=1; $nb_reg_no1=0; $nb_record1=0; for($k = 1; ($k < $nblignes+1); $k++){ //$ligne = dbase_get_record($fp,$k); if(!feof($fp)){ $ligne = fgets($fp, 4096); if(trim($ligne)!=""){ $tabligne=explode(";",$ligne); for($i = 0; $i < count($tabchamps); $i++) { //$ind = $tabindice[$i]; $affiche[$i] = traitement_magic_quotes(corriger_caracteres(dbase_filter(trim($tabligne[$tabindice[$i]])))); } // Stockage des données: $responsable[$affiche[0]]=array(); for($i=1;$i<count($tabchamps);$i++) { $responsable[$affiche[0]]["$tabchamps[$i]"]=$affiche[$i]; } $ele_id=$affiche[0]; $pers_id=$affiche[1]; $resp_legal=$affiche[2]; $pers_contact=$affiche[3]; //echo "<tr>\n";
for ($i = 0; $i < count($en_tete); $i++) { if ($en_tete[$i] == $tabchamps[$k]) { $tabindice[] = $i; } } } $nb_reg_ok = 0; $nb_reg_no = 0; for ($k = 1; $k < $nblignes + 1; $k++) { $enregistre = "yes"; $ligne = dbase_get_record($fp, $k); $query = "INSERT INTO temp_gep_import VALUES ('{$k}',''"; for ($i = 0; $i < count($tabchamps); $i++) { $query = $query . ","; $ind = $tabindice[$i]; $affiche = dbase_filter(trim($ligne[$ind])); $query = $query . "\"" . $affiche . "\""; if ($en_tete[$ind] == 'DIVCOD' and $affiche == '') { $enregistre = "no"; } } $query = $query . ")"; if ($enregistre == "yes") { $register = mysqli_query($GLOBALS["mysqli"], $query); if (!$register) { echo "<p class=\"small\"><font color='red'>Analyse de la ligne {$k} : erreur lors de l'enregistrement !</font></p>"; $nb_reg_no++; } else { $nb_reg_ok++; // echo "."; }