Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

step2.php
Go to the documentation of this file.
1 <?php
4 require( "ezuser/user/usercheck.php" );
5
6 include_once( "classes/INIFile.php" );
7 include_once( "classes/eztemplate.php" );
8 include_once( "classes/ezhttptool.php" );
9 include_once( "ezsession/classes/ezsession.php" );
10 include_once( "classes/eztexttool.php" );
11
12 $ini =& eZINI::instance( 'site.ini' );
13 $Language = $ini->variable( "eZUserMain", "Language" );
14 $SelectCountry = $ini->variable( "eZUserMain", "SelectCountry" );
15 $SelectRegion = $ini->variable( "eZUserMain", "SelectRegion" );
16 $AnonymousUserGroup = $ini->variable( "eZUserMain", "AnonymousUserGroup" );
17
18 $AutoCookieLogin = eZHTTPTool::getVar( "AutoCookieLogin" );
19
20 $session =& eZSession::globalSession();
21
22 include_once( "ezuser/classes/ezuser.php" );
23 include_once( "ezuser/classes/ezusergroup.php" );
24 include_once( "ezaddress/classes/ezaddress.php" );
25 include_once( "ezaddress/classes/ezcountry.php" );
26 include_once( "ezaddress/classes/ezregion.php" );
27 include_once( "ezmail/classes/ezmail.php" );
28
29
30
31 $user =& eZUser::currentUser();
32 $mainAddress = eZAddress::mainAddress( $user );
33 $addressList = $user->addresses();
34 $form_type = "Account Registration";
35 if($user){
36 $form_type = "Profile";
37 }
38
39 $default_country = 240; // 240 = U.S.
40 $canada = 39;
41
42 $countryList =& eZCountry::getAllArray();
43 $stateList =& eZRegion::getCountryArray($default_country);
44 $castateList =& eZRegion::getCountryArray($canada);
45 $stateList = array_merge($stateList, $castateList);
46
47 $states = array();
48 $states_unsorted = array();
49 foreach($stateList as $state){
50 $states[" ".$state['ID']] = $state['Name'];
51 }
52 $states_unsorted = $states;
53 array_multisort($states, SORT_ASC, SORT_STRING);
54 //print_r($states);
55 foreach($states as $k=>$v){
56 // print "$k = $states[$k]";
57 }
58 $sameaddress_checked = 'checked';
59
60 $default_ship_country = $default_country;
61 $default_bill_country = $default_country;
62
63 if($next){
64
65 // Report blank errors
66 $error['bill_address1'] = error_check($bill_address1);
67 $error['bill_city'] = error_check($bill_city);
68 $error['bill_zip'] = error_check($bill_zip);
69 $error['bill_phone'] = error_check($bill_phone);
70
71 if(! $sameaddress){
72 $error['ship_address1'] = error_check($ship_address1);
73 $error['ship_city'] = error_check($ship_city);
74 $error['ship_zip'] = error_check($ship_zip);
75 $error['ship_phone'] = error_check($ship_phone);
76 $sameaddress_checked = '';
77 }
78
79 // Check if there were any errors
80 foreach($error as $k=>$v){
81 if($v == 'red'){
82 $errors_ind = 1;
83 $all_fields_error = 'please complete all fields';
84 }
85 }
86
87 $default_bill_state = $bill_state;
88 $default_bill_country = $bill_country;
89 $default_ship_state = $ship_state;
90 $default_ship_country = $ship_country;
91
92 // Add/Edit Address
93 if(! $errors_ind){
94 //$mainAddress = eZAddress::mainAddress( $user );
95 if($addressList[0]){
96 $bill_address = $addressList[0];
97 }else{
98 $bill_add = 1;
99 $bill_address = new eZAddress();
100 }
101
102 if($addressList[1]){
103 $ship_address = $addressList[1];
104 }else{
105 $ship_add = 1;
106 $ship_address = new eZAddress();
107 }
108
109
110 $bill_address->setStreet1($bill_address1);
111 $bill_address->setStreet2($bill_address2);
112 $bill_address->setZip($bill_zip);
113 $bill_address->setPhone($bill_phone);
114 $bill_address->setPlace($bill_city);
115 $bill_address->setCountry($bill_country);
116 $bill_address->setRegion($bill_state);
117 $bill_address->store();
118 if($bill_add){
119 $user->addAddress($bill_address);
120 }
121
122 if(! $sameaddress){
123 $ship_address->setStreet1($ship_address1);
124 $ship_address->setStreet2($ship_address2);
125 $ship_address->setZip($ship_zip);
126 $ship_address->setPhone($ship_phone);
127 $ship_address->setPlace($ship_city);
128 $ship_address->setCountry($ship_country);
129 $ship_address->setRegion($ship_state);
130 $ship_address->store();
131 if($ship_add){
132 $user->addAddress($ship_address);
133 }
134 }
135 header("Location: /index.php/user/confirmation/");
136 }
137
138 }else{
139 if($addressList){
140 if($addressList[0]){
141 $bill_address1 = $addressList[0]->Street1();
142 $bill_address2 = $addressList[0]->Street2();
143 $bill_city = $addressList[0]->Place();
144 $bill_zip = $addressList[0]->Zip();
145 $bill_state = $addressList[0]->Region();
146 $bill_country = $addressList[0]->Country();
147 $bill_phone = $addressList[0]->Phone();
148 $default_bill_state = $bill_state->ID();
149 $default_bill_country = $bill_country->ID();
150 }
151 if($addressList[1]){
152 $ship_address1 = $addressList[1]->Street1();
153 $ship_address2 = $addressList[1]->Street2();
154 $ship_city = $addressList[1]->Place();
155 $ship_zip = $addressList[1]->Zip();
156 $ship_state = $addressList[1]->Region();
157 $ship_country = $addressList[1]->Country();
158 $ship_phone = $addressList[1]->Phone();
159 $default_ship_state = $ship_state->ID();
160 $default_ship_country = $ship_country->ID();
161
162 $sameaddress_checked = '';
163 }else{
164 $sameaddress_checked = 'checked';
165 $default_ship_country = $default_country;
166 }
167 }else{
168 $default_bill_country = $default_country;
169 }
170 }
171
172
173 function error_check($varcheck){
174 if(!($varcheck && strlen($varcheck) <= 50)){
175 return 'red';
176 }else{
177 return 'black';
178 }
179 }
180
181
182
183
184 ?>
185
186
187
188
189 <div id="breadcrumbs">
190 &nbsp;
191 </div>
192
193 <div id="contentWrap">
194 <h1 class="mainHeading"><?= $form_type ?> - Step 2 of 2</h1>
195
196 <form name="todo" method="post">
197 <p>
198 <?= $form_type ?> Step 2 is only required to checkout or obtain an
199 accurate shipping and handling price for items in your shopping cart. All
200 fields are required.
201 </p>
202
203 <p>
204 <input type="button" value="Skip This Step >" onClick="window.location='/index.php/user/confirmation/';">
205 </p>
206
207 <br><br>
208 <table border="0" cellspacing="5" cellpadding="5" class="boxtext" style="font-size=13;">
209 <tr>
210 <td colspan="2"><center>Billing</center><br><br></td><td>&nbsp;&nbsp;</td>
211 <td colspan="2"><center>Shipping</center><br>
212 <center>
213 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="sameaddress" value="1" <?= $sameaddress_checked ?> onClick="fillShipping();">
214 <span style="font-weight:normal;">Same as Billing</span>
215 </center>
216 </td>
217 </tr>
218
219
220 <tr>
221 <td style="color:<?= $error['bill_address1'] ?>;">Address 1: </td><td><input type="text" name="bill_address1" value="<?= $bill_address1 ?>"></td>
222 <td>&nbsp;&nbsp;</td>
223 <td style="color:<?= $error['ship_address1'] ?>;">Address 1: </td><td><input type="text" name="ship_address1" value="<?= $ship_address1 ?>"></td>
224 </tr>
225
226 <tr>
227 <td>Address 2: </td><td><input type="text" name="bill_address2" value="<?= $bill_address2 ?>"></td>
228 <td>&nbsp;&nbsp;</td>
229 <td>Address 2: </td><td><input type="text" name="ship_address2" value="<?= $ship_address2 ?>"></td>
230 </tr>
231
232 <tr>
233 <td style="color:<?= $error['bill_city'] ?>;">City : </td><td><input type="text" name="bill_city" value="<?= $bill_city ?>"></td>
234 <td>&nbsp;&nbsp;</td>
235 <td style="color:<?= $error['ship_city'] ?>;">City : </td><td><input type="text" name="ship_city" value="<?= $ship_city ?>"></td>
236 </tr>
237
238 <tr>
239 <td>State : </td><td>
240 <select name="bill_state">
241 <? foreach($states as $k=>$v): ?>
242 <? $check_state = ($k == $default_bill_state) ? 'selected' : ''; ?>
243 <option value="<?= $k ?>" <?= $check_state ?>><?= substr($v, 0, 26) ?></option>
244 <? endforeach; ?>
245 </select>
246 </td>
247 <td>&nbsp;&nbsp;</td>
248 <td>State : </td><td>
249 <select name="ship_state">
250 <? foreach($states as $k=>$v): ?>
251 <? $check_state = ($k == $default_ship_state) ? 'selected' : ''; ?>
252 <option value="<?= $k ?>" <?= $check_state ?>><?= substr($v, 0, 26) ?></option>
253 <? endforeach; ?>
254 </select>
255 </td>
256 </tr>
257
258 <tr>
259 <td style="color:<?= $error['bill_zip'] ?>;">Zip : </td><td><input type="text" name="bill_zip" value="<?= $bill_zip ?>"></td>
260 <td>&nbsp;&nbsp;</td>
261 <td style="color:<?= $error['ship_zip'] ?>;">Zip : </td><td><input type="text" name="ship_zip" value="<?= $ship_zip ?>"></td>
262 </tr>
263
264 <tr>
265 <td>Country : </td>
266 <td>
267 <select name="bill_country">
268 <? foreach($countryList as $country): ?>
269 <? $check_country = ($country['ID'] == $default_bill_country) ? 'selected' : ''; ?>
270 <option value="<?= $country['ID'] ?>" <?= $check_country ?>><?= substr($country['Name'], 0, 26) ?></option>
271 <? endforeach; ?>
272 </select>
273 </td>
274 <td>&nbsp;&nbsp;</td>
275 <td>Country : </td><td>
276 <select name="ship_country">
277 <? foreach($countryList as $country): ?>
278 <? $check_country = ($country['ID'] == $default_ship_country) ? 'selected' : ''; ?>
279 <option value="<?= $country['ID'] ?>" <?= $check_country ?>><?= substr($country['Name'], 0, 26) ?></option>
280 <? endforeach; ?>
281 </select>
282 </td>
283 </tr>
284
285 <tr>
286 <td style="color:<?= $error['bill_phone'] ?>;">Phone : </td><td><input type="text" name="bill_phone" value="<?= $bill_phone ?>"></td>
287 <td>&nbsp;&nbsp;</td>
288 <td style="color:<?= $error['ship_phone'] ?>;">Phone : </td><td><input type="text" name="ship_phone" value="<?= $ship_phone ?>" ></td>
289 </tr>
290
291 <tr>
292 <td colspan="5">
293 <p><br>
294 <center>
295 <input type="button" value="< Back" onClick="window.location='/index.php/user/step1/';"> &nbsp;&nbsp;&nbsp;&nbsp;
296 <input type="submit" value="Next >" name="next">
297 </center>
298 </p>
299
300 </td>
301 </tr>
302 </table>
303
304
305 <script language="Javascript">
306 function fillShipping(){
307 if(document.forms.todo.sameaddress.checked){
308
309 document.forms.todo.ship_address1.disabled = true;
310 document.forms.todo.ship_address2.disabled = true;
311 document.forms.todo.ship_city.disabled = true;
312 document.forms.todo.ship_state.disabled = true;
313 document.forms.todo.ship_country.disabled = true;
314 document.forms.todo.ship_zip.disabled = true;
315 document.forms.todo.ship_phone.disabled = true;
316
317 }else{
318
319 document.forms.todo.ship_address1.disabled = false;
320 document.forms.todo.ship_address2.disabled = false;
321 document.forms.todo.ship_city.disabled = false;
322 document.forms.todo.ship_state.disabled = false;
323 document.forms.todo.ship_country.disabled = false;
324 document.forms.todo.ship_zip.disabled = false;
325 document.forms.todo.ship_phone.disabled = false;
326
327 }
328 }
329 fillShipping();
330 </script>
331
332
333
334 </form>
eZAddress
Definition: ezaddress.php:42
eZAddress\mainAddress
static mainAddress( $user)
Definition: ezaddress.php:318
eZCountry\getAllArray
static & getAllArray()
Definition: ezcountry.php:196
eZHTTPTool\getVar
static getVar( $name, $onlyCheckPost=false)
Definition: ezhttptool.php:55
eZRegion\getCountryArray
static & getCountryArray( $RequestedCountry=240)
Definition: ezregion.php:238
eZSession\globalSession
static & globalSession( $id="", $fetch=true)
Definition: kernel/ezsession/classes/ezsession.php:614
eZUser\currentUser
static & currentUser()
Definition: ezuser.php:896
$error
$error
Definition: ezarticle/admin/categoryedit.php:51
table
$def table
Definition: ezprestauthorizedclient.php:13
$country
$country
Definition: paypal.php:46
error_check
if($next) error_check($varcheck)
Definition: registration.php:79
nbsp
& nbsp
Definition: step1.php:137
$default_country
if($user) $default_country
Definition: step2.php:39
$castateList
$castateList
Definition: step2.php:44
$default_ship_country
$default_ship_country
Definition: step2.php:60
$SelectCountry
$SelectCountry
Definition: step2.php:14
$AnonymousUserGroup
$AnonymousUserGroup
Definition: step2.php:16
$stateList
$stateList
Definition: step2.php:43
$mainAddress
$mainAddress
Definition: step2.php:32
$states
$states
Definition: step2.php:47
$user
$user
Definition: step2.php:31
$form_type
$form_type
Definition: step2.php:34
$AutoCookieLogin
$AutoCookieLogin
Definition: step2.php:18
$SelectRegion
$SelectRegion
Definition: step2.php:15
$addressList
$addressList
Definition: step2.php:33
$Language
$Language
Definition: step2.php:13
$ini
$ini
Definition: step2.php:12
$default_bill_country
$default_bill_country
Definition: step2.php:61
$countryList
$countryList
Definition: step2.php:42
$session
$session
Definition: step2.php:20
$canada
$canada
Definition: step2.php:40
$states_unsorted
$states_unsorted
Definition: step2.php:48
endforeach
if($next) elseforeach( $states as $k=> $v)($k==$default_bill_state) ? 'selected' endforeach
Definition: step2.php:243
$sameaddress_checked
foreach($states as $k=> $v) $sameaddress_checked
Definition: step2.php:58
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.