2004-10-19 22:43:23 +02:00
|
|
|
<?php
|
2005-07-02 13:29:15 +02:00
|
|
|
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2011-08-20 17:11:31 +02:00
|
|
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
2012-12-30 15:13:49 +01:00
|
|
|
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
2004-01-31 12:56:45 +01:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-01-31 12:56:45 +01:00
|
|
|
* (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
|
2011-08-01 01:54:11 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2004-01-31 12:56:45 +01:00
|
|
|
*/
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2004-12-25 19:37:40 +01:00
|
|
|
/**
|
2010-03-26 23:11:11 +01:00
|
|
|
* \file htdocs/contact/perso.php
|
|
|
|
|
* \ingroup societe
|
|
|
|
|
* \brief Onglet informations personnelles d'un contact
|
|
|
|
|
*/
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2004-11-11 22:15:34 +01:00
|
|
|
$langs->load("companies");
|
2008-05-24 03:13:59 +02:00
|
|
|
$langs->load("other");
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
$id = GETPOST('id','int');
|
|
|
|
|
$action = GETPOST('action','alpha');
|
|
|
|
|
|
2008-02-25 17:30:43 +01:00
|
|
|
// Security check
|
2008-02-25 21:03:21 +01:00
|
|
|
if ($user->societe_id) $socid=$user->societe_id;
|
2012-01-10 17:16:17 +01:00
|
|
|
$result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
|
|
|
|
|
$object = new Contact($db);
|
2010-11-19 22:24:48 +01:00
|
|
|
|
2008-06-12 13:51:11 +02:00
|
|
|
/*
|
|
|
|
|
* Action
|
|
|
|
|
*/
|
|
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
if ($action == 'update' && ! $_POST["cancel"] && $user->rights->societe->contact->creer)
|
2008-06-12 13:51:11 +02:00
|
|
|
{
|
2012-01-10 17:16:17 +01:00
|
|
|
$ret = $object->fetch($id);
|
2012-02-05 12:40:08 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
// Note: Correct date should be completed with location to have exact GM time of birth.
|
|
|
|
|
$object->birthday = dol_mktime(0,0,0,$_POST["birthdaymonth"],$_POST["birthdayday"],$_POST["birthdayyear"]);
|
|
|
|
|
$object->birthday_alert = $_POST["birthday_alert"];
|
2012-02-05 12:40:08 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
$result = $object->update_perso($id, $user);
|
|
|
|
|
if ($result > 0)
|
|
|
|
|
{
|
|
|
|
|
$object->old_name='';
|
|
|
|
|
$object->old_firstname='';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$error = $object->error;
|
|
|
|
|
}
|
2008-06-12 13:51:11 +02:00
|
|
|
}
|
|
|
|
|
|
2005-07-16 02:52:29 +02:00
|
|
|
|
2004-01-31 12:56:45 +01:00
|
|
|
/*
|
2011-08-20 17:11:31 +02:00
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
$now=dol_now();
|
2005-07-02 13:29:15 +02:00
|
|
|
|
2013-04-26 12:35:31 +02:00
|
|
|
$title = (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("Contacts") : $langs->trans("ContactsAddresses"));
|
|
|
|
|
|
|
|
|
|
llxHeader('',$title,'EN:Module_Third_Parties|FR:Module_Tiers|ES:Módulo_Empresas');
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2005-07-16 02:52:29 +02:00
|
|
|
$form = new Form($db);
|
|
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
$object->fetch($id, $user);
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
$head = contact_prepare_head($object);
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2013-04-26 12:35:31 +02:00
|
|
|
dol_fiche_head($head, 'perso', $title, 0, 'contact');
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
if ($action == 'edit')
|
2004-01-31 12:56:45 +01:00
|
|
|
{
|
2012-01-10 17:16:17 +01:00
|
|
|
/*
|
|
|
|
|
* Fiche en mode edition
|
|
|
|
|
*/
|
2005-02-15 23:38:40 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
print '<form name="perso" method="POST" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
|
2009-05-17 10:01:54 +02:00
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
2005-07-02 13:29:15 +02:00
|
|
|
print '<input type="hidden" name="action" value="update">';
|
2012-01-10 17:16:17 +01:00
|
|
|
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Ref
|
2007-11-05 19:35:45 +01:00
|
|
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
2012-01-10 17:16:17 +01:00
|
|
|
print $object->id;
|
2007-11-05 19:35:45 +01:00
|
|
|
print '</td></tr>';
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Name
|
2012-01-10 17:16:17 +01:00
|
|
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
|
|
|
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td>';
|
2007-11-05 19:35:45 +01:00
|
|
|
|
|
|
|
|
// Company
|
2011-02-13 13:55:40 +01:00
|
|
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
2004-01-31 12:56:45 +01:00
|
|
|
{
|
2012-01-10 17:16:17 +01:00
|
|
|
if ($object->socid > 0)
|
2011-02-13 13:55:40 +01:00
|
|
|
{
|
|
|
|
|
$objsoc = new Societe($db);
|
2012-01-10 17:16:17 +01:00
|
|
|
$objsoc->fetch($object->socid);
|
2011-02-13 13:55:40 +01:00
|
|
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
|
|
|
|
print $langs->trans("ContactNotLinkedToCompany");
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2005-08-25 23:38:24 +02:00
|
|
|
}
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Civility
|
2005-08-25 23:38:24 +02:00
|
|
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
2012-01-10 17:16:17 +01:00
|
|
|
print $object->getCivilityLabel();
|
2005-08-25 23:38:24 +02:00
|
|
|
print '</td></tr>';
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Date To Birth
|
2008-09-28 05:39:39 +02:00
|
|
|
print '<tr><td>'.$langs->trans("DateToBirth").'</td><td>';
|
2011-11-08 10:18:45 +01:00
|
|
|
$form=new Form($db);
|
2012-01-10 17:16:17 +01:00
|
|
|
print $form->select_date($object->birthday,'birthday',0,0,1,"perso");
|
2005-07-02 13:29:15 +02:00
|
|
|
print '</td>';
|
2004-07-17 19:14:36 +02:00
|
|
|
|
2005-07-16 02:52:29 +02:00
|
|
|
print '<td colspan="2">'.$langs->trans("Alert").': ';
|
2012-07-10 22:10:12 +02:00
|
|
|
if (! empty($object->birthday_alert))
|
2004-01-31 12:56:45 +01:00
|
|
|
{
|
2011-08-31 16:55:54 +02:00
|
|
|
print '<input type="checkbox" name="birthday_alert" checked="checked"></td>';
|
2004-01-31 12:56:45 +01:00
|
|
|
}
|
2005-07-02 13:29:15 +02:00
|
|
|
else
|
2004-01-31 12:56:45 +01:00
|
|
|
{
|
2005-07-02 13:29:15 +02:00
|
|
|
print '<input type="checkbox" name="birthday_alert"></td>';
|
2004-01-31 12:56:45 +01:00
|
|
|
}
|
2005-07-02 13:29:15 +02:00
|
|
|
print '</tr>';
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2010-11-19 22:24:48 +01:00
|
|
|
print "</table><br>";
|
|
|
|
|
|
|
|
|
|
print '<center>';
|
|
|
|
|
print '<input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
|
|
|
|
print ' ';
|
|
|
|
|
print '<input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
|
|
|
|
|
print '</center>';
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2005-07-02 13:29:15 +02:00
|
|
|
print "</form>";
|
2004-01-31 12:56:45 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2005-07-02 13:29:15 +02:00
|
|
|
/*
|
|
|
|
|
* Fiche en mode visu
|
|
|
|
|
*/
|
|
|
|
|
print '<table class="border" width="100%">';
|
|
|
|
|
|
2012-07-28 21:54:36 +02:00
|
|
|
$linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php">'.$langs->trans("BackToList").'</a>';
|
|
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Ref
|
2007-11-05 19:35:45 +01:00
|
|
|
print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td colspan="3">';
|
2012-07-28 21:54:36 +02:00
|
|
|
print $form->showrefnav($object, 'id', $linkback);
|
2007-11-05 19:35:45 +01:00
|
|
|
print '</td></tr>';
|
|
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Name
|
2012-01-10 17:16:17 +01:00
|
|
|
print '<tr><td width="20%">'.$langs->trans("Lastname").' / '.$langs->trans("Label").'</td><td width="30%">'.$object->lastname.'</td>';
|
|
|
|
|
print '<td width="20%">'.$langs->trans("Firstname").'</td><td width="30%">'.$object->firstname.'</td></tr>';
|
2007-11-05 19:35:45 +01:00
|
|
|
|
|
|
|
|
// Company
|
2011-02-13 13:55:40 +01:00
|
|
|
if (empty($conf->global->SOCIETE_DISABLE_CONTACTS))
|
2005-08-25 23:38:24 +02:00
|
|
|
{
|
2012-01-10 17:16:17 +01:00
|
|
|
if ($object->socid > 0)
|
2011-02-13 13:55:40 +01:00
|
|
|
{
|
|
|
|
|
$objsoc = new Societe($db);
|
2012-01-10 17:16:17 +01:00
|
|
|
$objsoc->fetch($object->socid);
|
2011-02-13 13:55:40 +01:00
|
|
|
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">'.$objsoc->getNomUrl(1).'</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<tr><td>'.$langs->trans("Company").'</td><td colspan="3">';
|
|
|
|
|
print $langs->trans("ContactNotLinkedToCompany");
|
|
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
2005-08-25 23:38:24 +02:00
|
|
|
}
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Civility
|
2005-08-25 23:38:24 +02:00
|
|
|
print '<tr><td>'.$langs->trans("UserTitle").'</td><td colspan="3">';
|
2012-01-10 17:16:17 +01:00
|
|
|
print $object->getCivilityLabel();
|
2005-08-25 23:38:24 +02:00
|
|
|
print '</td></tr>';
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
// Date To Birth
|
2012-02-05 12:40:08 +01:00
|
|
|
print '<tr>';
|
2012-07-10 22:10:12 +02:00
|
|
|
if (! empty($object->birthday))
|
2007-01-16 23:02:36 +01:00
|
|
|
{
|
2012-08-23 02:04:35 +02:00
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
2011-08-20 17:11:31 +02:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.dol_print_date($object->birthday,"day");
|
2011-08-20 17:11:31 +02:00
|
|
|
|
|
|
|
|
print ' ';
|
|
|
|
|
//var_dump($birthdatearray);
|
2012-02-07 10:25:58 +01:00
|
|
|
$ageyear=convertSecondToTime($now-$object->birthday,'year')-1970;
|
|
|
|
|
$agemonth=convertSecondToTime($now-$object->birthday,'month')-1;
|
2011-08-20 17:11:31 +02:00
|
|
|
if ($ageyear >= 2) print '('.$ageyear.' '.$langs->trans("DurationYears").')';
|
|
|
|
|
else if ($agemonth >= 2) print '('.$agemonth.' '.$langs->trans("DurationMonths").')';
|
|
|
|
|
else print '('.$agemonth.' '.$langs->trans("DurationMonth").')';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print ' - ';
|
2012-01-10 17:16:17 +01:00
|
|
|
if ($object->birthday_alert) print $langs->trans("BirthdayAlertOn");
|
2009-03-10 22:21:45 +01:00
|
|
|
else print $langs->trans("BirthdayAlertOff");
|
2011-08-20 17:11:31 +02:00
|
|
|
print '</td>';
|
2005-07-02 13:29:15 +02:00
|
|
|
}
|
2007-01-16 23:02:36 +01:00
|
|
|
else
|
|
|
|
|
{
|
2012-02-05 12:40:08 +01:00
|
|
|
print '<td>'.$langs->trans("DateToBirth").'</td><td colspan="3">'.$langs->trans("Unknown")."</td>";
|
2005-07-02 13:29:15 +02:00
|
|
|
}
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
2005-07-11 02:49:16 +02:00
|
|
|
print "</table>";
|
2005-07-02 13:29:15 +02:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
}
|
2005-07-02 13:29:15 +02:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
dol_fiche_end();
|
2005-07-16 02:52:29 +02:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
if ($action != 'edit')
|
|
|
|
|
{
|
2005-07-02 13:29:15 +02:00
|
|
|
// Barre d'actions
|
|
|
|
|
if ($user->societe_id == 0)
|
2004-01-31 12:56:45 +01:00
|
|
|
{
|
2005-07-02 13:29:15 +02:00
|
|
|
print '<div class="tabsAction">';
|
2009-08-05 19:49:12 +02:00
|
|
|
|
2011-08-20 17:11:31 +02:00
|
|
|
if ($user->rights->societe->contact->creer)
|
|
|
|
|
{
|
2012-01-10 17:16:17 +01:00
|
|
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=edit">'.$langs->trans('Modify').'</a>';
|
2005-12-02 12:55:43 +01:00
|
|
|
}
|
2004-01-31 12:56:45 +01:00
|
|
|
|
2005-07-02 13:29:15 +02:00
|
|
|
print "</div>";
|
2004-01-31 12:56:45 +01:00
|
|
|
}
|
|
|
|
|
}
|
2004-11-11 22:15:34 +01:00
|
|
|
|
2012-02-05 12:40:08 +01:00
|
|
|
|
2012-01-10 17:16:17 +01:00
|
|
|
llxFooter();
|
|
|
|
|
|
2004-11-11 22:15:34 +01:00
|
|
|
$db->close();
|
2004-01-31 12:56:45 +01:00
|
|
|
?>
|