<?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 utilizatori</h1>
<?php require_once(WEB_DIR . "/includes/print_messages.php"); ?>
<?php
$db = Application::getDb();
if(@$_GET["action"] == "detail")
{
$u = $db->tbUser->getUserById(@$_GET["id"]);
$u = Factory::instantiateUser($u);
?>
<p>
<a href="admin/address.php?id_user=<?php echo intval($u->id); ?>">vizualizati adresele acestui utilizator</a>
</p>
<h2>Informatii pentru autentificare</h2>
<table>
<tr>
<td>Username</td><td><?php echo Escape::html(@$u->username); ?></td>
</tr>
<tr>
<td>Email</td><td><?php echo Escape::html(@$u->email); ?></td>
</tr>
<tr>
<td>Tip de cont</td><td><?php echo ucfirst($u->acc_type); ?></td>
</tr>
<tr>
<td>Activ</td><td><?php echo (@$u->active) ? "Da" : "Nu"; ?></td>
</tr>
<tr>
<td> </td>
<td>
<?php
$temp = (intval(@$u->active) == 1) ? "dezactivati" : "activati";
$action = (intval(@$u->active) == 1) ? "dezactivati" : "activati";
?>
<form action="admin/formparser/user.php?action=<?php echo $action; ?>" method="post">
<input type="hidden" name="id" value="<?php echo intval(@$u->id); ?>">
<input type="hidden" name="detail" value="true">
<input type="submit" value="<?php echo $temp; ?>" class="button">
</form>
</td>
</tr>
<tr>
<td> </td>
<td>
<form action="admin/formparser/user.php?action=delete" method="post" onsubmit="return confirm('Sunteti sigur ca doriti sa stergeti acest utilizator?'); ">
<input type="hidden" name="id" value="<?php echo intval(@$u->id); ?>">
<input type="hidden" name="detail" value="true">
<input type="submit" value="Delete" style="color: red; " class="button">
</form>
</td>
</tr>
</table>
<div id="div_person" style="display: none; ">
<h2>Informatii personale</h2>
<table>
<tr>
<td>Sex</td>
<td><?php echo Escape::html(ucfirst(@$u->gender)); ?></td>
</tr>
<tr>
<td>Prenume</td><td><?php echo Escape::html(@$u->first_name); ?></td>
</tr>
<tr>
<td>Nume</td><td><?php echo Escape::html(@$u->last_name); ?></td>
</tr>
<tr>
<td>Data nasterii <br> (dd/mm/yyyy)</td><td><?php echo Escape::html(@$u->displayDate("birth_date")); ?></td>
</tr>
<tr>
<td>Telefon</td><td><?php echo Escape::html(@$u->phone); ?></td>
</tr>
<tr>
<td>Mobil</td><td><?php echo Escape::html(@$u->mobile); ?></td>
</tr>
<tr>
<td>Fax</td><td><?php echo Escape::html(@$u->fax); ?></td>
</tr>
<tr>
<td>CNP</td><td><?php echo Escape::html(@$u->cnp); ?></td>
</tr>
</table>
</div>
<div id="div_company" style="display: none; ">
<h2>Informatii companie</h2>
<table>
<tr>
<td>Nume companie</td><td><?php echo Escape::html(@$u->company_name); ?></td>
</tr>
<tr>
<td>Numar de inregistrare la registrul comertului</td><td><?php echo Escape::html(@$u->reg_comert); ?></td>
</tr>
<tr>
<td>CUI</td><td><?php echo Escape::html(@$u->cui); ?></td>
</tr>
<tr>
<td>Banca</td><td><?php echo Escape::html(@$u->bank); ?></td>
</tr>
<tr>
<td>IBAN</td><td><?php echo Escape::html(@$u->iban); ?></td>
</tr>
<tr>
<td>Telefon companie</td><td><?php echo Escape::html(@$u->comp_phone); ?></td>
</tr>
<tr>
<td>Fax companie</td><td><?php echo Escape::html(@$u->comp_fax); ?></td>
</tr>
<tr>
<td>Email companie</td><td><?php echo Escape::html(@$u->comp_email); ?></td>
</tr>
</table>
</div>
<?php
if(!is_a($u, "UserPerson"))
{
?>
<script language="javascript">
hidePersonForm();
</script>
<?php
}
if(!is_a($u, "UserCompany"))
{
?>
<script language="javascript">
hideCompanyForm();
</script>
<?php
}
elseif (is_a($u, "UserCompany"))
{
?>
<script language="javascript">
showCompanyForm();
</script>
<?php
}
}
elseif (@$_GET["action"] == "create_admin")
{
$registerAdmin = SessionHandler::get("registerAdmin");
if(!is_a($registerAdmin, "User"))
$registerAdmin = new User();
?>
<form action="admin/formparser/user.php?action=create_admin" method="post">
<h1>Creeare cont nou de admin</h1>
<?php require_once(WEB_DIR . "/includes/print_messages.php"); ?>
<h2>Informatii pentru autentificare</h2>
<table>
<tr>
<td>Username</td><td><input type="text" name="username" value="<?php echo Escape::htmlValue(@$registerAdmin->username); ?>"></td>
</tr>
<tr>
<td>Parola</td><td><input type="password" name="password"></td>
</tr>
<tr>
<td>Confirmare parola</td><td><input type="password" name="confirm_password"></td>
</tr>
<tr>
<td>Email</td><td><input type="text" name="email" value="<?php echo Escape::htmlValue(@$registerAdmin->email); ?>"></td>
</tr>
<tr>
<td> </td><td><input type="submit" value="Cont nou" class="button"></td>
</tr>
</table>
</form>
<?php
}
else
{
?>
<p>
<a href="admin/user.php?action=create_admin">Creeare cont nou de admin</a>
</p>
<?php
// list of users
$list = $db->tbUser->search($_GET, @$_GET["start"], @$_GET["rowsPerPage"], @$_GET["order_by"], @$_GET["order_direction"]);
$recordsCount = $db->tbUser->getCount($_GET, @$_GET["start"], @$_GET["rowsPerPage"], @$_GET["order_by"], @$_GET["order_direction"]);
if($recordsCount > 0)
{
?>
<table border="1">
<tr>
<th>ID</th>
<th>username</th>
<th>email</th>
<th>activ</th>
<th>tip cont</th>
<th>actiune</th>
</tr>
<?php
for ($i = 0; $i < count($list); $i++)
{
?>
<tr>
<td><?php echo $list[$i]->id; ?> </td>
<td><a href="admin/user.php?action=detail&id=<?php echo $list[$i]->id; ?>"><?php echo Escape::html($list[$i]->username); ?></a> </td>
<td><a href="mailto:<?php echo Escape::html($list[$i]->email); ?>"><?php echo Escape::html($list[$i]->email); ?></a> </td>
<td><?php echo ($list[$i]->active == "1") ? "Da" : "Nu"; ?> </td>
<td><?php echo Escape::html(ucfirst($list[$i]->acc_type)); ?></td>
<td>
<?php
$temp = (intval($list[$i]->active) == 1) ? "dezactivati" : "activati";
$action = (intval($list[$i]->active) == 1) ? "dezactivati" : "activati";
?>
<form action="admin/formparser/user.php?action=<?php echo $action; ?>" method="post">
<input type="hidden" name="id" value="<?php echo intval($list[$i]->id); ?>">
<input type="submit" value="<?php echo $temp; ?>" class="button">
</form>
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="6" align="right">
<?php echo getListPages($recordsCount, 50, "admin"); ?>
</td>
</tr>
</table>
<?php
}
else
{
?>
<p class="box">Nu au putut fi gasiti utilizatori pe baza criteriilor de cautare.</p>
<?php
}
}
?>
</div>
<?php require_once(WEB_DIR . "/includes/right.php"); ?>
<?php require_once(WEB_DIR . "/includes/footer.php"); ?>
</div>
</div>
</div>
</body>
</html>