2006-02-25 00:16:35 +01:00
< ? php
/* Copyright ( C ) 2004 - 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-06-23 18:11:21 +02:00
* Copyright ( C ) 2004 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2006-02-25 00:16:35 +01:00
* Copyright ( C ) 2004 Benoit Mortier < benoit . mortier @ opensides . be >
2018-01-10 12:38:12 +01:00
* Copyright ( C ) 2005 - 2017 Regis Houssin < regis . houssin @ capnetworks . com >
2007-01-06 15:59:34 +01:00
* Copyright ( C ) 2007 Franky Van Liedekerke < franky . van . liedekerke @ telenet . be >
2015-10-11 12:27:04 +02:00
* Copyright ( C ) 2013 Florian Henry < florian . henry @ open - concept . pro >
2016-08-10 15:01:43 +02:00
* Copyright ( C ) 2013 - 2016 Alexandre Spangaro < aspangaro . dolibarr @ gmail . com >
2014-05-09 16:36:18 +02:00
* Copyright ( C ) 2014 Juanjo Menent < jmenent @ 2 byte . es >
2015-10-11 12:27:04 +02:00
* Copyright ( C ) 2015 Jean - François Ferry < jfefe @ aternatik . fr >
2006-02-25 00:16:35 +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
2006-02-25 00:16:35 +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 />.
2006-02-25 00:16:35 +01:00
*/
/**
2014-09-18 21:18:25 +02:00
* \file htdocs / contact / card . php
2008-08-06 15:15:59 +02:00
* \ingroup societe
2011-01-05 18:43:58 +01:00
* \brief Card of a contact
2008-08-06 15:15:59 +02:00
*/
2006-02-25 00:16:35 +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 . '/comm/action/class/actioncomm.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/contact.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/company.lib.php' ;
2013-07-10 12:28:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/images.lib.php' ;
2015-10-04 17:25:46 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2012-09-19 17:53:09 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php' ;
2013-04-09 17:18:07 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php' ;
2013-07-10 12:28:28 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.form.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/user/class/user.class.php' ;
2015-06-11 14:50:11 +02:00
require_once DOL_DOCUMENT_ROOT . '/categories/class/categorie.class.php' ;
2018-05-26 20:32:23 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'companies' , 'users' , 'other' , 'commercial' ));
2006-02-25 00:16:35 +01:00
2011-08-23 00:04:21 +02:00
$mesg = '' ; $error = 0 ; $errors = array ();
2011-04-06 16:26:43 +02:00
2012-02-27 17:02:56 +01:00
$action = ( GETPOST ( 'action' , 'alpha' ) ? GETPOST ( 'action' , 'alpha' ) : 'view' );
2018-01-10 12:38:12 +01:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
2012-02-27 17:02:56 +01:00
$id = GETPOST ( 'id' , 'int' );
$socid = GETPOST ( 'socid' , 'int' );
2009-11-29 17:36:01 +01:00
2011-06-30 15:25:32 +02:00
$object = new Contact ( $db );
2012-09-19 17:53:09 +02:00
$extrafields = new ExtraFields ( $db );
2011-06-30 15:25:32 +02:00
2013-04-01 19:43:26 +02:00
// fetch optionals attributes and labels
2013-04-26 10:29:14 +02:00
$extralabels = $extrafields -> fetch_name_optionals_label ( $object -> table_element );
2013-04-01 19:43:26 +02:00
2010-11-03 12:39:40 +01:00
// Get object canvas (By default, this is not defined, so standard usage of dolibarr)
2011-09-13 14:00:37 +02:00
$object -> getCanvas ( $id );
2012-07-10 22:10:12 +02:00
$objcanvas = null ;
$canvas = ( ! empty ( $object -> canvas ) ? $object -> canvas : GETPOST ( " canvas " ));
2010-11-03 12:39:40 +01:00
if ( ! empty ( $canvas ))
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/canvas.class.php' ;
2011-09-24 17:57:52 +02:00
$objcanvas = new Canvas ( $db , $action );
$objcanvas -> getCanvas ( 'contact' , 'contactcard' , $canvas );
2010-11-03 12:39:40 +01:00
}
2006-03-11 15:18:37 +01:00
2011-09-13 14:00:37 +02:00
// Security check
2016-10-24 12:42:37 +02:00
if ( $user -> societe_id ) $socid = $user -> societe_id ;
2013-04-26 12:35:31 +02:00
$result = restrictedArea ( $user , 'contact' , $id , 'socpeople&societe' , '' , '' , 'rowid' , $objcanvas ); // If we create a contact with no company (shared contacts), no check on write permission
2011-09-13 14:00:37 +02:00
2017-06-10 12:56:28 +02:00
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
2014-10-06 07:20:58 +02:00
$hookmanager -> initHooks ( array ( 'contactcard' , 'globalcard' ));
2011-07-01 00:38:06 +02:00
2006-03-11 15:18:37 +01:00
2008-02-25 17:30:43 +01:00
/*
2009-11-28 08:30:45 +01:00
* Actions
*/
2007-02-26 00:08:25 +01:00
2011-09-24 17:57:52 +02:00
$parameters = array ( 'id' => $id , 'objcanvas' => $objcanvas );
2011-08-11 00:47:33 +02:00
$reshook = $hookmanager -> executeHooks ( 'doActions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by some hooks
2014-09-28 03:41:32 +02:00
if ( $reshook < 0 ) setEventMessages ( $hookmanager -> error , $hookmanager -> errors , 'errors' );
2011-07-01 00:38:06 +02:00
2011-07-02 01:11:12 +02:00
if ( empty ( $reshook ))
{
2011-07-04 10:00:52 +02:00
// Cancel
2017-09-15 10:50:50 +02:00
if ( GETPOST ( 'cancel' , 'alpha' ) && ! empty ( $backtopage ))
2011-07-04 10:00:52 +02:00
{
2012-02-27 17:02:56 +01:00
header ( " Location: " . $backtopage );
2011-07-04 10:00:52 +02:00
exit ;
}
// Creation utilisateur depuis contact
2011-09-24 17:57:52 +02:00
if ( $action == 'confirm_create_user' && $confirm == 'yes' && $user -> rights -> user -> user -> creer )
2011-03-26 19:34:41 +01:00
{
2011-06-30 15:25:32 +02:00
// Recuperation contact actuel
2012-02-27 17:02:56 +01:00
$result = $object -> fetch ( $id );
2011-03-26 19:34:41 +01:00
if ( $result > 0 )
{
2011-06-30 15:25:32 +02:00
$db -> begin ();
// Creation user
$nuser = new User ( $db );
2014-05-10 02:21:04 +02:00
$result = $nuser -> create_from_contact ( $object , GETPOST ( " login " )); // Do not use GETPOST(alpha)
2011-06-30 15:25:32 +02:00
if ( $result > 0 )
2011-03-26 19:34:41 +01:00
{
2014-05-10 02:21:04 +02:00
$result2 = $nuser -> setPassword ( $user , GETPOST ( " password " ), 0 , 0 , 1 ); // Do not use GETPOST(alpha)
2011-06-30 15:25:32 +02:00
if ( $result2 )
{
$db -> commit ();
}
else
{
$error = $nuser -> error ; $errors = $nuser -> errors ;
$db -> rollback ();
}
2011-03-26 19:34:41 +01:00
}
else
{
2011-06-01 18:23:33 +02:00
$error = $nuser -> error ; $errors = $nuser -> errors ;
2011-01-29 18:41:26 +01:00
$db -> rollback ();
2011-03-26 19:34:41 +01:00
}
}
else
{
2011-06-30 15:25:32 +02:00
$error = $object -> error ; $errors = $object -> errors ;
2011-03-26 19:34:41 +01:00
}
}
2013-09-25 19:58:22 +02:00
2011-03-26 19:34:41 +01:00
2018-01-10 12:38:12 +01:00
// Confirmation desactivation
if ( $action == 'disable' )
{
$object -> fetch ( $id );
if ( $object -> setstatus ( 0 ) < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
else
{
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
}
}
2013-07-10 12:28:28 +02:00
2018-01-10 12:38:12 +01:00
// Confirmation activation
if ( $action == 'enable' )
{
$object -> fetch ( $id );
if ( $object -> setstatus ( 1 ) < 0 )
{
setEventMessages ( $object -> error , $object -> errors , 'errors' );
}
else
{
header ( " Location: " . $_SERVER [ 'PHP_SELF' ] . '?id=' . $id );
exit ;
}
}
2013-09-25 19:58:22 +02:00
2018-01-10 12:38:12 +01:00
// Add contact
if ( $action == 'add' && $user -> rights -> societe -> contact -> creer )
{
$db -> begin ();
2011-06-30 00:29:50 +02:00
2011-06-30 15:25:32 +02:00
if ( $canvas ) $object -> canvas = $canvas ;
2011-03-26 19:34:41 +01:00
2018-01-10 12:38:12 +01:00
$object -> entity = ( GETPOSTISSET ( 'entity' ) ? GETPOST ( 'entity' , 'int' ) : $conf -> entity );
2014-05-09 16:36:18 +02:00
$object -> socid = GETPOST ( " socid " , 'int' );
2018-04-06 19:12:13 +02:00
$object -> lastname = GETPOST ( " lastname " , 'alpha' );
$object -> firstname = GETPOST ( " firstname " , 'alpha' );
$object -> civility_id = GETPOST ( " civility_id " , 'alpha' );
$object -> poste = GETPOST ( " poste " , 'alpha' );
$object -> address = GETPOST ( " address " , 'alpha' );
$object -> zip = GETPOST ( " zipcode " , 'alpha' );
$object -> town = GETPOST ( " town " , 'alpha' );
2014-05-09 16:36:18 +02:00
$object -> country_id = GETPOST ( " country_id " , 'int' );
2018-01-10 12:38:12 +01:00
$object -> state_id = GETPOST ( " state_id " , 'int' );
2018-04-06 19:12:13 +02:00
$object -> skype = GETPOST ( " skype " , 'alpha' );
2014-05-09 16:36:18 +02:00
$object -> email = GETPOST ( " email " , 'alpha' );
2018-04-06 19:12:13 +02:00
$object -> phone_pro = GETPOST ( " phone_pro " , 'alpha' );
$object -> phone_perso = GETPOST ( " phone_perso " , 'alpha' );
$object -> phone_mobile = GETPOST ( " phone_mobile " , 'alpha' );
$object -> fax = GETPOST ( " fax " , 'alpha' );
2014-05-09 16:36:18 +02:00
$object -> jabberid = GETPOST ( " jabberid " , 'alpha' );
$object -> no_email = GETPOST ( " no_email " , 'int' );
$object -> priv = GETPOST ( " priv " , 'int' );
2018-04-06 19:12:13 +02:00
$object -> note_public = GETPOST ( " note_public " , 'none' );
$object -> note_private = GETPOST ( " note_private " , 'none' );
2013-10-30 12:40:00 +01:00
$object -> statut = 1 ; //Defult status to Actif
2010-11-19 22:24:48 +01:00
2011-06-30 15:25:32 +02:00
// Note: Correct date should be completed with location to have exact GM time of birth.
2014-05-09 16:36:18 +02:00
$object -> birthday = dol_mktime ( 0 , 0 , 0 , GETPOST ( " birthdaymonth " , 'int' ), GETPOST ( " birthdayday " , 'int' ), GETPOST ( " birthdayyear " , 'int' ));
$object -> birthday_alert = GETPOST ( " birthday_alert " , 'alpha' );
2011-06-30 15:25:32 +02:00
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
2013-04-09 23:56:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
2015-06-05 15:41:27 +02:00
if ( $ret < 0 )
2015-05-25 17:36:36 +02:00
{
$error ++ ;
$action = 'create' ;
}
2015-06-05 15:41:27 +02:00
2014-05-10 02:21:04 +02:00
if ( ! GETPOST ( " lastname " ))
2011-06-30 15:25:32 +02:00
{
$error ++ ; $errors [] = $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Lastname " ) . ' / ' . $langs -> transnoentities ( " Label " ));
2011-10-23 13:02:54 +02:00
$action = 'create' ;
2011-06-30 15:25:32 +02:00
}
2012-05-12 12:32:24 +02:00
2012-03-19 10:17:24 +01:00
if ( ! $error )
2011-06-30 15:25:32 +02:00
{
$id = $object -> create ( $user );
if ( $id <= 0 )
{
2012-05-12 12:32:24 +02:00
$error ++ ; $errors = array_merge ( $errors ,( $object -> error ? array ( $object -> error ) : $object -> errors ));
2011-10-23 13:02:54 +02:00
$action = 'create' ;
2015-06-11 14:50:11 +02:00
} else {
// Categories association
2017-09-18 01:39:39 +02:00
$contcats = GETPOST ( 'contcats' , 'array' );
2015-09-30 18:46:51 +02:00
$object -> setCategories ( $contcats );
2015-06-11 14:50:11 +02:00
}
2011-06-30 15:25:32 +02:00
}
if ( ! $error && $id > 0 )
{
$db -> commit ();
2012-02-27 17:02:56 +01:00
if ( ! empty ( $backtopage )) $url = $backtopage ;
2014-09-18 21:18:25 +02:00
else $url = 'card.php?id=' . $id ;
2012-08-31 05:58:38 +02:00
header ( " Location: " . $url );
2011-06-30 15:25:32 +02:00
exit ;
}
else
{
$db -> rollback ();
}
}
2011-09-24 17:57:52 +02:00
if ( $action == 'confirm_delete' && $confirm == 'yes' && $user -> rights -> societe -> contact -> supprimer )
2011-06-30 15:25:32 +02:00
{
2013-10-07 22:50:12 +02:00
$result = $object -> fetch ( $id );
2011-06-30 15:25:32 +02:00
2014-05-10 02:21:04 +02:00
$object -> old_lastname = GETPOST ( " old_lastname " );
$object -> old_firstname = GETPOST ( " old_firstname " );
2011-03-26 19:34:41 +01:00
2011-06-30 15:25:32 +02:00
$result = $object -> delete ();
2011-03-26 19:34:41 +01:00
if ( $result > 0 )
{
2014-10-12 11:59:52 +02:00
if ( $backtopage )
{
2014-10-17 15:01:56 +02:00
header ( " Location: " . $backtopage );
2014-10-12 11:59:52 +02:00
exit ;
}
else
{
2014-10-17 15:01:56 +02:00
header ( " Location: " . DOL_URL_ROOT . '/contact/list.php' );
2014-10-12 11:59:52 +02:00
exit ;
}
2011-03-26 19:34:41 +01:00
}
else
{
2015-04-07 03:00:11 +02:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2011-06-30 15:25:32 +02:00
}
}
2011-09-24 17:57:52 +02:00
if ( $action == 'update' && ! $_POST [ " cancel " ] && $user -> rights -> societe -> contact -> creer )
2011-06-30 15:25:32 +02:00
{
2012-03-19 10:17:24 +01:00
if ( empty ( $_POST [ " lastname " ]))
2011-06-30 15:25:32 +02:00
{
$error ++ ; $errors = array ( $langs -> trans ( " ErrorFieldRequired " , $langs -> transnoentities ( " Name " ) . ' / ' . $langs -> transnoentities ( " Label " )));
2011-09-24 17:57:52 +02:00
$action = 'edit' ;
2011-06-30 15:25:32 +02:00
}
2018-01-10 12:52:30 +01:00
if ( ! $error )
{
$contactid = GETPOST ( " contactid " , 'int' );
$object -> fetch ( $contactid );
2015-10-04 17:25:46 +02:00
2018-01-10 12:52:30 +01:00
// Photo save
$dir = $conf -> societe -> multidir_output [ $object -> entity ] . " /contact/ " . $object -> id . " /photos " ;
2015-10-04 17:25:46 +02:00
$file_OK = is_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ]);
2015-12-21 17:32:20 +01:00
if ( GETPOST ( 'deletephoto' ) && $object -> photo )
{
$fileimg = $dir . '/' . $object -> photo ;
$dirthumbs = $dir . '/thumbs' ;
dol_delete_file ( $fileimg );
dol_delete_dir_recursive ( $dirthumbs );
$object -> photo = '' ;
}
2015-10-04 17:25:46 +02:00
if ( $file_OK )
{
if ( image_format_supported ( $_FILES [ 'photo' ][ 'name' ]) > 0 )
{
dol_mkdir ( $dir );
if ( @ is_dir ( $dir ))
{
$newfile = $dir . '/' . dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
$result = dol_move_uploaded_file ( $_FILES [ 'photo' ][ 'tmp_name' ], $newfile , 1 );
if ( ! $result > 0 )
{
$errors [] = " ErrorFailedToSaveFile " ;
}
else
{
$object -> photo = dol_sanitizeFileName ( $_FILES [ 'photo' ][ 'name' ]);
2016-04-09 14:12:21 +02:00
// Create thumbs
2017-06-07 16:44:04 +02:00
$object -> addThumbs ( $newfile );
2015-10-04 17:25:46 +02:00
}
}
}
else
{
$errors [] = " ErrorBadImageFormat " ;
}
}
else
{
switch ( $_FILES [ 'photo' ][ 'error' ])
{
case 1 : //uploaded file exceeds the upload_max_filesize directive in php.ini
case 2 : //uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the html form
$errors [] = " ErrorFileSizeTooLarge " ;
break ;
case 3 : //uploaded file was only partially uploaded
$errors [] = " ErrorFilePartiallyUploaded " ;
break ;
}
}
2016-02-18 15:18:47 +01:00
$object -> oldcopy = clone $object ;
2011-06-30 15:25:32 +02:00
2018-04-06 19:12:13 +02:00
$object -> old_lastname = GETPOST ( " old_lastname " , 'alpha' );
$object -> old_firstname = GETPOST ( " old_firstname " , 'alpha' );
2014-05-09 16:36:18 +02:00
$object -> socid = GETPOST ( " socid " , 'int' );
2018-04-06 19:12:13 +02:00
$object -> lastname = GETPOST ( " lastname " , 'alpha' );
$object -> firstname = GETPOST ( " firstname " , 'alpha' );
$object -> civility_id = GETPOST ( " civility_id " , 'alpha' );
$object -> poste = GETPOST ( " poste " , 'alpha' );
$object -> address = GETPOST ( " address " , 'alpha' );
$object -> zip = GETPOST ( " zipcode " , 'alpha' );
$object -> town = GETPOST ( " town " , 'alpha' );
$object -> state_id = GETPOST ( " state_id " , 'int' );
2015-10-03 12:21:27 +02:00
$object -> fk_departement = GETPOST ( " state_id " , 'int' ); // For backward compatibility
2014-05-09 16:36:18 +02:00
$object -> country_id = GETPOST ( " country_id " , 'int' );
$object -> email = GETPOST ( " email " , 'alpha' );
$object -> skype = GETPOST ( " skype " , 'alpha' );
2018-04-06 19:12:13 +02:00
$object -> phone_pro = GETPOST ( " phone_pro " , 'alpha' );
$object -> phone_perso = GETPOST ( " phone_perso " , 'alpha' );
$object -> phone_mobile = GETPOST ( " phone_mobile " , 'alpha' );
$object -> fax = GETPOST ( " fax " , 'alpha' );
2014-05-09 16:36:18 +02:00
$object -> jabberid = GETPOST ( " jabberid " , 'alpha' );
$object -> no_email = GETPOST ( " no_email " , 'int' );
$object -> priv = GETPOST ( " priv " , 'int' );
2018-04-06 19:12:13 +02:00
$object -> note_public = GETPOST ( " note_public " , 'none' );
$object -> note_private = GETPOST ( " note_private " , 'none' );
2011-06-30 15:25:32 +02:00
2013-04-01 19:43:26 +02:00
// Fill array 'array_options' with data from add form
2013-04-09 23:56:52 +02:00
$ret = $extrafields -> setOptionalsFromPost ( $extralabels , $object );
2015-02-26 14:25:30 +01:00
if ( $ret < 0 ) $error ++ ;
2012-09-17 01:39:30 +02:00
2013-10-07 22:50:12 +02:00
$result = $object -> update ( $contactid , $user );
2011-06-30 15:25:32 +02:00
2015-06-11 14:50:11 +02:00
if ( $result > 0 ) {
// Categories association
// First we delete all categories association
$sql = 'DELETE FROM ' . MAIN_DB_PREFIX . 'categorie_contact' ;
$sql .= ' WHERE fk_socpeople = ' . $object -> id ;
$db -> query ( $sql );
// Then we add the associated categories
2017-09-18 01:39:39 +02:00
$categories = GETPOST ( 'contcats' , 'array' );
2015-09-30 18:46:51 +02:00
$object -> setCategories ( $categories );
2013-03-09 20:34:38 +01:00
$object -> old_lastname = '' ;
2011-06-30 15:25:32 +02:00
$object -> old_firstname = '' ;
2012-02-28 16:48:18 +01:00
$action = 'view' ;
2011-06-30 15:25:32 +02:00
}
else
{
2015-11-18 16:05:41 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2012-02-28 16:48:18 +01:00
$action = 'edit' ;
2011-06-30 15:25:32 +02:00
}
2011-03-26 19:34:41 +01:00
}
2017-09-27 20:07:01 +02:00
if ( ! $error && empty ( $errors ))
{
if ( ! empty ( $backtopage ))
{
header ( " Location: " . $backtopage );
exit ;
}
}
2011-03-26 19:34:41 +01:00
}
2006-03-11 15:55:13 +01:00
}
2006-02-25 00:16:35 +01:00
/*
2009-11-28 08:30:45 +01:00
* View
*/
2006-02-25 00:16:35 +01:00
2012-09-17 01:39:30 +02:00
2015-10-15 14:13:31 +02:00
$title = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " Contacts " ) : $langs -> trans ( " ContactsAddresses " ));
if ( ! empty ( $conf -> global -> MAIN_HTML_TITLE ) && preg_match ( '/contactnameonly/' , $conf -> global -> MAIN_HTML_TITLE ) && $object -> lastname ) $title = $object -> lastname ;
2011-05-29 19:34:07 +02:00
$help_url = 'EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas' ;
2015-10-15 14:13:31 +02:00
llxHeader ( '' , $title , $help_url );
2006-04-01 17:01:01 +02:00
2006-02-25 00:16:35 +01:00
$form = new Form ( $db );
2008-11-16 02:54:33 +01:00
$formcompany = new FormCompany ( $db );
2006-02-25 00:16:35 +01:00
2010-06-06 16:30:28 +02:00
$countrynotdefined = $langs -> trans ( " ErrorSetACountryFirst " ) . ' (' . $langs -> trans ( " SeeAbove " ) . ')' ;
2010-09-15 14:00:05 +02:00
if ( $socid > 0 )
2006-02-25 00:16:35 +01:00
{
$objsoc = new Societe ( $db );
$objsoc -> fetch ( $socid );
}
2012-02-28 16:48:18 +01:00
if ( is_object ( $objcanvas ) && $objcanvas -> displayCanvasExists ( $action ))
2006-02-25 00:16:35 +01:00
{
2011-03-26 19:34:41 +01:00
// -----------------------------------------
// When used with CANVAS
// -----------------------------------------
2012-05-30 03:02:44 +02:00
if ( empty ( $object -> error ) && $id )
2011-09-24 22:50:57 +02:00
{
2013-04-09 23:56:52 +02:00
$object = new Contact ( $db );
$result = $object -> fetch ( $id );
if ( $result <= 0 ) dol_print_error ( '' , $object -> error );
2011-09-24 22:50:57 +02:00
}
2013-04-09 23:56:52 +02:00
$objcanvas -> assign_values ( $action , $object -> id , $object -> ref ); // Set value for templates
$objcanvas -> display_canvas ( $action ); // Show template
2006-02-25 00:16:35 +01:00
}
2010-11-03 12:39:40 +01:00
else
2006-02-25 00:16:35 +01:00
{
2011-03-26 19:34:41 +01:00
// -----------------------------------------
// When used in standard mode
// -----------------------------------------
// Confirm deleting contact
if ( $user -> rights -> societe -> contact -> supprimer )
{
2011-09-24 17:57:52 +02:00
if ( $action == 'delete' )
2011-03-26 19:34:41 +01:00
{
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $id . ( $backtopage ? '&backtopage=' . $backtopage : '' ), $langs -> trans ( " DeleteContact " ), $langs -> trans ( " ConfirmDeleteContact " ), " confirm_delete " , '' , 0 , 1 );
2011-03-26 19:34:41 +01:00
}
}
/*
* Onglets
*/
2014-12-30 21:04:02 +01:00
$head = array ();
2011-09-24 17:57:52 +02:00
if ( $id > 0 )
2011-03-26 19:34:41 +01:00
{
// Si edition contact deja existant
$object = new Contact ( $db );
2012-09-17 01:39:30 +02:00
$res = $object -> fetch ( $id , $user );
if ( $res < 0 ) { dol_print_error ( $db , $object -> error ); exit ; }
2018-02-21 14:48:25 +01:00
$res = $object -> fetch_optionals ();
if ( $res < 0 ) { dol_print_error ( $db , $object -> error ); exit ; }
2011-03-26 19:34:41 +01:00
// Show tabs
$head = contact_prepare_head ( $object );
2012-03-18 19:23:01 +01:00
2012-03-14 15:32:48 +01:00
$title = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " Contacts " ) : $langs -> trans ( " ContactsAddresses " ));
2011-03-26 19:34:41 +01:00
}
if ( $user -> rights -> societe -> contact -> creer )
{
2011-09-24 17:57:52 +02:00
if ( $action == 'create' )
2011-03-26 19:34:41 +01:00
{
/*
* Fiche en mode creation
*/
2011-09-24 22:50:57 +02:00
$object -> canvas = $canvas ;
2016-12-18 13:27:14 +01:00
$object -> state_id = GETPOST ( " state_id " );
2011-03-26 19:34:41 +01:00
2011-12-29 18:07:41 +01:00
// We set country_id, country_code and label for the selected country
2016-12-18 13:27:14 +01:00
$object -> country_id = $_POST [ " country_id " ] ? GETPOST ( " country_id " ) : ( empty ( $objsoc -> country_id ) ? $mysoc -> country_id : $objsoc -> country_id );
2011-12-29 18:07:41 +01:00
if ( $object -> country_id )
2011-03-26 19:34:41 +01:00
{
2011-12-29 18:07:41 +01:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
2011-03-26 19:34:41 +01:00
}
2012-03-18 19:23:01 +01:00
2012-03-14 15:04:55 +01:00
$title = $addcontact = ( ! empty ( $conf -> global -> SOCIETE_ADDRESSES_MANAGEMENT ) ? $langs -> trans ( " AddContact " ) : $langs -> trans ( " AddContactAddress " ));
2015-04-18 20:33:18 +02:00
$linkback = '' ;
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( $title , $linkback , 'title_companies.png' );
2011-03-26 19:34:41 +01:00
// Affiche les erreurs
2012-05-12 12:32:24 +02:00
dol_htmloutput_errors ( is_numeric ( $error ) ? '' : $error , $errors );
2011-03-26 19:34:41 +01:00
if ( $conf -> use_javascript_ajax )
{
2012-09-28 14:56:47 +02:00
print " \n " . '<script type="text/javascript" language="javascript">' . " \n " ;
print ' jQuery ( document ) . ready ( function () {
2011-12-29 18:07:41 +01:00
jQuery ( " #selectcountry_id " ) . change ( function () {
2010-11-03 12:39:40 +01:00
document . formsoc . action . value = " create " ;
document . formsoc . submit ();
2012-09-28 14:56:47 +02:00
});
2012-10-06 19:25:25 +02:00
2012-09-28 14:27:16 +02:00
$ ( " #copyaddressfromsoc " ) . click ( function () {
2013-02-12 10:33:10 +01:00
$ ( \ 'textarea[name="address"]\').val("' . dol_escape_js ( $objsoc -> address ) . ' " );
2012-12-11 10:59:03 +01:00
$ ( \ 'input[name="zipcode"]\').val("' . dol_escape_js ( $objsoc -> zip ) . ' " );
$ ( \ 'input[name="town"]\').val("' . dol_escape_js ( $objsoc -> town ) . ' " );
2016-02-03 02:06:12 +01:00
console . log ( " Set state_id to '.dol_escape_js( $objsoc->state_id ).' " );
$ ( \ 'select[name="state_id"]\').val("' . dol_escape_js ( $objsoc -> state_id ) . ' " ).trigger( " change " );
/* set country at end because it will trigger page refresh */
console . log ( " Set country id to '.dol_escape_js( $objsoc->country_id ).' " );
$ ( \ 'select[name="country_id"]\').val("' . dol_escape_js ( $objsoc -> country_id ) . ' " ).trigger( " change " ); /* trigger required to update select2 components */
});
2012-09-28 14:27:16 +02:00
}) ' . " \n " ;
2012-09-28 14:56:47 +02:00
print '</script>' . " \n " ;
2011-03-26 19:34:41 +01:00
}
2010-11-19 22:24:48 +01:00
2011-03-26 19:34:41 +01:00
print '<form method="post" name="formsoc" action="' . $_SERVER [ " PHP_SELF " ] . '">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="add">' ;
2012-02-27 17:02:56 +01:00
print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2018-01-10 12:38:12 +01:00
if ( ! empty ( $objsoc )) {
print '<input type="hidden" name="entity" value="' . $objsoc -> entity . '">' ;
}
2014-12-30 21:04:02 +01:00
dol_fiche_head ( $head , 'card' , '' , 0 , '' );
2011-03-26 19:34:41 +01:00
print '<table class="border" width="100%">' ;
2010-11-19 22:24:48 +01:00
2011-03-26 19:34:41 +01:00
// Name
2016-08-10 15:01:43 +02:00
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">' . $langs -> trans ( " Lastname " ) . ' / ' . $langs -> trans ( " Label " ) . '</label></td>' ;
2018-04-06 19:12:13 +02:00
print '<td><input name="lastname" id="lastname" type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " lastname " , 'alpha' ) ? GETPOST ( " lastname " , 'alpha' ) : $object -> lastname ) . '" autofocus="autofocus"></td>' ;
2016-08-10 15:01:43 +02:00
print '<td><label for="firstname">' . $langs -> trans ( " Firstname " ) . '</label></td>' ;
2018-04-06 19:12:13 +02:00
print '<td><input name="firstname" id="firstname"type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " firstname " , 'alpha' ) ? GETPOST ( " firstname " , 'alpha' ) : $object -> firstname ) . '"></td></tr>' ;
2010-11-19 22:24:48 +01:00
2011-03-26 19:34:41 +01:00
// Company
2011-02-13 13:55:40 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ))
{
2011-03-26 19:34:41 +01:00
if ( $socid > 0 )
{
2014-12-07 18:24:45 +01:00
print '<tr><td><label for="socid">' . $langs -> trans ( " ThirdParty " ) . '</label></td>' ;
2013-12-02 20:30:15 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2017-09-27 19:56:03 +02:00
print $objsoc -> getNomUrl ( 1 , 'contact' );
2011-03-26 19:34:41 +01:00
print '</td>' ;
2014-07-12 12:04:39 +02:00
print '<input type="hidden" name="socid" id="socid" value="' . $objsoc -> id . '">' ;
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
}
else {
2014-12-07 18:24:45 +01:00
print '<tr><td><label for="socid">' . $langs -> trans ( " ThirdParty " ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
2016-07-30 14:49:29 +02:00
print $form -> select_company ( $socid , 'socid' , '' , 'SelectThirdParty' );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
}
}
// Civility
2016-08-10 15:01:43 +02:00
print '<tr><td><label for="civility_id">' . $langs -> trans ( " UserTitle " ) . '</label></td><td colspan="3">' ;
2014-05-09 16:36:18 +02:00
print $formcompany -> select_civility ( GETPOST ( " civility_id " , 'alpha' ) ? GETPOST ( " civility_id " , 'alpha' ) : $object -> civility_id );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="title">' . $langs -> trans ( " PostOrFunction " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " poste " , 'alpha' ) ? GETPOST ( " poste " , 'alpha' ) : $object -> poste ) . '"></td>' ;
2011-03-26 19:34:41 +01:00
2012-10-25 16:23:58 +02:00
$colspan = 3 ;
if ( $conf -> use_javascript_ajax && $socid > 0 ) $colspan = 2 ;
2012-12-01 15:45:05 +01:00
2011-03-26 19:34:41 +01:00
// Address
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> address )) == 0 ) $object -> address = $objsoc -> address ; // Predefined with third party
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="address">' . $langs -> trans ( " Address " ) . '</label></td>' ;
2017-01-22 12:43:25 +01:00
print '<td colspan="' . $colspan . '"><textarea class="flat quatrevingtpercent" name="address" id="address" rows="' . ROWS_2 . '">' . ( GETPOST ( " address " , 'alpha' ) ? GETPOST ( " address " , 'alpha' ) : $object -> address ) . '</textarea></td>' ;
2012-10-06 19:25:25 +02:00
2012-10-25 16:23:58 +02:00
if ( $conf -> use_javascript_ajax && $socid > 0 )
{
2012-12-01 15:45:05 +01:00
$rowspan = 3 ;
2012-10-25 16:23:58 +02:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE )) $rowspan ++ ;
2012-12-01 15:45:05 +01:00
2012-10-25 16:23:58 +02:00
print '<td valign="middle" align="center" rowspan="' . $rowspan . '">' ;
print '<a href="#" id="copyaddressfromsoc">' . $langs -> trans ( 'CopyAddressFromSoc' ) . '</a>' ;
print '</td>' ;
}
2012-10-06 19:25:25 +02:00
print '</tr>' ;
2011-03-26 19:34:41 +01:00
// Zip / Town
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> zip )) == 0 ) $object -> zip = $objsoc -> zip ; // Predefined with third party
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> town )) == 0 ) $object -> town = $objsoc -> town ; // Predefined with third party
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="zipcode">' . $langs -> trans ( " Zip " ) . '</label> / <label for="town">' . $langs -> trans ( " Town " ) . '</label></td><td colspan="' . $colspan . '" class="maxwidthonsmartphone">' ;
2018-04-06 19:12:13 +02:00
print $formcompany -> select_ziptown (( GETPOST ( " zipcode " , 'alpha' ) ? GETPOST ( " zipcode " , 'alpha' ) : $object -> zip ), 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 ) . ' ' ;
print $formcompany -> select_ziptown (( GETPOST ( " town " , 'alpha' ) ? GETPOST ( " town " , 'alpha' ) : $object -> town ), 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
// Country
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="selectcountry_id">' . $langs -> trans ( " Country " ) . '</label></td><td colspan="' . $colspan . '" class="maxwidthonsmartphone">' ;
2014-05-09 16:36:18 +02:00
print $form -> select_country (( GETPOST ( " country_id " , 'alpha' ) ? GETPOST ( " country_id " , 'alpha' ) : $object -> country_id ), 'country_id' );
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
// State
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE ))
{
2018-01-25 17:14:39 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 ))
2018-01-25 17:10:04 +01:00
{
print '<tr><td><label for="state_id">' . $langs -> trans ( 'Region-State' ) . '</label></td><td colspan="' . $colspan . '" class="maxwidthonsmartphone">' ;
}
else
{
print '<tr><td><label for="state_id">' . $langs -> trans ( 'State' ) . '</label></td><td colspan="' . $colspan . '" class="maxwidthonsmartphone">' ;
}
2011-12-29 18:07:41 +01:00
if ( $object -> country_id )
2011-03-26 19:34:41 +01:00
{
2014-05-09 16:36:18 +02:00
print $formcompany -> select_state ( GETPOST ( " state_id " , 'alpha' ) ? GETPOST ( " state_id " , 'alpha' ) : $object -> state_id , $object -> country_code , 'state_id' );
2011-03-26 19:34:41 +01:00
}
else
2012-10-06 19:25:25 +02:00
{
2011-03-26 19:34:41 +01:00
print $countrynotdefined ;
}
print '</td></tr>' ;
}
// Phone / Fax
2013-09-25 19:58:22 +02:00
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> phone_pro )) == 0 ) $object -> phone_pro = $objsoc -> phone ; // Predefined with third party
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="phone_pro">' . $langs -> trans ( " PhonePro " ) . '</label></td>' ;
2017-01-22 12:43:25 +01:00
print '<td><input name="phone_pro" id="phone_pro" type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " phone_pro " ) ? GETPOST ( " phone_pro " ) : $object -> phone_pro ) . '"></td>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="phone_perso">' . $langs -> trans ( " PhonePerso " ) . '</label></td>' ;
2017-01-22 12:43:25 +01:00
print '<td><input name="phone_perso" id="phone_perso" type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " phone_perso " ) ? GETPOST ( " phone_perso " ) : $object -> phone_perso ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> fax )) == 0 ) $object -> fax = $objsoc -> fax ; // Predefined with third party
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="phone_mobile">' . $langs -> trans ( " PhoneMobile " ) . '</label></td>' ;
2017-01-22 12:43:25 +01:00
print '<td><input name="phone_mobile" id="phone_mobile" type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " phone_mobile " ) ? GETPOST ( " phone_mobile " ) : $object -> phone_mobile ) . '"></td>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="fax">' . $langs -> trans ( " Fax " ) . '</label></td>' ;
2017-01-22 12:43:25 +01:00
print '<td><input name="fax" id="fax" type="text" class="maxwidth100onsmartphone" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " fax " , 'alpha' ) ? GETPOST ( " fax " , 'alpha' ) : $object -> fax ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
// EMail
if (( $objsoc -> typent_code == 'TE_PRIVATE' || ! empty ( $conf -> global -> CONTACT_USE_COMPANY_ADDRESS )) && dol_strlen ( trim ( $object -> email )) == 0 ) $object -> email = $objsoc -> email ; // Predefined with third party
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="email">' . $langs -> trans ( " Email " ) . '</label></td>' ;
2018-04-06 19:12:13 +02:00
print '<td><input name="email" id="email" type="text" class="maxwidth100onsmartphone" value="' . dol_escape_htmltag ( GETPOST ( " email " , 'alpha' ) ? GETPOST ( " email " , 'alpha' ) : $object -> email ) . '"></td>' ;
2012-08-26 20:28:19 +02:00
if ( ! empty ( $conf -> mailing -> enabled ))
{
2014-07-12 12:04:39 +02:00
print '<td><label for="no_email">' . $langs -> trans ( " No_Email " ) . '</label></td>' ;
2016-03-25 15:53:44 +01:00
print '<td>' . $form -> selectyesno ( 'no_email' ,( GETPOST ( " no_email " , 'alpha' ) ? GETPOST ( " no_email " , 'alpha' ) : $object -> no_email ), 1 ) . '</td>' ;
2012-08-26 20:28:19 +02:00
}
else
2013-11-04 21:41:36 +01:00
{
2012-09-07 17:23:16 +02:00
print '<td colspan="2"> </td>' ;
2012-08-26 20:28:19 +02:00
}
2012-09-07 17:23:16 +02:00
print '</tr>' ;
2011-03-26 19:34:41 +01:00
2012-08-22 22:59:10 +02:00
// Instant message and no email
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="jabberid">' . $langs -> trans ( " IM " ) . '</label></td>' ;
2018-04-06 19:12:13 +02:00
print '<td colspan="3"><input name="jabberid" id="jabberid" type="text" class="minwidth100" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " jabberid " , 'alpha' ) ? GETPOST ( " jabberid " , 'alpha' ) : $object -> jabberid ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
2013-12-02 20:30:15 +01:00
{
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="skype">' . $langs -> trans ( " Skype " ) . '</label></td>' ;
2018-04-06 19:12:13 +02:00
print '<td colspan="3"><input name="skype" id="skype" type="text" class="minwidth100" maxlength="80" value="' . dol_escape_htmltag ( GETPOST ( " skype " , 'alpha' ) ? GETPOST ( " skype " , 'alpha' ) : $object -> skype ) . '"></td></tr>' ;
2013-11-04 21:41:36 +01:00
}
2013-12-02 20:30:15 +01:00
2011-03-26 19:34:41 +01:00
// Visibility
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="priv">' . $langs -> trans ( " ContactVisibility " ) . '</label></td><td colspan="3">' ;
2011-03-26 19:34:41 +01:00
$selectarray = array ( '0' => $langs -> trans ( " ContactPublic " ), '1' => $langs -> trans ( " ContactPrivate " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'priv' , $selectarray ,( GETPOST ( " priv " , 'alpha' ) ? GETPOST ( " priv " , 'alpha' ) : $object -> priv ), 0 );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
2015-06-11 14:50:11 +02:00
// Categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
print '<tr><td>' . fieldLabel ( 'Categories' , 'contcats' ) . '</td><td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CONTACT , null , 'parent' , null , null , 1 );
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'contcats' , $cate_arbo , GETPOST ( 'contcats' , 'array' ), null , null , null ,
2015-06-11 14:50:11 +02:00
null , '90%' );
print " </td></tr> " ;
}
2012-09-19 17:53:09 +02:00
// Other attributes
2018-01-10 12:38:12 +01:00
$parameters = array ( 'socid' => $socid , 'objsoc' => $objsoc , 'colspan' => ' colspan="3"' , 'cols' => 3 );
2012-09-19 17:53:09 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2012-09-19 17:53:09 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
2012-09-19 17:53:09 +02:00
}
2010-11-19 22:24:48 +01:00
print " </table><br> " ;
2017-03-24 17:32:38 +01:00
print '<hr style="margin-bottom: 20px">' ;
2017-06-07 16:44:04 +02:00
2010-11-19 22:24:48 +01:00
// Add personnal information
2015-09-24 18:33:48 +02:00
print load_fiche_titre ( '<div class="comboperso">' . $langs -> trans ( " PersonalInformations " ) . '</div>' , '' , '' );
2010-11-19 22:24:48 +01:00
print '<table class="border" width="100%">' ;
// Date To Birth
2014-07-12 12:04:39 +02:00
print '<tr><td width="20%"><label for="birthday">' . $langs -> trans ( " DateToBirth " ) . '</label></td><td width="30%">' ;
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-11-19 22:24:48 +01:00
if ( $object -> birthday )
{
2016-03-25 15:53:44 +01:00
print $form -> select_date ( $object -> birthday , 'birthday' , 0 , 0 , 0 , " perso " , 1 , 0 , 1 );
2010-11-19 22:24:48 +01:00
}
else
{
2016-03-25 15:53:44 +01:00
print $form -> select_date ( '' , 'birthday' , 0 , 0 , 1 , " perso " , 1 , 0 , 1 );
2010-11-19 22:24:48 +01:00
}
print '</td>' ;
2014-07-12 12:04:39 +02:00
print '<td colspan="2"><label for="birthday_alert">' . $langs -> trans ( " Alert " ) . '</label>: ' ;
2010-11-19 22:24:48 +01:00
if ( $object -> birthday_alert )
{
2015-09-06 07:56:43 +02:00
print '<input type="checkbox" name="birthday_alert" id="birthday_alert" checked></td>' ;
2010-11-19 22:24:48 +01:00
}
else
{
2014-07-12 12:04:39 +02:00
print '<input type="checkbox" name="birthday_alert" id="birthday_alert"></td>' ;
2010-11-19 22:24:48 +01:00
}
print '</tr>' ;
2014-12-30 21:04:02 +01:00
print " </table> " ;
2010-11-19 22:24:48 +01:00
2014-12-30 21:04:02 +01:00
print dol_fiche_end ();
2010-11-19 22:24:48 +01:00
2014-11-25 20:13:43 +01:00
print '<div class="center">' ;
2011-03-20 23:22:26 +01:00
print '<input type="submit" class="button" name="add" value="' . $langs -> trans ( " Add " ) . '">' ;
2012-02-27 17:02:56 +01:00
if ( ! empty ( $backtopage ))
2011-03-20 23:22:26 +01:00
{
2011-03-26 19:34:41 +01:00
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2011-03-20 23:22:26 +01:00
}
2017-02-01 13:25:16 +01:00
else
{
print ' ' ;
print '<input type="button" class="button" value="' . $langs -> trans ( " Cancel " ) . '" onClick="javascript:history.go(-1)">' ;
}
2014-11-25 20:13:43 +01:00
print '</div>' ;
2010-11-19 22:24:48 +01:00
2011-03-26 19:34:41 +01:00
print " </form> " ;
}
2011-09-24 17:57:52 +02:00
elseif ( $action == 'edit' && ! empty ( $id ))
2011-03-26 19:34:41 +01:00
{
/*
* Fiche en mode edition
*/
2011-12-29 18:07:41 +01:00
// We set country_id, and country_code label of the chosen country
if ( isset ( $_POST [ " country_id " ]) || $object -> country_id )
2011-03-26 19:34:41 +01:00
{
2011-12-29 18:07:41 +01:00
$tmparray = getCountry ( $object -> country_id , 'all' );
$object -> country_code = $tmparray [ 'code' ];
$object -> country = $tmparray [ 'label' ];
2011-03-26 19:34:41 +01:00
}
2012-10-06 19:25:25 +02:00
2012-09-28 14:56:47 +02:00
$objsoc = new Societe ( $db );
$objsoc -> fetch ( $object -> socid );
2011-03-26 19:34:41 +01:00
// Affiche les erreurs
2011-06-01 18:23:33 +02:00
dol_htmloutput_errors ( $error , $errors );
2011-03-26 19:34:41 +01:00
if ( $conf -> use_javascript_ajax )
{
2012-09-28 14:56:47 +02:00
print " \n " . '<script type="text/javascript" language="javascript">' . " \n " ;
print ' jQuery ( document ) . ready ( function () {
2011-12-29 18:07:41 +01:00
jQuery ( " #selectcountry_id " ) . change ( function () {
2012-09-28 14:58:47 +02:00
document . formsoc . action . value = " edit " ;
2010-11-03 12:39:40 +01:00
document . formsoc . submit ();
});
2012-10-06 19:25:25 +02:00
2012-09-28 14:56:47 +02:00
$ ( " #copyaddressfromsoc " ) . click ( function () {
2016-02-03 02:06:12 +01:00
$ ( \ 'textarea[name="address"]\').val("' . dol_escape_js ( $objsoc -> address ) . ' " );
2013-03-01 18:41:41 +01:00
$ ( \ 'input[name="zipcode"]\').val("' . dol_escape_js ( $objsoc -> zip ) . ' " );
$ ( \ 'input[name="town"]\').val("' . dol_escape_js ( $objsoc -> town ) . ' " );
2016-02-03 02:06:12 +01:00
console . log ( " Set state_id to '.dol_escape_js( $objsoc->state_id ).' " );
$ ( \ 'select[name="state_id"]\').val("' . dol_escape_js ( $objsoc -> state_id ) . ' " ).trigger( " change " );
/* set country at end because it will trigger page refresh */
console . log ( " Set country id to '.dol_escape_js( $objsoc->country_id ).' " );
$ ( \ 'select[name="country_id"]\').val("' . dol_escape_js ( $objsoc -> country_id ) . ' " ).trigger( " change " ); /* trigger required to update select2 components */
2012-10-06 19:25:25 +02:00
});
2012-09-28 14:56:47 +02:00
}) ' . " \n " ;
print '</script>' . " \n " ;
2011-03-26 19:34:41 +01:00
}
2015-10-04 17:25:46 +02:00
print '<form enctype="multipart/form-data" method="post" action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '" name="formsoc">' ;
2011-03-26 19:34:41 +01:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2012-02-27 17:02:56 +01:00
print '<input type="hidden" name="id" value="' . $id . '">' ;
2011-03-26 19:34:41 +01:00
print '<input type="hidden" name="action" value="update">' ;
print '<input type="hidden" name="contactid" value="' . $object -> id . '">' ;
2013-03-09 20:34:38 +01:00
print '<input type="hidden" name="old_lastname" value="' . $object -> lastname . '">' ;
2011-03-26 19:34:41 +01:00
print '<input type="hidden" name="old_firstname" value="' . $object -> firstname . '">' ;
2012-07-08 23:22:22 +02:00
if ( ! empty ( $backtopage )) print '<input type="hidden" name="backtopage" value="' . $backtopage . '">' ;
2014-12-30 21:04:02 +01:00
dol_fiche_head ( $head , 'card' , $title , 0 , 'contact' );
2011-03-26 19:34:41 +01:00
print '<table class="border" width="100%">' ;
2015-10-11 12:27:04 +02:00
// Ref/ID
if ( ! empty ( $conf -> global -> MAIN_SHOW_TECHNICAL_ID ))
{
print '<tr><td>' . $langs -> trans ( " ID " ) . '</td><td colspan="3">' ;
print $object -> ref ;
print '</td></tr>' ;
}
2017-06-07 16:44:04 +02:00
2013-02-23 16:08:35 +01:00
// Lastname
2016-08-10 15:01:43 +02:00
print '<tr><td class="titlefieldcreate fieldrequired"><label for="lastname">' . $langs -> trans ( " Lastname " ) . ' / ' . $langs -> trans ( " Label " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td colspan="3"><input name="lastname" id="lastname" type="text" class="minwidth200" maxlength="80" value="' . ( isset ( $_POST [ " lastname " ]) ? GETPOST ( " lastname " ) : $object -> lastname ) . '" autofocus="autofocus"></td>' ;
print '</tr>' ;
print '<tr>' ;
// Firstname
2016-08-10 15:01:43 +02:00
print '<td><label for="firstname">' . $langs -> trans ( " Firstname " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td colspan="3"><input name="firstname" id="firstname" type="text" class="minwidth200" maxlength="80" value="' . ( isset ( $_POST [ " firstname " ]) ? GETPOST ( " firstname " ) : $object -> firstname ) . '"></td>' ;
print '</tr>' ;
2011-03-26 19:34:41 +01:00
// Company
2011-02-13 13:55:40 +01:00
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ))
{
2014-12-07 18:24:45 +01:00
print '<tr><td><label for="socid">' . $langs -> trans ( " ThirdParty " ) . '</label></td>' ;
2013-12-02 20:30:15 +01:00
print '<td colspan="3" class="maxwidthonsmartphone">' ;
2016-03-30 00:06:55 +02:00
print $form -> select_company ( GETPOST ( 'socid' , 'int' ) ? GETPOST ( 'socid' , 'int' ) : ( $object -> socid ? $object -> socid :- 1 ), 'socid' , '' , $langs -> trans ( " SelectThirdParty " ));
2011-03-26 19:34:41 +01:00
print '</td>' ;
print '</tr>' ;
}
// Civility
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="civility_id">' . $langs -> trans ( " UserTitle " ) . '</label></td><td colspan="3">' ;
2016-12-18 13:27:14 +01:00
print $formcompany -> select_civility ( isset ( $_POST [ " civility_id " ]) ? GETPOST ( " civility_id " ) : $object -> civility_id );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="title">' . $langs -> trans ( " PostOrFunction " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td colspan="3"><input name="poste" id="title" type="text" class="minwidth100" maxlength="80" value="' . ( isset ( $_POST [ " poste " ]) ? GETPOST ( " poste " ) : $object -> poste ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
// Address
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="address">' . $langs -> trans ( " Address " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td colspan="3">' ;
print '<div class="paddingrightonly valignmiddle inline-block">' ;
print '<textarea class="flat minwidth200" name="address" id="address">' . ( isset ( $_POST [ " address " ]) ? GETPOST ( " address " ) : $object -> address ) . '</textarea>' ;
print '</div><div class="paddingrightonly valignmiddle inline-block">' ;
if ( $conf -> use_javascript_ajax ) print '<a href="#" id="copyaddressfromsoc">' . $langs -> trans ( 'CopyAddressFromSoc' ) . '</a><br>' ;
print '</div>' ;
print '</td>' ;
2011-03-26 19:34:41 +01:00
// Zip / Town
2016-12-18 13:27:14 +01:00
print '<tr><td><label for="zipcode">' . $langs -> trans ( " Zip " ) . '</label> / <label for="town">' . $langs -> trans ( " Town " ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
print $formcompany -> select_ziptown (( isset ( $_POST [ " zipcode " ]) ? GETPOST ( " zipcode " ) : $object -> zip ), 'zipcode' , array ( 'town' , 'selectcountry_id' , 'state_id' ), 6 ) . ' ' ;
print $formcompany -> select_ziptown (( isset ( $_POST [ " town " ]) ? GETPOST ( " town " ) : $object -> town ), 'town' , array ( 'zipcode' , 'selectcountry_id' , 'state_id' ));
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
// Country
2016-12-18 13:27:14 +01:00
print '<tr><td><label for="selectcountry_id">' . $langs -> trans ( " Country " ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
print $form -> select_country ( isset ( $_POST [ " country_id " ]) ? GETPOST ( " country_id " ) : $object -> country_id , 'country_id' );
2014-02-05 17:53:30 +01:00
if ( $user -> admin ) print info_admin ( $langs -> trans ( " YouCanChangeValuesForThisListFromDictionarySetup " ), 1 );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
// State
if ( empty ( $conf -> global -> SOCIETE_DISABLE_STATE ))
{
2018-01-25 17:14:39 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT ) && ( $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf -> global -> MAIN_SHOW_REGION_IN_STATE_SELECT == 2 ))
2018-01-25 17:10:04 +01:00
{
print '<tr><td><label for="state_id">' . $langs -> trans ( 'Region-State' ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
}
else
{
print '<tr><td><label for="state_id">' . $langs -> trans ( 'State' ) . '</label></td><td colspan="3" class="maxwidthonsmartphone">' ;
}
2016-12-18 13:27:14 +01:00
print $formcompany -> select_state ( $object -> state_id , isset ( $_POST [ " country_id " ]) ? GETPOST ( " country_id " ) : $object -> country_id , 'state_id' );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
}
// Phone
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="phone_pro">' . $langs -> trans ( " PhonePro " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="phone_pro" id="phone_pro" type="text" class="flat maxwidthonsmartphone" maxlength="80" value="' . ( isset ( $_POST [ " phone_pro " ]) ? GETPOST ( " phone_pro " ) : $object -> phone_pro ) . '"></td>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="phone_perso">' . $langs -> trans ( " PhonePerso " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="phone_perso" id="phone_perso" type="text" class="flat maxwidthonsmartphone" maxlength="80" value="' . ( isset ( $_POST [ " phone_perso " ]) ? GETPOST ( " phone_perso " ) : $object -> phone_perso ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="phone_mobile">' . $langs -> trans ( " PhoneMobile " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="phone_mobile" id="phone_mobile" class="flat maxwidthonsmartphone" type="text" maxlength="80" value="' . ( isset ( $_POST [ " phone_mobile " ]) ? GETPOST ( " phone_mobile " ) : $object -> phone_mobile ) . '"></td>' ;
2014-07-12 12:04:39 +02:00
print '<td><label for="fax">' . $langs -> trans ( " Fax " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="fax" id="fax" type="text" class="flat maxwidthonsmartphone" maxlength="80" value="' . ( isset ( $_POST [ " fax " ]) ? GETPOST ( " fax " ) : $object -> fax ) . '"></td></tr>' ;
2011-03-26 19:34:41 +01:00
// EMail
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="email">' . $langs -> trans ( " EMail " ) . '</label></td>' ;
2017-07-10 15:41:26 +02:00
print '<td><input name="email" id="email" type="text" class="flat maxwidthonsmartphone" value="' . ( isset ( $_POST [ " email " ]) ? GETPOST ( " email " ) : $object -> email ) . '"></td>' ;
2012-08-26 20:28:19 +02:00
if ( ! empty ( $conf -> mailing -> enabled ))
2011-03-26 19:34:41 +01:00
{
$langs -> load ( " mails " );
2014-04-29 09:43:16 +02:00
print '<td class="nowrap">' . $langs -> trans ( " NbOfEMailingsSend " ) . '</td>' ;
2011-03-26 19:34:41 +01:00
print '<td>' . $object -> getNbOfEMailings () . '</td>' ;
}
else
2012-08-26 20:28:19 +02:00
{
print '<td colspan="2"> </td>' ;
2011-03-26 19:34:41 +01:00
}
print '</tr>' ;
// Jabberid
2015-07-08 12:33:37 +02:00
print '<tr><td><label for="jabberid">' . $langs -> trans ( " IM " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="jabberid" id="jabberid" type="text" class="minwidth100" maxlength="80" value="' . ( isset ( $_POST [ " jabberid " ]) ? $_POST [ " jabberid " ] : $object -> jabberid ) . '"></td>' ;
2012-08-26 20:28:19 +02:00
if ( ! empty ( $conf -> mailing -> enabled ))
{
2014-07-12 12:04:39 +02:00
print '<td><label for="no_email">' . $langs -> trans ( " No_Email " ) . '</label></td>' ;
2016-03-25 15:53:44 +01:00
print '<td>' . $form -> selectyesno ( 'no_email' ,( isset ( $_POST [ " no_email " ]) ? $_POST [ " no_email " ] : $object -> no_email ), 1 ) . '</td>' ;
2012-08-26 20:28:19 +02:00
}
else
{
print '<td colspan="2"> </td>' ;
}
2012-09-07 17:23:16 +02:00
print '</tr>' ;
2013-12-02 20:30:15 +01:00
2013-11-04 21:41:36 +01:00
// Skype
if ( ! empty ( $conf -> skype -> enabled ))
{
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="skype">' . $langs -> trans ( " Skype " ) . '</label></td>' ;
2016-12-18 13:27:14 +01:00
print '<td><input name="skype" id="skype" type="text" class="minwidth100" maxlength="80" value="' . ( isset ( $_POST [ " skype " ]) ? GETPOST ( " skype " ) : $object -> skype ) . '"></td></tr>' ;
2013-11-04 21:41:36 +01:00
}
2013-12-02 20:30:15 +01:00
2011-03-26 19:34:41 +01:00
// Visibility
2014-07-12 12:04:39 +02:00
print '<tr><td><label for="priv">' . $langs -> trans ( " ContactVisibility " ) . '</label></td><td colspan="3">' ;
2011-03-26 19:34:41 +01:00
$selectarray = array ( '0' => $langs -> trans ( " ContactPublic " ), '1' => $langs -> trans ( " ContactPrivate " ));
2016-03-25 15:34:37 +01:00
print $form -> selectarray ( 'priv' , $selectarray , $object -> priv , 0 );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
2016-08-10 15:01:43 +02:00
// Note Public
2015-05-15 02:34:57 +02:00
print '<tr><td class="tdtop"><label for="note_public">' . $langs -> trans ( " NotePublic " ) . '</label></td><td colspan="3">' ;
2016-11-25 17:47:47 +01:00
$doleditor = new DolEditor ( 'note_public' , $object -> note_public , '' , 80 , 'dolibarr_notes' , 'In' , 0 , false , true , ROWS_3 , '90%' );
2014-01-27 10:36:59 +01:00
print $doleditor -> Create ( 1 );
print '</td></tr>' ;
2014-04-28 04:27:49 +02:00
2014-01-27 10:36:59 +01:00
// Note Private
2015-05-15 02:34:57 +02:00
print '<tr><td class="tdtop"><label for="note_private">' . $langs -> trans ( " NotePrivate " ) . '</label></td><td colspan="3">' ;
2016-11-25 17:47:47 +01:00
$doleditor = new DolEditor ( 'note_private' , $object -> note_private , '' , 80 , 'dolibarr_notes' , 'In' , 0 , false , true , ROWS_3 , '90%' );
2014-01-27 10:36:59 +01:00
print $doleditor -> Create ( 1 );
print '</td></tr>' ;
2013-09-25 19:58:22 +02:00
2016-08-10 15:01:43 +02:00
// Status
2015-05-15 02:34:57 +02:00
print '<tr><td>' . $langs -> trans ( " Status " ) . '</td>' ;
2016-07-15 14:22:49 +02:00
print '<td colspan="3">' ;
2015-05-22 12:21:36 +02:00
print $object -> getLibStatut ( 4 );
2013-07-10 12:28:28 +02:00
print '</td></tr>' ;
2015-06-11 14:50:11 +02:00
// Categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
print '<tr><td>' . fieldLabel ( 'Categories' , 'contcats' ) . '</td>' ;
print '<td colspan="3">' ;
$cate_arbo = $form -> select_all_categories ( Categorie :: TYPE_CONTACT , null , null , null , null , 1 );
$c = new Categorie ( $db );
2016-02-15 09:23:36 +01:00
$cats = $c -> containing ( $object -> id , 'contact' );
2015-06-11 14:50:11 +02:00
foreach ( $cats as $cat ) {
$arrayselected [] = $cat -> id ;
}
2016-03-25 15:34:43 +01:00
print $form -> multiselectarray ( 'contcats' , $cate_arbo , $arrayselected , '' , 0 , '' , 0 , '90%' );
2015-06-11 14:50:11 +02:00
print " </td></tr> " ;
}
2012-09-19 17:53:09 +02:00
// Other attributes
2017-06-07 16:44:04 +02:00
$parameters = array ( 'colspan' => ' colspan="3"' , 'cols' => 3 );
2012-09-19 17:53:09 +02:00
$reshook = $hookmanager -> executeHooks ( 'formObjectOptions' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
2017-06-11 10:37:58 +02:00
print $hookmanager -> resPrint ;
2018-04-13 13:28:48 +02:00
if ( empty ( $reshook ))
2012-09-19 17:53:09 +02:00
{
2013-04-01 19:43:26 +02:00
print $object -> showOptionals ( $extrafields , 'edit' );
2012-09-19 17:53:09 +02:00
}
2011-03-26 19:34:41 +01:00
$object -> load_ref_elements ();
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> commande -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForOrders " ) . '</td><td colspan="3">' ;
print $object -> ref_commande ? $object -> ref_commande : $langs -> trans ( " NoContactForAnyOrder " );
print '</td></tr>' ;
}
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> propal -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForProposals " ) . '</td><td colspan="3">' ;
print $object -> ref_propal ? $object -> ref_propal : $langs -> trans ( " NoContactForAnyProposal " );
print '</td></tr>' ;
}
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> contrat -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForContracts " ) . '</td><td colspan="3">' ;
print $object -> ref_contrat ? $object -> ref_contrat : $langs -> trans ( " NoContactForAnyContract " );
print '</td></tr>' ;
}
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> facture -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForInvoices " ) . '</td><td colspan="3">' ;
print $object -> ref_facturation ? $object -> ref_facturation : $langs -> trans ( " NoContactForAnyInvoice " );
print '</td></tr>' ;
}
// Login Dolibarr
print '<tr><td>' . $langs -> trans ( " DolibarrLogin " ) . '</td><td colspan="3">' ;
if ( $object -> user_id )
{
$dolibarr_user = new User ( $db );
$result = $dolibarr_user -> fetch ( $object -> user_id );
print $dolibarr_user -> getLoginUrl ( 1 );
}
else print $langs -> trans ( " NoDolibarrAccess " );
print '</td></tr>' ;
2010-11-19 22:24:48 +01:00
2015-10-04 17:25:46 +02:00
// Photo
2016-04-19 19:15:31 +02:00
print '<tr>' ;
print '<td>' . $langs -> trans ( " PhotoFile " ) . '</td>' ;
2015-10-04 17:25:46 +02:00
print '<td colspan="3">' ;
if ( $object -> photo ) {
2016-03-25 15:24:57 +01:00
print $form -> showphoto ( 'contact' , $object );
2015-10-04 17:25:46 +02:00
print " <br> \n " ;
}
print '<table class="nobordernopadding">' ;
2015-12-21 17:32:20 +01:00
if ( $object -> photo ) print '<tr><td><input type="checkbox" class="flat photodelete" name="deletephoto" id="photodelete"> ' . $langs -> trans ( " Delete " ) . '<br><br></td></tr>' ;
2015-10-04 17:25:46 +02:00
//print '<tr><td>'.$langs->trans("PhotoFile").'</td></tr>';
print '<tr><td><input type="file" class="flat" name="photo" id="photoinput"></td></tr>' ;
print '</table>' ;
print '</td>' ;
print '</tr>' ;
2014-12-30 21:04:02 +01:00
print '</table>' ;
print dol_fiche_end ();
2010-11-19 22:24:48 +01:00
2014-11-25 20:13:43 +01:00
print '<div class="center">' ;
2011-03-26 19:34:41 +01:00
print '<input type="submit" class="button" name="save" value="' . $langs -> trans ( " Save " ) . '">' ;
2017-02-01 13:25:16 +01:00
print ' ' ;
2011-03-26 19:34:41 +01:00
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2014-11-25 20:13:43 +01:00
print '</div>' ;
2011-03-26 19:34:41 +01:00
print " </form> " ;
}
}
2012-05-12 12:32:24 +02:00
if ( ! empty ( $id ) && $action != 'edit' && $action != 'create' )
2011-03-26 19:34:41 +01:00
{
$objsoc = new Societe ( $db );
/*
* Fiche en mode visualisation
*/
2011-06-01 18:23:33 +02:00
dol_htmloutput_errors ( $error , $errors );
2011-03-26 19:34:41 +01:00
2017-05-23 01:32:19 +02:00
dol_fiche_head ( $head , 'card' , $title , - 1 , 'contact' );
2014-12-30 21:04:02 +01:00
2011-09-24 17:57:52 +02:00
if ( $action == 'create_user' )
2011-03-26 19:34:41 +01:00
{
2013-02-23 16:08:35 +01:00
// Full firstname and lastname separated with a dot : firstname.lastname
2012-08-23 02:04:35 +02:00
include_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php' ;
2013-02-23 16:08:35 +01:00
$login = dol_buildlogin ( $object -> lastname , $object -> firstname );
2011-01-10 01:04:27 +01:00
2011-01-29 18:41:26 +01:00
$generated_password = '' ;
2011-01-29 19:23:01 +01:00
if ( ! $ldap_sid ) // TODO ldap_sid ?
2011-01-29 18:41:26 +01:00
{
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/lib/security2.lib.php' ;
2014-04-28 04:27:49 +02:00
$generated_password = getRandomPassword ( false );
2011-01-29 18:41:26 +01:00
}
$password = $generated_password ;
2011-03-26 19:34:41 +01:00
// Create a form array
$formquestion = array (
array ( 'label' => $langs -> trans ( " LoginToCreate " ), 'type' => 'text' , 'name' => 'login' , 'value' => $login ),
2011-05-25 14:05:18 +02:00
array ( 'label' => $langs -> trans ( " Password " ), 'type' => 'text' , 'name' => 'password' , 'value' => $password ),
2016-03-25 15:24:57 +01:00
//array('label' => $form->textwithpicto($langs->trans("Type"),$langs->trans("InternalExternalDesc")), 'type' => 'select', 'name' => 'intern', 'default' => 1, 'values' => array(0=>$langs->trans('Internal'),1=>$langs->trans('External')))
2011-05-25 14:05:18 +02:00
);
$text = $langs -> trans ( " ConfirmCreateContact " ) . '<br>' ;
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> societe -> enabled ))
2011-05-25 14:05:18 +02:00
{
if ( $object -> socid > 0 ) $text .= $langs -> trans ( " UserWillBeExternalUser " );
else $text .= $langs -> trans ( " UserWillBeInternalUser " );
}
2016-03-25 15:53:44 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id , $langs -> trans ( " CreateDolibarrLogin " ), $text , " confirm_create_user " , $formquestion , 'yes' );
2013-09-25 19:58:22 +02:00
2011-03-26 19:34:41 +01:00
}
2010-11-19 22:24:48 +01:00
2017-10-03 16:00:52 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/contact/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2017-06-07 16:44:04 +02:00
2016-12-19 16:35:40 +01:00
$morehtmlref = '<div class="refidno">' ;
if ( empty ( $conf -> global -> SOCIETE_DISABLE_CONTACTS ))
{
$objsoc -> fetch ( $object -> socid );
// Thirdparty
$morehtmlref .= $langs -> trans ( 'ThirdParty' ) . ' : ' ;
2017-09-27 19:56:03 +02:00
if ( $objsoc -> id > 0 ) $morehtmlref .= $objsoc -> getNomUrl ( 1 , 'contact' );
2016-12-19 16:35:40 +01:00
else $morehtmlref .= $langs -> trans ( " ContactNotLinkedToCompany " );
}
2017-06-07 16:44:04 +02:00
$morehtmlref .= '</div>' ;
2016-12-19 16:35:40 +01:00
dol_banner_tab ( $object , 'id' , $linkback , 1 , 'rowid' , 'ref' , $morehtmlref );
2017-06-07 16:44:04 +02:00
2015-10-11 12:27:04 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
2017-06-07 16:44:04 +02:00
2015-10-11 12:27:04 +02:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2011-03-26 19:34:41 +01:00
// Civility
2016-08-10 15:01:43 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " UserTitle " ) . '</td><td>' ;
2011-03-26 19:34:41 +01:00
print $object -> getCivilityLabel ();
print '</td></tr>' ;
2011-05-25 14:05:18 +02:00
// Role
2015-10-11 12:27:04 +02:00
print '<tr><td>' . $langs -> trans ( " PostOrFunction " ) . '</td><td>' . $object -> poste . '</td></tr>' ;
2011-03-26 19:34:41 +01:00
// Email
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> mailing -> enabled ))
2011-03-26 19:34:41 +01:00
{
$langs -> load ( " mails " );
2015-12-06 00:37:58 +01:00
print '<tr><td>' . $langs -> trans ( " NbOfEMailingsSend " ) . '</td>' ;
2015-10-11 12:27:04 +02:00
print '<td><a href="' . DOL_URL_ROOT . '/comm/mailing/list.php?filteremail=' . urlencode ( $object -> email ) . '">' . $object -> getNbOfEMailings () . '</a></td></tr>' ;
2011-03-26 19:34:41 +01:00
}
2012-08-22 22:59:10 +02:00
// Instant message and no email
2015-10-11 12:27:04 +02:00
print '<tr><td>' . $langs -> trans ( " IM " ) . '</td><td>' . $object -> jabberid . '</td></tr>' ;
2012-08-26 20:28:19 +02:00
if ( ! empty ( $conf -> mailing -> enabled ))
{
2015-10-11 12:27:04 +02:00
print '<tr><td>' . $langs -> trans ( " No_Email " ) . '</td><td>' . yn ( $object -> no_email ) . '</td></tr>' ;
2012-08-26 20:28:19 +02:00
}
2013-12-02 20:30:15 +01:00
2015-10-11 12:27:04 +02:00
print '<tr><td>' . $langs -> trans ( " ContactVisibility " ) . '</td><td>' ;
2011-03-26 19:34:41 +01:00
print $object -> LibPubPriv ( $object -> priv );
print '</td></tr>' ;
2015-10-11 12:27:04 +02:00
print '</table>' ;
2017-06-07 16:44:04 +02:00
2015-10-11 12:27:04 +02:00
print '</div>' ;
print '<div class="fichehalfright"><div class="ficheaddleft">' ;
2017-06-07 16:44:04 +02:00
2015-10-11 12:27:04 +02:00
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield" width="100%">' ;
2017-06-07 16:44:04 +02:00
2015-06-11 14:50:11 +02:00
// Categories
if ( ! empty ( $conf -> categorie -> enabled ) && ! empty ( $user -> rights -> categorie -> lire )) {
2016-08-10 15:01:43 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " Categories " ) . '</td>' ;
2015-06-11 14:50:11 +02:00
print '<td colspan="3">' ;
print $form -> showCategories ( $object -> id , 'contact' , 1 );
print '</td></tr>' ;
}
2017-06-07 16:44:04 +02:00
// Other attributes
$cols = 3 ;
$parameyers = array ( 'socid' => $socid );
include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php' ;
2012-09-19 17:53:09 +02:00
2011-03-26 19:34:41 +01:00
$object -> load_ref_elements ();
2016-02-24 11:17:47 +01:00
if ( ! empty ( $conf -> propal -> enabled ))
2011-03-26 19:34:41 +01:00
{
2016-08-10 15:01:43 +02:00
print '<tr><td class="titlefield">' . $langs -> trans ( " ContactForProposals " ) . '</td><td colspan="3">' ;
2016-02-24 11:17:47 +01:00
print $object -> ref_propal ? $object -> ref_propal : $langs -> trans ( " NoContactForAnyProposal " );
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
2011-02-13 13:55:40 +01:00
}
2010-11-19 22:24:48 +01:00
2016-02-24 11:17:47 +01:00
if ( ! empty ( $conf -> commande -> enabled ) || ! empty ( $conf -> expedition -> enabled ))
2011-03-26 19:34:41 +01:00
{
2016-02-24 11:17:47 +01:00
print '<tr><td>' ;
if ( ! empty ( $conf -> expedition -> enabled )) { print $langs -> trans ( " ContactForOrdersOrShipments " ); }
else print $langs -> trans ( " ContactForOrders " );
print '</td><td colspan="3">' ;
$none = $langs -> trans ( " NoContactForAnyOrder " );
if ( ! empty ( $conf -> expedition -> enabled )) { $none = $langs -> trans ( " NoContactForAnyOrderOrShipments " ); }
print $object -> ref_commande ? $object -> ref_commande : $none ;
2011-03-26 19:34:41 +01:00
print '</td></tr>' ;
}
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> contrat -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForContracts " ) . '</td><td colspan="3">' ;
print $object -> ref_contrat ? $object -> ref_contrat : $langs -> trans ( " NoContactForAnyContract " );
print '</td></tr>' ;
}
2012-09-15 10:01:35 +02:00
if ( ! empty ( $conf -> facture -> enabled ))
2011-03-26 19:34:41 +01:00
{
print '<tr><td>' . $langs -> trans ( " ContactForInvoices " ) . '</td><td colspan="3">' ;
print $object -> ref_facturation ? $object -> ref_facturation : $langs -> trans ( " NoContactForAnyInvoice " );
print '</td></tr>' ;
}
print '<tr><td>' . $langs -> trans ( " DolibarrLogin " ) . '</td><td colspan="3">' ;
if ( $object -> user_id )
{
$dolibarr_user = new User ( $db );
$result = $dolibarr_user -> fetch ( $object -> user_id );
print $dolibarr_user -> getLoginUrl ( 1 );
}
else print $langs -> trans ( " NoDolibarrAccess " );
print '</td></tr>' ;
2015-06-23 18:11:21 +02:00
print '<tr><td>' ;
2016-12-05 13:45:57 +01:00
print $langs -> trans ( " VCard " ) . '</td><td colspan="3">' ;
2015-07-19 23:39:07 +02:00
print '<a href="' . DOL_URL_ROOT . '/contact/vcard.php?id=' . $object -> id . '">' ;
2016-12-05 13:45:57 +01:00
print img_picto ( $langs -> trans ( " Download " ), 'vcard.png' ) . ' ' ;
print $langs -> trans ( " Download " );
2015-06-23 18:11:21 +02:00
print '</a>' ;
print '</td></tr>' ;
2015-07-12 12:50:24 +02:00
2011-03-26 19:34:41 +01:00
print " </table> " ;
2017-06-07 16:44:04 +02:00
2015-10-11 12:27:04 +02:00
print '</div></div></div>' ;
print '<div style="clear:both"></div>' ;
2017-06-07 16:44:04 +02:00
2014-12-30 21:04:02 +01:00
print dol_fiche_end ();
2011-03-26 19:34:41 +01:00
// Barre d'actions
2014-01-24 11:15:25 +01:00
print '<div class="tabsAction">' ;
2011-03-26 19:34:41 +01:00
2014-01-24 11:15:25 +01:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'addMoreActionsButtons' , $parameters , $object , $action ); // Note that $action and $object may have been modified by hook
if ( empty ( $reshook ))
{
if ( $user -> rights -> societe -> contact -> creer )
2011-03-26 19:34:41 +01:00
{
2015-06-05 15:41:27 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=edit">' . $langs -> trans ( 'Modify' ) . '</a>' ;
2011-03-26 19:34:41 +01:00
}
if ( ! $object -> user_id && $user -> rights -> user -> user -> creer )
{
2015-06-05 15:41:27 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=create_user">' . $langs -> trans ( " CreateDolibarrLogin " ) . '</a>' ;
2011-03-26 19:34:41 +01:00
}
2013-07-10 12:28:28 +02:00
// Activer
2013-08-22 10:06:57 +02:00
if ( $object -> statut == 0 && $user -> rights -> societe -> contact -> creer )
2013-07-10 12:28:28 +02:00
{
2014-10-12 11:59:52 +02:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=enable">' . $langs -> trans ( " Reactivate " ) . '</a>' ;
2013-07-10 12:28:28 +02:00
}
// Desactiver
2013-08-22 10:06:57 +02:00
if ( $object -> statut == 1 && $user -> rights -> societe -> contact -> creer )
2013-07-10 12:28:28 +02:00
{
2014-10-12 11:59:52 +02:00
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=disable&id=' . $object -> id . '">' . $langs -> trans ( " DisableUser " ) . '</a>' ;
2015-06-05 15:41:27 +02:00
}
// Delete
if ( $user -> rights -> societe -> contact -> supprimer )
{
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?id=' . $object -> id . '&action=delete' . ( $backtopage ? '&backtopage=' . urlencode ( $backtopage ) : '' ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
2013-07-10 12:28:28 +02:00
}
2011-03-26 19:34:41 +01:00
}
2014-04-28 04:27:49 +02:00
2014-12-30 21:04:02 +01:00
print " </div> " ;
2014-04-28 04:27:49 +02:00
2011-03-26 19:34:41 +01:00
}
2006-02-25 00:16:35 +01:00
}
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-13 01:43:35 +01:00
$db -> close ();