Пример #1
0
<?php

require '../include/global_functions.php';
startSession();
//Select the new product for the comparison according to the id
$product_dao = new ProductDAO();
$new_product = $product_dao->find($_SESSION['new_product_id']);
$old_product = new Product();
$language_fields_addition = $_SESSION['language'] == 'en_US' ? '' : '_' . $_SESSION['language'];
if (!isset($_COOKIE['uniqueID'])) {
    $expire = time() + 10 * 365 * 24 * 60 * 60;
    setcookie('uniqueID', uniqid(), $expire);
}
if (isset($_GET['action'])) {
    $purchase_dao = new PurchaseDAO();
    $respurchase = $purchase_dao->insert($_SESSION['new_product_id'], $_SERVER['REQUEST_TIME'], $_COOKIE['uniqueID']);
}
if (isset($_SESSION['old_product_id'])) {
    if ($_SESSION['old_product_id'] != 0) {
        $old_product = $product_dao->find($_SESSION['old_product_id']);
        $old_product->release_year = $_SESSION['purchase_year'];
    } else {
        $old_product->release_year = $_SESSION['purchase_year'];
        $old_product->purchase_price = $_SESSION['old_puchase_price'];
        $old_product->consumption = $_SESSION['old_energy_consumption'];
    }
}
function remainingLifetime($product)
{
    date_default_timezone_set('Europe/Bucharest');
    $currentYear = date('Y');
Пример #2
0
require '../../include/global_functions.php';
loggedInOrRedirect();
$product_dao = new ProductDAO();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if (file_exists($_FILES['image']['tmp_name']) && is_uploaded_file($_FILES['image']['tmp_name'])) {
        $image = base64_encode(file_get_contents($_FILES['image']['tmp_name']));
    } else {
        $image = '';
    }
    //update the product
    $product_dao->updateproduct($_GET['idproduct'], $_GET['idcategory'], $_GET['idspecification'], $_POST['serial_number'], $_POST['purchase_price'], $_POST['periodical_discount'], $_POST['brand'], $_POST['model'], $_POST['classification'], $_POST['cost'], $_POST['consumption'], $_POST['release_year'], $_POST['description'], $image);
    header('Location: manage_products.php?&idcategory=' . $_GET['idcategory'] . '&idspecification=' . $_GET['idspecification']);
}
//Select the product according to the id
$product = $product_dao->find($_GET['idproduct']);
$page['title'] = 'Modify product';
require '../../include/header.inc';
require '../../include/index.inc';
?>
<h3><?php 
echo t('Modify product');
?>
</h3>
<form class="form-horizontal" action = "?<?php 
echo 'idproduct=' . $_GET['idproduct'] . '&idcategory=' . $_GET['idcategory'] . '&idspecification=' . $_GET['idspecification'];
?>
" method="POST" enctype="multipart/form-data">

	<div class="form-group">
 		 <label class="col-md-1 control-label" for="textinput"><?php 
Пример #3
0
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title"><?php 
echo t('Details about the product');
?>
</h4>
      </div>
      <div class="modal-body">

        <?php 
//Select the product according to the id
$product_dao = new ProductDAO();
$product = $product_dao->find($_GET['product_id']);
//Put the id of the new product in a session
$_SESSION['new_product_id'] = $_GET['product_id'];
?>

        <!-- display the device informations in a table according to the user's choice -->
   <table class="table table-bordered">
       <tr>
       <tr>
           <td><?php 
echo t('Serial number');
?>
</td>
           <td><?php 
echo $product->serial_number;
?>