예제 #1
0
 public static function cartProducts()
 {
     $izdelki = [];
     foreach ($_SESSION["CART"] as $id => $value) {
         $izdelki[$id] = ProductsDB::get(["id" => $id]);
         $izdelki[$id]["vseh"] = $value;
     }
     return $izdelki;
 }
예제 #2
0
 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);
     }
 }
예제 #3
0
 public static function getCartProducts()
 {
     $izdelki = [];
     if (isset($_SESSION["CART"])) {
         foreach ($_SESSION["CART"] as $id => $value) {
             $izdelek = ProductsDB::get(["id" => $id]);
             $izdelek["vseh"] = $value;
             $izdelki[] = $izdelek;
         }
         http_response_code(200);
         echo json_encode($izdelki);
     } else {
         http_response_code(204);
     }
 }
예제 #4
0
 public static function updateProductForm($values = ["naziv" => "", "cena" => "", "opis" => "", "ektiven" => ""])
 {
     $rules = ["id" => ['filter' => FILTER_VALIDATE_INT, 'options' => ['min_range' => 1]]];
     $data = filter_input_array(INPUT_POST, $rules);
     if (self::checkValues($data)) {
         $result = ProductsDB::get($data);
         $_SESSION["pid"] = $data["id"];
         $_SESSION["pname"] = $result["naziv"];
         $form = new ProductForm('registracija', $result, "spreminjanje");
         echo ViewHelper::render("view/salesman-product-edit.php", ["form" => $form]);
     } else {
         $form = new ProductForm('registracija', $values, "spreminjanje");
         echo ViewHelper::render("view/salesman-product-edit.php", ["form" => $form]);
     }
 }
예제 #5
0
파일: index.php 프로젝트: benjaminovak/ep
         parse_str(file_get_contents("php://input"), $inputParams);
         $filteredInput = filter_var_array($inputParams, $rules);
         $filteredInput["id"] = $param;
         $product = array_filter($filteredInput);
         //var_dump($product);
         try {
             ProductsDB::update($product);
             http_response_code(204);
             // vračamo prazen odgovor
         } catch (Exception $exc) {
             echo returnError(400, $exc->getMessage());
         }
     } else {
         if ($http_method == "DELETE" && $param != null) {
             try {
                 $product = ProductsDB::get(["id" => $param]);
                 if ($product != null) {
                     ProductsDB::delete(["id" => $param]);
                     http_response_code(204);
                 } else {
                     returnError(404, "No book with id {$param}");
                 }
             } catch (Exception $exc) {
                 echo returnError(400, $exc->getMessage());
             }
         } else {
             // error
             echo returnError(404, "Unknown request: [{$http_method} {$resource}]");
         }
     }
 }