These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /* |
||
3 | You may not change or alter any portion of this comment or credits |
||
4 | of supporting developers from this source code or any supporting source code |
||
5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
6 | |||
7 | This program is distributed in the hope that it will be useful, |
||
8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
10 | */ |
||
11 | |||
12 | /** |
||
13 | * oledrion |
||
14 | * |
||
15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
18 | */ |
||
19 | |||
20 | /** |
||
21 | * Saisie des données du client + affichage des informations saisies pour validation avec redirection vers la passerelle de paiement |
||
22 | */ |
||
23 | require_once __DIR__ . '/header.php'; |
||
24 | $GLOBALS['current_category'] = -1; |
||
25 | $GLOBALS['xoopsOption']['template_main'] = 'oledrion_command.tpl'; |
||
26 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
27 | require_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php'; |
||
28 | require_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; |
||
29 | require_once XOOPS_ROOT_PATH . '/class/tree.php'; |
||
30 | require_once OLEDRION_PATH . 'class/registryfile.php'; |
||
31 | |||
32 | // Get user id |
||
33 | $uid = OledrionUtility::getCurrentUserID(); |
||
34 | // Get checkout level |
||
35 | $checkout_level = OledrionUtility::getModuleOption('checkout_level'); |
||
36 | // Passage de commandes réservé aux utilisateurs enregistrés |
||
37 | if (OledrionUtility::getModuleOption('restrict_orders', false) == 1 && $uid == 0) { |
||
38 | $registry = new oledrion_registryfile(); |
||
39 | $text = $registry->getfile(OLEDRION_TEXTFILE5); |
||
40 | OledrionUtility::redirect(xoops_trim($text), 'index.php', 5); |
||
41 | } |
||
42 | // Get option |
||
43 | $op = 'default'; |
||
44 | if (isset($_POST['op'])) { |
||
45 | $op = $_POST['op']; |
||
46 | } elseif (isset($_GET['op'])) { |
||
47 | $op = $_GET['op']; |
||
48 | } |
||
49 | // Get action |
||
50 | $action = 'default'; |
||
51 | View Code Duplication | if (isset($_POST['action'])) { |
|
52 | $action = $_POST['action']; |
||
53 | } elseif (isset($_GET['action'])) { |
||
54 | $action = $_GET['action']; |
||
55 | } |
||
56 | // Get commend id |
||
57 | $commend_id = 0; |
||
58 | View Code Duplication | if (isset($_POST['commend_id'])) { |
|
0 ignored issues
–
show
|
|||
59 | $commend_id = (int)$_POST['commend_id']; |
||
60 | } elseif (isset($_GET['commend_id'])) { |
||
61 | $commend_id = (int)$_GET['commend_id']; |
||
62 | } |
||
63 | |||
64 | $xoopsTpl->assign('op', $op); |
||
65 | $xoopsTpl->assign('mod_pref', $mod_pref); |
||
66 | $cartForTemplate = array(); |
||
67 | $emptyCart = false; |
||
68 | $shippingAmount = $commandAmount = $vatAmount = $commandAmountTTC = $discountsCount = $commandAmountVAT = 0; |
||
69 | $goOn = ''; |
||
70 | $discountsDescription = array(); |
||
71 | // B.R. New |
||
72 | $checkoutAttributes = array(); |
||
73 | // Assume optional checkout steps skipped (listCart updates) |
||
74 | $checkoutAttributes['skip_packing'] = 1; |
||
75 | $checkoutAttributes['skip_location'] = 1; |
||
76 | $checkoutAttributes['skip_delivery'] = 1; |
||
77 | // B.R. End |
||
78 | |||
79 | function listCart() |
||
80 | { |
||
81 | // B.R. global $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription; |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
55% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
82 | global $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $checkoutAttributes; |
||
83 | $reductions = new oledrion_reductions(); |
||
84 | // B.R. $reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
85 | $reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount, $checkoutAttributes); |
||
86 | } |
||
87 | |||
88 | $oledrion_Currency = Oledrion_Currency::getInstance(); |
||
89 | $countries = OledrionUtility::getCountriesList(); |
||
90 | |||
91 | // B.R. New |
||
92 | listCart(); |
||
93 | // End New |
||
94 | |||
95 | switch ($op) { |
||
96 | case 'save': |
||
97 | if (empty($_POST)) { |
||
98 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
99 | } |
||
100 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
101 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
102 | } |
||
103 | // B.R. listCart(); |
||
104 | |||
105 | switch ($action) { |
||
106 | case 'make': |
||
107 | // B.R. Not sure if this is dead code |
||
108 | trigger_error("case make"); |
||
109 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
110 | $password = md5(xoops_makepass()); |
||
111 | $passwordCancel = md5(xoops_makepass()); |
||
112 | $commande = $h_oledrion_commands->create(true); |
||
113 | $commande->setVars($_POST); |
||
114 | $commande->setVar('cmd_uid', $uid); |
||
115 | $commande->setVar('cmd_date', date('Y-m-d')); |
||
116 | $commande->setVar('cmd_create', time()); |
||
117 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
118 | $commande->setVar('cmd_ip', OledrionUtility::IP()); |
||
119 | $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
||
120 | $commande->setVar('cmd_total', OledrionUtility::formatFloatForDB($commandAmountTTC)); |
||
121 | $commande->setVar('cmd_shipping', OledrionUtility::formatFloatForDB($shippingAmount)); |
||
122 | $commande->setVar('cmd_password', $password); |
||
123 | $commande->setVar('cmd_cancel', $passwordCancel); |
||
124 | $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
||
125 | $commande->setVar('cmd_status', 2); |
||
126 | $res = $h_oledrion_commands->insert($commande, true); |
||
127 | if (!$res) { |
||
128 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
129 | } |
||
130 | // Check checkout level |
||
131 | if ($checkout_level == 1) { |
||
132 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
133 | } elseif ($checkout_level == 2) { |
||
134 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
135 | } else { |
||
136 | OledrionUtility::redirect(_OLEDRION_SELECT_PACKING, OLEDRION_URL . 'checkout.php?op=packing&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
137 | } |
||
138 | break; |
||
139 | |||
140 | case 'find': |
||
141 | // B.R. Not sure if this is dead code |
||
142 | trigger_error("case find"); |
||
143 | if ($commend_id == 0) { |
||
144 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
145 | } |
||
146 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
147 | $commande = $h_oledrion_commands->get($commend_id); |
||
148 | $commande->setVars($_POST); |
||
149 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
150 | $commande->setVar('cmd_ip', OledrionUtility::IP()); |
||
151 | $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
||
152 | $commande->setVar('cmd_total', OledrionUtility::formatFloatForDB($commandAmountTTC)); |
||
153 | $commande->setVar('cmd_shipping', OledrionUtility::formatFloatForDB($shippingAmount)); |
||
154 | $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
||
155 | $commande->setVar('cmd_status', 2); |
||
156 | $res = $h_oledrion_commands->insert($commande, true); |
||
157 | if (!$res) { |
||
158 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
159 | } |
||
160 | OledrionUtility::redirect(_OLEDRION_SELECT_PACKING, OLEDRION_URL . 'checkout.php?op=packing&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
161 | break; |
||
162 | |||
163 | case 'packing': |
||
164 | // B.R. Not sure if this is dead code |
||
165 | trigger_error("case packing"); |
||
166 | $packing_id = 0; |
||
167 | if (isset($_POST['packing_id'])) { |
||
168 | $packing_id = (int)$_POST['packing_id']; |
||
169 | } |
||
170 | if ($packing_id == 0) { |
||
171 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
172 | } |
||
173 | if ($commend_id == 0) { |
||
174 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
175 | } |
||
176 | // Check checkout level |
||
177 | if ($checkout_level == 1) { |
||
178 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
179 | } elseif ($checkout_level == 2) { |
||
180 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commend_id, 1); |
||
181 | } |
||
182 | |||
183 | $packing = $h_oledrion_packing->get($packing_id); |
||
184 | if (!$packing->getVar('packing_id')) { |
||
185 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
186 | } |
||
187 | $commande = $h_oledrion_commands->get($commend_id); |
||
188 | $commande->setVar('cmd_packing', $packing->getVar('packing_title')); |
||
189 | $commande->setVar('cmd_packing_id', $packing->getVar('packing_id')); |
||
190 | $commande->setVar('cmd_packing_price', $packing->getVar('packing_price')); |
||
191 | $res = $h_oledrion_commands->insert($commande, true); |
||
192 | if (!$res) { |
||
193 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
194 | } |
||
195 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
196 | break; |
||
197 | |||
198 | case 'location': |
||
199 | // B.R. Not sure if this is dead code |
||
200 | trigger_error("case location"); |
||
201 | $location_id = 0; |
||
202 | if (isset($_POST['location_id'])) { |
||
203 | $location_id = (int)$_POST['location_id']; |
||
204 | } |
||
205 | if ($location_id == 0) { |
||
206 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
207 | } |
||
208 | if ($commend_id == 0) { |
||
209 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
210 | } |
||
211 | // Check checkout level |
||
212 | if ($checkout_level == 1) { |
||
213 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
214 | } |
||
215 | $location = $h_oledrion_location->get($location_id); |
||
216 | $commande = $h_oledrion_commands->get($commend_id); |
||
217 | $commande->setVar('cmd_location', $location->getVar('location_title')); |
||
218 | $commande->setVar('cmd_location_id', $location->getVar('location_id')); |
||
219 | $res = $h_oledrion_commands->insert($commande, true); |
||
220 | if (!$res) { |
||
221 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
222 | } |
||
223 | |||
224 | if ($h_oledrion_location->haveChild($location->getVar('location_id'))) { |
||
225 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&action=select&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
226 | } else { |
||
227 | OledrionUtility::redirect(_OLEDRION_SELECT_DELIVERY, OLEDRION_URL . 'checkout.php?op=delivery&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
228 | } |
||
229 | break; |
||
230 | |||
231 | case 'delivery': |
||
232 | // B.R. Not sure if this is dead code |
||
233 | trigger_error("case delivery"); |
||
234 | $delivery_id = 0; |
||
235 | if (isset($_POST['delivery_id'])) { |
||
236 | $delivery_id = (int)$_POST['delivery_id']; |
||
237 | } |
||
238 | if ($delivery_id == 0) { |
||
239 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
240 | } |
||
241 | if ($commend_id == 0) { |
||
242 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
243 | } |
||
244 | // Check checkout level |
||
245 | if ($checkout_level == 1) { |
||
246 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
247 | } |
||
248 | $commande = $h_oledrion_commands->get($commend_id); |
||
249 | $delivery = $h_oledrion_delivery->getThisLocationThisDelivery($delivery_id, $commande->getVar('cmd_location_id')); |
||
250 | |||
251 | $shipping_price = ''; |
||
252 | $shipping_price_op = OledrionUtility::getModuleOption('checkout_shipping', false); |
||
253 | switch ($shipping_price_op) { |
||
254 | case 1: |
||
255 | $shipping_price = $shippingAmount + $delivery['delivery_price']; |
||
256 | break; |
||
257 | |||
258 | case 2: |
||
259 | $shipping_price = $shippingAmount; |
||
260 | break; |
||
261 | |||
262 | case 3: |
||
263 | $shipping_price = $delivery['delivery_price']; |
||
264 | break; |
||
265 | |||
266 | case 4: |
||
267 | $shipping_price = 0; |
||
268 | break; |
||
269 | } |
||
270 | $commande->setVar('cmd_delivery', $delivery['delivery_title']); |
||
271 | $commande->setVar('cmd_delivery_id', $delivery['delivery_id']); |
||
272 | $commande->setVar('cmd_shipping', $shipping_price); |
||
273 | $res = $h_oledrion_commands->insert($commande, true); |
||
274 | if (!$res) { |
||
275 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
276 | } |
||
277 | OledrionUtility::redirect(_OLEDRION_SELECT_PAYMENT, OLEDRION_URL . 'checkout.php?op=payment&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
278 | break; |
||
279 | |||
280 | case 'payment': |
||
281 | // B.R. Not sure if this is dead code |
||
282 | trigger_error("case payment"); |
||
283 | $payment_id = 0; |
||
284 | if (isset($_POST['payment_id'])) { |
||
285 | $payment_id = (int)$_POST['payment_id']; |
||
286 | } |
||
287 | if ($payment_id == 0) { |
||
288 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
289 | } |
||
290 | if ($commend_id == 0) { |
||
291 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
292 | } |
||
293 | // Check checkout level |
||
294 | if ($checkout_level == 1) { |
||
295 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
296 | } |
||
297 | $payment = $h_oledrion_payment->get($payment_id); |
||
298 | $commande = $h_oledrion_commands->get($commend_id); |
||
299 | $commande->setVar('cmd_payment', $payment->getVar('payment_title')); |
||
300 | $commande->setVar('cmd_payment_id', $payment->getVar('payment_id')); |
||
301 | $res = $h_oledrion_commands->insert($commande, true); |
||
302 | if (!$res) { |
||
303 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
304 | } |
||
305 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
306 | break; |
||
307 | } |
||
308 | |||
309 | break; |
||
310 | |||
311 | // **************************************************************************************************************** |
||
312 | case 'default': |
||
313 | // Présentation du formulaire |
||
314 | // **************************************************************************************************************** |
||
315 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
316 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
317 | } |
||
318 | // B.R. listCart(); |
||
319 | $notFound = true; |
||
320 | |||
321 | if ($uid > 0) { |
||
322 | // Si c'est un utlisateur enregistré, on recherche dans les anciennes commandes pour pré-remplir les champs |
||
323 | $commande = null; |
||
324 | $commande = $h_oledrion_commands->getLastUserOrder($uid); |
||
325 | if (is_object($commande)) { |
||
326 | $notFound = false; |
||
327 | } |
||
328 | } |
||
329 | |||
330 | if ($notFound) { |
||
331 | $commande = $h_oledrion_commands->create(true); |
||
332 | $commande->setVar('cmd_country', OLEDRION_DEFAULT_COUNTRY); |
||
333 | } |
||
334 | |||
335 | // texte à afficher |
||
336 | $registry = new oledrion_registryfile(); |
||
337 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
338 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
339 | |||
340 | $sform = new XoopsThemeForm(_OLEDRION_PLEASE_ENTER, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
341 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
342 | if ($commande->getVar('cmd_id') && $commande->getVar('cmd_id') > 0) { |
||
343 | $sform->addElement(new XoopsFormHidden('action', 'find')); |
||
344 | $sform->addElement(new XoopsFormHidden('commend_id', $commande->getVar('cmd_id'))); |
||
345 | } else { |
||
346 | $sform->addElement(new XoopsFormHidden('action', 'make')); |
||
347 | } |
||
348 | $sform->addElement(new XoopsFormLabel(_OLEDRION_TOTAL, $oledrion_Currency->amountForDisplay($commandAmountTTC))); |
||
349 | // By voltan |
||
350 | if (in_array(OledrionUtility::getModuleOption('checkout_shipping'), array(1, 2)) && $shippingAmount > 0) { |
||
351 | $sform->addElement(new XoopsFormLabel(_OLEDRION_SHIPPING_PRICE, $oledrion_Currency->amountForDisplay($shippingAmount))); |
||
352 | } |
||
353 | $sform->addElement(new XoopsFormText(_OLEDRION_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname', 'e')), true); |
||
354 | // B.R. New |
||
355 | if ($checkoutAttributes['skip_delivery'] == 0) { |
||
356 | // Assume that select delivery implies also need first name, physical address and phone numbers |
||
357 | $mandatory = true; |
||
358 | } else { |
||
359 | $mandatory = false; |
||
360 | } |
||
361 | // B.R. $sform->addElement(new XoopsFormText(_OLEDRION_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname', 'e')), false); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
362 | $sform->addElement(new XoopsFormText(_OLEDRION_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname', 'e')), $mandatory); |
||
363 | if ($uid > 0) { |
||
364 | $sform->addElement(new XoopsFormText(_OLEDRION_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email', 'e')), true); |
||
365 | } else { |
||
366 | $sform->addElement(new XoopsFormText(_OLEDRION_EMAIL, 'cmd_email', 50, 255, ''), true); |
||
367 | } |
||
368 | $sform->addElement(new XoopsFormText(_OLEDRION_CITY, 'cmd_town', 50, 255, $commande->getVar('cmd_town', 'e')), true); |
||
369 | // By voltan |
||
370 | View Code Duplication | if (OledrionUtility::getModuleOption('checkout_country')) { |
|
371 | $countriesList = new XoopsFormSelect(_OLEDRION_COUNTRY, 'cmd_country', $commande->getVar('cmd_country', ' e')); |
||
372 | $countriesList->addOptionArray($countries); |
||
373 | $sform->addElement($countriesList, true); |
||
374 | } else { |
||
375 | $sform->addElement(new XoopsFormHidden('cmd_country', OLEDRION_DEFAULT_COUNTRY)); |
||
376 | } |
||
377 | $sform->addElement(new XoopsFormText(_OLEDRION_CP, 'cmd_zip', 15, 30, $commande->getVar('cmd_zip', 'e')), true); |
||
378 | // B.R. $sform->addElement(new XoopsFormText(_OLEDRION_MOBILE, 'cmd_mobile', 15, 50, $commande->getVar('cmd_mobile', 'e')), true); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
379 | // B.R. $sform->addElement(new XoopsFormText(_OLEDRION_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone', 'e')), true); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
380 | $sform->addElement(new XoopsFormText(_OLEDRION_MOBILE, 'cmd_mobile', 15, 50, $commande->getVar('cmd_mobile', 'e')), $mandatory); |
||
381 | $sform->addElement(new XoopsFormText(_OLEDRION_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone', 'e')), $mandatory); |
||
382 | if (OledrionUtility::getModuleOption('ask_vatnumber')) { |
||
383 | $sform->addElement(new XoopsFormText(_OLEDRION_VAT_NUMBER, 'cmd_vat_number', 50, 255, $commande->getVar('cmd_vat_number', 'e')), false); |
||
384 | } |
||
385 | if (OledrionUtility::getModuleOption('ask_bill')) { |
||
386 | // B.R. $sform->addElement(new XoopsFormRadioYN(_OLEDRION_INVOICE, 'cmd_bill', 0), true); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
52% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
387 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_INVOICE, 'cmd_bill', 0), false); |
||
388 | } |
||
389 | // B.R. $sform->addElement(new XoopsFormTextArea(_OLEDRION_STREET, 'cmd_adress', $commande->getVar('cmd_adress', 'e'), 3, 50), true); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
59% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
390 | $sform->addElement(new XoopsFormTextArea(_OLEDRION_STREET, 'cmd_adress', $commande->getVar('cmd_adress', 'e'), 3, 50), $mandatory); |
||
391 | $sform->addElement(new XoopsFormText(_OLEDRION_GIFT, 'cmd_gift', 15, 30, $commande->getVar('cmd_gift', 'e')), false); |
||
392 | $button_tray = new XoopsFormElementTray('', ''); |
||
393 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit'); |
||
394 | $button_tray->addElement($submit_btn); |
||
395 | $sform->addElement($button_tray); |
||
396 | $sform = OledrionUtility::formMarkRequiredFields($sform); |
||
397 | $xoopsTpl->assign('form', $sform->render()); |
||
398 | break; |
||
399 | |||
400 | case 'packing': |
||
401 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
402 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
403 | } |
||
404 | if ($commend_id == 0) { |
||
405 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
406 | } |
||
407 | // Check checkout level |
||
408 | if ($checkout_level == 1) { |
||
409 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
410 | // B.R. Start |
||
411 | } elseif ($checkoutAttributes['skip_packing'] == 1) { |
||
412 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commend_id, 1); |
||
413 | // B.R. End |
||
414 | } elseif ($checkout_level == 2) { |
||
415 | OledrionUtility::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commend_id, 1); |
||
416 | } |
||
417 | // B.R. listCart(); |
||
418 | $packings = $h_oledrion_packing->getPacking(); |
||
419 | |||
420 | $sform = new XoopsThemeForm(_OLEDRION_PACKING_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
421 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
422 | $sform->addElement(new XoopsFormHidden('action', 'packing')); |
||
423 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
424 | $packingSelect = new XoopsFormRadio(_OLEDRION_SELECT_PACKING, 'packing_id', ''); |
||
425 | foreach ($packings as $packing) { |
||
426 | $packingSelect->addOption($packing['packing_id'], OledrionUtility::packingHtmlSelect($packing)); |
||
427 | } |
||
428 | $sform->addElement($packingSelect, true); |
||
429 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
430 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
431 | $xoopsTpl->assign('form', $sform->render()); |
||
432 | |||
433 | // texte à afficher |
||
434 | $registry = new oledrion_registryfile(); |
||
435 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
436 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
437 | break; |
||
438 | |||
439 | case 'location': |
||
440 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
441 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
442 | } |
||
443 | if ($commend_id == 0) { |
||
444 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
445 | } |
||
446 | // Check checkout level |
||
447 | View Code Duplication | if ($checkout_level == 1) { |
|
448 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
449 | // B.R. Start |
||
450 | } elseif ($checkoutAttributes['skip_location'] == 1) { |
||
451 | //$commande = $h_oledrion_commands->get($commend_id); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
452 | //OledrionUtility::redirect(_OLEDRION_SELECT_DELIVERY, OLEDRION_URL . 'checkout.php?op=delivery&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
453 | OledrionUtility::redirect(_OLEDRION_SELECT_DELIVERY, OLEDRION_URL . 'checkout.php?op=delivery&commend_id=' . $commend_id, 1); |
||
454 | // B.R. End |
||
455 | } |
||
456 | // B.R. listCart(); |
||
457 | switch ($action) { |
||
458 | case 'default': |
||
459 | $sform = new XoopsThemeForm(_OLEDRION_LOCATION_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
460 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
461 | $sform->addElement(new XoopsFormHidden('action', 'location')); |
||
462 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
463 | $pids = $h_oledrion_location->getAllPid(new Oledrion_parameters()); |
||
464 | $location_pid = new XoopsFormRadio(_OLEDRION_SELECT_LOCATION, 'location_id'); |
||
465 | foreach ($pids as $pid) { |
||
466 | $location_pid->addOption($pid->getVar('location_id'), $pid->getVar('location_title')); |
||
467 | } |
||
468 | $sform->addElement($location_pid, true); |
||
469 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
470 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
471 | $xoopsTpl->assign('form', $sform->render()); |
||
472 | break; |
||
473 | |||
474 | case 'select': |
||
475 | $commande = $h_oledrion_commands->get($commend_id); |
||
476 | $sform = new XoopsThemeForm(_OLEDRION_LOCATION_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
477 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
478 | $sform->addElement(new XoopsFormHidden('action', 'location')); |
||
479 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
480 | $locations = $h_oledrion_location->getLocation($commande->getVar('cmd_location_id')); |
||
481 | $location_select = new XoopsFormSelect(_OLEDRION_SELECT_LOCATION, 'location_id', ''); |
||
482 | foreach ($locations as $location) { |
||
483 | $location_select->addOption($location->getVar('location_id'), $location->getVar('location_title')); |
||
484 | } |
||
485 | $sform->addElement($location_select, true); |
||
486 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
487 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
488 | $xoopsTpl->assign('form', $sform->render()); |
||
489 | break; |
||
490 | } |
||
491 | |||
492 | // texte à afficher |
||
493 | $registry = new oledrion_registryfile(); |
||
494 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
495 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
496 | break; |
||
497 | |||
498 | case 'delivery': |
||
499 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
500 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
501 | } |
||
502 | if ($commend_id == 0) { |
||
503 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
504 | } |
||
505 | // Check checkout level |
||
506 | View Code Duplication | if ($checkout_level == 1) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
507 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
508 | // B.R. Start |
||
509 | } elseif ($checkoutAttributes['skip_delivery'] == 1) { |
||
510 | //$commande = $h_oledrion_commands->get($commend_id); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
64% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
511 | //OledrionUtility::redirect(_OLEDRION_SELECT_PAYMENT, OLEDRION_URL . 'checkout.php?op=payment&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
512 | OledrionUtility::redirect(_OLEDRION_SELECT_PAYMENT, OLEDRION_URL . 'checkout.php?op=payment&commend_id=' . $commend_id, 1); |
||
513 | // B.R. End |
||
514 | } |
||
515 | // B.R. listCart(); |
||
516 | $commande = $h_oledrion_commands->get($commend_id); |
||
517 | $location_id = $commande->getVar('cmd_location_id'); |
||
518 | $deliveres = $h_oledrion_delivery->getThisLocationDelivery($location_id); |
||
519 | |||
520 | $sform = new XoopsThemeForm(_OLEDRION_DELIVERY_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
521 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
522 | $sform->addElement(new XoopsFormHidden('action', 'delivery')); |
||
523 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
524 | $delivery_options = new XoopsFormRadio(_OLEDRION_SELECT_DELIVERY, 'delivery_id'); |
||
525 | foreach ($deliveres as $delivery) { |
||
526 | $delivery_options->addOption($delivery['delivery_id'], OledrionUtility::deliveryHtmlSelect($delivery)); |
||
527 | } |
||
528 | $sform->addElement($delivery_options, true); |
||
529 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
530 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
531 | $xoopsTpl->assign('form', $sform->render()); |
||
532 | |||
533 | // texte à afficher |
||
534 | $registry = new oledrion_registryfile(); |
||
535 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
536 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
537 | break; |
||
538 | |||
539 | case 'payment': |
||
540 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
541 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
542 | } |
||
543 | if ($commend_id == 0) { |
||
544 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
545 | } |
||
546 | // Check checkout level |
||
547 | if ($checkout_level == 1) { |
||
548 | OledrionUtility::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
549 | } |
||
550 | // B.R. listCart(); |
||
551 | // B.R. Start |
||
552 | $commande = $h_oledrion_commands->get($commend_id); |
||
553 | if ($checkoutAttributes['skip_delivery'] == 1) { |
||
554 | // Assumes first deliery method is free shipping (else, why skip?) |
||
555 | // TODO: Consider pre-configuring free shipping as #1 |
||
556 | $delivery_id = 1; |
||
557 | } else { |
||
558 | // B.R. End |
||
559 | $delivery_id = $commande->getVar('cmd_delivery_id'); |
||
560 | } |
||
561 | $payments = $h_oledrion_payment->getThisDeliveryPayment($delivery_id); |
||
562 | |||
563 | $sform = new XoopsThemeForm(_OLEDRION_PAYMENT_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post', true); |
||
564 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
565 | $sform->addElement(new XoopsFormHidden('action', 'payment')); |
||
566 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
567 | $payment_options = new XoopsFormRadio(_OLEDRION_SELECT_PAYMENT, 'payment_id'); |
||
568 | foreach ($payments as $payment) { |
||
569 | $payment_options->addOption($payment['payment_id'], OledrionUtility::paymentHtmlSelect($payment)); |
||
570 | } |
||
571 | $sform->addElement($payment_options, true); |
||
572 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_CONFIRM, 'submit')); |
||
573 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
574 | $xoopsTpl->assign('form', $sform->render()); |
||
575 | |||
576 | // texte à afficher |
||
577 | $registry = new oledrion_registryfile(); |
||
578 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
579 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
580 | break; |
||
581 | |||
582 | // **************************************************************************************************************** |
||
583 | case 'confirm': |
||
584 | // Validation finale avant envoi sur la passerelle de paiement (ou arrêt) |
||
585 | // **************************************************************************************************************** |
||
586 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
587 | OledrionUtility::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
588 | } |
||
589 | if ($commend_id == 0) { |
||
590 | OledrionUtility::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
591 | } |
||
592 | // B.R. listCart(); |
||
593 | |||
594 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
595 | |||
596 | $commande = $h_oledrion_commands->get($commend_id); |
||
597 | if ($commande->getVar('cmd_status') == 1) { |
||
598 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'), 6); |
||
599 | } |
||
600 | $commande->setVar('cmd_create', time()); |
||
601 | $commande->setVar('cmd_date', date('Y-m-d')); |
||
602 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
603 | $commande->setVar('cmd_ip', OledrionUtility::IP()); |
||
604 | $commande->setVar('cmd_status', 1); |
||
605 | $res = $h_oledrion_commands->insert($commande, true); |
||
606 | if (!$res) { |
||
607 | OledrionUtility::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
608 | } |
||
609 | |||
610 | // Save command and empty cart |
||
611 | $h_oledrion_caddy->emptyCart(); |
||
612 | |||
613 | // Enregistrement du panier |
||
614 | $msgCommande = ''; |
||
615 | $handlers = OledrionHandler::getInstance(); |
||
616 | foreach ($cartForTemplate as $line) { |
||
617 | $panier = $h_oledrion_caddy->create(true); |
||
618 | $panier->setVar('caddy_product_id', $line['product_id']); |
||
619 | $panier->setVar('caddy_qte', $line['product_qty']); |
||
620 | $panier->setVar('caddy_price', OledrionUtility::formatFloatForDB($line['totalPrice'])); |
||
621 | // Attention, prix TTC avec frais de port |
||
622 | $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
||
623 | $panier->setVar('caddy_shipping', OledrionUtility::formatFloatForDB($line['discountedShipping'])); |
||
624 | $panier->setVar('caddy_pass', md5(xoops_makepass())); |
||
625 | // Pour le téléchargement |
||
626 | $res = $h_oledrion_caddy->insert($panier, true); |
||
627 | // Make msg |
||
628 | $cat = $h_oledrion_cat->get($line['product_cid'])->toArray(); |
||
629 | $msgCommande .= str_pad($line['product_id'], 5, ' ') . ' '; |
||
630 | $msgCommande .= str_pad($cat['cat_title'], 10, ' ', STR_PAD_LEFT) . ' '; |
||
631 | $msgCommande .= str_pad($line['product_title'], 19, ' ', STR_PAD_LEFT) . ' '; |
||
632 | $msgCommande .= str_pad($line['product_qty'], 8, ' ', STR_PAD_LEFT) . ' '; |
||
633 | $msgCommande .= str_pad($oledrion_Currency->amountForDisplay($line['product_price']), 15, ' ', STR_PAD_LEFT) . ' '; |
||
634 | //$msgCommande .= str_pad($line['totalPriceFormated'],10,' ', STR_PAD_LEFT) . ' '; |
||
635 | $msgCommande .= "\n"; |
||
636 | // Attributs |
||
637 | if ($res && is_array($line['attributes']) && count($line['attributes']) > 0) { |
||
638 | // Enregistrement des attributs pour ce produit |
||
639 | foreach ($line['attributes'] as $attributeId => $attributeInformation) { |
||
640 | $caddyAttribute = $handlers->h_oledrion_caddy_attributes->create(true); |
||
641 | $caddyAttribute->setVar('ca_cmd_id', $commande->getVar('cmd_id')); |
||
642 | $caddyAttribute->setVar('ca_caddy_id', $panier->getVar('caddy_id')); |
||
643 | $caddyAttribute->setVar('ca_attribute_id', $attributeId); |
||
644 | $selectedOptions = $attributeInformation['attribute_options']; |
||
645 | $msgCommande .= '- ' . $attributeInformation['attribute_title'] . "\n"; |
||
646 | foreach ($selectedOptions as $selectedOption) { |
||
647 | $caddyAttribute->addOption($selectedOption['option_name'], $selectedOption['option_value'], $selectedOption['option_price']); |
||
648 | $msgCommande .= ' ' . $selectedOption['option_name'] . ' : ' . $selectedOption['option_ttc_formated'] . "\n"; |
||
649 | } |
||
650 | $handlers->h_oledrion_caddy_attributes->insert($caddyAttribute, true); |
||
651 | } |
||
652 | } |
||
653 | } |
||
654 | |||
655 | // Totaux généraux |
||
656 | //$msgCommande .= "\n\n"._OLEDRION_SHIPPING_PRICE.' '.$oledrion_Currency->amountForDisplay($shippingAmount)."\n"; |
||
657 | $msgCommande .= "\n\n" . _OLEDRION_TOTAL . ' ' . $oledrion_Currency->amountForDisplay($commandAmountTTC) . "\n"; |
||
658 | if (count($discountsDescription) > 0) { |
||
659 | $msgCommande .= "\n\n" . _OLEDRION_CART4 . "\n"; |
||
660 | $msgCommande .= implode("\n", $discountsDescription); |
||
661 | $msgCommande .= "\n"; |
||
662 | } |
||
663 | |||
664 | $msg = array(); |
||
665 | $msg['COMMANDE'] = $msgCommande; |
||
666 | $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
||
667 | $msg['NOM'] = $commande->getVar('cmd_lastname'); |
||
668 | $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
||
669 | $msg['ADRESSE'] = $commande->getVar('cmd_adress', 'n'); |
||
670 | $msg['CP'] = $commande->getVar('cmd_zip'); |
||
671 | $msg['VILLE'] = $commande->getVar('cmd_town'); |
||
672 | $msg['PAYS'] = $countries[$commande->getVar('cmd_country')]; |
||
673 | $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
||
674 | $msg['EMAIL'] = $commande->getVar('cmd_email'); |
||
675 | $msg['URL_BILL'] = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
676 | $msg['IP'] = OledrionUtility::IP(); |
||
677 | if ($commande->getVar('cmd_bill') == 1) { |
||
678 | $msg['FACTURE'] = _YES; |
||
679 | } else { |
||
680 | $msg['FACTURE'] = _NO; |
||
681 | } |
||
682 | // Send mail to client |
||
683 | // B.R. New Rather than sending message before payment approval, save parameters in OLEDRION_UPLOAD_PATH/${cmd_id}_conf_email.serialize |
||
684 | // TODO: Make a configuration option? |
||
685 | // Then, based on payment approval / disapproval, send email at payment gatewayNotify callback |
||
686 | $email_name = sprintf('%s/%d%s', OLEDRION_UPLOAD_PATH, $commande->getVar('cmd_id'), OLEDRION_CONFIRMATION_EMAIL_FILENAME_SUFFIX); |
||
687 | file_put_contents($email_name, serialize($msg)); |
||
688 | //OledrionUtility::sendEmailFromTpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_OLEDRION_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
70% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
689 | // Send mail to admin |
||
690 | //OledrionUtility::sendEmailFromTpl('command_shop.tpl', OledrionUtility::getEmailsFromGroup(OledrionUtility::getModuleOption('grp_sold')), _OLEDRION_NEW_COMMAND, $msg); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
62% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
691 | // End New |
||
692 | |||
693 | // Présentation du formulaire pour envoi à la passerelle de paiement |
||
694 | // Présentation finale avec panier en variables cachées ****************************** |
||
695 | $registry = new oledrion_registryfile(); |
||
696 | $text = $registry->getfile(OLEDRION_TEXTFILE7); |
||
697 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
698 | |||
699 | if ($checkout_level == 1) { |
||
700 | $text = $registry->getfile(OLEDRION_TEXTFILE4); |
||
701 | $xoopsTpl->append('text', '<br>' . xoops_trim($text)); |
||
702 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
703 | $sform = new XoopsThemeForm(_OLEDRION_FINISH, 'payform', $payURL, 'post', true); |
||
704 | } else { |
||
705 | // B.R. New |
||
706 | $payment_id = 1; // TODO: figure out how to get |
||
707 | $payment = $h_oledrion_payment->get($payment_id); |
||
708 | // End new |
||
709 | // B.R. if (!isset($payment) || $payment['payment_type'] === 'offline' || $commandAmountTTC == 0) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
50% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
710 | if (!isset($payment) || $payment->getVar('payment_type') === 'offline' || $commandAmountTTC == 0) { |
||
711 | $text = $registry->getfile(OLEDRION_TEXTFILE4); |
||
712 | $xoopsTpl->append('text', '<br>' . xoops_trim($text)); |
||
713 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
714 | $sform = new XoopsThemeForm(_OLEDRION_FINISH, 'payform', $payURL, 'post', true); |
||
715 | } else { |
||
716 | // Set gateway |
||
717 | // B.R. $gateway = Oledrion_gateways::getGatewayObject($payment['payment_gateway']); |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
45% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
718 | $gateway = Oledrion_gateways::getGatewayObject($payment->getVar('payment_gateway')); |
||
719 | if (!is_object($gateway)) { |
||
720 | die(_OLEDRION_ERROR20); |
||
721 | } |
||
722 | if (is_object($gateway)) { |
||
723 | $payURL = $gateway->getRedirectURL($commande->getVar('cmd_total'), $commande->getVar('cmd_id')); |
||
724 | } else { |
||
725 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
726 | } |
||
727 | $sform = new XoopsThemeForm(_OLEDRION_PAY_GATEWAY, 'payform', $payURL, 'post', true); |
||
728 | $elements = array(); |
||
729 | if (is_object($gateway)) { |
||
730 | $elements = $gateway->getCheckoutFormContent($commande); |
||
731 | } |
||
732 | foreach ($elements as $key => $value) { |
||
733 | $sform->addElement(new XoopsFormHidden($key, $value)); |
||
734 | } |
||
735 | } |
||
736 | } |
||
737 | |||
738 | $sform->addElement(new XoopsFormLabel(_OLEDRION_AMOUNT_PRICE, $oledrion_Currency->amountForDisplay($commandAmountTTC))); |
||
739 | View Code Duplication | if ($commande->getVar('cmd_shipping') > 0) { |
|
740 | $sform->addElement(new XoopsFormLabel(_OLEDRION_SHIPPING_PRICE, $oledrion_Currency->amountForDisplay($commande->getVar('cmd_shipping')))); |
||
741 | } |
||
742 | View Code Duplication | if ($commande->getVar('cmd_packing_price') > 0) { |
|
743 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PACKING_PRICE, $oledrion_Currency->amountForDisplay($commande->getVar('cmd_packing_price')))); |
||
744 | } |
||
745 | $sform->addElement(new XoopsFormLabel(_OLEDRION_TOTAL, $oledrion_Currency->amountForDisplay($commandAmountTTC + $commande->getVar('cmd_shipping') + $commande->getVar('cmd_packing_price')))); |
||
746 | $sform->addElement(new XoopsFormLabel(_OLEDRION_LASTNAME, $commande->getVar('cmd_lastname'))); |
||
747 | $sform->addElement(new XoopsFormLabel(_OLEDRION_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
||
748 | $sform->addElement(new XoopsFormLabel(_OLEDRION_STREET, $commande->getVar('cmd_adress'))); |
||
749 | $sform->addElement(new XoopsFormLabel(_OLEDRION_CP, $commande->getVar('cmd_zip'))); |
||
750 | $sform->addElement(new XoopsFormLabel(_OLEDRION_CITY, $commande->getVar('cmd_town'))); |
||
751 | if (OledrionUtility::getModuleOption('checkout_country')) { |
||
752 | $sform->addElement(new XoopsFormLabel(_OLEDRION_COUNTRY, $countries[$commande->getVar('cmd_country')])); |
||
753 | } |
||
754 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PHONE, $commande->getVar('cmd_telephone'))); |
||
755 | $sform->addElement(new XoopsFormLabel(_OLEDRION_MOBILE, $commande->getVar('cmd_mobile'))); |
||
756 | $sform->addElement(new XoopsFormLabel(_OLEDRION_EMAIL, $commande->getVar('cmd_email'))); |
||
757 | $sform->addElement(new XoopsFormLabel(_OLEDRION_GIFT, $commande->getVar('cmd_gift'))); |
||
758 | if ($commande->getVar('cmd_packing')) { |
||
759 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PACKING, $commande->getVar('cmd_packing'))); |
||
760 | } |
||
761 | if ($commande->getVar('cmd_location')) { |
||
762 | $sform->addElement(new XoopsFormLabel(_OLEDRION_LOCATION, $commande->getVar('cmd_location'))); |
||
763 | } |
||
764 | if ($commande->getVar('cmd_delivery')) { |
||
765 | $sform->addElement(new XoopsFormLabel(_OLEDRION_DELIVERY, $commande->getVar('cmd_delivery'))); |
||
766 | } |
||
767 | if ($commande->getVar('cmd_payment')) { |
||
768 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PAYMENT, $commande->getVar('cmd_payment'))); |
||
769 | } |
||
770 | if (OledrionUtility::getModuleOption('ask_vatnumber')) { |
||
771 | $sform->addElement(new XoopsFormLabel(_OLEDRION_VAT_NUMBER, $commande->getVar('cmd_vat_number'))); |
||
772 | } |
||
773 | if (OledrionUtility::getModuleOption('ask_bill')) { |
||
774 | if ($commande->getVar('cmd_bill') == 0) { |
||
775 | $sform->addElement(new XoopsFormLabel(_OLEDRION_INVOICE, _NO)); |
||
776 | } else { |
||
777 | $sform->addElement(new XoopsFormLabel(_OLEDRION_INVOICE, _YES)); |
||
778 | } |
||
779 | } |
||
780 | $button_tray = new XoopsFormElementTray('', ''); |
||
781 | //B.R. if (!isset($payment) || $payment['payment_type'] === 'offline' || $commandAmountTTC == 0 || $checkout_level == 1 ) { |
||
0 ignored issues
–
show
Unused Code
Comprehensibility
introduced
by
48% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it. The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production. This check looks for comments that seem to be mostly valid code and reports them. ![]() |
|||
782 | if (!isset($payment) || $payment->getVar('payment_type') === 'offline' || $commandAmountTTC == 0 || $checkout_level == 1) { |
||
783 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_FINISH, 'submit'); |
||
784 | } else { |
||
785 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_PAY_GATEWAY, 'submit'); |
||
786 | } |
||
787 | $button_tray->addElement($submit_btn); |
||
788 | $sform->addElement($button_tray); |
||
789 | $xoopsTpl->assign('form', $sform->render()); |
||
790 | |||
791 | // Send sms |
||
792 | if (OledrionUtility::getModuleOption('sms_checkout')) { |
||
793 | $information['to'] = ltrim($commande->getVar('cmd_mobile'), 0); |
||
794 | $information['text'] = OledrionUtility::getModuleOption('sms_checkout_text'); |
||
795 | $sms = Oledrion_sms::sendSms($information); |
||
796 | } |
||
797 | break; |
||
798 | } |
||
799 | |||
800 | $xoopsTpl->assign('breadcrumb', OledrionUtility::breadcrumb(array(OLEDRION_URL . basename(__FILE__) => _OLEDRION_VALIDATE_CMD))); |
||
801 | |||
802 | // Image icons |
||
803 | View Code Duplication | if (file_exists(OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/image/step1.png')) { |
|
804 | $step1 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step1.png'; |
||
805 | $step2 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step2.png'; |
||
806 | $step3 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step3.png'; |
||
807 | } else { |
||
808 | // Fallback |
||
809 | $step1 = OLEDRION_URL . 'language/english/image/step1.png'; |
||
810 | $step2 = OLEDRION_URL . 'language/english/image/step2.png'; |
||
811 | $step3 = OLEDRION_URL . 'language/english/image/step3.png'; |
||
812 | } |
||
813 | $xoopsTpl->assign('step1', $step1); |
||
814 | $xoopsTpl->assign('step2', $step2); |
||
815 | $xoopsTpl->assign('step3', $step3); |
||
816 | |||
817 | $title = _OLEDRION_VALIDATE_CMD . ' - ' . OledrionUtility::getModuleName(); |
||
818 | OledrionUtility::setMetas($title, $title); |
||
819 | OledrionUtility::setCSS(); |
||
820 | OledrionUtility::setLocalCSS($xoopsConfig['language']); |
||
821 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
822 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.