Example #1
0
 /**
  * Hozzá adja, elmenti az adatbázisban az új termék adatait.
  *
  * @param Product $product
  * @return Exception|string
  */
 public function productAddStore($product)
 {
     //die("temrék neve: " . $product->getName());
     if ($this->checkProductExist($product->getName()) === FALSE) {
         try {
             self::$conn->preparedInsert("termekek", array("nev", "kat_azon", "kisz_azon", "suly", "egysegar", "min_keszlet", "min_rend", "kim_azon", "akcio", "reszletek", "kep"), array($product->getName(), $product->getCategory(), $product->getPackage(), $product->getWeight(), $product->getPrice(), $product->getMinStock(), $product->getMinOrder(), $product->getHighlight(), $product->getDiscount(), $product->getDescription(), $product->getImg()));
             //die("Sql után!");
         } catch (Exception $e) {
             return new Exception("Nem sikerült elmenteni a terméket!");
         }
         //$stmt = $conn->preparedQuery("SELECT t_azon FROM termekek WHERE nev=?",array("$name"));
         return "Sikeres termék felvitel!";
     } else {
         return "Létezik már ilyen termék!";
     }
 }
 public function create(SubCategory $sub_category, $name, $description, $price, $img, $stock)
 {
     $errors = array();
     $product = new Product($this->db);
     try {
         $product->setSubCategory($sub_category);
         $product->setName($name);
         $product->setDescription($description);
         $product->setPrice($price);
         $product->setImg($img);
         $product->setStock($stock);
     } catch (Exception $e) {
         $errors[] = $e->getMessage();
     }
     $errors = array_filter($errors, function ($val) {
         return $val !== true;
     });
     if (count($errors) == 0) {
         $idSubCategory = intval($product->getIdSubCategory());
         $name = $this->db->quote($product->getName());
         $description = $this->db->quote($product->getDescription());
         $price = $this->db->quote($product->getPrice());
         $img = $this->db->quote($product->getImg());
         $stock = $this->db->quote($product->getStock());
         $query = "INSERT INTO product(id_sub_category, name, description, price, img, stock) VALUES('" . $idSub_category . "', " . $name . ", " . $description . ", " . $price . ", " . $img . ", " . $stock . ")";
         $res = $this->db->exec($query);
         if ($res) {
             $id = $this->db->lastInsertId();
             if ($id) {
                 return $this->findById($id);
             } else {
                 return "Internal Server error";
             }
         }
     } else {
         return $errors;
     }
 }
Example #3
0
 }
 echo '">
                     </form>
                 </div>
             </div>
             <div class="all-products products-page col s10">
                 <div class="category products-list-page">
                     <div class="products-list row">';
 $i = 0;
 foreach ($product as $productItem) {
     if (is_array($productItem)) {
         $product = new Product($productItem['id']);
         echo '
                                 <div class="item col s3">
                                     <div class="padding-box card-panel">
                                         <div class="image" style="background-image: url(\'' . $product->getImg() . '\')">';
         if (!$productItem['instock']) {
             echo '
                                                  <div class="os-overlay z-depth-1">OUT OF STOCK</div>
                                             ';
         }
         echo '
                                         </div>
                                         <a href="item.php?id=' . $productItem['id'] . '" class="title">' . $productItem['name'] . '</a>
                                         <div class="price">Rs.' . $productItem['price'] . '</div>
                                     </div>
                                 </div>
                             ';
         $i++;
         if ($i == 4) {
             echo '<div class="clearfix"></div>';
Example #4
0
    <script src="include/js/init.js" type="text/javascript"></script>
</head>
<body>
    <?php 
require_once 'include/php/header.php';
$cart = $user->loadCart();
echo '
            <div id="cart" class="checkout">
                <h2>Checkout</h2>';
if ($cart != null) {
    echo '
                        <ul class="collection">';
    $i = 0;
    foreach ($cart as $cartItem) {
        $product = new Product($cartItem['productid']);
        $img = $product->getImg();
        echo '
                                    <li class="collection-item row item' . $i . '">
                                        <div class="overlay"><p>REMOVED</p></div>
                                        <i class="mdi-navigation-close" id="close' . $i . '"></i>
                                        <div class="thumb col s3" style="background-image: url(\'' . $img . '\');"></div>
                                        <div class="details col s9">
                                            <a href="item.php?id=' . $cartItem['productid'] . '">' . $cartItem['name'] . '</a>
                                            <p>Price: Rs.' . $cartItem['price'] . '</p>
                                            <p class="qty">Quantity: </p>
                                            <input id="cartItem' . $i . '" type="text" value="' . $cartItem['qty'] . '"/>
                                        </div>
                                        <script type="text/javascript">
                                            function cartLoad' . $i . '() {
                                                $("#cart #cartItem' . $i . '").on("input", function () {
                                                    $.post("include/php/updateQty.php", {"qty": $("#cart #cartItem' . $i . '").val(), "pid": ' . $cartItem['productid'] . '}, function(response) {