Code Duplication    Length = 27-27 lines in 4 locations

admin/actions/orders.php 4 locations

@@ 193-219 (lines=27) @@
190
        break;
191
192
    // ****************************************************************************************************************
193
    case 'validate': // Validation d'une commande
194
        // ****************************************************************************************************************
195
        xoops_cp_header();
196
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
197
        if (empty($id)) {
198
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
199
        }
200
        $opRedirect = 'orders';
201
        $item       = $h_oledrion_commands->get($id);
202
        if (is_object($item)) {
203
            $res = $h_oledrion_commands->validateOrder($item);
204
            if ($res) {
205
                // Send sms
206
                if (OledrionUtility::getModuleOption('sms_validate')) {
207
                    $information['to']   = ltrim($item->getVar('cmd_mobile'), 0);
208
                    $information['text'] = OledrionUtility::getModuleOption('sms_validate_text');
209
                    $sms                 = Oledrion_sms::sendSms($information);
210
                }
211
                //
212
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
213
            } else {
214
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
215
            }
216
        } else {
217
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
218
        }
219
        break;
220
221
    // ****************************************************************************************************************
222
    case 'pack': // Validation d'une commande
@@ 222-248 (lines=27) @@
219
        break;
220
221
    // ****************************************************************************************************************
222
    case 'pack': // Validation d'une commande
223
        // ****************************************************************************************************************
224
        xoops_cp_header();
225
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
226
        if (empty($id)) {
227
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
228
        }
229
        $opRedirect = 'orders';
230
        $item       = $h_oledrion_commands->get($id);
231
        if (is_object($item)) {
232
            $res = $h_oledrion_commands->packOrder($item);
233
            if ($res) {
234
                // Send sms
235
                if (OledrionUtility::getModuleOption('sms_validate')) {
236
                    $information['to']   = ltrim($item->getVar('cmd_mobile'), 0);
237
                    $information['text'] = OledrionUtility::getModuleOption('sms_pack_text');
238
                    $sms                 = Oledrion_sms::sendSms($information);
239
                }
240
                //
241
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
242
            } else {
243
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
244
            }
245
        } else {
246
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
247
        }
248
        break;
249
250
    // ****************************************************************************************************************
251
    case 'submit': // Validation d'une commande
@@ 251-277 (lines=27) @@
248
        break;
249
250
    // ****************************************************************************************************************
251
    case 'submit': // Validation d'une commande
252
        // ****************************************************************************************************************
253
        xoops_cp_header();
254
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
255
        if (empty($id)) {
256
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
257
        }
258
        $opRedirect = 'orders';
259
        $item       = $h_oledrion_commands->get($id);
260
        if (is_object($item)) {
261
            $res = $h_oledrion_commands->submitOrder($item);
262
            if ($res) {
263
                // Send sms
264
                if (OledrionUtility::getModuleOption('sms_validate')) {
265
                    $information['to']   = ltrim($item->getVar('cmd_mobile'), 0);
266
                    $information['text'] = OledrionUtility::getModuleOption('sms_submit_text');
267
                    $sms                 = Oledrion_sms::sendSms($information);
268
                }
269
                //
270
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
271
            } else {
272
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
273
            }
274
        } else {
275
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
276
        }
277
        break;
278
279
    // ****************************************************************************************************************
280
    case 'delivery': // Validation d'une commande
@@ 280-306 (lines=27) @@
277
        break;
278
279
    // ****************************************************************************************************************
280
    case 'delivery': // Validation d'une commande
281
        // ****************************************************************************************************************
282
        xoops_cp_header();
283
        $id = isset($_GET['id']) ? (int)$_GET['id'] : 0;
284
        if (empty($id)) {
285
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
286
        }
287
        $opRedirect = 'orders';
288
        $item       = $h_oledrion_commands->get($id);
289
        if (is_object($item)) {
290
            $res = $h_oledrion_commands->deliveryOrder($item);
291
            if ($res) {
292
                // Send sms
293
                if (OledrionUtility::getModuleOption('sms_validate')) {
294
                    $information['to']   = ltrim($item->getVar('cmd_mobile'), 0);
295
                    $information['text'] = OledrionUtility::getModuleOption('sms_delivery_text');
296
                    $sms                 = Oledrion_sms::sendSms($information);
297
                }
298
                //
299
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
300
            } else {
301
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
302
            }
303
        } else {
304
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
305
        }
306
        break;
307
308
    // ****************************************************************************************************************
309
    case 'export': // Export des commandes au format CSV