Example #1
0
 /**
  * Метод добавления нового продукта
  * @param Product $product - продукт
  * @return bool - добавлен/не добавлен
  */
 public function create($product)
 {
     $db = DataBase::getInstance();
     $connection = $db->connect();
     $data = $product->getData();
     $sql = "INSERT INTO " . self::TABLE_NAME . " (title, mark, `count`, price, description, id_catalog) VALUES (:title, :mark, :count, :price, :description, :id_catalog)";
     $stmt = $connection->prepare($sql);
     $result = $stmt->execute($data);
     $db->close();
     return $result;
 }
Example #2
0
<?php

include "../../includes/inc.main.php";
$ID = $_GET['id'];
$Edit = new Product($ID);
$Data = $Edit->getData();
$Title = "Modificar producto '" . $Data['title'] . "'";
$Head->setTitle("Modificar Producto");
$Head->setHead();
?>
<body>
  <div id="wrapper">
    <?php 
include '../../includes/inc.nav.php';
?>
 <!-- Nav -->
    <?php 
echo insertElement("hidden", "action", 'update');
?>
    <?php 
echo insertElement("hidden", "id", $ID);
?>
    <div class="container additemdiv animated fadeIn">
      <div class="col-sm-12 form-box formitems">
        <div class="additemtit">
          <div class="maintitle"><h4 class="maintitletxt"><?php 
echo $Title;
?>
</h4></div>
        </div>
        <div class="row">
Example #3
0
        $ret = -1 * ($ap->isAvailable() - $bp->isAvailable());
    }
    if (!$ret && $atd['unitPrice'] && $btd['unitPrice']) {
        $ret = 1 * (int) 1000 * ($atd['unitPrice'] - $btd['unitPrice']);
    }
    if (!$ret) {
        $ret = (int) ($ap->getData()['price'] - $bp->getData()['price']);
    }
    if (!$ret) {
        $ret = strcmp($ap->getData()['name'], $bp->getData()['name']);
    }
    return $ret;
});
foreach ($availableProducts as $rawProd) {
    $prod = new Product($rawProd['id'], $rawProd['spider']);
    $data = $prod->getData();
    $history = $prod->getHistory();
    foreach ($history as $k => $hist) {
        if ($hist['run_id'] == $data['run_id']) {
            unset($history[$k]);
        }
    }
    /* compute the class relative to the first item in history */
    $trClass = array();
    $fhist = reset($history);
    $sign = 0;
    $adiff = 0;
    if ($fhist) {
        if ($fhist['price'] > $data['price']) {
            $trClass[] = "price-lower";
            $sign = -1;
Example #4
0
 /**
  * Default action to get price of product
  *
  * @param Product $product
  * @return float
  */
 public function getPrice($product)
 {
     return $product->getData('cost') * 1.25;
 }