IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

APIs Google Discussion :

Une seule chaîne de caractères dans l'adresse au lieu de deux


Sujet :

APIs Google

  1. #1
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut Une seule chaîne de caractères dans l'adresse au lieu de deux
    Bonjour,

    Je soulève une question dont je n'ai pas trouvé réponse dans le forum...
    Dans l'exemple de base de l'autocompletion address form on a la structure suivante:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    var placeSearch, autocomplete;
    var componentForm = {
      street_number: 'short_name',
      route: 'short_name',
      locality: 'long_name',
      administrative_area_level_1: 'long_name',
      country: 'long_name',
      postal_code: 'short_name'
    };
     
    function initialize() {
      // Create the autocomplete object, restricting the search
      // to geographical location types.
      autocomplete = new google.maps.places.Autocomplete(
          /** @type {HTMLInputElement} */(document.getElementById('autocomplete')),
          { types: ['geocode'] });
      // When the user selects an address from the dropdown,
      // populate the address fields in the form.
      google.maps.event.addListener(autocomplete, 'place_changed', function() {
        fillInAddress();
      });
    }
    ce qui implique à avoir le numéro de rue dans un input et la rue juste à coté dans un autre input. Est il possible de ressortir les deux dans le même input soit street_number, espace, route? La section de sortie est celle-ci:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <tr>
        <td class="main b_width"><strong><?php echo ENTRY_STREET_ADDRESS; ?></strong></td>
        <td class="main"><?php echo tep_draw_input_field('street_address','','class="field_adresse" id="route" disabled="true"') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
    </tr>
    ainsi en sortie l'adresse ressort bien mais sans le numéro de rue. Et si je fais:
    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    <tr>
        <td class="main b_width"><strong><?php echo ENTRY_STREET_ADDRESS; ?></strong></td>
        <td class="main"><input class="field_streetnumber" id="street_number"  disabled="true"></input><?php echo tep_draw_input_field('street_address','','class="field_adresse" id="route" disabled="true"') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
    </tr>
    les deux éléments s'affichent de façon séparées ce qui ne m'arrange pas. Je cherche à obtenir ce format de sortie:
    Nom : autocomplete.png
Affichages : 170
Taille : 11,0 Ko
    Quelqu'un aurait il une idée?

  2. #2
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Je suis presque arrivé au résultat souhaité sauf que j'ai encore une erreur quelque part. Si une âme charitable voulait bien me donner un coup de pouce...
    Nom : autocomplete2.png
Affichages : 150
Taille : 11,6 Ko
    il y a ce "[object HTMLInputElement]" en trop et je n'arrive pas à trouver l'erreur qui doit se trouver quelque part coté JavaScript:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
     
    // This example displays an address form, using the autocomplete feature
    // of the Google Places API to help users fill in the information.
     
    var placeSearch, autocomplete;
    var componentForm = {
     // street_number: 'short_name',
      route: ' ',
      locality: 'long_name',
      administrative_area_level_1: 'long_name',
     // country: 'long_name',
      postal_code: 'short_name'
    };
     
    function initialize() {
      // Create the autocomplete object, restricting the search
      // to geographical location types.
      autocomplete = new google.maps.places.Autocomplete(
          /** @type {HTMLInputElement} */(document.getElementById('autocomplete')),
          { types: ['geocode'] });
      // When the user selects an address from the dropdown,
      // populate the address fields in the form.
      google.maps.event.addListener(autocomplete, 'place_changed', function() {
        fillInAddress();
      });
    }
     
    function fillInAddress() {
      // Get the place details from the autocomplete object.
      var place = autocomplete.getPlace();
     
      for (var component in componentForm) {
        document.getElementById(component).value = '';
        document.getElementById(component).disabled = false;
      }
     
      // Get each component of the address from the place details
      // and fill the corresponding field on the form.
      for (var i = 0; i < place.address_components.length; i++) {
        var addressType = place.address_components[i].types[0];
     
     
    	if (addressType == 'street_number') {
                        route += place.address_components[i].long_name + ' ';
                    }
                    if (place.address_components[i].types[0] == 'route') {
                        route += place.address_components[i].long_name;
                    }
    				// update the textboxes
                $('#route').val(route);
     
    	   if (componentForm[addressType]) {
          var val = place.address_components[i][componentForm[addressType]];
          document.getElementById(addressType).value = val;
        }
     
     
     
      }
    }
     
    // Bias the autocomplete object to the user's geographical location,
    // as supplied by the browser's 'navigator.geolocation' object.
    function geolocate() {
      if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
          var geolocation = new google.maps.LatLng(
              position.coords.latitude, position.coords.longitude);
          autocomplete.setBounds(new google.maps.LatLngBounds(geolocation,
              geolocation));
        });
      }
    }

  3. #3
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 098
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 098
    Points : 44 675
    Points
    44 675
    Par défaut
    Bonjour,
    pas tout bien saisie mais lorsque l'on concatène via un += il est impératif qu'il y ait initialisation au préalable
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    var i, nb = place.address_components.length,
        route = '';
    for( i= 0; i < nb ; i++{
      route += ............
    }

  4. #4
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Bonjour,

    Je te remercie du conseil qui doit pointer du doigt la source de mon souci... sauf que je ne comprends pas où placer cette boucle? J'ai essayé de remplacer
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $('#route').val(route);
    par
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    var i, nb = place.address_components.length,
        route = '';
    for( i= 0; i < nb ; i++{
      route += $('#route').val(route);
    }
    mais ça ne marche pas. En fait je n'arrive pas à décrypter ce que veut dire le "route +=". Dois-je laisser tomber la variable $('#route...)??

  5. #5
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Cette ligne superflue "[object HTMLInputElement]" doit s'afficher du fait que l'objet street_number + route n'est pas en html? Je cale complètement, incapable de comprendre pourquoi elle apparait... J'ai entre autre essayé ceci qui ne fonctionne pas non plus:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    for (var i = 0; i < place.address_components.length; i++) {
        var addressType = place.address_components[i].types[0];
     
     
    	if (addressType == 'street_number') {
                        route += place.address_components[i].long_name + ' ';
                    }
        if (place.address_components[i].types[0] == 'route') {
                        route += place.address_components[i].long_name;
                    }
    				// update the textboxes
               // $('#route').val(route);
    		   var i, nb = place.address_components.length,
        route = '';
    for( i= 0; i < nb ; i++{
      route += document.getElementById("route");
    }
    La ligne "route += document.getElementById("route");" n'est pas bonne?

  6. #6
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    D'un point de vue logique je ne comprends pas non plus pourquoi cette combinaison ne marche pas:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    // update the textboxes
               // $('#route').val(route);
    		   var i, nb = place.address_components.length,
        route = '';
    for( i= 0; i < nb ; i++{
      route += place.address_components[i].street_number + ' '+route;
    }
    La boucle "route += place.address_components[i].street_number + ' '+route;" appelle pourtant bien l'affichage numéro/espace/rue??

  7. #7
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    En partant sur l'idée de NoSmoking quelqu'un verrait quoi mettre à la place des points de suspension dans ? J'ai essayé plusieurs choses, rien ne prend...

  8. #8
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Finalement je m'en suis sorti en refondant le tout. Dans mon cas j'ai dû placer le Javascript sur la page du formulaire et non dans un dossier externe - une déduction qui m'a valu de tourner en rond pendant un long moment... Le formulaire en question vise la page create_account d'un environnement OsCommerce.

    Juste avant le </head> :

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>

    Juste après le <body> :

    Code html : Sélectionner tout - Visualiser dans une fenêtre à part
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>

    La section complète de l'enregistrement de l'adresse postale :

    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <table border="0" cellspacing="4" cellpadding="2">
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_STREET_ADDRESS; ?></strong></td>
                    <td class="main"><?php echo tep_draw_input_field('street_address','','id="address" placeholder="Saisissez ici votre adresse" style="width: 440px;"') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      if (ACCOUNT_SUBURB == 'true') {
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_SUBURB; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('suburb') . '&nbsp;' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      }
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_POST_CODE; ?></strong></td>
                    <!--<td class="main width2_100"><?php //echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>-->
    				<td class="main"><?php echo tep_draw_input_field('postcode','','id="zip" style="width: 60px;"') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_CITY; ?></strong></td>
                    <!--<td class="main width2_100"><?php// echo tep_draw_input_field('city') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>-->
    				<td class="main"><?php echo tep_draw_input_field('city','','id="suburb" style="width: 250px;"') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      if (ACCOUNT_STATE == 'true') {
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_STATE; ?></strong></td>
                    <td class="main width2_100">
    <?php
        if ($process == true) {
          if ($entry_state_has_zones == true) {
            $zones_array = array();
            $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
            while ($zones_values = tep_db_fetch_array($zones_query)) {
              $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
            }
            echo tep_draw_pull_down_menu('state', $zones_array);
          } else {
            echo tep_draw_input_field('state','','id="state" style="width: 250px;"');
          }
        } else {
          echo tep_draw_input_field('state','','id="state" style="width: 250px;"');
        }
     
        if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;
    ?>
                    </td>
                  </tr>
    <?php
      }
    ?>
     
    <!--<body onload="setDefaultCountry();">-->
     
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_COUNTRY; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_get_country_list('country','73') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>

    Et enfin ce script à placer après le </html> :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    <script type="text/javascript">
    var updateAddress = {
        autocomplete: new google.maps.places.Autocomplete($("#address")[0], {}),
        event: function(){
            var self = this;
            google.maps.event.addListener(self.autocomplete, 'place_changed', function() {
                var place = self.autocomplete.getPlace(),
                    address = place.address_components,
                    streetAddress = '',
                    suburb = '',
                    state = '',
                    zip = '';
                  //  country = '';
     
                for (var i = 0; i < address.length; i++) {
                    var addressType = address[i].types[0];
     
                    if (addressType == 'subpremise') {
                        streetAddress += address[i].long_name + '/';
                    }
                    if (addressType == 'street_number') {
                        streetAddress += address[i].long_name + ' ';
                    }
                    if (address[i].types[0] == 'route') {
                        streetAddress += address[i].long_name;
                    }
                    if (addressType == 'locality') {
                        suburb = address[i].long_name;
                    }
                    if (addressType == 'administrative_area_level_1') {
                        state = address[i].long_name;
                    }
                    if (addressType == 'postal_code') {
                        zip = address[i].long_name;
                    }
                   // if (addressType == 'country') {
                   //     country = address[i].long_name;
                   // }
                }
     
                // update the textboxes
                $('#address').val(streetAddress);
                $('#suburb').val(suburb);
                $('#state').val(state);
                $('#zip').val(zip);
               // $('#country').val(country);             
            });
     
        }
    };
     
    updateAddress.event();
    </script>
    A priori il y a peu de discussion sur l'autocomplétion d'adresse coté OsCommerce, ce qui me laisse à penser que ce petit bout de code devrait faire son bonhomme de chemin...

  9. #9
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 098
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 098
    Points : 44 675
    Points
    44 675
    Par défaut
    A priori il y a peu de discussion sur l'autocomplétion d'adresse coté OsCommerce, ce qui me laisse à penser que ce petit bout de code devrait faire son bonhomme de chemin...
    peut être aurais dû tu allé faire un tour du coté des exemples (nombreux) fournis par la documentation officielle
    Place Autocomplete Address Form

    Dans mon cas j'ai dû placer le Javascript sur la page du formulaire et non dans un dossier externe - une déduction qui m'a valu de tourner en rond pendant un long moment...
    Je ne comprends pas trop ce qui t'a obligé à faire de la sorte si ce n'est que le script est appelé avant la création des éléments dans la page.

  10. #10
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Bonjour NoSmoking,

    Ce sont justement les exemples fournis par la source officielle qui m'ont inspiré! J'ai trouvé le concept pratique et original au point d'avoir eu l'idée de tenter de l'intégrer à mon site visible ici. Et c'est vrai qu'étrangement, j'ai passé un certain temps à m'en rendre compte, dans un environnement OsCommerce si l'on cherche à mettre le JavaScript dans un fichier *.js lui-même placé dans un dossier js le script ne prend pas. J'ai pensé bon de faire circuler l'info... Au final mon fichier create_account.php donne ceci:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    <?php
     
      require('includes/application_top.php');
     
    // needs to be included earlier to set the success message in the messageStack
      require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);
      // +Login Page a la Amazon
    // redirect the customer to a friendly cookie-must-be-enabled page if cookies are disabled (or the session has not started)
      if ($session_started == false) {
        tep_redirect(tep_href_link(FILENAME_COOKIE_USAGE));
      }
     
      if (isset($login_email_address)) $email_address = $login_email_address;
    // -Login Page a la Amazon
      $HTTP_POST_VARS['dob'] = $HTTP_POST_VARS['dob_ind'].'/'.$HTTP_POST_VARS['dob_inm'].'/'.$HTTP_POST_VARS['dob_inY'];
     
      $process = false;
      if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
        $process = true;
     
        if (ACCOUNT_GENDER == 'true') {
          if (isset($HTTP_POST_VARS['gender'])) {
            $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
          } else {
            $gender = false;
          }
        }
    	$firstname = tep_db_prepare_input(ucfirst(strtolower($HTTP_POST_VARS['firstname'])));
        $lastname = tep_db_prepare_input(mb_strtoupper($HTTP_POST_VARS['lastname']));
        if (ACCOUNT_DOB == 'true') $dob = tep_db_prepare_input($HTTP_POST_VARS['dob']);
        $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
    	if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input(strtoupper($HTTP_POST_VARS['company']));
        $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
        if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input(ucfirst(strtolower($HTTP_POST_VARS['suburb'])));
        $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
        $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
        if (ACCOUNT_STATE == 'true') {
          $state = tep_db_prepare_input($HTTP_POST_VARS['state']);
          if (isset($HTTP_POST_VARS['zone_id'])) {
            $zone_id = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
          } else {
            $zone_id = false;
          }
        }
    //$country = tep_db_prepare_input($HTTP_POST_VARS['country']);
    $input_country = tep_db_prepare_input($HTTP_POST_VARS['country']);
    $country_query = tep_db_query("select countries_id, countries_iso_code_2 from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . tep_db_input($input_country) . "'");
    $country_result = tep_db_fetch_array($country_query);
    $country = $country_result['countries_id'];
        $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
    	$portable = tep_db_prepare_input($HTTP_POST_VARS['portable']);
        $fax = tep_db_prepare_input($HTTP_POST_VARS['fax']);
        if (isset($HTTP_POST_VARS['newsletter'])) {
          $newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);
        } else {
          $newsletter = false;
        }
    //	if (isset($HTTP_POST_VARS['method_id'])) {
    //      $method_id = tep_db_prepare_input($HTTP_POST_VARS['method_id']);
    //    } else {
     //     $method_id = false;
     //   }
        $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
        $confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);
     
        $error = false;
     
        if (ACCOUNT_GENDER == 'true') {
          if ( ($gender != 'm') && ($gender != 'f') ) {
            $error = true;
     
            $messageStack->add('create_account', ENTRY_GENDER_ERROR);
          }
        }
     
        if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR);
        }
     
        if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_LAST_NAME_ERROR);
        }
     
        if (ACCOUNT_DOB == 'true') {
          if (checkdate(substr(tep_date_raw($dob), 4, 2), substr(tep_date_raw($dob), 6, 2), substr(tep_date_raw($dob), 0, 4)) == false) {
            $error = false;
     
            $messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
          }
        }
     
        if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);
        } elseif (tep_validate_email($email_address) == false) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
        } else {
          $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
          $check_email = tep_db_fetch_array($check_email_query);
          if ($check_email['total'] > 0) {
            $error = true;
     
            $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
          }
        }
     
        if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_STREET_ADDRESS_ERROR);
        }
     
        if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_POST_CODE_ERROR);
        }
     
        if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_CITY_ERROR);
        }
     
        if (is_numeric($country) == false) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_COUNTRY_ERROR);
        }
     
        if (ACCOUNT_STATE == 'true') {
          $zone_id = 0;
          $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");
          $check = tep_db_fetch_array($check_query);
          $entry_state_has_zones = ($check['total'] > 0);
          if ($entry_state_has_zones == true) {
            $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and (zone_name = '" . tep_db_input($state) . "' or zone_code = '" . tep_db_input($state) . "')");
            if (tep_db_num_rows($zone_query) == 1) {
              $zone = tep_db_fetch_array($zone_query);
              $zone_id = $zone['zone_id'];
            } else {
              $error = true;
     
              $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
            }
          } else {
            if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
              $error = true;
     
              $messageStack->add('create_account', ENTRY_STATE_ERROR);
            }
          }
        }
     
        if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);
        }
     
     
        if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_PASSWORD_ERROR);
        } elseif ($password != $confirmation) {
          $error = true;
     
          $messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
        }
     
        if ($error == false) {
          $sql_data_array = array('customers_firstname' => $firstname,
                                  'customers_lastname' => $lastname,
                                  'customers_email_address' => $email_address,
    							  'customers_ip_address' => $HTTP_SERVER_VARS["REMOTE_ADDR"],
                                  'customers_telephone' => $telephone,
    							  'customers_portable' => $portable,
                                  'customers_fax' => $fax,
                                  'customers_newsletter' => $newsletter,
                                  'customers_password' => tep_encrypt_password($password));
    							 // 'heard_method_id' => $method_id);
     
          if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
          if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_date_raw($dob);
     
          tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);
     
          $customer_id = tep_db_insert_id();
     
          $sql_data_array = array('customers_id' => $customer_id,
                                  'entry_firstname' => $firstname,
                                  'entry_lastname' => $lastname,
                                  'entry_street_address' => $street_address,
                                  'entry_postcode' => $postcode,
                                  'entry_city' => $city,
                                  'entry_country_id' => $country);
     
          if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
          if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
          if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
          if (ACCOUNT_STATE == 'true') {
            if ($zone_id > 0) {
              $sql_data_array['entry_zone_id'] = $zone_id;
              $sql_data_array['entry_state'] = '';
            } else {
              $sql_data_array['entry_zone_id'] = '0';
              $sql_data_array['entry_state'] = $state;
            }
          }
     
          tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);
     
          $address_id = tep_db_insert_id();
     
          tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");
     
          tep_db_query("insert into " . TABLE_CUSTOMERS_INFO . " (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values ('" . (int)$customer_id . "', '0', now())");
     
          if (SESSION_RECREATE == 'True') {
            tep_session_recreate();
          }
     
          $customer_first_name = $firstname;
          $customer_default_address_id = $address_id;
          $customer_country_id = $country;
          $customer_zone_id = $zone_id;
          tep_session_register('customer_id');
          tep_session_register('customer_first_name');
          tep_session_register('customer_default_address_id');
          tep_session_register('customer_country_id');
          tep_session_register('customer_zone_id');
     
    // restore cart contents
          $cart->restore_contents();
     
    // build the message content
          $name = $firstname . ' ' . $lastname;
     
          if (ACCOUNT_GENDER == 'true') {
             if ($gender == 'm') {
               $email_text = sprintf(EMAIL_GREET_MR, $lastname);
             } else {
               $email_text = sprintf(EMAIL_GREET_MS, $lastname);
             }
          } else {
            $email_text = sprintf(EMAIL_GREET_NONE, $firstname);
          }
     
          // Points/Rewards system V2.1beta BOF
          if ((USE_POINTS_SYSTEM == 'true') && (NEW_SIGNUP_POINT_AMOUNT > 0)) {
    	      tep_add_welcome_points($customer_id);
     
    	      $points_account = '<a href="' . tep_href_link(FILENAME_MY_POINTS, '', 'SSL') . '"><b><u>' . EMAIL_POINTS_ACCOUNT . '</u></b></a>.';
    	      $points_faq = '<a href="' . tep_href_link(FILENAME_MY_POINTS_HELP, '', 'NONSSL') . '"><b><u>' . EMAIL_POINTS_FAQ . '</u></b></a>.';
    	      $text_points = sprintf(EMAIL_WELCOME_POINTS , $points_account, number_format(NEW_SIGNUP_POINT_AMOUNT,POINTS_DECIMAL_PLACES), $currencies->format(tep_calc_shopping_pvalue(NEW_SIGNUP_POINT_AMOUNT)), $points_faq) ."\n\n";
     
    	      $email_text .= EMAIL_WELCOME . EMAIL_USERNAME . EMAIL_PASSWORD . EMAIL_TEXT . $text_points . EMAIL_CONTACT . EMAIL_WARNING;
          } else {
    	      $email_text .= EMAIL_WELCOME . EMAIL_USERNAME . EMAIL_PASSWORD . EMAIL_TEXT . $text_points . EMAIL_CONTACT . EMAIL_WARNING;
          }
    // Points/Rewards system V2.1beta EOF
          if (file_exists(DIR_WS_MODULES.'mail_manager/create_account.php')){
    include(DIR_WS_MODULES.'mail_manager/create_account.php'); 
    }else{ 
    tep_mail($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); 
    }
     
          tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));
        }
      }
     
      $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
    //  require(DIR_WS_INCLUDES . 'template_top.php');
     
    ?>
    <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html <?php echo HTML_PARAMS; ?>>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET; ?>">
    <title><?php echo TITLE; ?></title>
    <base href="<?php echo (($request_type == 'SSL') ? HTTPS_SERVER : HTTP_SERVER) . DIR_WS_CATALOG; ?>">
    <link rel="stylesheet" type="text/css" href="css/constants.css">
    <link rel="stylesheet" type="text/css" href="css/stylesheet.css">
     
    <link rel="stylesheet" type="text/css" href="css/stylesheet_boxes.css">
    <link rel="stylesheet" type="text/css" href="css/stylesheet_content.css">
     
     
    <link rel="stylesheet" type="text/css" href="css/style.css">
    			<script type="text/javascript" src="includes/js/cufon-yui.js"></script>
                <script type="text/javascript" src="includes/js/cufon-replace.js"></script>
                <script type="text/javascript" src="includes/js/Myriad_Web_400.font.js"></script>
     
    <script type="text/javascript" src="includes/js/jquery-1.3.2.min.js"></script>
    <!-- header slider -->
    <script type="text/javascript" src="includes/js/jquery-ui.min.js"></script>
    <script type="text/javascript">
    	$(document).ready(function(){
    		$("#featured > ul").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 7000, true);
    	});
    </script>
    <!-- header slider -->
    <!-- footer bestsellers -->
    <script type="text/javascript" src="includes/js/jzcarousellite.js"></script>
    <!-- footer bestsellers -->
     
    <?php require('includes/form_check.js.php'); ?>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
    </head>
     
    <!-- header //-->
    <?php $tab_sel = 5; ?>
    <?php
      if ((DOWN_FOR_MAINTENANCE == 'false') ||
              ((DOWN_FOR_MAINTENANCE == 'true') && (DOWN_FOR_MAINTENANCE_HEADER_OFF == 'false')) ) {
        require(DIR_WS_INCLUDES . 'header.php');
      }
    ?>
    <!-- header_eof //-->
    <body>
    <script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?libraries=places&sensor=false"></script>
    <!-- body //-->
    <table border="0" class="<?php echo MAIN_TABLE; ?>" cellspacing="0" cellpadding="0" align="center">
    <tr>
        <td class="<?php echo BOX_WIDTH_TD_LEFT; ?>"><table border="0" class="<?php echo BOX_WIDTH_LEFT; ?>" cellspacing="0" cellpadding="0">
    <!-- left_navigation //-->
    <?php require(DIR_WS_INCLUDES . 'column_left.php'); ?>
    <!-- left_navigation_eof //-->
        </table></td>
    <!-- body_text //-->
        <td class="<?php echo CONTENT_WIDTH_TD; ?>"><?php include(DIR_WS_BOXES . 'panel_top.php');?><?php echo tep_draw_form('create_account', tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'), 'post', 'onSubmit="return check_form(create_account);"') . tep_draw_hidden_field('action', 'process'); ?>
     
    <?php echo tep_draw_top();?>
     
    <?php echo tep_draw_title_top();?>
     
    				<?php echo HEADING_TITLE; ?>
     
    <?php echo tep_draw_title_bottom();?>
     
    <?php echo tep_draw1_top();?>
     
    	<table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td class="smallText"><br><?php echo sprintf(TEXT_ORIGIN_LOGIN, tep_href_link(FILENAME_LOGIN, tep_get_all_get_params(), 'SSL')); ?></td>
          </tr>
          <tr>
            <td><?php echo tep_draw_separator('pixel_trans.gif', '100%', '10'); ?></td>
          </tr>
    <?php
      if ($messageStack->size('create_account') > 0) {
    ?>
          <tr>
            <td><?php echo $messageStack->output('create_account'); ?></td>
          </tr>
    	</table>
     
    <?php echo tep_pixel_trans();?>
     
    <?php
      }
    ?>
     
    		<table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr>
                <td class="main indent_2"><b><?php echo CATEGORY_PERSONAL; ?></b></td>
               <td class="inputRequirement" align="right"><?php echo FORM_REQUIRED_INFORMATION; ?></td>
              </tr>
            </table>
     
    <?php echo tep_draw_infoBox_top();?>
     
    			<table border="0" cellspacing="4" cellpadding="2">
    <?php
      if (ACCOUNT_GENDER == 'true') {
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_GENDER; ?></strong></td>
                    <td class="main radio"><?php echo tep_draw_radio_field('gender', 'm') . ' ' . MALE . ' ' . tep_draw_radio_field('gender', 'f') . ' ' . FEMALE . '&nbsp;' . (tep_not_null(ENTRY_GENDER_TEXT) ? '<span class="inputRequirement">' . ENTRY_GENDER_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      }
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_FIRST_NAME; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('firstname') . '&nbsp;' . (tep_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_LAST_NAME; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('lastname') . '&nbsp;' . (tep_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="inputRequirement">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?></td>
                  </tr>
     
    <?php
     if (ACCOUNT_DOB == 'true') { 
    $syear=1980;if (isset($HTTP_POST_VARS['dob_in'])){$syear=$HTTP_POST_VARS['dob_in'];}
    ?>
    <tr>
    <td class="main b_width"><strong><?php echo ENTRY_DATE_OF_BIRTH; ?></strong></td>
    <td class="main"><?php echo tep_draw_pull_down_date('dob_in', '', '', (isset($HTTP_POST_VARS['dob_inY'])? $HTTP_POST_VARS['dob_inY'] : 1980), false, true, 1900); 
                           		         echo '&nbsp;' . (tep_not_null(ENTRY_DATE_OF_BIRTH_TEXT) ? '<span class="inputRequirement">' . ENTRY_DATE_OF_BIRTH_TEXT . '</span>': '');?></td>
    </tr>
    <?php
    }   
    ?>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_EMAIL_ADDRESS; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('email_address') . '&nbsp;' . (tep_not_null(ENTRY_EMAIL_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_EMAIL_ADDRESS_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php
      if (ACCOUNT_COMPANY == 'true') {
    ?>
     
    <?php echo tep_pixel_trans();?>
     
    	<table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td class="main indent_2"><b><?php echo CATEGORY_COMPANY; ?></b></td>
          </tr>
    	</table>
     
    <?php echo tep_draw_infoBox_top();?>
     
    			<table border="0" cellspacing="4" cellpadding="2">
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_COMPANY; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('company') . '&nbsp;' . (tep_not_null(ENTRY_COMPANY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COMPANY_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php
      }
    ?>
     
    <?php echo tep_pixel_trans();?>
     
        <table cellpadding="0" cellspacing="0" border="0">
    	  <tr>
            <td class="main indent_2"><b><?php echo CATEGORY_ADDRESS; ?></b></td>
          </tr>
    	</table>
     
    <?php echo tep_draw_infoBox_top();?>
     
     
     
     
    			<table border="0" cellspacing="2" cellpadding="2">
                  <tr>
                    <td class="main"><?php echo ENTRY_STREET_ADDRESS; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('street_address','','id="address" placeholder="Saisissez ici votre adresse" style="width: 410px;"') . '&nbsp;' . (tep_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="inputRequirement">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      if (ACCOUNT_SUBURB == 'true') {
    ?>
                  <tr>
                    <td class="main"><?php echo ENTRY_SUBURB; ?></td>
                    <td class="main"><?php echo tep_draw_input_field('suburb','','style="width: 255px;"') . '&nbsp;' . (tep_not_null(ENTRY_SUBURB_TEXT) ? '<span class="inputRequirement">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      }
    ?>
                  <tr>
                    <td class="main"><?php echo ENTRY_POST_CODE; ?></td>
                    <!--<td class="main width2_100"><?php //echo tep_draw_input_field('postcode') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>-->
    				<td class="main"><?php echo tep_draw_input_field('postcode','','id="zip" style="width: 60px;"') . '&nbsp;' . (tep_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="inputRequirement">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                    <td class="main"><?php echo ENTRY_CITY; ?></td>
                    <!--<td class="main width2_100"><?php// echo tep_draw_input_field('city') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>-->
    				<td class="main"><?php echo tep_draw_input_field('city','','id="suburb" style="width: 255px;"') . '&nbsp;' . (tep_not_null(ENTRY_CITY_TEXT) ? '<span class="inputRequirement">' . ENTRY_CITY_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php
      if (ACCOUNT_STATE == 'true') {
    ?>
                  <tr>
                    <td class="main"><?php echo ENTRY_STATE; ?></td>
                    <td class="main">
    <?php
        if ($process == true) {
          if ($entry_state_has_zones == true) {
            $zones_array = array();
            $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
            while ($zones_values = tep_db_fetch_array($zones_query)) {
              $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
            }
            echo tep_draw_pull_down_menu('state', $zones_array);
          } else {
            echo tep_draw_input_field('state','','id="state" style="width: 255px;"');
          }
        } else {
          echo tep_draw_input_field('state','','id="state" style="width: 255px;"');
        }
     
        if (tep_not_null(ENTRY_STATE_TEXT)) echo '&nbsp;<span class="inputRequirement">' . ENTRY_STATE_TEXT;
    ?>
                    </td>
                  </tr>
    <?php
      }
    ?>
    <!--<body onload="setDefaultCountry();">-->
     
                  <tr>
                    <td class="main"><?php echo ENTRY_COUNTRY; ?></td>
                    <td class="main"><?php echo tep_get_country_list('country','FR','id="country"') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>
     
     
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php echo tep_pixel_trans();?>
     
    	<table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td class="main indent_2"><b><?php echo CATEGORY_CONTACT2; ?></b></td>
          </tr>
    	</table>
     
    <?php echo tep_draw_infoBox_top();?>
     
    			<table border="0" cellspacing="4" cellpadding="2">
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_TELEPHONE_NUMBER; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('telephone') . '&nbsp;' . (tep_not_null(ENTRY_TELEPHONE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_TELEPHONE_NUMBER_TEXT . '</span>': ''); ?></td>
                  </tr>
    			  <tr>
            <td class="main b_width"><strong><?php echo ENTRY_PORTABLE_NUMBER; ?></strong></td>
            <td class="main width2_100"><?php echo tep_draw_input_field('portable', '', 'class="input"') . '&nbsp;' . (tep_not_null(ENTRY_PORTABLE_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_PORTABLE_NUMBER_TEXT . '</span>': ''); ?></td>
          </tr>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_FAX_NUMBER; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_input_field('fax') . '&nbsp;' . (tep_not_null(ENTRY_FAX_NUMBER_TEXT) ? '<span class="inputRequirement">' . ENTRY_FAX_NUMBER_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php echo tep_pixel_trans();?>
     
    <?php echo tep_draw_infoBox_top();?>
     
    			<table border="0" cellspacing="4" cellpadding="2">
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_NEWSLETTER; ?></strong></td>
                    <td class="main radio"><?php echo tep_draw_checkbox_field('newsletter', '1') . '&nbsp;' . (tep_not_null(ENTRY_NEWSLETTER_TEXT) ? '<span class="inputRequirement">' . ENTRY_NEWSLETTER_TEXT . '</span>': ''); ?></td>
                  </tr>
    <?php /*
            
            $heard_array = array('id'=>'');
            $heard_query = tep_db_query("select * from " . TABLE_HEARDABOUT . " order by method");
            while ($heard_values = tep_db_fetch_array($heard_query)) {
              if($heard_values['active']) $heard_array[] = array('id' => $heard_values['method_id'], 'text' => $heard_values['method']);
            }
            sort($heard_array);
            if($heard_array && count($heard_array) > 0){
    ?>          
                  <tr>
                    <td class="main"><?php echo ENTRY_HEARDABOUT; ?></td>
                    <td class="main"><?php echo tep_draw_pull_down_menu('method_id', $heard_array, ''); ?></td>
                  </tr>
    <?php 
            } 
            
    */?> 
                </table>
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php echo tep_pixel_trans();?>
     
    	<table cellpadding="0" cellspacing="0" border="0">
          <tr>
            <td class="main indent_2"><b><?php echo CATEGORY_PASSWORD; ?></b></td>
          </tr>
    	</table>
     
    <?php echo tep_draw_infoBox_top();?>
     
    			<table border="0" cellspacing="4" cellpadding="2">
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_PASSWORD; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_password_field('password') . '&nbsp;' . (tep_not_null(ENTRY_PASSWORD_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_TEXT . '</span>': ''); ?></td>
                  </tr>
                  <tr>
                    <td class="main b_width"><strong><?php echo ENTRY_PASSWORD_CONFIRMATION; ?></strong></td>
                    <td class="main width2_100"><?php echo tep_draw_password_field('confirmation') . '&nbsp;' . (tep_not_null(ENTRY_PASSWORD_CONFIRMATION_TEXT) ? '<span class="inputRequirement">' . ENTRY_PASSWORD_CONFIRMATION_TEXT . '</span>': ''); ?></td>
                  </tr>
                </table>
     
    <?php echo tep_draw_infoBox_bottom();?>
     
    <?php echo tep_pixel_trans();?>
     
    <?php echo tep_draw_infoBox2_top();?>
     
    			<table border="0" width="100%" cellspacing="0" cellpadding="2">
    				<tr><td align="right"><?php echo tep_image_submit('button_continue.gif', IMAGE_BUTTON_CONTINUE); ?></td></tr>
                </table>
     
    <?php echo tep_draw_infoBox2_bottom();?>
     
    <?php echo tep_draw1_bottom();?>
     
    <?php echo tep_draw_bottom();?>
     
    	</form></td>
    <!-- body_text_eof //-->
    	<td class="<?php echo BOX_WIDTH_TD_RIGHT; ?>"><table border="0" class="<?php echo BOX_WIDTH_RIGHT; ?>" cellspacing="0" cellpadding="0">
    <!-- right_navigation //-->
    <?php include(DIR_WS_INCLUDES . 'column_right.php'); ?>
    <!-- right_navigation_eof //-->
        </table></td>
      </tr>
    </table>
    <!-- body_eof //-->
     
    <!-- footer //-->
    <?php include(DIR_WS_INCLUDES . 'footer.php'); ?>
    <!-- footer_eof //-->
    </body>
    <?php require(DIR_WS_INCLUDES . 'footer_includes.php'); ?>
    </html>
    <script type="text/javascript">
    var updateAddress = {
        autocomplete: new google.maps.places.Autocomplete($("#address")[0], {}),
        event: function(){
            var self = this;
            google.maps.event.addListener(self.autocomplete, 'place_changed', function() {
                var place = self.autocomplete.getPlace(),
                    address = place.address_components,
                    streetAddress = '',
                    suburb = '',
                    state = '',
                    zip = '';
                  //  country = '';
     
                for (var i = 0; i < address.length; i++) {
                    var addressType = address[i].types[0];
     
                    if (addressType == 'subpremise') {
                        streetAddress += address[i].long_name + '/';
                    }
                    if (addressType == 'street_number') {
                        streetAddress += address[i].long_name + ' ';
                    }
                    if (address[i].types[0] == 'route') {
                        streetAddress += address[i].long_name;
                    }
                    if (addressType == 'locality') {
                        suburb = address[i].long_name;
                    }
                    if (addressType == 'administrative_area_level_1') {
                        state = address[i].long_name;
                    }
                    if (addressType == 'postal_code') {
                        zip = address[i].long_name;
                    }
                   // if (addressType == 'country') {
                   //     country = address[i].long_name;
                   // }
                }
     
                // update the textboxes
                $('#address').val(streetAddress);
                $('#suburb').val(suburb);
                $('#state').val(state);
                $('#zip').val(zip);
               // $('#country').val(country);             
            });
     
        }
    };
     
    updateAddress.event();
    </script>
    <?php require(DIR_WS_INCLUDES . 'application_bottom.php'); ?>
    ... et là ça fonctionne très bien! Par contre en l'état la sélection du pays reste manuelle pour l'instant car je n'ai pas encore trouvé la parade pour convertir l'input texte en numérique (exemple: France = 73). Si quelqu'un a une idée...?

  11. #11
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 098
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 098
    Points : 44 675
    Points
    44 675
    Par défaut
    Par contre en l'état la sélection du pays reste manuelle pour l'instant car je n'ai pas encore trouvé la parade pour convertir l'input texte en numérique (exemple: France = 73). Si quelqu'un a une idée...?
    Du mal à comprendre le soucis

  12. #12
    Candidat au Club
    Homme Profil pro
    Inscrit en
    Octobre 2012
    Messages
    9
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Octobre 2012
    Messages : 9
    Points : 2
    Points
    2
    Par défaut
    Un soucis mineur mais qui empêche d'autocompléter le pays... Sous OsCommerce la page create_account.php ci-dessus comporte le formulaire de création du compte. La sélection du pays dépend d'un menu déroulant lié à cette fonction:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    function tep_get_country_list($name, $selected = '', $parameters = '') {
        $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
        $countries = tep_get_countries();
     
        for ($i=0, $n=sizeof($countries); $i<$n; $i++) {
          $countries_array[] = array('id' => $countries[$i]['countries_iso_code_2'], 'text' => $countries[$i]['countries_name']);
        }
     
        return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);
      }
    Cette fonction permet donc de convertir le pays sélectionné en chiffre via son id lequel ira alimenter la base mysql - exemple, pour la France l'ID = 73... L'input en texte enverrai en BDD non pas 73 mais "France" ce qui perturbe toutes les liaisons liées à l'ID du pays sélectionné. En somme pour une autocomplétion entière faudrait, comme le menu déroulant existant, que le pays soit lié à un ID... En tout cas c'est une hypothèse.

  13. #13
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 098
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 098
    Points : 44 675
    Points
    44 675
    Par défaut
    Dans ce cas passe par un table de correspondance du type JSON
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    var oData = {
      'France' : 73,
      'Suisse' : 74
    }
    console.log( oData ['France']);  // 73

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [XL-2010] Recherche d'une sous-chaîne de caractères dans une cellule
    Par StephThai dans le forum Excel
    Réponses: 7
    Dernier message: 13/01/2014, 04h21
  2. Recherche une sous chaîne de caractères dans un Vector
    Par brino1987 dans le forum API standards et tierces
    Réponses: 5
    Dernier message: 12/06/2013, 14h31
  3. Insérer une certaine chaîne de caractères dans MySQL
    Par laurentSc dans le forum Langage
    Réponses: 31
    Dernier message: 05/12/2009, 22h44
  4. Réponses: 7
    Dernier message: 27/04/2007, 10h01
  5. Réponses: 3
    Dernier message: 09/05/2002, 01h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo