Example #1
0
 public function getLineProduct()
 {
     $stmt = $this->pdo->PDOInstance->prepare("SELECT id FROM link_order_product WHERE id_order = :id");
     $stmt->bindParam(':id', $this->id);
     try {
         $stmt->execute();
     } catch (Exception $e) {
         echo "Problem at " . $e->getLine() . " from model order :" . $e->getMessage();
     }
     $stmt = $stmt->fetchAll(PDO::FETCH_ASSOC);
     foreach ($stmt as $line_product) {
         $line_product = new link_order_product($line_product["id"]);
         $this->price += $line_product->getAmount() * $line_product->getPrice_bis();
         array_push($this->line_product, $line_product);
     }
 }
<?php

require_once '../model/link_order_product.php';
$id_order = $_GET["id_order"];
$quantity = $_GET["quantity"];
$price = $_GET["price"];
$ref_batch = $_GET["ref_batch"];
if (isset($_GET["parameter"])) {
    $id_parameter = $_GET["parameter"];
}
$id_product = $_GET["id_product"];
$lop = new link_order_product();
$lop->setId_order($id_order);
$lop->setAmount($quantity);
if (isset($_GET["parameter"])) {
    $lop->setId_parameter($id_parameter);
}
$lop->setPrice_bis($price);
$lop->setId_product($id_product);
$lop->setRef_batch($ref_batch);
$lop->addToDatabase();
header('location:../controller/viewOrder.php?id=' . $id_order);
<?php

require_once '../model/link_order_product.php';
$lop = new link_order_product($_GET["id_link_order"]);
//on fetch les infos
$id_order = $lop->getId_order();
$quantity = $_GET["quantity"];
$price = $_GET["price"];
$ref_batch = $_GET["ref_batch"];
if (isset($_GET["parameter"])) {
    $id_parameter = $_GET["parameter"];
}
$id_product = $_GET["id_product"];
$quantity_tbd = $_GET["amount_to_be_delivered"];
$quantity_ad = $_GET["amount_already_delivered"];
//On monte sur l'objet
$lop->setAmount($quantity);
if (isset($_GET["parameter"])) {
    $lop->setId_parameter($id_parameter);
}
$lop->setPrice_bis($price);
$lop->setId_product($id_product);
$lop->setRef_batch($ref_batch);
$lop->setAmount_already_delivered($quantity_ad);
$lop->setAmount_to_be_delivered($quantity_tbd);
//On update en db
$lop->setToDatabase();
//On redirige
header('location:../controller/viewOrder.php?id=' . $id_order);
<?php

require_once '../model/order.php';
require_once '../model/extraction.php';
require_once '../model/product.php';
require_once '../model/link_order_product.php';
$lop = new link_order_product($_GET["id"]);
?>

<div class="input-group">
	<label for="product">Name of the product (type and let the machine seek for you)</label>
	<input id="searchProductInOrder" name="product" type="text" class="form-control" placeholder="Product name" value="<?php 
echo $lop->getProduct()->getName();
?>
" aria-describedby="searchProduct">
	<span class="input-group-addon glyphicon glyphicon-search" id="searchProduct"></span>
</div>
<div id="list-product"></div>

<form method="get" action="../controller/setLineProductToOrder.php">
	<input type="hidden" name="id_link_order" value="<?php 
echo $lop->getId();
?>
">
	<input type="hidden" name="id_product" value="<?php 
echo $lop->getId_product();
?>
">
	<div id="parameter_product_add" class="form-group">
		<label for="parameter">Parameter</label>
		<select name="parameter" type="text" class="form-control">