1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
<?PHP
include("../inc/header_admin.php");
// Activer le rapport d'erreurs PHP
if ($_SERVER['SERVER_NAME'] == "localhost" ) error_reporting(E_ALL);
$fichier = fopen("../maj_dossier/EXPARTHQ.txt", "r");
while (($tableau_chaine = fgetcsv($fichier,1024,";")) !== FALSE)
{
echo "Première boucle : OK.";
//$tableau_chaine = fgetcsv($fichier,1024,";");
if ($tableau_chaine[0]=="ARTMAG" && $tableau_chaine[4]=="10")
{
echo "Produit du magasin 10 !";
$code_article=sprintf("%s %s %s",$tableau_chaine[1],$tableau_chaine[2],$tableau_chaine[3]);
//$quantite=$tableau_chaine[5];
/***********************************************************************************/
fclose($fichier);
$fichier2 = fopen("../maj_dossier/EXPARTHQ.txt", "r");
while (($tableau_chaine2 = fgetcsv($fichier2,1024,";")) !== FALSE)
{
echo "Deuxième boucle : OK.";
//$tableau_chaine2 = fgetcsv($fichier2,1024,";");
if ($tableau_chaine2[0]=="ARTICLE" && $tableau_chaine2[1]==$tableau_chaine[1] && $tableau_chaine2[2]==$tableau_chaine[2] && $tableau_chaine2[3]==$tableau_chaine[3])
{
$prix=$tableau_chaine2[17];
$description=addslashes($tableau_chaine2[5]);
$description2=addslashes($tableau_chaine2[6]);
echo "Code article : ".$code_article."<br />";
//echo "Quantite : ".$quantite."<br />";
echo "Description : ".$description."<br />";
echo "Description 2 : ".$description2."<br />";
echo "Prix : ".$prix."<br />";
$sql_compte = sprintf("SELECT COUNT(*) FROM types_produits WHERE ref_produit='%s'",$code_article);
$requete_compte = mysql_query($sql_compte);
if (!$requete_compte)
{
die('Requete invalide : ' . mysql_error());
}
if ($donnees_compte = mysql_fetch_array($requete_compte))
{
$nombre_enregistrement = $donnees_compte['COUNT(*)'];
//$selection = $donnees_compte['selection'];
echo "Nombre enregistrement : ".$nombre_enregistrement."<br />";
//echo "Selection : ".$selection."<br />";
//$nouvelle_quantite=$selection+$quantite;
if ($nombre_enregistrement==0)
{
$requete="INSERT INTO types_produits (ref_produit, marque, sous_marque, prix_u) VALUES ('$code_article','$description','$description2','$prix')";
$execution = mysql_query($requete);
if (!$execution) {
die("Erreur d execution :".mysql_error());
}
}
else
{
$requete="UPDATE types_produits SET prix_u='$prix' WHERE ref_produit='$code_article'";
$execution = mysql_query($requete);
if (!$execution) {
die("Erreur d execution :".mysql_error());
}
}
}
}
}
echo "Fin du fichier ARTICLE <br />";
echo "**************************<br />";
fclose($fichier2);
/***********************************************************************************/
}
}
echo "Fin du fichier ARTMAG <br />";
fclose($fichier);
/**************************************/
echo "<center><br /><a href='../administration/accueil_admin.php'>Retour</a></center>";
include("../inc/footer_admin.php");
?> |
Partager