| Current Path : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/ |
| Current File : /home/ataenra/www/ATA/INTRANET/Admin/Gestion_ACC/leccsvCP.php |
<?php
$ID = $_GET['ID'];
require "../../Outils/co.php";
$list1 = $dbco->prepare("SELECT ID_acc_conso FROM gest_acc_prod_heures WHERE ID_acc_site='$ID'");
$list1->execute();
$R1 = $list1->fetch(PDO::FETCH_OBJ);
if(isset($R1->ID_acc_conso)){
$del=$dbco->prepare("DELETE FROM `gest_acc_prod_heures` WHERE ID_acc_site='$ID'");
$del->execute();
}
$row = 1; $heure=0;
if (($handle = fopen("testcp.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 20000, ";")) !== FALSE) {
$num = count($data);
echo "<p>ligne $row: <br /></p>\n";
$row++; if($heure>23){$heure=0;}
$datadate = $data[0];
$arr1 = str_split($datadate, 4);
$arr2 = str_split($datadate, 2);
$jour = $arr2[3];
$mois = $arr2[2];
$annee = $arr1[0];
$date = "".$annee."-".$mois."-".$jour."";
$puissance = ((int)$data[2]);
echo $date ."<br />\n";
echo $heure ."<br />\n";
echo $puissance ."<br />\n";
$UP3 = $dbco->prepare("INSERT INTO gest_acc_prod_heures (ID_acc_site, prod_jour, prod_heure, prod_puissance) VALUES (:ID_acc_site, :prod_jour, :prod_heure, :prod_puissance)");
$UP3->bindparam(':ID_acc_site',$ID);
$UP3->bindparam(':prod_jour',$date);
$UP3->bindparam(':prod_heure',$heure);
$UP3->bindparam(':prod_puissance',$puissance);
$UP3->execute();
echo 'Valeur enregistrée';
$heure++;
}
fclose($handle);
}
?>