2010-01-26 17:54:40 +01:00
< ? php
2012-04-18 11:16:15 +02:00
/* Copyright ( C ) 2005 Rodolphe Quiedeville < rodolphe @ quiedeville . org >
2015-04-23 13:44:45 +02:00
* Copyright ( C ) 2006 - 2015 Laurent Destailleur < eldy @ users . sourceforge . net >
2012-12-30 15:13:49 +01:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ capnetworks . com >
2010-01-26 17:54:40 +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
2010-01-26 17:54:40 +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:19:04 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2010-01-26 17:54:40 +01:00
*/
/**
2010-02-07 03:39:01 +01:00
* \file htdocs / projet / tasks / contact . php
2010-01-26 17:54:40 +01:00
* \ingroup project
2010-02-07 03:39:01 +01:00
* \brief Actors of a task
2010-01-26 17:54:40 +01:00
*/
2010-03-01 09:42:10 +01:00
require ( " ../../main.inc.php " );
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/projet/class/task.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/project.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formcompany.class.php' ;
2010-01-26 17:54:40 +01:00
2018-05-26 21:11:25 +02:00
// Load translation files required by the page
$langs -> loadLangs ( array ( 'projects' , 'companies' ));
2010-01-26 17:54:40 +01:00
2012-04-18 11:16:15 +02:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
$action = GETPOST ( 'action' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$withproject = GETPOST ( 'withproject' , 'int' );
$project_ref = GETPOST ( 'project_ref' , 'alpha' );
2010-01-26 17:54:40 +01:00
// Security check
2010-05-30 14:21:32 +02:00
$socid = 0 ;
2017-01-12 15:23:30 +01:00
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
2012-04-18 11:16:15 +02:00
//$result = restrictedArea($user, 'projet', $id, 'projet_task');
if ( ! $user -> rights -> projet -> lire ) accessforbidden ();
$object = new Task ( $db );
$projectstatic = new Project ( $db );
2010-01-26 17:54:40 +01:00
/*
* Actions
*/
// Add new contact
2012-02-15 23:08:20 +01:00
if ( $action == 'addcontact' && $user -> rights -> projet -> creer )
2010-01-26 17:54:40 +01:00
{
2014-12-22 22:52:43 +01:00
$result = $object -> fetch ( $id , $ref );
2010-01-26 17:54:40 +01:00
2012-04-18 11:16:15 +02:00
if ( $result > 0 && $id > 0 )
2010-01-26 17:54:40 +01:00
{
2015-04-23 13:44:45 +02:00
$idfortaskuser = ( GETPOST ( " contactid " ) != 0 ) ? GETPOST ( " contactid " ) : GETPOST ( " userid " ); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody"
if ( $idfortaskuser == - 2 )
{
$result = $projectstatic -> fetch ( $object -> fk_project );
if ( $result <= 0 )
{
dol_print_error ( $db , $projectstatic -> error , $projectstatic -> errors );
}
else
{
$contactsofproject = $projectstatic -> getListContactId ( 'internal' );
foreach ( $contactsofproject as $key => $val )
{
$result = $object -> add_contact ( $val , GETPOST ( " type " ), GETPOST ( " source " ));
}
}
}
else
{
$result = $object -> add_contact ( $idfortaskuser , GETPOST ( " type " ), GETPOST ( " source " ));
}
2010-01-26 17:54:40 +01:00
}
if ( $result >= 0 )
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( $withproject ? '&withproject=1' : '' ));
2010-01-26 17:54:40 +01:00
exit ;
}
else
{
2012-04-18 11:16:15 +02:00
if ( $object -> error == 'DB_ERROR_RECORD_ALREADY_EXISTS' )
2010-01-26 17:54:40 +01:00
{
$langs -> load ( " errors " );
2015-12-17 14:14:44 +01:00
setEventMessages ( $langs -> trans ( " ErrorThisContactIsAlreadyDefinedAsThisType " ), null , 'errors' );
2010-01-26 17:54:40 +01:00
}
else
{
2015-12-17 14:14:44 +01:00
setEventMessages ( $object -> error , $object -> errors , 'errors' );
2010-01-26 17:54:40 +01:00
}
}
}
// bascule du statut d'un contact
2012-02-15 23:08:20 +01:00
if ( $action == 'swapstatut' && $user -> rights -> projet -> creer )
2010-01-26 17:54:40 +01:00
{
2014-12-22 22:52:43 +01:00
if ( $object -> fetch ( $id , $ref ))
2010-01-26 17:54:40 +01:00
{
2012-04-18 11:16:15 +02:00
$result = $object -> swapContactStatus ( GETPOST ( 'ligne' ));
2010-01-26 17:54:40 +01:00
}
else
{
dol_print_error ( $db );
}
}
// Efface un contact
2012-02-15 23:08:20 +01:00
if ( $action == 'deleteline' && $user -> rights -> projet -> creer )
2010-01-26 17:54:40 +01:00
{
2014-12-22 22:52:43 +01:00
$object -> fetch ( $id , $ref );
2012-04-18 11:16:15 +02:00
$result = $object -> delete_contact ( $_GET [ " lineid " ]);
2010-01-26 17:54:40 +01:00
if ( $result >= 0 )
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( $withproject ? '&withproject=1' : '' ));
2010-01-26 17:54:40 +01:00
exit ;
}
else
{
dol_print_error ( $db );
}
}
2012-04-18 11:16:15 +02:00
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
if ( ! empty ( $project_ref ) && ! empty ( $withproject ))
{
if ( $projectstatic -> fetch ( 0 , $project_ref ) > 0 )
{
$tasksarray = $object -> getTasksArray ( 0 , 0 , $projectstatic -> id , $socid , 0 );
if ( count ( $tasksarray ) > 0 )
{
$id = $tasksarray [ 0 ] -> id ;
}
else
{
2012-08-31 05:58:38 +02:00
header ( " Location: " . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . ( $withproject ? '&withproject=1' : '' ) . ( empty ( $mode ) ? '' : '&mode=' . $mode ));
2012-04-18 12:15:14 +02:00
exit ;
2012-04-18 11:16:15 +02:00
}
}
}
2010-01-26 17:54:40 +01:00
/*
* View
*/
llxHeader ( '' , $langs -> trans ( " Task " ));
2011-11-08 10:18:45 +01:00
$form = new Form ( $db );
2010-01-26 17:54:40 +01:00
$formcompany = new FormCompany ( $db );
$contactstatic = new Contact ( $db );
2011-02-09 19:27:56 +01:00
$userstatic = new User ( $db );
2010-01-26 17:54:40 +01:00
/* *************************************************************************** */
/* */
/* Mode vue et edition */
/* */
/* *************************************************************************** */
if ( $id > 0 || ! empty ( $ref ))
{
2014-12-22 22:52:43 +01:00
if ( $object -> fetch ( $id , $ref ) > 0 )
2010-01-26 17:54:40 +01:00
{
2018-05-22 16:07:32 +02:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_TASK ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) $object -> fetchComments ();
2015-12-04 15:37:28 +01:00
$id = $object -> id ; // So when doing a search from ref, id is also set correctly.
2017-06-07 10:55:39 +02:00
2012-04-18 11:16:15 +02:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2018-05-22 16:07:32 +02:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $projectstatic , 'fetchComments' ) && empty ( $projectstatic -> comments )) $projectstatic -> fetchComments ();
2014-09-20 10:14:26 +02:00
if ( ! empty ( $projectstatic -> socid )) $projectstatic -> fetch_thirdparty ();
2010-04-24 15:39:16 +02:00
2015-09-24 16:32:48 +02:00
$object -> project = clone $projectstatic ;
2014-05-10 16:43:47 +02:00
2012-04-18 11:16:15 +02:00
$userWrite = $projectstatic -> restrictedProjectArea ( $user , 'write' );
2012-02-15 23:08:20 +01:00
2012-02-15 23:27:03 +01:00
if ( $withproject )
2012-02-15 23:08:20 +01:00
{
// Tabs for project
$tab = 'tasks' ;
2012-04-18 11:16:15 +02:00
$head = project_prepare_head ( $projectstatic );
2017-09-17 20:05:36 +02:00
dol_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), - 1 , ( $projectstatic -> public ? 'projectpub' : 'project' ));
2012-02-15 23:08:20 +01:00
$param = ( $mode == 'mine' ? '&mode=mine' : '' );
2016-10-18 12:16:12 +02:00
// Project card
2017-06-07 10:55:39 +02:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
2016-10-18 12:16:12 +02:00
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $projectstatic -> title ;
// Thirdparty
2017-06-07 10:55:39 +02:00
if ( $projectstatic -> thirdparty -> id > 0 )
2016-10-18 12:16:12 +02:00
{
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $projectstatic -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Define a complementary filter for search of next/prev ref.
if ( ! $user -> rights -> projet -> all -> lire )
{
2017-01-04 16:35:04 +01:00
$objectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2016-10-18 12:16:12 +02:00
$projectstatic -> next_prev_filter = " rowid in ( " . ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
}
2017-06-07 10:55:39 +02:00
2017-01-20 10:27:37 +01:00
dol_banner_tab ( $projectstatic , 'project_ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<table class="border" width="100%">' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
if ( $projectstatic -> public ) print $langs -> trans ( 'SharedProject' );
else print $langs -> trans ( 'PrivateProject' );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
2018-02-15 02:02:32 +01:00
$start = dol_print_date ( $projectstatic -> date_start , 'day' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $projectstatic -> date_end , 'day' );
print ' - ' ;
print ( $end ? $end : '?' );
if ( $projectstatic -> hasDelay ()) print img_warning ( " Late " );
2016-10-18 12:16:12 +02:00
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
if ( strcmp ( $projectstatic -> budget_amount , '' )) print price ( $projectstatic -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Other attributes
$cols = 2 ;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="ficheaddleft">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<table class="border" width="100%">' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $projectstatic -> description );
print '</td></tr>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
// Categories
if ( $conf -> categorie -> enabled ) {
print '<tr><td valign="middle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
print $form -> showCategories ( $projectstatic -> id , 'project' , 1 );
print " </td></tr> " ;
}
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</table>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '</div>' ;
print '</div>' ;
print '</div>' ;
2017-06-07 10:55:39 +02:00
2016-10-18 12:16:12 +02:00
print '<div class="clearboth"></div>' ;
2012-02-15 23:08:20 +01:00
dol_fiche_end ();
2017-09-17 20:05:36 +02:00
print '<br>' ;
2012-02-15 23:08:20 +01:00
}
2017-09-17 20:05:36 +02:00
2010-03-02 08:52:31 +01:00
// To verify role of users
2012-04-18 11:16:15 +02:00
//$userAccess = $projectstatic->restrictedProjectArea($user); // We allow task affected to user even if a not allowed project
//$arrayofuseridoftask=$object->getListContactId('internal');
2010-01-26 17:54:40 +01:00
2012-04-18 11:16:15 +02:00
$head = task_prepare_head ( $object );
2018-03-06 21:51:43 +01:00
dol_fiche_head ( $head , 'task_contact' , $langs -> trans ( " Task " ), - 1 , 'projecttask' , 0 , '' , 'reposition' );
2010-01-26 17:54:40 +01:00
2012-02-15 23:08:20 +01:00
$param = ( GETPOST ( 'withproject' ) ? '&withproject=1' : '' );
2012-04-18 11:16:15 +02:00
$linkback = GETPOST ( 'withproject' ) ? '<a href="' . DOL_URL_ROOT . '/projet/tasks.php?id=' . $projectstatic -> id . '">' . $langs -> trans ( " BackToList " ) . '</a>' : '' ;
2017-06-07 10:55:39 +02:00
2012-04-18 11:16:15 +02:00
if ( ! GETPOST ( 'withproject' ) || empty ( $projectstatic -> id ))
2012-02-15 23:08:20 +01:00
{
2014-09-20 10:14:26 +02:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 );
2012-04-18 11:16:15 +02:00
$object -> next_prev_filter = " fk_projet in ( " . $projectsListId . " ) " ;
2012-02-15 23:08:20 +01:00
}
2012-04-18 11:16:15 +02:00
else $object -> next_prev_filter = " fk_projet = " . $projectstatic -> id ;
2017-06-07 10:55:39 +02:00
2017-04-05 14:48:24 +02:00
$morehtmlref = '' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Project
if ( empty ( $withproject ))
2012-02-15 23:27:03 +01:00
{
2018-05-16 16:34:19 +02:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2017-05-18 12:12:36 +02:00
$morehtmlref .= '<div class="refidno">' ;
$morehtmlref .= $langs -> trans ( " Project " ) . ': ' ;
$morehtmlref .= $projectstatic -> getNomUrl ( 1 );
$morehtmlref .= '<br>' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Third party
$morehtmlref .= $langs -> trans ( " ThirdParty " ) . ': ' ;
2018-05-16 16:34:19 +02:00
if ( $projectstatic -> socid > 0 ) {
$projectstatic -> fetch_thirdparty ();
$morehtmlref .= $projectstatic -> thirdparty -> getNomUrl ( 1 );
}
2017-05-18 12:12:36 +02:00
$morehtmlref .= '</div>' ;
2012-02-15 23:27:03 +01:00
}
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
dol_banner_tab ( $object , 'ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref , $param , 0 , '' , '' , 1 );
2012-02-15 23:08:20 +01:00
dol_fiche_end ();
2010-01-26 17:54:40 +01:00
/*
* Lignes de contacts
*/
2014-02-04 20:49:07 +01:00
/*
// Contacts lines (modules that overwrite templates must declare this into descriptor)
$dirtpls = array_merge ( $conf -> modules_parts [ 'tpl' ], array ( '/core/tpl' ));
foreach ( $dirtpls as $reldir )
{
$res =@ include dol_buildpath ( $reldir . '/contacts.tpl.php' );
if ( $res ) break ;
}
*/
2010-01-26 17:54:40 +01:00
/*
2015-04-23 13:44:45 +02:00
* Add a new contact line
2010-01-26 17:54:40 +01:00
* Non affiche en mode modification de ligne
*/
2015-06-03 21:01:50 +02:00
print '<table class="noborder" width="100%">' ;
2012-02-15 23:08:20 +01:00
if ( $action != 'editline' && $user -> rights -> projet -> creer )
2010-01-26 17:54:40 +01:00
{
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Source " ) . '</td>' ;
2014-05-09 13:39:10 +02:00
print '<td>' . $langs -> trans ( " ThirdParty " ) . '</td>' ;
2017-10-20 04:25:49 +02:00
print '<td>' . $langs -> trans ( " TaskContact " ) . '</td>' ;
2010-01-26 17:54:40 +01:00
print '<td>' . $langs -> trans ( " ContactType " ) . '</td>' ;
print '<td colspan="3"> </td>' ;
print " </tr> \n " ;
$var = false ;
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '" method="POST">' ;
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addcontact">' ;
print '<input type="hidden" name="source" value="internal">' ;
print '<input type="hidden" name="id" value="' . $id . '">' ;
2014-02-04 20:49:07 +01:00
if ( $withproject ) print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
2010-01-26 17:54:40 +01:00
// Ligne ajout pour contact interne
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2010-01-26 17:54:40 +01:00
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2010-01-26 17:54:40 +01:00
print img_object ( '' , 'user' ) . ' ' . $langs -> trans ( " Users " );
print '</td>' ;
print '<td colspan="1">' ;
print $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
print '</td>' ;
print '<td colspan="1">' ;
// On recupere les id des users deja selectionnes
2015-06-03 21:01:50 +02:00
if ( $object -> project -> public ) $contactsofproject = '' ; // Everybody
else $contactsofproject = $projectstatic -> getListContactId ( 'internal' );
print $form -> select_dolusers (( GETPOST ( 'contactid' ) ? GETPOST ( 'contactid' ) : $user -> id ), 'contactid' , 0 , '' , 0 , '' , $contactsofproject , 0 , 0 , 0 , '' , 1 , $langs -> trans ( " ResourceNotAssignedToProject " ));
2010-01-26 17:54:40 +01:00
print '</td>' ;
print '<td>' ;
2012-04-18 11:16:15 +02:00
$formcompany -> selectTypeContact ( $object , '' , 'type' , 'internal' , 'rowid' );
2010-01-26 17:54:40 +01:00
print '</td>' ;
print '<td align="right" colspan="3" ><input type="submit" class="button" value="' . $langs -> trans ( " Add " ) . '"></td>' ;
print '</tr>' ;
print '</form>' ;
2010-02-07 03:39:01 +01:00
// Line to add an external contact. Only if project linked to a third party.
2012-04-18 11:16:15 +02:00
if ( $projectstatic -> socid )
2010-02-07 03:39:01 +01:00
{
2012-04-18 11:16:15 +02:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '" method="POST">' ;
2010-05-09 17:04:16 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
print '<input type="hidden" name="action" value="addcontact">' ;
print '<input type="hidden" name="source" value="external">' ;
2012-04-18 11:16:15 +02:00
print '<input type="hidden" name="id" value="' . $object -> id . '">' ;
2014-02-04 20:49:07 +01:00
if ( $withproject ) print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
2010-05-09 17:04:16 +02:00
2017-06-07 10:55:39 +02:00
2017-04-14 11:22:48 +02:00
print '<tr class="oddeven">' ;
2010-02-07 03:39:01 +01:00
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2010-02-07 03:39:01 +01:00
print img_object ( '' , 'contact' ) . ' ' . $langs -> trans ( " ThirdPartyContacts " );
print '</td>' ;
print '<td colspan="1">' ;
2012-04-18 11:16:15 +02:00
$thirdpartyofproject = $projectstatic -> getListContactId ( 'thirdparty' );
2017-09-20 00:53:48 +02:00
$selectedCompany = isset ( $_GET [ " newcompany " ]) ? $_GET [ " newcompany " ] : $projectstatic -> socid ;
2014-12-05 13:26:47 +01:00
$selectedCompany = $formcompany -> selectCompaniesForNewContact ( $object , 'id' , $selectedCompany , 'newcompany' , $thirdpartyofproject , 0 , '&withproject=' . $withproject );
2010-02-07 03:39:01 +01:00
print '</td>' ;
print '<td colspan="1">' ;
2012-04-18 11:16:15 +02:00
$contactofproject = $projectstatic -> getListContactId ( 'external' );
2011-11-08 10:18:45 +01:00
$nbofcontacts = $form -> select_contacts ( $selectedCompany , '' , 'contactid' , 0 , '' , $contactofproject );
2010-02-07 03:39:01 +01:00
print '</td>' ;
print '<td>' ;
2012-04-18 11:16:15 +02:00
$formcompany -> selectTypeContact ( $object , '' , 'type' , 'external' , 'rowid' );
2010-02-07 03:39:01 +01:00
print '</td>' ;
2014-02-04 20:49:07 +01:00
print '<td align="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" value="' . $langs -> trans ( " Add " ) . '"' ;
2015-05-07 11:57:23 +02:00
if ( ! $nbofcontacts ) print ' disabled' ;
2010-02-07 03:39:01 +01:00
print '></td>' ;
print '</tr>' ;
2010-01-26 17:54:40 +01:00
2010-05-09 17:04:16 +02:00
print " </form> " ;
}
2010-01-26 17:54:40 +01:00
}
// Liste des contacts lies
print '<tr class="liste_titre">' ;
print '<td>' . $langs -> trans ( " Source " ) . '</td>' ;
2014-05-09 13:39:10 +02:00
print '<td>' . $langs -> trans ( " ThirdParty " ) . '</td>' ;
2017-10-20 04:25:49 +02:00
print '<td>' . $langs -> trans ( " TaskContact " ) . '</td>' ;
2010-01-26 17:54:40 +01:00
print '<td>' . $langs -> trans ( " ContactType " ) . '</td>' ;
print '<td align="center">' . $langs -> trans ( " Status " ) . '</td>' ;
print '<td colspan="2"> </td>' ;
print " </tr> \n " ;
2010-05-09 16:55:49 +02:00
$companystatic = new Societe ( $db );
2010-01-26 17:54:40 +01:00
$var = true ;
foreach ( array ( 'internal' , 'external' ) as $source )
{
2012-04-18 11:16:15 +02:00
$tab = $object -> liste_contact ( - 1 , $source );
2011-09-17 21:49:50 +02:00
$num = count ( $tab );
2010-01-26 17:54:40 +01:00
$i = 0 ;
while ( $i < $num )
{
$var = ! $var ;
print '<tr ' . $bc [ $var ] . ' valign="top">' ;
// Source
print '<td align="left">' ;
if ( $tab [ $i ][ 'source' ] == 'internal' ) print $langs -> trans ( " User " );
if ( $tab [ $i ][ 'source' ] == 'external' ) print $langs -> trans ( " ThirdPartyContact " );
print '</td>' ;
// Societe
print '<td align="left">' ;
if ( $tab [ $i ][ 'socid' ] > 0 )
{
2010-05-09 17:15:10 +02:00
$companystatic -> fetch ( $tab [ $i ][ 'socid' ]);
print $companystatic -> getNomUrl ( 1 );
2010-01-26 17:54:40 +01:00
}
if ( $tab [ $i ][ 'socid' ] < 0 )
{
print $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
}
if ( ! $tab [ $i ][ 'socid' ])
{
print ' ' ;
}
print '</td>' ;
// Contact
print '<td>' ;
2011-02-09 19:27:56 +01:00
if ( $tab [ $i ][ 'source' ] == 'internal' )
{
$userstatic -> id = $tab [ $i ][ 'id' ];
2012-01-29 23:24:47 +01:00
$userstatic -> lastname = $tab [ $i ][ 'lastname' ];
$userstatic -> firstname = $tab [ $i ][ 'firstname' ];
2017-04-05 14:48:24 +02:00
$userstatic -> photo = $tab [ $i ][ 'photo' ];
$userstatic -> login = $tab [ $i ][ 'login' ];
print $userstatic -> getNomUrl ( - 1 );
2011-02-09 19:27:56 +01:00
}
if ( $tab [ $i ][ 'source' ] == 'external' )
{
$contactstatic -> id = $tab [ $i ][ 'id' ];
2012-01-29 23:24:47 +01:00
$contactstatic -> lastname = $tab [ $i ][ 'lastname' ];
2011-02-09 19:27:56 +01:00
$contactstatic -> firstname = $tab [ $i ][ 'firstname' ];
print $contactstatic -> getNomUrl ( 1 );
}
2010-01-26 17:54:40 +01:00
print '</td>' ;
// Type de contact
print '<td>' . $tab [ $i ][ 'libelle' ] . '</td>' ;
// Statut
print '<td align="center">' ;
// Activation desativation du contact
2012-04-18 12:15:14 +02:00
if ( $object -> statut >= 0 ) print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=swapstatut&ligne=' . $tab [ $i ][ 'rowid' ] . ( $withproject ? '&withproject=1' : '' ) . '">' ;
2010-01-26 17:54:40 +01:00
print $contactstatic -> LibStatut ( $tab [ $i ][ 'status' ], 3 );
2012-04-18 11:16:15 +02:00
if ( $object -> statut >= 0 ) print '</a>' ;
2010-01-26 17:54:40 +01:00
print '</td>' ;
// Icon update et delete
2015-05-12 15:37:35 +02:00
print '<td align="center" class="nowrap">' ;
2010-02-10 16:55:29 +01:00
if ( $user -> rights -> projet -> creer )
2010-01-26 17:54:40 +01:00
{
print ' ' ;
2012-04-18 12:15:14 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=deleteline&lineid=' . $tab [ $i ][ 'rowid' ] . ( $withproject ? '&withproject=1' : '' ) . '">' ;
2010-01-26 17:54:40 +01:00
print img_delete ();
print '</a>' ;
}
print '</td>' ;
print " </tr> \n " ;
$i ++ ;
}
}
print " </table> " ;
2014-02-04 20:49:07 +01:00
2010-01-26 17:54:40 +01:00
}
else
{
print " ErrorRecordNotFound " ;
}
}
2016-03-30 21:09:27 +02:00
if ( is_object ( $hookmanager ))
{
$hookmanager -> initHooks ( array ( 'contacttpl' ));
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formContactTpl' , $parameters , $object , $action );
}
2010-01-26 17:54:40 +01:00
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-04-18 12:15:14 +02:00
2012-02-15 23:08:20 +01:00
$db -> close ();