Subversion Repositories eFlore/Applications.cel

Rev

Rev 416 | Rev 996 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 416 Rev 885
Line 1... Line 1...
1
<?php
1
<?php
-
 
2
/**
-
 
3
* PHP Version 5
-
 
4
*
-
 
5
* @category  PHP
-
 
6
* @package   jrest
-
 
7
* @author    David Delon <david.delon@clapas.net>
-
 
8
* @copyright 2010 Tela-Botanica
-
 
9
* @license   http://www.cecill.info/licences/Licence_CeCILL_V2-fr.txt Licence CECILL
-
 
10
* @version   SVN: <svn_id>
-
 
11
* @link      /doc/jrest/
-
 
12
*/
Line 2... Line -...
2
 
-
 
3
// In : utf8
-
 
4
// Out : iso8859
-
 
5
 
-
 
Line 6... Line 13...
6
// Formatage pdf d'un releve (a revoir)
13
 
7
 
14
 
8
/** Constante stockant l'URL de la page d'accueil de Photoflora.*/
15
/** Constante stockant l'URL de la page d'accueil de Photoflora.*/
9
define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/');
16
define('EF_URL_PHOTOFLORA', 'http://photoflora.free.fr/');
Line 16... Line 23...
16
/** Constante stockant l'expression r.guli.re r.cup.rant l'abr.viation du photographe et le nom du fichier.*/
23
/** Constante stockant l'expression r.guli.re r.cup.rant l'abr.viation du photographe et le nom du fichier.*/
17
define('EF_URL_PHOTOFLORA_REGEXP', '/\/photos\/([^\/]+)\/max\/(.+)$/');
24
define('EF_URL_PHOTOFLORA_REGEXP', '/\/photos\/([^\/]+)\/max\/(.+)$/');
18
/** Constante stockant l'URL du service XML de Photoflora.*/
25
/** Constante stockant l'URL du service XML de Photoflora.*/
19
define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s');
26
define('EF_URL_PHOTOFLORA_SERVICE', EF_URL_PHOTOFLORA.'ef_photoflora.php?nt=%s');
Line -... Line 27...
-
 
27
 
-
 
28
/**
-
 
29
* InventoryPDF.php
-
 
30
*
-
 
31
* in : utf8
-
 
32
* out : iso8859
-
 
33
*
-
 
34
* Formatage pdf d'un releve (a revoir)
-
 
35
*/
Line 20... Line -...
20
 
-
 
21
 
-
 
22
Class InventoryPDF extends DBAccessor  {
-
 
23
 
-
 
24
 
36
class InventoryPDF extends Cel  {
Line 25... Line 37...
25
	var $config;
37
 
Line -... Line 38...
-
 
38
	var $extendPDFProductor;
-
 
39
	
26
	var $extendPDFProductor;
40
	function InventoryPDF($config) {
27
	
41
 
28
	function InventoryPDF($config) {
42
		parent::__construct($config);
29
 
43
 
30
		$this->config=$config;
44
		$this->config=$config;
Line -... Line 45...
-
 
45
		// Pas d'heritage multiple en php :(
-
 
46
		$this->extendPDFProductor = new PDFProductor();
-
 
47
		$this->extendPDFProductor->initPDF();
-
 
48
	}
-
 
49
	
-
 
50
	/**
31
		// Pas d'heritage multiple en php :(
51
	* uid[0] : utilisateur obligatoire
32
		$this->extendPDFProductor = new PDFProductor();
52
	* uid[1] : si absent : valeur 'all' (commune)
Line 33... Line 53...
33
		$this->extendPDFProductor->initPDF();
53
	* uid[2] : si absent : valeur 'all' (date)
34
	}
54
	* uid[3] : si absent : valeur 'all' (recherche libre)
35
	
55
	* uid[4] : si absent : valeur 'all' (station)
Line 36... Line -...
36
 
-
 
37
	function getElement($uid){
-
 
38
		
-
 
39
		   // Controle detournement utilisateur 
-
 
40
		    session_start();
-
 
41
		 	$this->controleUtilisateur($uid[0]);
-
 
42
 
-
 
43
			// uid[0] : utilisateur obligatoire
-
 
44
			// uid[1] : si absent : valeur 'all' (commune)
56
	*/
45
			// uid[2] : si absent : valeur 'all' (date)
57
	function getElement($uid){
46
			// uid[3] : si absent : valeur 'all' (recherche libre)
58
		
47
			// uid[4] : si absent : valeur 'all' (station)
59
	   // Controle detournement utilisateur 
48
			
60
	    session_start();
49
			$DB=$this->connectDB($this->config,'database_cel');
61
	 	$this->controleUtilisateur($uid[0]);
50
			 
62
	 				 
Line 51... Line 63...
51
			if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
63
		if (!isset($uid[1]) || $uid[1]=="" || $uid[1]=="all" ) {
52
				$uid[1]="all";
64
			$uid[1]="all";
53
				$query_location="";
65
			$requete_location="";
54
			}
66
		}
55
			else {
67
		else {
56
				$query_location=" AND location='".$DB->escapeSimple($uid[1])."' ";
68
			$requete_location=" AND location= ".$this->proteger($uid[1])." ";
57
			}
69
		}
Line 58... Line 70...
58
			
70
		
59
			if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all") {
71
		if (!isset($uid[2]) || $uid[2]=="" || $uid[2]=="all") {
60
				$uid[2]="all";
72
			$uid[2]="all";
61
				$query_date="";
73
			$requete_date="";
62
			}
74
		}
63
			else {
75
		else {
-
 
76
			$requete_date=" AND date_observation= ".$this->proteger($uid[2])." ";
-
 
77
		}
-
 
78
		
64
				$query_date=" AND date_observation='".$DB->escapeSimple($uid[2])."' ";
79
		if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all") {
Line 65... Line 80...
65
			}
80
			$uid[3]="all";
66
			
81
			$requete_libre="";
67
			if (!isset($uid[3]) || $uid[3]=="" || $uid[3]=="all") {
82
		}
68
				$uid[3]="all";
83
		else {
69
				$query_libre="";
84
			$requete_libre=" AND (nom_sel LIKE ".$this->proteger('%'.$uid[3].'%').
70
			}
85
						" OR nom_ret LIKE ".$this->proteger('%'.$uid[3].'%').
71
			else {
86
						" OR station LIKE ".$this->proteger('%'.$uid[3].'%').
Line 72... Line -...
72
				$query_libre=" AND (nom_sel like '%".$DB->escapeSimple($uid[3])."%' OR nom_ret like '%".$DB->escapeSimple($uid[3])."%' OR station like '%".$DB->escapeSimple($uid[3])."%' OR commentaire like '%".$DB->escapeSimple($uid[3])."%') ";
-
 
73
			}
87
						" OR commentaire LIKE ".$this->proteger('%'.$uid[3].'%');
Line 74... Line -...
74
 
-
 
75
			if (!isset($uid[4]) || $uid[4]=="" || $uid[4]=="all") {
88
		}
76
				$uid[4]="all";
89
 
77
				$query_station="";
90
		if (!isset($uid[4]) || $uid[4]=="" || $uid[4]=="all") {
78
			}
91
			$uid[4]="all";
79
			else {
92
			$requete_station="";
80
				$query_station=" AND station='".$DB->escapeSimple($uid[4])."' ";
93
		}
81
			}
94
		else {
Line 82... Line 95...
82
			
95
			$requete_station=" AND station= ".$this->proteger($uid[4])." ";
Line 83... Line -...
83
 
-
 
84
			$value=array();
96
		}
85
			
97
		
-
 
98
		$value=array();
86
			
99
		
Line 87... Line -...
87
		   	$query="SELECT identifiant, ordre, nom_sel, num_nom_sel, nom_ret, num_nom_ret, num_taxon, famille, location, date_observation," .
-
 
88
		           " station, commentaire, transmission  FROM cel_inventory WHERE identifiant='".$DB->escapeSimple($uid[0])."' " .
100
	   	$requete="SELECT ce_utilisateur, ordre, nom_sel, nom_sel_nn, nom_ret, nom_ret_nn, nt, famille, zone_geo, date_observation," .
89
					$query_location.	
101
	           " station, commentaire, transmission  FROM cel_obs WHERE ce_utilisateur = ".$this->proteger($uid[0])." " .
90
	        		$query_date.	
102
				$requete_location.	
91
	        		$query_libre.	
103
        		$requete_date.	
92
	         		$query_station.	
104
        		$requete_libre.	
Line 114... Line 126...
114
			$pdf->setFont('Times', '' , 12);
126
		$pdf->setFont('Times', '' , 12);
Line 115... Line 127...
115
			
127
		
116
			$i=1;	
128
		$i=1;	
Line 117... Line 129...
117
		    $tempfn = tempnam("","");
129
	    $tempfn = tempnam("","");
-
 
130
		
118
			
131
		foreach ($observations as $obs) {
119
			 while ($row =& $res->fetchrow(DB_FETCHMODE_ASSOC)) {
132
			
120
			 	// Denullifiage   
133
		 	// Denullifiage   
121
				foreach($row as $k=>$v) {
134
			foreach($obs as $k=>$v) {
122
					if (($v=="null") || ($v=="000null")) {
135
				if (($v=="null") || ($v=="000null")) {
123
						$row[$k]="";
136
					$obs[$k]="";
124
					}
137
				}
125
					else {
138
				else {
126
						$row[$k]=utf8_decode($v);
139
					$obs[$k]=utf8_decode($v);
Line 127... Line 140...
127
					}
140
				}
128
				} 
141
			} 
129
				
142
			
130
			  	if ($row['date_observation']!="0000-00-00 00:00:00") {
143
		  	if ($obs['date_observation']!="0000-00-00 00:00:00") {
131
	                list($year,$month,$day)= split ('-',$row['date_observation']);
144
                list($year,$month,$day)= split ('-',$obs['date_observation']);
132
    	            list($day)= split (' ',$day);
145
	            list($day)= split (' ',$day);
133
	                $row['date_observation']=$day."/".$month."/".$year;
146
                $obs['date_observation']=$day."/".$month."/".$year;
134
	        	}
147
        	}
Line 135... Line 148...
135
	        	else {
148
        	else {
136
	                $row['date_observation']="00/00/0000";
149
                $obs['date_observation']="00/00/0000";
137
	        	}
150
        	}
Line 138... Line 151...
138
          
151
      
Line 139... Line 152...
139
                $text= $row['nom_sel']." ".$row['num_nom_sel']." ".$row['nom_ret']." ".$row['num_nom_ret']." ".$row['num_taxon']." ".
152
            $text= $obs['nom_sel']." ".$obs['nom_sel_nn']." ".$obs['nom_ret']." ".$obs['nom_ret_nn']." ".$obs['nt']." ".
Line 140... Line 153...
140
                $row['famille']." ".$row['location']." ".$row['id_location']." ".$row['date_observation']." ".$row['station'];
153
            $obs['famille']." ".$obs['zone_geo']." ".$obs['ce_zone_geo']." ".$obs['date_observation']." ".$obs['station'];
Line 141... Line 154...
141
                $row['commentaire'];
154
            $obs['commentaire'];
Line 142... Line 155...
142
                
155
            
Line 160... Line 173...
160
							break;
173
						break;
161
						}
174
					}
162
					}
175
				}
163
				}
176
			}
Line 164... Line -...
164
 
-
 
165
 
-
 
166
 
177
 
167
				if ($url_miniature!='') {				
178
			if ($url_miniature!='') {				
168
					list($debut,$ext)=split("\.",basename($url_miniature));
179
				list($debut,$ext)=split("\.",basename($url_miniature));
169
	       		    $temp = fopen($tempfn, "w");
180
       		    $temp = fopen($tempfn, "w");
170
					$buf=file_get_contents($url_miniature);
181
				$buf=file_get_contents($url_miniature);
Line 174... Line 185...
174
				}
185
			}
Line 175... Line 186...
175
		
186
	
176
                $i++;
187
            $i++;
Line 177... Line -...
177
    	    }
-
 
178
    	
-
 
179
			
-
 
180
			// Print the generated file.
188
	    }
181
			
-
 
182
		echo $pdf->output("Rapport");
-
 
183
			
189
    			
184
 
-
 
185
	}
-
 
186
	
-
 
187
 
190
		echo $pdf->output("Rapport");
Line 188... Line 191...
188
 
191
	}
189
}
192
}
190
 
193
 
Line 225... Line 228...
225
			$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));
228
			$aso_info['dcterms:dateSubmitted'] = utf8_decode($rdf_description->getAttribute('dateSubmitted'));
226
			$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));
229
			$aso_info['dcterms:spatial'] = utf8_decode($rdf_description->getAttribute('spatial'));
227
			$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));
230
			$aso_info['dcterms:licence'] = utf8_decode($rdf_description->getAttribute('licence'));
228
			$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info; 
231
			$tab_infos[$rdf_description->getAttribute('identifier')] = $aso_info; 
229
		}
232
		}
230
		//echo '<pre>'.$chemin.print_r($tab_infos, true).'</pre>';
-
 
-
 
233
 
231
		return $tab_infos;
234
		return $tab_infos;
232
}
235
}
Line 233... Line -...
233
 
-
 
234
 
-
 
235
 
236
 
236
/* +--Fin du code ---------------------------------------------------------------------------------------+
237
/* +--Fin du code ---------------------------------------------------------------------------------------+
237
* $Log$
238
* $Log$
238
* Revision 1.2  2008-01-30 08:57:28  ddelon
239
* Revision 1.2  2008-01-30 08:57:28  ddelon
239
* fin mise en place mygwt
240
* fin mise en place mygwt
Line 242... Line 243...
242
* v0.09
243
* v0.09
243
*
244
*
244
* Revision 1.4  2007-05-22 12:54:09  ddelon
245
* Revision 1.4  2007-05-22 12:54:09  ddelon
245
* Securisation acces utilisateur
246
* Securisation acces utilisateur
246
*
247
*
247
*
-
 
248
* 
-
 
249
*/
248
*/
250
 
-
 
251
 
-
 
252
?>
249
?>