Mini Shell
<?php
require_once '_extras/CSV.php';
require_once '_framework/Model.php';
require_once '_framework/Crypto.php';
require_once '_framework/Configuration.php';
class Export extends Model {
private $eol = "\r\n";
function __construct() {
}
public function exportPrestataire($config){
$sql = 'select fonction,nom,prenom,adresse,npa,lieu,tel,email,avis,attrib1,attrib2,attrib3,
note_g,note1,note2,note3,note4,note5,note6,note7,note8,note9,note10,remarque from v_prestataires order by nom';
$prestataire = $this->runQuery($sql, null);
$rs = $prestataire->fetchAll();
$CSVheader = array("Fonction","Nom","Prénom","Adresse","NPA","Lieu","Téléphone","EMail","Nb avis",
"Attrib1","Attrib2","Attrib3","Note glob.",
explode(",",$config["criteres"])[0],
explode(",",$config["criteres"])[1],
explode(",",$config["criteres"])[2],
explode(",",$config["criteres"])[3],
explode(",",$config["criteres"])[4],
explode(",",$config["criteres"])[5],
explode(",",$config["criteres"])[6],
explode(",",$config["criteres"])[7],
explode(",",$config["criteres"])[8],
explode(",",$config["criteres"])[9],
"Remarques");
$csv = new CSV('prestataires.csv',$CSVheader);
foreach($rs as $record) {
$csv->pushValue($record['fonction']);
$csv->pushValue($record['nom']);
$csv->pushValue($record['prenom']);
$csv->pushValue($record['adresse']);
$csv->pushValue($record['npa']);
$csv->pushValue($record['lieu']);
$csv->pushValue($record['tel']);
$csv->pushValue($record['email']);
$csv->pushValue($record['avis']);
$csv->pushValue($record['attrib1']);
$csv->pushValue($record['attrib2']);
$csv->pushValue($record['attrib3']);
$csv->pushValue($record['note_g']);
$csv->pushValue($record['note1']);
$csv->pushValue($record['note2']);
$csv->pushValue($record['note3']);
$csv->pushValue($record['note4']);
$csv->pushValue($record['note5']);
$csv->pushValue($record['note6']);
$csv->pushValue($record['note7']);
$csv->pushValue($record['note8']);
$csv->pushValue($record['note9']);
$csv->pushValue($record['note10']);
$csv->pushValue($record['remarque']);
$csv->writeLine();
}
$csv->startDownload();
}
public function exportAvis($config){
$sql = 'select fdate_avis,avis_statut_txt,memb_nom,memb_email,fonction,prestataire,lieu,
note1,note2,note3,note4,note5,note6,note7,note8,note9,note10,remarque from v_avis order by prestataire,date_avis';
$prestataire = $this->runQuery($sql, null);
$rs = $prestataire->fetchAll();
$CSVheader = array("Date","Statut","Soumi par","EMail","Fonction","Prestataire","Lieu",
explode(",",$config["criteres"])[0],
explode(",",$config["criteres"])[1],
explode(",",$config["criteres"])[2],
explode(",",$config["criteres"])[3],
explode(",",$config["criteres"])[4],
explode(",",$config["criteres"])[5],
explode(",",$config["criteres"])[6],
explode(",",$config["criteres"])[7],
explode(",",$config["criteres"])[8],
explode(",",$config["criteres"])[9],
"Remarques");
$csv = new CSV('avis.csv',$CSVheader);
foreach($rs as $record) {
$csv->pushValue($record['fdate_avis']);
$csv->pushValue($record['avis_statut_txt']);
$csv->pushValue($record['memb_nom']);
$csv->pushValue($record['memb_email']);
$csv->pushValue($record['fonction']);
$csv->pushValue($record['prestataire']);
$csv->pushValue($record['lieu']);
$csv->pushValue($record['note1']);
$csv->pushValue($record['note2']);
$csv->pushValue($record['note3']);
$csv->pushValue($record['note4']);
$csv->pushValue($record['note5']);
$csv->pushValue($record['note6']);
$csv->pushValue($record['note7']);
$csv->pushValue($record['note8']);
$csv->pushValue($record['note9']);
$csv->pushValue($record['note10']);
$csv->pushValue($record['remarque']);
$csv->writeLine();
}
$csv->startDownload();
}
}