<?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(__FILE__) . "/init.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 . "/includes/left.php"); ?>
<div id="content">
<h1>Adresele mele</h1>
<dl>
<dt></dt>
<dd>
<ul>
<li><a href="address.php">Toate adresele</a></li>
<li><a href="address.php?condition=primary_addr">Adresele primare</a></li>
<li><a href="address.php?condition=delivery">Adresele de livrare</a></li>
<li><a href="address.php?condition=invoiceing">Adresele de facturare</a></li>
<li><a href="address.php?detail=true&id=0">Adaugare adresa noua</a></li>
</ul>
</dd>
</dl>
<?php require_once(WEB_DIR . "/includes/print_messages.php"); ?>
<?php
$user = Application::getUser();
$db = Application::getDb();
if(@$_GET["detail"] == "true")
{
if(!array_key_exists("id", $_GET))
{
$a = SessionHandler::get("editAddress");
if(!is_a($a, "Address"))
$a = new Address();
}
else
{
$a = $db->tbAddress->getRecordById(@$_GET["id"]);
}
?>
<form id="frm_delete_address" action="formparser/address.php?action=delete" method="post">
<input type="hidden" name="id" value="<?php echo intval($a->id); ?>">
</form>
<form action="formparser/address.php?action=save" method="post">
<input type="hidden" name="id" value="<?php echo $a->id; ?>">
<dl>
<dt class="title"><b>Editare adresa</b></dt>
<dd>
<table style="border-bottom: 1px solid #000000; width: 375px; ">
<tr valign="top">
<td width="150">
<input type="checkbox" name="primary_addr" value="1" <?php echo ($a->primary_addr == 1) ? "checked" : ""; ?>> Adresa primara<br>
<input type="checkbox" name="delivery" value="1" <?php echo ($a->delivery == 1) ? "checked" : ""; ?>> Adresa de livrare<br>
<input type="checkbox" name="invoiceing" value="1" <?php echo ($a->invoiceing == 1) ? "checked" : ""; ?>> Adresa de facturare<br>
<input type="submit" value="Salvati" class="button">
<input type="button" value="Stergeti" style="color: red; " onclick="deleteAddress(); " class="button">
</td>
<td align="right">
Judetul:
<select name="county">
<option value="">-- Alegeti --</option>
<?php
$list = Application::getConfigValue("counties");
for($i = 0; $i < count($list); $i++)
{
$selected = ($a->county == $list[$i]) ? "selected" : "";
?>
<option value="<?php echo Escape::htmlValue($list[$i]); ?>" <?php echo $selected; ?>><?php echo Escape::html($list[$i]); ?></option>
<?php
}
?>
</select><br>
Oras: <input type="text" name="city" value="<?php echo Escape::htmlValue($a->city); ?>"><br>
<textarea name="address" rows="5" cols="25"><?php echo Escape::html($a->address); ?></textarea>
</td>
</tr>
</table>
</dd>
</dl>
</form>
<?php
}
else
{
// show list of addresses
$list = $db->tbAddress->getRecordsByUserId($user->id, @$_GET["condition"]);
if(count($list) > 0)
{
for($i = 0; $i < count($list); $i++)
{
$a = $list[$i];
?>
<dl>
<dt></dt>
<dd>
<table style="border-bottom: 1px solid #000000; width: 375px; ">
<tr valign="top">
<td width="150">
<form action="formparser/address.php?action=toggle_checkbox" method="post">
<input type="hidden" name="id" value="<?php echo intval($a->id); ?>">
<input type="hidden" name="field" value="primary_addr">
<input type="checkbox" <?php echo ($a->primary_addr == 1) ? "checked" : ""; ?> onclick="this.form.submit(); "> Adresa primara<br>
</form>
<form action="formparser/address.php?action=toggle_checkbox" method="post">
<input type="hidden" name="id" value="<?php echo intval($a->id); ?>">
<input type="hidden" name="field" value="delivery">
<input type="checkbox" <?php echo ($a->delivery == 1) ? "checked" : ""; ?> onclick="this.form.submit(); "> Livrare<br>
</form>
<form action="formparser/address.php?action=toggle_checkbox" method="post">
<input type="hidden" name="id" value="<?php echo intval($a->id); ?>">
<input type="hidden" name="field" value="invoiceing">
<input type="checkbox" <?php echo ($a->invoiceing == 1) ? "checked" : ""; ?> onclick="this.form.submit(); "> Facturare<br>
</form>
<form action="formparser/address.php?action=delete" method="post" onsubmit="return confirm('Sunteti sigur ca doriti sa stergeti aceasta adresa?'); ">
<input type="hidden" name="id" value="<?php echo intval($a->id); ?>">
<input type="submit" value="Stergeti" style="color: red; " class="button">
</form>
</td>
<td>
<a href="address.php?detail=true&id=<?php echo $a->id; ?>">Judet <?php echo $a->county; ?></a><br>
<a href="address.php?detail=true&id=<?php echo $a->id; ?>">Oras <?php echo $a->city; ?></a><br>
<a href="address.php?detail=true&id=<?php echo $a->id; ?>"><?php echo $a->address; ?></a>
</td>
</tr>
</table>
</dl>
<?php
}
}
else
{
?>
<p style="background-color: white; ">Nu au fost gasite adrese</p>
<?php
}
}
?>
</div>
<?php require_once(WEB_DIR . "/includes/right.php"); ?>
<?php require_once(WEB_DIR . "/includes/footer.php"); ?>
</div>
</div>
</div>
</body>
</html>