Example #1
0
 public function loadCart()
 {
     $conn = new ConnectionHandler();
     $products = [];
     $quantities = [];
     //termék id összegűjtése a user_id alapján
     $stmt = $conn->preparedQuery("SELECT * FROM Kosar WHERE u_id = ?", array($this->getId()));
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         //a termék adatok összegűjtése a termék_id alapján (row[termek_id])
         $stmtProduct = $conn->preparedQuery("SELECT * FROM Termekek WHERE t_azon=?", array($row["termek_id"]));
         while ($rowProduct = $stmtProduct->fetch(PDO::FETCH_ASSOC)) {
             $products[$rowProduct['t_azon']] = Product::createProductByArray($rowProduct);
             /*Csak t_azonnal indexelem mert ha esetleg lesz szükség még másra is a termékből, nem csak a nevére, mikor
               a kosárba kiírjuk, akkor ott legyen minden*/
             $quantities[$rowProduct['t_azon']] = $row['mennyiseg'];
         }
     }
     return new Cart($products, $quantities);
 }
Example #2
0
<?php

/**
 * Created by PhpStorm.
 * User: István
 * Date: 2015.12.13.
 * Time: 14:38
 */
require_once $_SERVER['DOCUMENT_ROOT'] . "/rftCandyShop/Model/ListingUtilities.php";
require_once $_SERVER['DOCUMENT_ROOT'] . "/rftCandyShop/Model/UserAsCustomer.php";
session_start();
$lu = new ListingUtilities();
$user = unserialize($_SESSION['actUser']);
$productID = $_GET['t_id'];
$qauntity = $_GET['qauntity'];
$productData = $lu->getProductByPID($productID);
$user->getCart()->addProduct(Product::createProductByArray($productData), $qauntity);
$_SESSION['actUser'] = serialize($user);
Example #3
0
             //$img = $_POST["file"];
     */
     foreach ($_POST as $key => $value) {
         echo $value . '<br/>';
     }
     $newfilename = null;
     $location = 'images/product/';
     /*if(move_uploaded_file($temp_name, $location.$img_name)){
           echo 'uploaded';
       }*/
     $temp = explode(".", $_FILES["kep"]["name"]);
     $newfilename = round(microtime(true)) . '.' . end($temp);
     move_uploaded_file($_FILES["kep"]["tmp_name"], "images/product/" . $newfilename);
     $_POST["kep"] = $newfilename;
     $_POST["t_azon"] = null;
     $product = Product::createProductByArray($_POST);
     ///die("product: ".$product);
     $leader = new UserAsLeader($_SESSION["id"], $_SESSION["email"], $_SESSION["password"]);
     $message = $leader->productAddStore($product);
     $_SESSION["message"] = $message;
     header("Location: Leader_Add_Product.php");
 }
 //kontruktor $id, $name, $package, $category, $weight, $price, $min_order, $min_stock, $discount, $highlight, $img, $description)
 //$product = Product::createProduct(null, $name,$package,$category,$weight,$price,$minO,$recQ,$action,$highlight,$newfilename,$details);
 //echo $product."<br>";
 /*
             $conn = new ConnectionHandler();
         $conn->preparedInsert("termekek",
                 array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek"),
                 array($name, $categ, $package, $weight, $price, $recQ,$minO,$highlight,$action,$details));
     /*