if ($action) { switch ($action) { case 'packageByUserId': require_once APP_PATH . 'model/getPackagesByUserId.php'; $userId = (int) filter_input(INPUT_POST, 'userId', FILTER_SANITIZE_STRING); if ($userId) { print json_encode(getPackagesByUserId($db, $userId), JSON_FORCE_OBJECT); exit; } else { die('ERROR'); } break; case 'getProductById': require_once APP_PATH . 'model/createUrl.php'; require_once APP_PATH . 'model/toUrl.php'; require_once APP_PATH . 'model/getSingleProductById.php'; $productId = (int) filter_input(INPUT_POST, 'productId', FILTER_SANITIZE_STRING); if ($productId) { print json_encode(getSingleProductById($productId, $db), JSON_FORCE_OBJECT); exit; } else { die('ERROR'); } break; default: die('ERROR'); break; } } else { die('ERROR'); }
// Model require_once APP_PATH . 'model/getJs.php'; require_once APP_PATH . 'model/toUrl.php'; require_once APP_PATH . 'model/getAllProductsByUserId.php'; require_once APP_PATH . 'model/getSingleProductById.php'; require_once APP_PATH . 'model/updateProduct.php'; require_once APP_PATH . 'model/getAllSubcategories.php'; require_once APP_PATH . 'model/getAllCategories.php'; require_once APP_PATH . 'model/getActivePackages.php'; require_once APP_PATH . 'model/getContacts.php'; require_once APP_PATH . 'model/deleteProduct.php'; // call models $scripts = getJs($allScripts, ['addLine' => 1, 'switchProduct' => 1, 'liveChange' => 1], true); $products = getAllProductsByUserId($_SESSION['user_id'], $db); if (isset($_SESSION['last_edit_product'])) { $last = getSingleProductById($_SESSION['last_edit_product'], $db); } $categories = getAllCategories($db); $subcategories = getAllSubcategories($db); $contacts = getContacts($db); // controller require_once APP_PATH . 'control/editProductController.php'; // Template $menuPath = '/view/site/dashboard/user/menu.php'; $sitePath = '/view/site/dashboard/user/edit.php'; } else { header('Location: /dashboard'); } break; case 'gifts': if ($_SESSION['user_status'] != 'pending' && $_SESSION['has_contact'] == true && $_SESSION['user_has_package']) {