Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 2449 → Rev 2450

/trunk/jrest/services/InventoryPDF.php
36,7 → 36,7
class InventoryPDF extends Cel {
 
var $extendPDFProductor;
 
function InventoryPDF($config) {
 
parent::__construct($config);
46,7 → 46,7
$this->extendPDFProductor = new PDFProductor();
$this->extendPDFProductor->initPDF();
}
 
/**
* uid[0] : utilisateur obligatoire
* uid[1] : si absent : valeur 'all' (commune)
55,10 → 55,10
* uid[4] : si absent : valeur 'all' (station)
*/
function getElement($uid){
// Controle detournement utilisateur
 
// Controle detournement utilisateur
$this->controleUtilisateur($uid[0]);
 
if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
$uid[1]="all";
$requete_location="";
66,7 → 66,7
else {
$requete_location=" AND location= ".Cel::db()->proteger($uid[1])." ";
}
 
if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all") {
$uid[2]="all";
$requete_date="";
74,7 → 74,7
else {
$requete_date=" AND date_observation= ".Cel::db()->proteger($uid[2])." ";
}
 
if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all") {
$uid[3]="all";
$requete_libre="";
93,24 → 93,24
else {
$requete_station=" AND station= ".Cel::db()->proteger($uid[4])." ";
}
 
$value=array();
$requete="SELECT ce_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation," .
" station, commentaire, transmission FROM cel_obs WHERE ce_utilisateur = ".Cel::db()->proteger($uid[0])." " .
$requete_location.
$requete_date.
$requete_libre.
$requete_station.
 
$requete="SELECT ce_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation, " .
"station, commentaire, transmission FROM cel_obs WHERE ce_utilisateur = ".Cel::db()->proteger($uid[0])." " .
$requete_location.
$requete_date.
$requete_libre.
$requete_station.
" ORDER BY ordre ";
 
$resultat_requete = Cel::db()->requeter($requete);
 
$observations = array();;
if(is_array($resultat_requete)) {
$observations = $resultat_requete;
}
 
// Set up the pdf object.
$pdf = &File_PDF::factory(array('orientation' => 'P', 'format' => 'A4'));
// DesActivate compression.
123,13 → 123,13
// Start a page.
$pdf->addPage();
$pdf->setFont('Times', '' , 12);
$i=1;
 
$i=1;
$tempfn = tempnam("","");
 
foreach ($observations as $obs) {
// Denullifiage
 
// Denullifiage
foreach($obs as $k=>$v) {
if (($v=="null") || ($v=="000null")) {
$obs[$k]="";
137,8 → 137,8
else {
$obs[$k]=utf8_decode($v);
}
}
}
 
if ($obs['date_observation']!="0000-00-00 00:00:00") {
list($year,$month,$day)= explode('-',$obs['date_observation']);
list($day)= explode(' ',$day);
147,26 → 147,26
else {
$obs['date_observation']="00/00/0000";
}
 
$text= $obs['nom_sel']." ".$obs['nom_sel_nn']." ".$obs['nom_ret']." ".$obs['nom_ret_nn']." ".$obs['nt']." ".
$obs['famille']." ".$obs['zone_geo']." ".$obs['ce_zone_geo']." ".$obs['date_observation']." ".$obs['station'];
$obs['commentaire'];
 
$pdf->write(10, $text."\n");
 
$projet_photo = 'photoflora';
 
$tab_retour[$projet_photo]=chercherIllustrationsServiceXml(sprintf(EF_URL_PHOTOFLORA_SERVICE, $obs['nt']));
$url_miniature ='';
 
 
$url_miniature ='';
 
foreach ($tab_retour[$projet_photo] as $cle => $illustration) {
if (preg_match(EF_URL_PHOTOFLORA_REGEXP, $illustration['about'], $match)) {
$abreviation = $match[1];
$fichier = $match[2];
$url_miniature = sprintf(EF_URL_PHOTOFLORA_IMG_MIN, $abreviation, $fichier);;
 
// Priorite aux images en png
if (strstr($fichier, '.png')) {
break;
174,7 → 174,7
}
}
 
if ($url_miniature!='') {
if ($url_miniature!='') {
list($debut,$ext)=explode("\.",basename($url_miniature));
$temp = fopen($tempfn, "w");
$buf=file_get_contents($url_miniature);
182,10 → 182,10
fclose($temp);
$pdf->image($tempfn,10,($i*10),0,0,$ext);
}
 
$i++;
}
 
echo $pdf->output("Rapport");
}
}
194,7 → 194,7
{
return analyserFichierRdf($url);
}
 
function analyserFichierRdf($chemin)
{
$aso_info = array();
205,7 → 205,7
} else {
$dom->load($chemin);
}
 
$tab_infos = array();
foreach ($dom->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description') as $rdf_description) {
$aso_info['about'] = $rdf_description->getAttribute('about');
220,7 → 220,7
date_default_timezone_set('Europe/Paris');
}
if (preg_match('/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/', $rdf_description->getAttribute('created'))) {
$aso_info['dcterms:created'] = date('j-m-Y � H:i:s', strtotime($rdf_description->getAttribute('created')));
$aso_info['dcterms:created'] = date('j-m-Y � H:i:s', strtotime($rdf_description->getAttribute('created')));
} else {
$aso_info['dcterms:created'] = $rdf_description->getAttribute('created');
}
227,7 → 227,7
$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));
$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));
$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));
$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info;
$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info;
}
 
return $tab_infos;