name="onhome" /> Pagina Inicial <br /> <button type="submit" name="save" class="green"><?php echo $language['save']; ?> </button> <button type="reset" name="cancel" class="red"><?php echo $language['cancel']; ?> </button> </div> </form> <?php } else { $product = new product(); $product->setId(intval($_GET['i'])); // convert to bool the service box if (isset($_REQUEST['service'])) { $service = true; } else { $service = false; } // convert to bool the published box if (isset($_REQUEST['published'])) { $published = true; } else { $published = false; } // convert to bool the onhome box if (isset($_REQUEST['onhome'])) { $onhome = true;
public function getProductByGroup($id = NULL) { if ($id) { $stmt = $this->pdo->PDOInstance->prepare("SELECT * FROM product as p WHERE p.id_group = :id"); $stmt->bindParam(':id', $id); } else { $stmt = $this->pdo->PDOInstance->prepare("SELECT * FROM product as p"); } try { $stmt->execute(); } catch (Exception $e) { echo "Problem at " . $e->getLine() . " from model Extraction :" . $e->getMessage(); } $result = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($id) { $result_group = $this->getGroup($id); } else { $result_group = $this->getGroup(); } foreach ($result as $product) { $product_ = new product(); $product_->setId($product["id"]); $product_->setRef($product["ref"]); $product_->setName($product["name"]); $product_->setDescription($product["description"]); $product_->setCost($product["cost"]); $product_->setPrice($product["price"]); $product_->setUnit($product["unit"]); $product_->setId_group($product["id_group"]); $indice = 0; foreach ($result_group as $group) { if ($group->getId() == $product_->getId_group()) { $result_group[$indice]->addProduct($product_); } $indice++; } } return $result_group; }
<?php if (isset($_REQUEST['i']) && !empty($_REQUEST['i'])) { $product = new product(); $product->setId($_REQUEST['i']); if ($product->delete()) { print 'sucess'; } else { print 'error'; } } else { print 'error'; }