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 http://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 __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 = Oledrion_utils::getCurrentUserID(); |
||
34 | // Get checkout level |
||
35 | $checkout_level = Oledrion_utils::getModuleOption('checkout_level'); |
||
36 | // Passage de commandes réservé aux utilisateurs enregistrés |
||
37 | if (Oledrion_utils::getModuleOption('restrict_orders', false) == 1 && $uid == 0) { |
||
38 | $registry = new oledrion_registryfile(); |
||
39 | $text = $registry->getfile(OLEDRION_TEXTFILE5); |
||
40 | Oledrion_utils::redirect(xoops_trim($text), 'index.php', 5); |
||
41 | } |
||
42 | // Get option |
||
43 | $op = 'default'; |
||
44 | View Code Duplication | if (isset($_POST['op'])) { |
|
0 ignored issues
–
show
|
|||
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 | if (isset($_POST['commend_id'])) { |
||
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 | |||
72 | function listCart() |
||
73 | { |
||
74 | global $cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription; |
||
75 | $reductions = new oledrion_reductions(); |
||
76 | $reductions->computeCart($cartForTemplate, $emptyCart, $shippingAmount, $commandAmount, $vatAmount, $goOn, $commandAmountTTC, $discountsDescription, $discountsCount); |
||
77 | } |
||
78 | |||
79 | $oledrion_Currency = Oledrion_Currency::getInstance(); |
||
80 | $countries = Oledrion_utils::getCountriesList(); |
||
81 | |||
82 | switch ($op) { |
||
83 | case 'save' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
84 | if (empty($_POST)) { |
||
85 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
86 | } |
||
87 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
88 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
89 | } |
||
90 | listCart(); |
||
91 | |||
92 | switch ($action) { |
||
93 | case 'make' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
94 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
95 | $password = md5(xoops_makepass()); |
||
96 | $passwordCancel = md5(xoops_makepass()); |
||
97 | $commande = $h_oledrion_commands->create(true); |
||
98 | $commande->setVars($_POST); |
||
99 | $commande->setVar('cmd_uid', $uid); |
||
100 | $commande->setVar('cmd_date', date('Y-m-d')); |
||
101 | $commande->setVar('cmd_create', time()); |
||
102 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
103 | $commande->setVar('cmd_ip', Oledrion_utils::IP()); |
||
104 | $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
||
105 | $commande->setVar('cmd_total', Oledrion_utils::formatFloatForDB($commandAmountTTC)); |
||
106 | $commande->setVar('cmd_shipping', Oledrion_utils::formatFloatForDB($shippingAmount)); |
||
107 | $commande->setVar('cmd_password', $password); |
||
108 | $commande->setVar('cmd_cancel', $passwordCancel); |
||
109 | $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
||
110 | $commande->setVar('cmd_status', 2); |
||
111 | $res = $h_oledrion_commands->insert($commande, true); |
||
112 | if (!$res) { |
||
113 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
114 | } |
||
115 | // Check checkout level |
||
116 | if ($checkout_level == 1) { |
||
117 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
118 | } elseif ($checkout_level == 2) { |
||
119 | Oledrion_utils::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
120 | } else { |
||
121 | Oledrion_utils::redirect(_OLEDRION_SELECT_PACKING, OLEDRION_URL . 'checkout.php?op=packing&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
122 | } |
||
123 | break; |
||
124 | |||
125 | case 'find' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
126 | if ($commend_id == 0) { |
||
127 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
128 | } |
||
129 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
130 | $commande = $h_oledrion_commands->get($commend_id); |
||
131 | $commande->setVars($_POST); |
||
132 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
133 | $commande->setVar('cmd_ip', Oledrion_utils::IP()); |
||
134 | $commande->setVar('cmd_articles_count', count($cartForTemplate)); |
||
135 | $commande->setVar('cmd_total', Oledrion_utils::formatFloatForDB($commandAmountTTC)); |
||
136 | $commande->setVar('cmd_shipping', Oledrion_utils::formatFloatForDB($shippingAmount)); |
||
137 | $commande->setVar('cmd_text', implode("\n", $discountsDescription)); |
||
138 | $commande->setVar('cmd_status', 2); |
||
139 | $res = $h_oledrion_commands->insert($commande, true); |
||
140 | if (!$res) { |
||
141 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
142 | } |
||
143 | Oledrion_utils::redirect(_OLEDRION_SELECT_PACKING, OLEDRION_URL . 'checkout.php?op=packing&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
144 | break; |
||
145 | |||
146 | case 'packing' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
147 | $packing_id = 0; |
||
148 | if (isset($_POST['packing_id'])) { |
||
149 | $packing_id = (int)$_POST['packing_id']; |
||
150 | } |
||
151 | if ($packing_id == 0) { |
||
152 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
153 | } |
||
154 | if ($commend_id == 0) { |
||
155 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
156 | } |
||
157 | // Check checkout level |
||
158 | 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. ![]() |
|||
159 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
160 | } elseif ($checkout_level == 2) { |
||
161 | Oledrion_utils::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commend_id, 1); |
||
162 | } |
||
163 | |||
164 | $packing = $h_oledrion_packing->get($packing_id); |
||
165 | if (!$packing->getVar('packing_id')) { |
||
166 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
167 | } |
||
168 | $commande = $h_oledrion_commands->get($commend_id); |
||
169 | $commande->setVar('cmd_packing', $packing->getVar('packing_title')); |
||
170 | $commande->setVar('cmd_packing_id', $packing->getVar('packing_id')); |
||
171 | $commande->setVar('cmd_packing_price', $packing->getVar('packing_price')); |
||
172 | $res = $h_oledrion_commands->insert($commande, true); |
||
173 | if (!$res) { |
||
174 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
175 | } |
||
176 | Oledrion_utils::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
177 | break; |
||
178 | |||
179 | case 'location' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
180 | $location_id = 0; |
||
181 | if (isset($_POST['location_id'])) { |
||
182 | $location_id = (int)$_POST['location_id']; |
||
183 | } |
||
184 | if ($location_id == 0) { |
||
185 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
186 | } |
||
187 | if ($commend_id == 0) { |
||
188 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
189 | } |
||
190 | // Check checkout level |
||
191 | if ($checkout_level == 1) { |
||
192 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
193 | } |
||
194 | $location = $h_oledrion_location->get($location_id); |
||
195 | $commande = $h_oledrion_commands->get($commend_id); |
||
196 | $commande->setVar('cmd_location', $location->getVar('location_title')); |
||
197 | $commande->setVar('cmd_location_id', $location->getVar('location_id')); |
||
198 | $res = $h_oledrion_commands->insert($commande, true); |
||
199 | if (!$res) { |
||
200 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
201 | } |
||
202 | |||
203 | if ($h_oledrion_location->haveChild($location->getVar('location_id'))) { |
||
204 | Oledrion_utils::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&action=select&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
205 | } else { |
||
206 | Oledrion_utils::redirect(_OLEDRION_SELECT_DELIVERY, OLEDRION_URL . 'checkout.php?op=delivery&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
207 | } |
||
208 | break; |
||
209 | |||
210 | case 'delivery' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
211 | $delivery_id = 0; |
||
212 | if (isset($_POST['delivery_id'])) { |
||
213 | $delivery_id = (int)$_POST['delivery_id']; |
||
214 | } |
||
215 | if ($delivery_id == 0) { |
||
216 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
217 | } |
||
218 | if ($commend_id == 0) { |
||
219 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
220 | } |
||
221 | // Check checkout level |
||
222 | if ($checkout_level == 1) { |
||
223 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
224 | } |
||
225 | $commande = $h_oledrion_commands->get($commend_id); |
||
226 | $delivery = $h_oledrion_delivery->getThisLocationThisDelivery($delivery_id, $commande->getVar('cmd_location_id')); |
||
227 | |||
228 | $shipping_price = ''; |
||
229 | $shipping_price_op = Oledrion_utils::getModuleOption('checkout_shipping', false); |
||
230 | switch ($shipping_price_op) { |
||
231 | case 1 : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
232 | $shipping_price = $shippingAmount + $delivery['delivery_price']; |
||
233 | break; |
||
234 | |||
235 | case 2 : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
236 | $shipping_price = $shippingAmount; |
||
237 | break; |
||
238 | |||
239 | case 3 : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
240 | $shipping_price = $delivery['delivery_price']; |
||
241 | break; |
||
242 | |||
243 | case 4 : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
244 | $shipping_price = 0; |
||
245 | break; |
||
246 | } |
||
247 | $commande->setVar('cmd_delivery', $delivery['delivery_title']); |
||
248 | $commande->setVar('cmd_delivery_id', $delivery['delivery_id']); |
||
249 | $commande->setVar('cmd_shipping', $shipping_price); |
||
250 | $res = $h_oledrion_commands->insert($commande, true); |
||
251 | if (!$res) { |
||
252 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
253 | } |
||
254 | Oledrion_utils::redirect(_OLEDRION_SELECT_PAYMENT, OLEDRION_URL . 'checkout.php?op=payment&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
255 | break; |
||
256 | |||
257 | case 'payment' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
258 | $payment_id = 0; |
||
259 | if (isset($_POST['payment_id'])) { |
||
260 | $payment_id = (int)$_POST['payment_id']; |
||
261 | } |
||
262 | if ($payment_id == 0) { |
||
263 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
264 | } |
||
265 | if ($commend_id == 0) { |
||
266 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
267 | } |
||
268 | // Check checkout level |
||
269 | if ($checkout_level == 1) { |
||
270 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
271 | } |
||
272 | $payment = $h_oledrion_payment->get($payment_id); |
||
273 | $commande = $h_oledrion_commands->get($commend_id); |
||
274 | $commande->setVar('cmd_payment', $payment->getVar('payment_title')); |
||
275 | $commande->setVar('cmd_payment_id', $payment->getVar('payment_id')); |
||
276 | $res = $h_oledrion_commands->insert($commande, true); |
||
277 | if (!$res) { |
||
278 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
279 | } |
||
280 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commande->getVar('cmd_id'), 1); |
||
281 | break; |
||
282 | } |
||
283 | |||
284 | break; |
||
285 | |||
286 | // **************************************************************************************************************** |
||
287 | case 'default' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
288 | // Présentation du formulaire |
||
289 | // **************************************************************************************************************** |
||
290 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
291 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
292 | } |
||
293 | listCart(); |
||
294 | $notFound = true; |
||
295 | |||
296 | if ($uid > 0) { |
||
297 | // Si c'est un utlisateur enregistré, on recherche dans les anciennes commandes pour pré-remplir les champs |
||
298 | $commande = null; |
||
299 | $commande = $h_oledrion_commands->getLastUserOrder($uid); |
||
300 | if (is_object($commande)) { |
||
301 | $notFound = false; |
||
302 | } |
||
303 | } |
||
304 | |||
305 | if ($notFound) { |
||
306 | $commande = $h_oledrion_commands->create(true); |
||
307 | $commande->setVar('cmd_country', OLEDRION_DEFAULT_COUNTRY); |
||
308 | } |
||
309 | |||
310 | // texte à afficher |
||
311 | $registry = new oledrion_registryfile(); |
||
312 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
313 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
314 | |||
315 | $sform = new XoopsThemeForm(_OLEDRION_PLEASE_ENTER, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
316 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
317 | if ($commande->getVar('cmd_id') && $commande->getVar('cmd_id') > 0) { |
||
318 | $sform->addElement(new XoopsFormHidden('action', 'find')); |
||
319 | $sform->addElement(new XoopsFormHidden('commend_id', $commande->getVar('cmd_id'))); |
||
320 | } else { |
||
321 | $sform->addElement(new XoopsFormHidden('action', 'make')); |
||
322 | } |
||
323 | $sform->addElement(new XoopsFormLabel(_OLEDRION_TOTAL, $oledrion_Currency->amountForDisplay($commandAmountTTC))); |
||
324 | // By voltan |
||
325 | if (in_array(Oledrion_utils::getModuleOption('checkout_shipping'), array(1, 2)) && $shippingAmount > 0) { |
||
326 | $sform->addElement(new XoopsFormLabel(_OLEDRION_SHIPPING_PRICE, $oledrion_Currency->amountForDisplay($shippingAmount))); |
||
327 | } |
||
328 | $sform->addElement(new XoopsFormText(_OLEDRION_LASTNAME, 'cmd_lastname', 50, 255, $commande->getVar('cmd_lastname', 'e')), true); |
||
329 | $sform->addElement(new XoopsFormText(_OLEDRION_FIRSTNAME, 'cmd_firstname', 50, 255, $commande->getVar('cmd_firstname', 'e')), false); |
||
330 | if ($uid > 0) { |
||
331 | $sform->addElement(new XoopsFormText(_OLEDRION_EMAIL, 'cmd_email', 50, 255, $xoopsUser->getVar('email', 'e')), true); |
||
332 | } else { |
||
333 | $sform->addElement(new XoopsFormText(_OLEDRION_EMAIL, 'cmd_email', 50, 255, ''), true); |
||
334 | } |
||
335 | $sform->addElement(new XoopsFormText(_OLEDRION_CITY, 'cmd_town', 50, 255, $commande->getVar('cmd_town', 'e')), true); |
||
336 | // By voltan |
||
337 | View Code Duplication | if (Oledrion_utils::getModuleOption('checkout_country')) { |
|
338 | $countriesList = new XoopsFormSelect(_OLEDRION_COUNTRY, 'cmd_country', $commande->getVar('cmd_country', ' e')); |
||
339 | $countriesList->addOptionArray($countries); |
||
340 | $sform->addElement($countriesList, true); |
||
341 | } else { |
||
342 | $sform->addElement(new XoopsFormHidden('cmd_country', OLEDRION_DEFAULT_COUNTRY)); |
||
343 | } |
||
344 | $sform->addElement(new XoopsFormText(_OLEDRION_CP, 'cmd_zip', 15, 30, $commande->getVar('cmd_zip', 'e')), true); |
||
345 | $sform->addElement(new XoopsFormText(_OLEDRION_MOBILE, 'cmd_mobile', 15, 50, $commande->getVar('cmd_mobile', 'e')), true); |
||
346 | $sform->addElement(new XoopsFormText(_OLEDRION_PHONE, 'cmd_telephone', 15, 50, $commande->getVar('cmd_telephone', 'e')), true); |
||
347 | if (Oledrion_utils::getModuleOption('ask_vatnumber')) { |
||
348 | $sform->addElement(new XoopsFormText(_OLEDRION_VAT_NUMBER, 'cmd_vat_number', 50, 255, $commande->getVar('cmd_vat_number', 'e')), false); |
||
349 | } |
||
350 | if (Oledrion_utils::getModuleOption('ask_bill')) { |
||
351 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_INVOICE, 'cmd_bill', 0), true); |
||
352 | } |
||
353 | $sform->addElement(new XoopsFormTextArea(_OLEDRION_STREET, 'cmd_adress', $commande->getVar('cmd_adress', 'e'), 3, 50), true); |
||
354 | $sform->addElement(new XoopsFormText(_OLEDRION_GIFT, 'cmd_gift', 15, 30, $commande->getVar('cmd_gift', 'e')), false); |
||
355 | $button_tray = new XoopsFormElementTray('', ''); |
||
356 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit'); |
||
357 | $button_tray->addElement($submit_btn); |
||
358 | $sform->addElement($button_tray); |
||
359 | $sform = Oledrion_utils::formMarkRequiredFields($sform); |
||
360 | $xoopsTpl->assign('form', $sform->render()); |
||
361 | break; |
||
362 | |||
363 | case 'packing' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
364 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
365 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
366 | } |
||
367 | if ($commend_id == 0) { |
||
368 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
369 | } |
||
370 | // Check checkout level |
||
371 | View Code Duplication | if ($checkout_level == 1) { |
|
372 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
373 | } elseif ($checkout_level == 2) { |
||
374 | Oledrion_utils::redirect(_OLEDRION_SELECT_LOCATION, OLEDRION_URL . 'checkout.php?op=location&commend_id=' . $commend_id, 1); |
||
375 | } |
||
376 | listCart(); |
||
377 | $packings = $h_oledrion_packing->getPacking(); |
||
378 | |||
379 | $sform = new XoopsThemeForm(_OLEDRION_PACKING_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
380 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
381 | $sform->addElement(new XoopsFormHidden('action', 'packing')); |
||
382 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
383 | $packingSelect = new XoopsFormRadio(_OLEDRION_SELECT_PACKING, 'packing_id', ''); |
||
384 | foreach ($packings as $packing) { |
||
385 | $packingSelect->addOption($packing['packing_id'], Oledrion_utils::packingHtmlSelect($packing)); |
||
386 | } |
||
387 | $sform->addElement($packingSelect, true); |
||
388 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
389 | $sform =& Oledrion_utils::formMarkRequiredFields($sform); |
||
390 | $xoopsTpl->assign('form', $sform->render()); |
||
391 | |||
392 | // texte à afficher |
||
393 | $registry = new oledrion_registryfile(); |
||
394 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
395 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
396 | break; |
||
397 | |||
398 | case 'location' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
399 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
400 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
401 | } |
||
402 | if ($commend_id == 0) { |
||
403 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
404 | } |
||
405 | // Check checkout level |
||
406 | if ($checkout_level == 1) { |
||
407 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
408 | } |
||
409 | listCart(); |
||
410 | switch ($action) { |
||
411 | case 'default' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
412 | $sform = new XoopsThemeForm(_OLEDRION_LOCATION_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
413 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
414 | $sform->addElement(new XoopsFormHidden('action', 'location')); |
||
415 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
416 | $pids = $h_oledrion_location->getAllPid(new Oledrion_parameters()); |
||
417 | $location_pid = new XoopsFormRadio(_OLEDRION_SELECT_LOCATION, 'location_id'); |
||
418 | foreach ($pids as $pid) { |
||
419 | $location_pid->addOption($pid->getVar('location_id'), $pid->getVar('location_title')); |
||
420 | } |
||
421 | $sform->addElement($location_pid, true); |
||
422 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
423 | $sform =& Oledrion_utils::formMarkRequiredFields($sform); |
||
424 | $xoopsTpl->assign('form', $sform->render()); |
||
425 | break; |
||
426 | |||
427 | case 'select' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
428 | $commande = $h_oledrion_commands->get($commend_id); |
||
429 | $sform = new XoopsThemeForm(_OLEDRION_LOCATION_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
430 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
431 | $sform->addElement(new XoopsFormHidden('action', 'location')); |
||
432 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
433 | $locations = $h_oledrion_location->getLocation($commande->getVar('cmd_location_id')); |
||
434 | $location_select = new XoopsFormSelect(_OLEDRION_SELECT_LOCATION, 'location_id', ''); |
||
435 | foreach ($locations as $location) { |
||
436 | $location_select->addOption($location->getVar('location_id'), $location->getVar('location_title')); |
||
437 | } |
||
438 | $sform->addElement($location_select, true); |
||
439 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
440 | $sform =& Oledrion_utils::formMarkRequiredFields($sform); |
||
441 | $xoopsTpl->assign('form', $sform->render()); |
||
442 | break; |
||
443 | } |
||
444 | |||
445 | // texte à afficher |
||
446 | $registry = new oledrion_registryfile(); |
||
447 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
448 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
449 | break; |
||
450 | |||
451 | View Code Duplication | case 'delivery' : |
|
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. ![]() There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
452 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
453 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
454 | } |
||
455 | if ($commend_id == 0) { |
||
456 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
457 | } |
||
458 | // Check checkout level |
||
459 | if ($checkout_level == 1) { |
||
460 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
461 | } |
||
462 | listCart(); |
||
463 | $commande = $h_oledrion_commands->get($commend_id); |
||
464 | $location_id = $commande->getVar('cmd_location_id'); |
||
465 | $deliveres = $h_oledrion_delivery->getThisLocationDelivery($location_id); |
||
466 | |||
467 | $sform = new XoopsThemeForm(_OLEDRION_DELIVERY_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
468 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
469 | $sform->addElement(new XoopsFormHidden('action', 'delivery')); |
||
470 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
471 | $delivery_options = new XoopsFormRadio(_OLEDRION_SELECT_DELIVERY, 'delivery_id'); |
||
472 | foreach ($deliveres as $delivery) { |
||
473 | $delivery_options->addOption($delivery['delivery_id'], Oledrion_utils::deliveryHtmlSelect($delivery)); |
||
474 | } |
||
475 | $sform->addElement($delivery_options, true); |
||
476 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_NEXT, 'submit')); |
||
477 | $sform =& Oledrion_utils::formMarkRequiredFields($sform); |
||
478 | $xoopsTpl->assign('form', $sform->render()); |
||
479 | |||
480 | // texte à afficher |
||
481 | $registry = new oledrion_registryfile(); |
||
482 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
483 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
484 | break; |
||
485 | |||
486 | View Code Duplication | case 'payment' : |
|
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. ![]() There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
487 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
488 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
489 | } |
||
490 | if ($commend_id == 0) { |
||
491 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
492 | } |
||
493 | // Check checkout level |
||
494 | if ($checkout_level == 1) { |
||
495 | Oledrion_utils::redirect(_OLEDRION_FINAL_CHECKOUT, OLEDRION_URL . 'checkout.php?op=confirm&commend_id=' . $commend_id, 1); |
||
496 | } |
||
497 | listCart(); |
||
498 | $commande = $h_oledrion_commands->get($commend_id); |
||
499 | $delivery_id = $commande->getVar('cmd_delivery_id'); |
||
500 | $payments = $h_oledrion_payment->getThisDeliveryPayment($delivery_id); |
||
501 | |||
502 | $sform = new XoopsThemeForm(_OLEDRION_PAYMENT_FORM, 'informationfrm', OLEDRION_URL . 'checkout.php', 'post'); |
||
503 | $sform->addElement(new XoopsFormHidden('op', 'save')); |
||
504 | $sform->addElement(new XoopsFormHidden('action', 'payment')); |
||
505 | $sform->addElement(new XoopsFormHidden('commend_id', $commend_id)); |
||
506 | $payment_options = new XoopsFormRadio(_OLEDRION_SELECT_PAYMENT, 'payment_id'); |
||
507 | foreach ($payments as $payment) { |
||
508 | $payment_options->addOption($payment['payment_id'], Oledrion_utils::paymentHtmlSelect($payment)); |
||
509 | } |
||
510 | $sform->addElement($payment_options, true); |
||
511 | $sform->addElement(new XoopsFormButton('', 'post', _OLEDRION_SAVE_CONFIRM, 'submit')); |
||
512 | $sform =& Oledrion_utils::formMarkRequiredFields($sform); |
||
513 | $xoopsTpl->assign('form', $sform->render()); |
||
514 | |||
515 | // texte à afficher |
||
516 | $registry = new oledrion_registryfile(); |
||
517 | $text = $registry->getfile(OLEDRION_TEXTFILE6); |
||
518 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
519 | break; |
||
520 | |||
521 | // **************************************************************************************************************** |
||
522 | case 'confirm' : |
||
0 ignored issues
–
show
There must be no space before the colon in a CASE statement
As per the PSR-2 coding standard, there must not be a space in front of the colon in case statements. switch ($selector) {
case "A": //right
doSomething();
break;
case "B" : //wrong
doSomethingElse();
break;
}
To learn more about the PSR-2 coding standard, please refer to the PHP-Fig. ![]() |
|||
523 | // Validation finale avant envoi sur la passerelle de paiement (ou arrêt) |
||
524 | // **************************************************************************************************************** |
||
525 | if ($h_oledrion_caddy->isCartEmpty()) { |
||
526 | Oledrion_utils::redirect(_OLEDRION_CART_IS_EMPTY, OLEDRION_URL, 4); |
||
527 | } |
||
528 | if ($commend_id == 0) { |
||
529 | Oledrion_utils::redirect(_OLEDRION_ERROR20, OLEDRION_URL, 4); |
||
530 | } |
||
531 | listCart(); |
||
532 | |||
533 | $commandAmountTTC = $commandAmountTTC + $commandAmountVAT; |
||
534 | |||
535 | $commande = $h_oledrion_commands->get($commend_id); |
||
536 | if ($commande->getVar('cmd_status') == 1) { |
||
537 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'), 6); |
||
538 | } |
||
539 | $commande->setVar('cmd_create', time()); |
||
540 | $commande->setVar('cmd_date', date('Y-m-d')); |
||
541 | $commande->setVar('cmd_state', OLEDRION_STATE_NOINFORMATION); |
||
542 | $commande->setVar('cmd_ip', Oledrion_utils::IP()); |
||
543 | $commande->setVar('cmd_status', 1); |
||
544 | $res = $h_oledrion_commands->insert($commande, true); |
||
545 | if (!$res) { |
||
546 | Oledrion_utils::redirect(_OLEDRION_ERROR10, OLEDRION_URL, 6); |
||
547 | } |
||
548 | |||
549 | // Save command and empty cart |
||
550 | $h_oledrion_caddy->emptyCart(); |
||
551 | |||
552 | // Enregistrement du panier |
||
553 | $msgCommande = ''; |
||
554 | $handlers = OledrionHandler::getInstance(); |
||
555 | foreach ($cartForTemplate as $line) { |
||
556 | $panier = $h_oledrion_caddy->create(true); |
||
557 | $panier->setVar('caddy_product_id', $line['product_id']); |
||
558 | $panier->setVar('caddy_qte', $line['product_qty']); |
||
559 | $panier->setVar('caddy_price', Oledrion_utils::formatFloatForDB($line['totalPrice'])); |
||
560 | // Attention, prix TTC avec frais de port |
||
561 | $panier->setVar('caddy_cmd_id', $commande->getVar('cmd_id')); |
||
562 | $panier->setVar('caddy_shipping', Oledrion_utils::formatFloatForDB($line['discountedShipping'])); |
||
563 | $panier->setVar('caddy_pass', md5(xoops_makepass())); |
||
564 | // Pour le téléchargement |
||
565 | $res = $h_oledrion_caddy->insert($panier, true); |
||
566 | // Make msg |
||
567 | $cat = $h_oledrion_cat->get($line['product_cid'])->toArray(); |
||
568 | $msgCommande .= str_pad($line['product_id'], 5, ' ') . ' '; |
||
569 | $msgCommande .= str_pad($cat['cat_title'], 10, ' ', STR_PAD_LEFT) . ' '; |
||
570 | $msgCommande .= str_pad($line['product_title'], 19, ' ', STR_PAD_LEFT) . ' '; |
||
571 | $msgCommande .= str_pad($line['product_qty'], 8, ' ', STR_PAD_LEFT) . ' '; |
||
572 | $msgCommande .= str_pad($oledrion_Currency->amountForDisplay($line['product_price']), 15, ' ', STR_PAD_LEFT) . ' '; |
||
573 | //$msgCommande .= str_pad($line['totalPriceFormated'],10,' ', STR_PAD_LEFT) . ' '; |
||
574 | $msgCommande .= "\n"; |
||
575 | // Attributs |
||
576 | if ($res && is_array($line['attributes']) && count($line['attributes']) > 0) { |
||
577 | // Enregistrement des attributs pour ce produit |
||
578 | foreach ($line['attributes'] as $attributeId => $attributeInformation) { |
||
579 | $caddyAttribute = $handlers->h_oledrion_caddy_attributes->create(true); |
||
580 | $caddyAttribute->setVar('ca_cmd_id', $commande->getVar('cmd_id')); |
||
581 | $caddyAttribute->setVar('ca_caddy_id', $panier->getVar('caddy_id')); |
||
582 | $caddyAttribute->setVar('ca_attribute_id', $attributeId); |
||
583 | $selectedOptions = $attributeInformation['attribute_options']; |
||
584 | $msgCommande .= '- ' . $attributeInformation['attribute_title'] . "\n"; |
||
585 | foreach ($selectedOptions as $selectedOption) { |
||
586 | $caddyAttribute->addOption($selectedOption['option_name'], $selectedOption['option_value'], $selectedOption['option_price']); |
||
587 | $msgCommande .= ' ' . $selectedOption['option_name'] . ' : ' . $selectedOption['option_ttc_formated'] . "\n"; |
||
588 | } |
||
589 | $handlers->h_oledrion_caddy_attributes->insert($caddyAttribute, true); |
||
590 | } |
||
591 | } |
||
592 | } |
||
593 | |||
594 | // Totaux généraux |
||
595 | //$msgCommande .= "\n\n"._OLEDRION_SHIPPING_PRICE.' '.$oledrion_Currency->amountForDisplay($shippingAmount)."\n"; |
||
596 | $msgCommande .= "\n\n" . _OLEDRION_TOTAL . ' ' . $oledrion_Currency->amountForDisplay($commandAmountTTC) . "\n"; |
||
597 | if (count($discountsDescription) > 0) { |
||
598 | $msgCommande .= "\n\n" . _OLEDRION_CART4 . "\n"; |
||
599 | $msgCommande .= implode("\n", $discountsDescription); |
||
600 | $msgCommande .= "\n"; |
||
601 | } |
||
602 | |||
603 | $msg = array(); |
||
604 | $msg['COMMANDE'] = $msgCommande; |
||
605 | $msg['NUM_COMMANDE'] = $commande->getVar('cmd_id'); |
||
606 | $msg['NOM'] = $commande->getVar('cmd_lastname'); |
||
607 | $msg['PRENOM'] = $commande->getVar('cmd_firstname'); |
||
608 | $msg['ADRESSE'] = $commande->getVar('cmd_adress', 'n'); |
||
609 | $msg['CP'] = $commande->getVar('cmd_zip'); |
||
610 | $msg['VILLE'] = $commande->getVar('cmd_town'); |
||
611 | $msg['PAYS'] = $countries[$commande->getVar('cmd_country')]; |
||
612 | $msg['TELEPHONE'] = $commande->getVar('cmd_telephone'); |
||
613 | $msg['EMAIL'] = $commande->getVar('cmd_email'); |
||
614 | $msg['URL_BILL'] = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
615 | $msg['IP'] = Oledrion_utils::IP(); |
||
616 | if ($commande->getVar('cmd_bill') == 1) { |
||
617 | $msg['FACTURE'] = _YES; |
||
618 | } else { |
||
619 | $msg['FACTURE'] = _NO; |
||
620 | } |
||
621 | // Send mail to client |
||
622 | Oledrion_utils::sendEmailFromTpl('command_client.tpl', $commande->getVar('cmd_email'), sprintf(_OLEDRION_THANKYOU_CMD, $xoopsConfig['sitename']), $msg); |
||
623 | // Send mail to admin |
||
624 | Oledrion_utils::sendEmailFromTpl('command_shop.tpl', Oledrion_utils::getEmailsFromGroup(Oledrion_utils::getModuleOption('grp_sold')), _OLEDRION_NEW_COMMAND, $msg); |
||
625 | |||
626 | // Présentation du formulaire pour envoi à la passerelle de paiement |
||
627 | // Présentation finale avec panier en variables cachées ****************************** |
||
628 | $registry = new oledrion_registryfile(); |
||
629 | $text = $registry->getfile(OLEDRION_TEXTFILE7); |
||
630 | $xoopsTpl->assign('text', xoops_trim($text)); |
||
631 | |||
632 | if ($checkout_level == 1) { |
||
633 | $text = $registry->getfile(OLEDRION_TEXTFILE4); |
||
634 | $xoopsTpl->append('text', '<br>' . xoops_trim($text)); |
||
635 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
636 | $sform = new XoopsThemeForm(_OLEDRION_FINISH, 'payform', $payURL, 'post'); |
||
637 | } else { |
||
638 | if (!isset($payment) || $payment['payment_type'] === 'offline' || $commandAmountTTC == 0) { |
||
639 | $text = $registry->getfile(OLEDRION_TEXTFILE4); |
||
640 | $xoopsTpl->append('text', '<br>' . xoops_trim($text)); |
||
641 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
642 | $sform = new XoopsThemeForm(_OLEDRION_FINISH, 'payform', $payURL, 'post'); |
||
643 | } else { |
||
644 | // Set gateway |
||
645 | $gateway = Oledrion_gateways::getGatewayObject($payment['payment_gateway']); |
||
646 | if (!is_object($gateway)) { |
||
647 | die(_OLEDRION_ERROR20); |
||
648 | } |
||
649 | if (is_object($gateway)) { |
||
650 | $payURL = $gateway->getRedirectURL($commande->getVar('cmd_total'), $commande->getVar('cmd_id')); |
||
651 | } else { |
||
652 | $payURL = OLEDRION_URL . 'invoice.php?id=' . $commande->getVar('cmd_id') . '&pass=' . $commande->getVar('cmd_password'); |
||
653 | } |
||
654 | $sform = new XoopsThemeForm(_OLEDRION_PAY_GATEWAY, 'payform', $payURL, 'post'); |
||
655 | $elements = array(); |
||
656 | if (is_object($gateway)) { |
||
657 | $elements = $gateway->getCheckoutFormContent($commande); |
||
658 | } |
||
659 | foreach ($elements as $key => $value) { |
||
660 | $sform->addElement(new XoopsFormHidden($key, $value)); |
||
661 | } |
||
662 | } |
||
663 | } |
||
664 | |||
665 | $sform->addElement(new XoopsFormLabel(_OLEDRION_AMOUNT_PRICE, $oledrion_Currency->amountForDisplay($commandAmountTTC))); |
||
666 | View Code Duplication | if ($commande->getVar('cmd_shipping') > 0) { |
|
667 | $sform->addElement(new XoopsFormLabel(_OLEDRION_SHIPPING_PRICE, $oledrion_Currency->amountForDisplay($commande->getVar('cmd_shipping')))); |
||
668 | } |
||
669 | View Code Duplication | if ($commande->getVar('cmd_packing_price') > 0) { |
|
670 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PACKING_PRICE, $oledrion_Currency->amountForDisplay($commande->getVar('cmd_packing_price')))); |
||
671 | } |
||
672 | $sform->addElement(new XoopsFormLabel(_OLEDRION_TOTAL, $oledrion_Currency->amountForDisplay($commandAmountTTC + $commande->getVar('cmd_shipping') + $commande->getVar('cmd_packing_price')))); |
||
673 | $sform->addElement(new XoopsFormLabel(_OLEDRION_LASTNAME, $commande->getVar('cmd_lastname'))); |
||
674 | $sform->addElement(new XoopsFormLabel(_OLEDRION_FIRSTNAME, $commande->getVar('cmd_firstname'))); |
||
675 | $sform->addElement(new XoopsFormLabel(_OLEDRION_STREET, $commande->getVar('cmd_adress'))); |
||
676 | $sform->addElement(new XoopsFormLabel(_OLEDRION_CP, $commande->getVar('cmd_zip'))); |
||
677 | $sform->addElement(new XoopsFormLabel(_OLEDRION_CITY, $commande->getVar('cmd_town'))); |
||
678 | if (Oledrion_utils::getModuleOption('checkout_country')) { |
||
679 | $sform->addElement(new XoopsFormLabel(_OLEDRION_COUNTRY, $countries[$commande->getVar('cmd_country')])); |
||
680 | } |
||
681 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PHONE, $commande->getVar('cmd_telephone'))); |
||
682 | $sform->addElement(new XoopsFormLabel(_OLEDRION_MOBILE, $commande->getVar('cmd_mobile'))); |
||
683 | $sform->addElement(new XoopsFormLabel(_OLEDRION_EMAIL, $commande->getVar('cmd_email'))); |
||
684 | $sform->addElement(new XoopsFormLabel(_OLEDRION_GIFT, $commande->getVar('cmd_gift'))); |
||
685 | if ($commande->getVar('cmd_packing')) { |
||
686 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PACKING, $commande->getVar('cmd_packing'))); |
||
687 | } |
||
688 | if ($commande->getVar('cmd_location')) { |
||
689 | $sform->addElement(new XoopsFormLabel(_OLEDRION_LOCATION, $commande->getVar('cmd_location'))); |
||
690 | } |
||
691 | if ($commande->getVar('cmd_delivery')) { |
||
692 | $sform->addElement(new XoopsFormLabel(_OLEDRION_DELIVERY, $commande->getVar('cmd_delivery'))); |
||
693 | } |
||
694 | if ($commande->getVar('cmd_payment')) { |
||
695 | $sform->addElement(new XoopsFormLabel(_OLEDRION_PAYMENT, $commande->getVar('cmd_payment'))); |
||
696 | } |
||
697 | if (Oledrion_utils::getModuleOption('ask_vatnumber')) { |
||
698 | $sform->addElement(new XoopsFormLabel(_OLEDRION_VAT_NUMBER, $commande->getVar('cmd_vat_number'))); |
||
699 | } |
||
700 | if (Oledrion_utils::getModuleOption('ask_bill')) { |
||
701 | if ($commande->getVar('cmd_bill') == 0) { |
||
702 | $sform->addElement(new XoopsFormLabel(_OLEDRION_INVOICE, _NO)); |
||
703 | } else { |
||
704 | $sform->addElement(new XoopsFormLabel(_OLEDRION_INVOICE, _YES)); |
||
705 | } |
||
706 | } |
||
707 | $button_tray = new XoopsFormElementTray('', ''); |
||
708 | if (!isset($payment) || $payment['payment_type'] === 'offline' || $commandAmountTTC == 0 |
||
709 | || $checkout_level == 1 |
||
710 | ) { |
||
711 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_FINISH, 'submit'); |
||
712 | } else { |
||
713 | $submit_btn = new XoopsFormButton('', 'post', _OLEDRION_PAY_GATEWAY, 'submit'); |
||
714 | } |
||
715 | $button_tray->addElement($submit_btn); |
||
716 | $sform->addElement($button_tray); |
||
717 | $xoopsTpl->assign('form', $sform->render()); |
||
718 | |||
719 | // Send sms |
||
720 | if (Oledrion_utils::getModuleOption('sms_checkout')) { |
||
721 | $information['to'] = ltrim($commande->getVar('cmd_mobile'), 0); |
||
722 | $information['text'] = Oledrion_utils::getModuleOption('sms_checkout_text'); |
||
723 | $sms = Oledrion_sms::sendSms($information); |
||
724 | } |
||
725 | break; |
||
726 | } |
||
727 | |||
728 | $xoopsTpl->assign('breadcrumb', Oledrion_utils::breadcrumb(array(OLEDRION_URL . basename(__FILE__) => _OLEDRION_VALIDATE_CMD))); |
||
729 | |||
730 | // Image icons |
||
731 | View Code Duplication | if (file_exists(OLEDRION_PATH . 'language/' . $xoopsConfig['language'] . '/image/step1.png')) { |
|
732 | $step1 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step1.png'; |
||
733 | $step2 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step2.png'; |
||
734 | $step3 = OLEDRION_URL . 'language/' . $xoopsConfig['language'] . '/image/step3.png'; |
||
735 | } else { |
||
736 | // Fallback |
||
737 | $step1 = OLEDRION_URL . 'language/english/image/step1.png'; |
||
738 | $step2 = OLEDRION_URL . 'language/english/image/step2.png'; |
||
739 | $step3 = OLEDRION_URL . 'language/english/image/step3.png'; |
||
740 | } |
||
741 | $xoopsTpl->assign('step1', $step1); |
||
742 | $xoopsTpl->assign('step2', $step2); |
||
743 | $xoopsTpl->assign('step3', $step3); |
||
744 | |||
745 | $title = _OLEDRION_VALIDATE_CMD . ' - ' . Oledrion_utils::getModuleName(); |
||
746 | Oledrion_utils::setMetas($title, $title); |
||
747 | Oledrion_utils::setCSS(); |
||
748 | Oledrion_utils::setLocalCSS($xoopsConfig['language']); |
||
749 | require_once XOOPS_ROOT_PATH . '/footer.php'; |
||
750 |
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.