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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
ini_set('display_errors', true);
error_reporting(E_ALL);
//if(ISSET($_POST['listSource']) AND ISSET($_POST['listTable']) AND ISSET($_POST['listData']) AND ISSET($_POST['start']) AND ISSET('stop')) {
$listSupervision = $_POST['listSupervision'];
$listZone = $_POST['listZone'];
$listData = $_POST['listData'];
$startDate = $_POST['startDate'];
$stopDate = $_POST['stopDate'];
$startHeure = $_POST['startHeure'];
$stopHeure = $_POST['stopHeure'];
$resolution = $_POST['resolution'];
$mode = $_POST['mode'];
$version = $_POST['version'];
$file = $_POST['file'];
$wwResolution = 0;
$reponse = "";
//$test = false;
$fp = fopen( "$file", 'w+');
$fp2 = fopen('unfichier.csv', 'w+');
fwrite( $fp2, "test");
fclose($fp2);
switch ( $resolution){
case "seconde":
$wwResolution = 1000;
break;
case "minute":
$wwResolution = 60*1000;
break;
case "heure":
$wwResolution = 60*1000*60;
break;
case "jour":
$wwResolution = 60*1000*60*24;
break;
default:
}
$start = $startDate . " " . $startHeure;
$stop = $stopDate . " " . $stopHeure;
if( $listZone=="Sige" ){
try{
$bdd = new PDO('odbc:driver=freetds;servername=mssql;dabase=Runtime', 'xxx','xxx');
$reponse = $bdd->query('SELECT DateTime=convert(nvarchar, DateTime, 20),TagName,Value FROM Runtime.dbo.History WHERE Runtime.dbo.History.TagName LIKE '. "PLB_AUXI_183_BF_183_01.Debit" .' AND wwResolution=1000 AND wwRetrievalMode='."average".' AND wwVersion='."latest".' AND DateTime>='."2017-30-03 08:00:00".' AND DateTime<='."2017-31-03 08:00:00".'; ');
echo '<p>'.$reponse.'</p>';
} catch( Exception $e){
print $e;
}
$reponse->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $reponse->fetch()){
//print '<p>'.$row['TagName'].'</p>';
//fputcsv( $fp, $row);
fwrite( $fp, "test dans la boucle while");
}
fwrite( $fp, "test en dehors de la boucle while");
} else if( $listZone=="Abels"){
try{
$bdd = new PDO('mysql:host=localhost;dbname=sige_export;charset=utf8', 'xxx','xxx');
$reponse = $bdd->query('SELECT * FROM data_SMP0 order by id asc limit 10');
} catch( Exception $e){
print $e;
}
$reponse->setFetchMode(PDO::FETCH_ASSOC);
while( $row = $reponse->fetch()){
fputcsv( $fp, $row);
}
}
fclose($fp);
$id = session_id();
//$n_id = $_SESSION['xxx'];
//print '<p>session id: ' . $n_id . '</p>';
sleep(30);
header('Refresh:2;/config/export_file_csv.php?id=' . $id);
?> |
Partager