<?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_person_company.php");
$db = Application::getDb();
$user = Application::getUser();
//$order = $db->tbOrder->getRecordByCode(@$_GET["code"]);
$order = SessionHandler::get("generateProforma");
if(!is_a($order, "Order"))
$order = new Order();
if($order->id == 0)
{
die("Nu a putut fi gasita comanda pentru care trebuie generata proforma");
}
elseif($order->id_user != $user->id)
{
die("Comanda selectat nu poate fi afisata deoarece nu va apartine");
}
?>
<html>
<head>
<title><?php echo APP_NAME; ?> - factura proforma <?php echo Escape::html($order->code); ?></title>
</head>
<body>
<table width="800">
<tr valign="top">
<td width="30%">
<?php echo nl2br(Escape::html(Application::getConfigValue("shop_invoice_info"))); ?>
</td>
<td width="30%">
<table>
<tr>
<td>
Adresa de facturare: <br>
<?php echo nl2br(Escape::html($order->invoice_address)); ?>
</td>
</tr>
<tr>
<td style="border: 1px solid #000000; ">
Cod proforma: <?php echo Escape::html($order->code); ?> <br>
Data emiterii: <?php echo Escape::html($order->displayDateTime("date_ordered")); ?> <br>
</td>
</tr>
</table>
</td>
<td width="30%">
Informatii despre client:
<?php echo nl2br(Escape::html($order->user_short_description)); ?>
</td>
</tr>
</table>
<?php
if($order->getProductsCount() > 0)
{
$order->computeValue();
$vat = Application::getConfigValue("default_vat");
$cfgDf = Application::getConfigValue("date_format");
?>
Procent TVA: <?php echo Escape::html($vat); ?> % <br>
<table style="text-align: right; " cellpadding="2" cellspacing="0" border="1" width="800">
<tr align="center">
<th>Nr.</th>
<th>Produs</th>
<th>U. M.</th>
<th>Cantitate</th>
<th><nobr>Pret unitar<nobr><br><nobr>(fara TVA)</nobr><br><nobr>- <?php echo Escape::html(Application::getConfigValue("default_currency")); ?> -</nobr></th>
<th><nobr>Valoare<nobr><br><nobr>(fara TVA)</nobr><br><nobr>- <?php echo Escape::html(Application::getConfigValue("default_currency")); ?> -</nobr></th>
<th>Valoare<br>TVA<br><nobr>- <?php echo Escape::html(Application::getConfigValue("default_currency")); ?> -</nobr></th>
<th><nobr>Valoare<nobr><br><nobr>(cu TVA)</nobr><br><nobr>- <?php echo Escape::html(Application::getConfigValue("default_currency")); ?> -</nobr></th>
</tr>
<tr align="center">
<th> </th>
<th>1</th>
<th>2</th>
<th>3</th>
<th>4</th>
<th>5 (3x4)</th>
<th>6</th>
<th>7</th>
</tr>
<?php
for($i = 0; $i < $order->getProductsCount(); $i++)
{
$op = $order->getOrderProduct($i + 1);
?>
<tr>
<td>
<?php echo Escape::html($op->line_number); ?>
</td>
<td align="center">
<?php echo Escape::html($op->product_name); ?>
</td>
<td><?php echo Escape::html($op->measuring_unit); ?> </td>
<td><?php echo Escape::html(displayPrice($op->quantity)); ?> </td>
<td><?php echo Escape::html(displayPrice($op->price)); ?></td>
<td><?php echo Escape::html(displayPrice($op->value_without_vat)); ?></td>
<td><?php echo Escape::html(displayPrice($op->value_vat)); ?></td>
<td><?php echo Escape::html(displayPrice($op->value_total)); ?></td>
</tr>
<?php
}
?>
<tr align="center" style="font-weight: bold; ">
<td colspan="4" align="right"> </td>
<th>TOTAL: </th>
<td><?php echo Escape::html(displayPrice($order->value_without_vat)); ?></td>
<td><?php echo Escape::html(displayPrice($order->value_vat)); ?></td>
<td> </td>
</tr>
<tr align="center" style="font-weight: bold; ">
<td colspan="5" align="right" style="font-size: larger; ">
<nobr>Total de plata:</nobr><br>
<nobr>(col. 5 + col. 6)</nobr><br>
</td>
<td colspan="3" style="font-size: larger; ">
<nobr><?php echo Escape::html(displayPrice($order->value_total)); ?> <?php echo Escape::html(Application::getConfigValue("default_currency")); ?></nobr>
</td>
</tr>
</table>
<?php
}
?>
<table width="800">
<tr>
<td width="50%">
Adresa de livrare: <br>
<?php echo nl2br(Escape::html($order->delivery_address)); ?>
</td>
<td width="50%">
<?php
$u = $db->tbUser->getUserById($order->id_user);
$u = Factory::instantiateUser($u);
?>
Client: <?php echo Escape::html($u->first_name . " " . $u->last_name); ?> <br>
ID client: <?php echo Escape::html($u->id); ?> <br>
Cod proforma: <?php echo Escape::html($order->code); ?> <br>
Total de plata: <?php echo Escape::html($order->value_total); ?>
</td>
</tr>
</table>
</body>
</html>