<?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__) . "/User.php");
class UserPerson extends User
{
// database stored properties
var $id = 0;
var $first_name = "";
var $last_name = "";
var $gender = "";
var $cnp = "";
var $birth_date = "";
var $phone = "";
var $mobile = "";
var $fax = "";
function UserPerson()
{
parent::User();
}
function getInstanceProps($myClass = "")
{
if(empty($myClass))
$myClass = __CLASS__;
return parent::getInstanceProps($myClass);
}
function validateRegister($confirmPassword)
{
if(!parent::validateRegister($confirmPassword))
return false;
$errors = array();
if(!in_array($this->gender, array("female", "male")))
$errors[] = "Va rugam sa alegeti sexul dumneavoastra";
if(strlen($this->first_name) < 3 || strlen($this->first_name) > 20)
$errors[] = "Prenumele trebuie sa aiba intre 3 si 20 caractere";
if(strlen($this->last_name) < 3 || strlen($this->last_name) > 20)
$errors[] = "Numele trebuie sa aiba intre 3 si 20 caractere";
Application::appendErrors($errors);
return (count($errors) == 0);
}
function validateUpdate($oldPassword, $newPassword, $confirmPassword)
{
if(!parent::validateUpdate($oldPassword, $newPassword, $confirmPassword))
return false;
$errors = array();
if(!in_array($this->gender, array("female", "male")))
$errors[] = "Va rugam sa alegeti sexul dumneavoastra";
if(strlen($this->first_name) < 3 || strlen($this->first_name) > 20)
$errors[] = "Prenumele trebuie sa aiba intre 3 si 20 caractere";
if(strlen($this->last_name) < 3 || strlen($this->last_name) > 20)
$errors[] = "Numele trebuie sa aiba intre 3 si 20 caractere";
Application::appendErrors($errors);
return (count($errors) == 0);
}
function toStr($humanReadable = false, $brief = false)
{
if($humanReadable)
{
$s = parent::toStr($humanReadable, $brief);
if($brief)
{
$s .= "
{$this->first_name} {$this->last_name}
CNP: {$this->cnp}";
}
else
{
$s .= "
Cont de tip persoana fizica cu detaliile:
Prenume: {$this->first_name}
Nume: {$this->last_name}
Sex: {$this->gender}
CNP: {$this->cnp}
Data nasterii: {$this->birth_date}
Telefon: {$this->phone}
Mobil: {$this->mobile}
Fax: {$this->fax}
";
}
return $s;
}
else
{
return parent::toStr();
}
}
}
?>