public static function productsDetail() { $data = filter_input_array(INPUT_GET, self::getIdRules()); if (self::checkValues($data)) { $product = ProductsDB::get($data); $images = ImagesDB::getProdutAll(["izdelek_id" => $product["id"]]); echo ViewHelper::render("view/anonymous-products-detail.php", ["product" => $product, "images" => $images]); } else { ViewHelper::redirect(BASE_URL); } }
public static function delete() { $rules = ['delete_confirmation' => FILTER_REQUIRE_SCALAR, 'id' => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]]]; $data = filter_input_array(INPUT_POST, $rules); if (self::checkValues($data)) { UporabnikDB::delete($data); $url = BASE_URL . "uporabnik"; } else { if (isset($data["id"])) { $url = BASE_URL . "uporabnik/edit?id=" . $data["id"]; } else { $url = BASE_URL . "uporabnik"; } } ViewHelper::redirect($url); }
public static function orderCancelledDetail() { $rules = ["id" => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]]]; $data = filter_input_array(INPUT_POST, $rules); if ($data == null) { $data["id"] = $_SESSION["pid"]; } if (self::checkValues($data)) { $order = OrdersDB::get($data); echo ViewHelper::render("view/customer-order-detail-cancelled.php", ["order" => $order, "products" => OrdersDB::getOrderProducts(["narocilo_id" => $data["id"]]), "user" => UsersDB::get(["id" => $order["uporabnik_id"]])]); } else { ViewHelper::redirect(BASE_URL); } }
public static function addUser($data = []) { if (self::checkValues($data)) { $id = UsersDB::insertCustomer($data); self::addActionToDiary($_SESSION["id"], "Prodajalec z id-jem " . $_SESSION["id"] . " je dodal stranko z id-jem " . $id); echo ViewHelper::redirect(BASE_URL . "users"); } else { self::addUserForm(); } }
if ($_SERVER["REQUEST_METHOD"] == "POST") { CustomerController::order(); } else { ViewHelper::redirect(BASE_URL . "customer/cart"); } } else { ViewHelper::redirect(BASE_URL); } }, "customer/checkout/order" => function () { if (isset($_SESSION["active"]) && $_SESSION["role"] == "customer") { if ($_SERVER["REQUEST_METHOD"] == "POST") { CustomerController::saveOrder(); } else { ViewHelper::redirect(BASE_URL . "customer/cart"); } } else { ViewHelper::redirect(BASE_URL); } }]; try { if (isset($urls[$path])) { $urls[$path](); } else { echo "No controller for '{$path}'"; } } catch (InvalidArgumentException $e) { var_dump($urls, $path); ViewHelper::error404(); } catch (Exception $e) { echo "An error occurred: <pre>{$e}</pre>"; }