Code Duplication    Length = 28-28 lines in 2 locations

admin/actions/delivery.php 1 location

@@ 220-247 (lines=28) @@
217
        xoops_confirm(array('op' => 'delivery', 'action' => 'confdelete', 'id' => $id), 'index.php', $msg);
218
        break;
219
220
    case 'confdelete':
221
222
        xoops_cp_header();
223
        $id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
224
        if (empty($id)) {
225
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
226
        }
227
        $opRedirect = 'delivery';
228
229
        $item = null;
230
        $item = $h_oledrion_delivery->get($id);
231
        if (is_object($item)) {
232
            //Delete delivery payment info
233
            $criteria = new CriteriaCompo();
234
            $criteria->add(new Criteria('dp_delivery', $item->getVar('delivery_id')));
235
            $h_oledrion_delivery_payment->deleteAll($criteria);
236
            // Delete delivery
237
            $res = $h_oledrion_delivery->delete($item);
238
            if ($res) {
239
                OledrionUtility::updateCache();
240
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
241
            } else {
242
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
243
            }
244
        } else {
245
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
246
        }
247
        break;
248
}
249

admin/actions/location.php 1 location

@@ 233-260 (lines=28) @@
230
        xoops_confirm(array('op' => 'location', 'action' => 'confdelete', 'id' => $id), 'index.php', $msg);
231
        break;
232
233
    case 'confdelete':
234
235
        xoops_cp_header();
236
        $id = isset($_POST['id']) ? (int)$_POST['id'] : 0;
237
        if (empty($id)) {
238
            OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5);
239
        }
240
        $opRedirect = 'location';
241
242
        $item = null;
243
        $item = $h_oledrion_location->get($id);
244
        if (is_object($item)) {
245
            //Delete location_delivery info
246
            $criteria = new CriteriaCompo();
247
            $criteria->add(new Criteria('ld_location', $item->getVar('location_id')));
248
            $h_oledrion_location_delivery->deleteAll($criteria);
249
            // Delete delivery
250
            $res = $h_oledrion_location->delete($item);
251
            if ($res) {
252
                OledrionUtility::updateCache();
253
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2);
254
            } else {
255
                OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5);
256
            }
257
        } else {
258
            OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5);
259
        }
260
        break;
261
}
262