Subversion Repositories Applications.papyrus

Rev

Rev 1344 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1344 Rev 1420
Line 17... Line 17...
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: inscription.class.php,v 1.19 2007-04-20 08:40:22 alexandre_tb Exp $
22
// CVS : $Id: inscription.class.php,v 1.20 2007-05-25 13:54:23 alexandre_tb Exp $
23
/**
23
/**
24
* Inscription
24
* Inscription
25
*
25
*
26
* Un module d'inscription, en général ce code est spécifique à
26
* Un module d'inscription, en général ce code est spécifique à
27
* un site web
27
* un site web
Line 29... Line 29...
29
*@package inscription
29
*@package inscription
30
//Auteur original :
30
//Auteur original :
31
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
31
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.19 $ $Date: 2007-04-20 08:40:22 $
34
*@version       $Revision: 1.20 $ $Date: 2007-05-25 13:54:23 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 176... Line 176...
176
        $this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
176
        $this->addRule(array ('mot_de_passe', 'mot_de_passe_repete'), INS_MOTS_DE_PASSE_DIFFERENTS, 'compare', '', 'client') ;
177
        $this->addElement('text', 'nom', INS_NOM) ;
177
        $this->addElement('text', 'nom', INS_NOM) ;
178
        $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
178
        $this->addRule('nom', INS_NOM_REQUIS, 'required', '', 'client') ;
179
        $this->addElement('text', 'prenom', INS_PRENOM) ;
179
        $this->addElement('text', 'prenom', INS_PRENOM) ;
180
        $this->addRule('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
180
        $this->addRule('prenom', INS_PRENOM_REQUIS, 'required', '', 'client') ;
181
        $this->addElement('text', 'adresse_1', INS_ADRESSE_1) ;
181
        $this->addElement('text', 'adresse_1', INS_ADRESSE_1, array('id' => 'adresse_1')) ;
182
        $this->addElement('text', 'adresse_2', INS_ADRESSE_2) ;
182
        $this->addElement('text', 'adresse_2', INS_ADRESSE_2, array('id' => 'adresse_2')) ;
183
        $this->addElement('text', 'cp', INS_CODE_POSTAL) ;
183
        $this->addElement('text', 'cp', INS_CODE_POSTAL, array('id' => 'cp')) ;
184
        $this->addRule('cp', INS_CODE_POSTAL_REQUIS, 'required', '', 'client') ;
184
        $this->addRule('cp', INS_CODE_POSTAL_REQUIS, 'required', '', 'client') ;
185
        $this->addElement('text', 'ville', INS_VILLE) ;
185
        $this->addElement('text', 'ville', INS_VILLE, array('id' => 'ville')) ;
186
        // L'élément pays est construit à partir du tableau liste_pays
186
        // L'élément pays est construit à partir du tableau liste_pays
187
        $liste_pays = new ListeDePays($GLOBALS['ins_db']) ;
187
        $liste_pays = new ListeDePays($GLOBALS['ins_db']) ;
188
        $this->addElement('select', 'pays', INS_PAYS, $liste_pays->getListePays(INS_LANGUE_DEFAUT)) ;
188
        $this->addElement('select', 'pays', INS_PAYS, $liste_pays->getListePays(INS_LANGUE_DEFAUT), array('id' => 'pays')) ;
189
        $this->addElement('text', 'telephone', INS_TELEPHONE, array('size' => '12')) ;
189
        $this->addElement('text', 'telephone', INS_TELEPHONE, array('size' => '12')) ;
190
        $this->addElement('text', 'fax', INS_FAX, array('size' => '12')) ;
190
        $this->addElement('text', 'fax', INS_FAX, array('size' => '12')) ;
191
        $this->addElement('text', 'site', INS_SITE_INTERNET) ;
191
        $this->addElement('text', 'site', INS_SITE_INTERNET) ;
192
        $this->addElement('file', 'image', INS_LOGO_OU_IMAGE) ;
192
        $this->addElement('file', 'image', INS_LOGO_OU_IMAGE) ;
193
		$this->setMaxFileSize(150000); //logo de 15ko maximum
193
		$this->setMaxFileSize(150000); //logo de 15ko maximum
194
        if (INS_CHAMPS_LETTRE != '') $this->addElement('checkbox', 'lettre',INS_LETTRE, '<br />') ;
194
        if (INS_CHAMPS_LETTRE != '') $this->addElement('checkbox', 'lettre',INS_LETTRE, '<br />') ;
195
        $this->addElement('checkbox', 'visible',INS_VISIBLE, '<br />') ;
195
        $this->addElement('checkbox', 'visible',INS_VISIBLE, '<br />') ;
-
 
196
        
196
        $this->addElement('hidden', 'est_structure', 0) ;
197
        $this->addElement('hidden', 'est_structure', 0) ;
197
        $defauts=array ('lettre'=>1,'pays'=>'FR');      
198
        $defauts=array ('lettre'=>1,'pays'=>'FR');
-
 
199
        if (isset ($GLOBALS['ins_config']['ic_google_key']) && $GLOBALS['ins_config']['ic_google_key'] != '') {
-
 
200
	        $this->addElement('button', 'chercher_sur_carte', 'Vérifier mon adresse avec la carte', array("onclick" => "showAddress();"));
-
 
201
	        $this->addElement('text', 'latitude', 'Latitude', array('id' => 'latitude', 'size' => 6, 'readonly' => 'readonly'));
-
 
202
	        $this->addElement('text', 'longitude', 'longitude', array('id' => 'longitude', 'size' => 6, 'readonly' => 'readonly'));
-
 
203
	        $this->addElement('html', '<tr><td colspan="2"	><div id="map" style="width: 600px; height: 450px"></div></td></tr>');
-
 
204
        }      
198
        $this->setDefaults($defauts);	
205
        $this->setDefaults($defauts);	
199
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
206
        // on fait un groupe avec les boutons pour les mettres sur la même ligne
200
        $boutons[] = &HTML_QuickForm::createElement('button', 'annuler', INS_ANNULER, array ("onclick" => "javascript:document.location.href='".$url."'",
207
        $boutons[] = &HTML_QuickForm::createElement('button', 'annuler', INS_ANNULER, array ("onclick" => "javascript:document.location.href='".$url."'",
201
        												'id' => 'annuler', 'class' => 'bouton'));
208
        												'id' => 'annuler', 'class' => 'bouton'));
202
        $boutons[] = &HTML_QuickForm::createElement('submit', 'valider', INS_VALIDER, array ('id' => 'valider', 'class' =>'bouton'));
209
        $boutons[] = &HTML_QuickForm::createElement('submit', 'valider', INS_VALIDER, array ('id' => 'valider', 'class' =>'bouton'));
203
        $this->addGroup($boutons, 'groupe_bouton', '', "\n");
210
        $this->addGroup($boutons, 'groupe_bouton', '', "\n");
-
 
211
        
-
 
212
        if (isset ($GLOBALS['ins_config']['ic_google_key']) && $GLOBALS['ins_config']['ic_google_key'] != '') {
-
 
213
        	GEN_stockerFichierScript('googleMapScript', $GLOBALS['ins_config']['ic_google_key']);
-
 
214
        	
-
 
215
        	
-
 
216
	        $script = '
-
 
217
	        // Variables globales
-
 
218
	        var map = null;
-
 
219
	    	var geocoder = null;
-
 
220
			var lat = document.getElementById("latitude");
-
 
221
	        var lon = document.getElementById("longitude");
-
 
222
	        
-
 
223
	        function load() {
-
 
224
	        if (GBrowserIsCompatible()) {
-
 
225
	          map = new GMap2(document.getElementById("map"));
-
 
226
	          map.addControl(new GSmallMapControl());
-
 
227
			  map.addControl(new GMapTypeControl());
-
 
228
			  map.addControl(new GScaleControl());
-
 
229
			  map.enableContinuousZoom();
-
 
230
			
-
 
231
			  // On centre la carte sur le languedoc roussillon
-
 
232
			  center = new GLatLng(43.84245116699036, 3.768310546875);
-
 
233
	          map.setCenter(center, 7);
-
 
234
			  //marker = new GMarker(center, {draggable: true}) ;
-
 
235
	          GEvent.addListener(map, "click", function(marker, point) {
-
 
236
	  		    if (marker) {
-
 
237
	    	      map.removeOverlay(marker);
-
 
238
	    	      var lat = document.getElementById("latitude");
-
 
239
	              var lon = document.getElementById("longitude");
-
 
240
	    	      lat.value = "";
-
 
241
	              lon.value = "";
-
 
242
			    } else {
-
 
243
			      // On ajoute un marqueur a l endroit du clic et on place les coordonnees dans les champs latitude et longitude
-
 
244
			      marker = new GMarker(point, {draggable: true}) ;
-
 
245
			      GEvent.addListener(marker, "dragend", function () {
-
 
246
	                coordMarker = marker.getPoint() ;
-
 
247
	                var lat = document.getElementById("latitude");
-
 
248
	                var lon = document.getElementById("longitude");
-
 
249
		            lat.value = coordMarker.lat();
-
 
250
	                lon.value = coordMarker.lng();
-
 
251
	              });
-
 
252
		          map.addOverlay(marker);
-
 
253
		          setLatLonForm(marker);
-
 
254
	  		    }
-
 
255
	        });' ;
-
 
256
			if ($this->getElementValue ('latitude') != '' && $this->getElementValue('longitude') != '') {
-
 
257
				$script .= '
-
 
258
						point = new GLatLng('.$this->getElementValue('latitude').', '.$this->getElementValue('longitude').');
-
 
259
						marker = new GMarker(point, {draggable: true});
-
 
260
						map.addOverlay(marker);' ;
-
 
261
			} 
-
 
262
	        $script .= 'geocoder = new GClientGeocoder();
-
 
263
	      }
-
 
264
	    };
-
 
265
	    function showAddress() {
-
 
266
	      var adress_1 = document.getElementById("adresse_1").value ;
-
 
267
	      var adress_2 = document.getElementById("adresse_2").value ;
-
 
268
	      var ville = document.getElementById("ville").value ;
-
 
269
	      var cp = document.getElementById("cp").value ;
-
 
270
	      var selectIndex = document.getElementById("pays").selectedIndex;
-
 
271
	      var pays = document.getElementById("pays").options[selectIndex].text ;
-
 
272
	      
-
 
273
	      var address = adress_1 + \' \' + adress_2 + \' \' + \' \' + cp + \' \' + ville + \' \' +pays ;
-
 
274
	      if (geocoder) {
-
 
275
	        geocoder.getLatLng(
-
 
276
	          address,
-
 
277
	          function(point) {
-
 
278
	            if (!point) {
-
 
279
	              alert(address + " not found");
-
 
280
	            } else {
-
 
281
	              map.setCenter(point, 13);
-
 
282
	              var marker = new GMarker(point, {draggable: true});
-
 
283
	              GEvent.addListener(marker, "dragend", function () {
-
 
284
	      coordMarker = marker.getPoint() ;
-
 
285
	      var lat = document.getElementById("latitude");
-
 
286
	      var lon = document.getElementById("longitude");
-
 
287
		  lat.value = coordMarker.lat();
-
 
288
	      lon.value = coordMarker.lng();
-
 
289
	    });
-
 
290
	
-
 
291
	              map.addOverlay(marker);
-
 
292
	              setLatLonForm(marker)
-
 
293
	              marker.openInfoWindowHtml(address+ "'.INS_GOOGLE_MSG.'");
-
 
294
	            }
-
 
295
	          }
-
 
296
	        );
-
 
297
	      }
-
 
298
	    }
-
 
299
	    function setLatLonForm(marker) {
-
 
300
	      coordMarker = marker.getPoint() ;
-
 
301
	      var lat = document.getElementById("latitude");
-
 
302
	      var lon = document.getElementById("longitude");
-
 
303
		  lat.value = coordMarker.lat();
-
 
304
	      lon.value = coordMarker.lng();
-
 
305
	    }
-
 
306
	    ';
-
 
307
	    GEN_stockerCodeScript($script);
-
 
308
        }
204
    } // end of member function construitFormulaire
309
    } // end of member function construitFormulaire
Line 205... Line 310...
205
    
310
    
206
    /** Modifie le formulaire pour l'adapter au cas des structures
311
    /** Modifie le formulaire pour l'adapter au cas des structures
207
     * 
312
     *