<?php
/**
* Product: Katyshop
* @version 0.3.2.1
* @author Catalin Hulea - hide@address.com
* @copyright Copyright (C) 2007 Catalin Hulea
* @license GNU General Public License version 3
* You can find a copy of GNU GPL v3 at this path: /docs/LICENSE
* @link https://sourceforge.net/projects/katyshop
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once(dirname(dirname(__FILE__)) . "/init.php");
require_once(WEB_DIR . "/includes/req_admin.php");
?>
<html>
<head>
<title><?php echo APP_NAME; ?></title>
<?php require_once(WEB_DIR . "/includes/html_head.php"); ?>
</head>
<body>
<div id="container">
<?php require_once(WEB_DIR . "/includes/header.php"); ?>
<div id="middle">
<div id="left_vertical_line">
<?php require_once(WEB_DIR . "/admin/includes/left.php"); ?>
<div id="content">
<h1>Administrare produse</h1>
<?php require_once(WEB_DIR . "/includes/print_messages.php"); ?>
<?php require_once(WEB_DIR . "/admin/includes/breadcrumb.php"); ?>
<form action="admin/formparser/product.php?action=delete" method="post" id="frm_delete_product">
<input type="hidden" name="id_product" value="0">
</form>
<?php
$p = Application::getCurrentProduct();
if($p->id > 0)
{
?>
<dl>
<dt class="title"><b><?php echo Escape::html($p->title); ?></b></dt>
<dd>
<table cellpadding="0" cellspacing="0" style="margin: 0px; width: 98%; ">
<tr>
<td>
<p class="content">
<?php
if(!empty($p->picture) && is_file(WEB_DIR . "/img/products/medium/{$p->picture}"))
{
?>
<a href="javascript:popupImage('popupimage.php?img_src=img/products/large/<?php echo Escape::htmlValue($p->picture); ?>'); "><img src="img/products/medium/<?php echo Escape::htmlValue($p->picture); ?>"></a><br>
<?php
}
echo nl2br(Escape::html($p->description));
?>
</p>
<ul class="actions">
<li class="up"><a href="admin/category.php?id_category=<?php echo intval(@$p->id_category); ?>">Categoria parinte</a></li>
<?php
if(intval($p->id) > 0)
{
?>
<li class="edit"><a href="admin/product.php?action=edit&id_product=<?php echo intval(@$p->id); ?>">Editati produsul <?php echo Escape::html($p->title); ?></a></li>
<li class="move"><a href="admin/product.php?action=change_parent&id_product=<?php echo intval(@$p->id); ?>">Mutati produsul</a></li>
<li class="delete"><a href="javascript:deleteProduct('<?php echo intval($p->id); ?>'); " style="color: red; ">Stergeti produsul <?php echo Escape::html($p->title); ?></a></li>
<?php
if($p->active == 1)
{
?>
<li><img src="img/icons/bullet_green.gif"> Produsul este activ</a></li>
<li><a href="product.php?id_product=<?php echo Escape::htmlValue($p->id); ?>">Vizualizati produsul pe siteul public</a></li>
<?php
}
else
{
?>
<li><img src="img/icons/bullet_red.gif"> Produsul nu este activ</a></li>
<?php
}
}
?>
</ul>
<br clear="all">
</td>
</tr>
</table>
</dd>
</dl>
<?php
}
if(@$_GET["action"] == "edit")
{
if(isset($_GET["id_product"]))
{
$p = $db->tbProduct->getRecordById(@$_GET["id_product"]);
}
else
{
$p = SessionHandler::get("editProduct");
if(!is_a($p, "Product"))
$p = new Product();
}
if(!empty($_GET["id_category"]))
$p->id_category = intval($_GET["id_category"]);
if($p->pos == 0)
{
$temp = $db->tbProduct->getMaxPos($p->id_category);
$p->pos = $temp + 1;
}
?>
<dl>
<dt></dt>
<dd>
<h2><?php echo (intval($p->id) > 0) ? "Editare produs " . Escape::html($p->title) : "Adaugare produs nou"; ?></h2>
<form action="admin/formparser/product.php?action=save" method="post" enctype="multipart/form-data">
<input type="hidden" name="MAX_FILE_SIZE" value="8000000">
<input type="hidden" name="id" value="<?php echo Escape::htmlValue($p->id); ?>">
<table>
<tr>
<td>Titlu</td><td><input type="text" name="title" value="<?php echo Escape::htmlValue($p->title); ?>"></td>
</tr>
<tr>
<td>Pret (fara TVA)</td><td><input type="text" name="price" value="<?php echo displayPrice($p->price); ?>"></td>
</tr>
<tr>
<td>Unitate de masura</td>
<td>
<select name="measuring_unit">
<option value="">-- Alegeti --</option>
<?php
$list = Product::getPossibleMeasuringUnits();
for($i = 0; $i < count($list); $i++)
{
$selected = ($p->measuring_unit == $list[$i]) ? "selected" : "";
?>
<option value="<?php echo Escape::htmlValue($list[$i]); ?>" <?php echo $selected; ?>><?php echo Escape::html($list[$i]); ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Categoria parinte</td>
<td>
<?php
$temp = $db->tbCategory->getRecordById($p->id_category);
?>
<input type="hidden" name="id_category" value="<?php echo Escape::htmlValue($p->id_category); ?>">
<a href="admin/category.php?id_category=<?php echo intval($temp->id); ?>"><?php echo ($temp->id > 0) ? Escape::html($temp->title) : Escape::html(APP_NAME); ?></a>
<?php
if($p->id > 0)
{
?>
<br>
<a href="admin/product.php?action=change_parent&id_product=<?php echo intval($p->id); ?>">click aici pentru a schimba categoria parinte</a>
<?php
}
?>
</td>
</tr>
<tr>
<td>Producator</td>
<td>
<select name="id_manufacturer">
<option value="0">-- Alegeti --</option>
<?php
$list = $db->tbManufacturer->search(array(), 0, 500, "title");
for($i = 0; $i < count($list); $i++)
{
$selected = ($list[$i]->id == $p->id_manufacturer) ? "selected" : "";
?>
<option value="<?php echo Escape::htmlValue($list[$i]->id); ?>" <?php echo $selected; ?>><?php echo Escape::html($list[$i]->title); ?></option>
<?php
}
?>
</select>
</td>
</tr>
<tr>
<td>Pozitia</td><td><input type="text" name="pos" value="<?php echo Escape::htmlValue($p->pos); ?>"></td>
</tr>
<tr>
<td>Scurta descriere <br>(apare la lista de produse)</td><td><textarea name="description" cols="30" rows="5"><?php echo Escape::html($p->description); ?></textarea></td>
</tr>
<tr>
<td>Continut <br>(descriere detaliata, apare pe pagina de detalii produs)</td><td><textarea name="content" cols="50" rows="10"><?php echo Escape::html($p->content); ?></textarea></td>
</tr>
<tr>
<td>Detalii tehnice</td><td><textarea name="technical_details" cols="30" rows="5"><?php echo Escape::html($p->technical_details); ?></textarea></td>
</tr>
<tr>
<td>Imagine</td>
<td>
<?php
if(!empty($p->picture))
{
?>
<a href="img/products/large/<?php echo Escape::htmlValue($p->picture); ?>" target="_blank"><?php echo Escape::html($p->picture); ?></a>
<br>
<?php
}
?>
<a href="javascript:changeProductPicture(); " id="the_picture_link">click aici pentru a schimba imaginea</a>
<br>
<input type="file" name="picture" disabled style="display: none; " id="the_picture">
</td>
</tr>
<tr>
<td>Activ</td>
<td>
<input type="radio" name="active" value="0" id="product_active_0" <?php echo $p->active == 1 ? "" : "checked"; ?>><label for="product_active_0"> Da</label>
<input type="radio" name="active" value="1" id="product_active_1" <?php echo $p->active == 1 ? "checked" : ""; ?>><label for="product_active_1"> Nu</label>
</td>
</tr>
<tr>
<td> </td>
<td>
<input type="submit" value="Salvati" class="button">
<input type="button" value="Cancel" class="button" onclick="redirect('admin/category.php?id_category=<?php echo intval($p->id_category); ?>'); ">
</td>
</tr>
</table>
</form>
</dd>
<?php
}
?>
</div>
<?php require_once(WEB_DIR . "/includes/right.php"); ?>
<?php require_once(WEB_DIR . "/includes/footer.php"); ?>
</div>
</div>
</div>
</body>
</html>