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 >
2018-10-27 14:43:12 +02:00
* Copyright ( C ) 2010 - 2012 Regis Houssin < regis . houssin @ inodbox . 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
2019-09-23 21:55:30 +02:00
* along with this program . If not , see < https :// 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
*/
2018-07-26 11:57:25 +02: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
2020-04-10 10:59:32 +02:00
$id = GETPOST ( 'id' , 'int' );
$ref = GETPOST ( 'ref' , 'alpha' );
2020-09-16 19:39:50 +02:00
$action = GETPOST ( 'action' , 'aZ09' );
2020-04-10 10:59:32 +02:00
$confirm = GETPOST ( 'confirm' , 'alpha' );
$withproject = GETPOST ( 'withproject' , 'int' );
$project_ref = GETPOST ( 'project_ref' , 'alpha' );
2010-01-26 17:54:40 +01:00
2021-09-19 01:30:39 +02:00
$object = new Task ( $db );
$projectstatic = new Project ( $db );
if ( $id > 0 || $ref ) {
$object -> fetch ( $id , $ref );
}
2010-01-26 17:54:40 +01:00
// Security check
2020-04-10 10:59:32 +02:00
$socid = 0 ;
2012-04-18 11:16:15 +02:00
2021-09-19 01:30:39 +02:00
restrictedArea ( $user , 'projet' , $object -> fk_project , 'projet&project' );
2010-01-26 17:54:40 +01:00
/*
* Actions
*/
// Add new contact
2021-02-26 18:49:22 +01:00
if ( $action == 'addcontact' && $user -> rights -> projet -> creer ) {
2021-10-25 22:07:31 +02:00
$source = 'internal' ;
2021-02-02 15:35:40 +01:00
if ( GETPOST ( " addsourceexternal " )) {
2021-10-25 22:07:31 +02:00
$source = 'external' ;
2021-02-02 15:35:40 +01:00
}
2014-12-22 22:52:43 +01:00
$result = $object -> fetch ( $id , $ref );
2010-01-26 17:54:40 +01:00
2021-02-26 18:49:22 +01:00
if ( $result > 0 && $id > 0 ) {
2021-02-02 15:35:40 +01:00
if ( $source == 'internal' ) {
$idfortaskuser = (( GETPOST ( " userid " ) != 0 && GETPOST ( 'userid' ) != - 1 ) ? GETPOST ( " userid " ) : 0 ); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody"
$typeid = GETPOST ( 'type' );
} else {
$idfortaskuser = (( GETPOST ( " contactid " ) > 0 ) ? GETPOST ( " contactid " , 'int' ) : 0 ); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody"
$typeid = GETPOST ( 'typecontact' );
}
2021-02-26 18:49:22 +01:00
if ( $idfortaskuser == - 2 ) {
2020-10-31 14:32:18 +01:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2021-02-26 18:49:22 +01:00
if ( $result <= 0 ) {
2020-10-31 14:32:18 +01:00
dol_print_error ( $db , $projectstatic -> error , $projectstatic -> errors );
} else {
$contactsofproject = $projectstatic -> getListContactId ( 'internal' );
2021-02-26 18:49:22 +01:00
foreach ( $contactsofproject as $key => $val ) {
2021-02-02 15:35:40 +01:00
$result = $object -> add_contact ( $val , $typeid , $source );
2020-10-31 14:32:18 +01:00
}
}
} else {
2021-02-02 15:35:40 +01:00
$result = $object -> add_contact ( $idfortaskuser , $typeid , $source );
2020-10-31 14:32:18 +01:00
}
}
2010-01-26 17:54:40 +01:00
2020-11-30 13:18:23 +01:00
if ( $result >= 0 ) {
2020-04-10 10:59:32 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( $withproject ? '&withproject=1' : '' ));
2010-01-26 17:54:40 +01:00
exit ;
2020-11-30 13:18:23 +01:00
} else {
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' );
2020-05-21 15:05:19 +02: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
2021-02-26 18:49:22 +01:00
if ( $action == 'swapstatut' && $user -> rights -> projet -> creer ) {
2020-11-30 13:18:23 +01:00
if ( $object -> fetch ( $id , $ref )) {
2021-03-29 15:07:23 +02:00
$result = $object -> swapContactStatus ( GETPOST ( 'ligne' , 'int' ));
2020-05-21 15:05:19 +02:00
} else {
2010-01-26 17:54:40 +01:00
dol_print_error ( $db );
}
}
// Efface un contact
2021-02-26 18:49:22 +01:00
if ( $action == 'deleteline' && $user -> rights -> projet -> creer ) {
2014-12-22 22:52:43 +01:00
$object -> fetch ( $id , $ref );
2021-03-29 15:07:23 +02:00
$result = $object -> delete_contact ( GETPOST ( " lineid " , 'int' ));
2010-01-26 17:54:40 +01:00
2021-02-26 18:49:22 +01:00
if ( $result >= 0 ) {
2020-04-10 10:59:32 +02:00
header ( " Location: " . $_SERVER [ " PHP_SELF " ] . " ?id= " . $object -> id . ( $withproject ? '&withproject=1' : '' ));
2010-01-26 17:54:40 +01:00
exit ;
2020-05-21 15:05:19 +02:00
} else {
2010-01-26 17:54:40 +01:00
dol_print_error ( $db );
}
}
2020-10-23 20:08:35 +02:00
// Retrieve First Task ID of Project if withprojet is on to allow project prev next to work
2021-02-26 18:49:22 +01:00
if ( ! empty ( $project_ref ) && ! empty ( $withproject )) {
if ( $projectstatic -> fetch ( 0 , $project_ref ) > 0 ) {
2020-04-10 10:59:32 +02:00
$tasksarray = $object -> getTasksArray ( 0 , 0 , $projectstatic -> id , $socid , 0 );
2021-02-26 18:49:22 +01:00
if ( count ( $tasksarray ) > 0 ) {
2020-04-10 10:59:32 +02:00
$id = $tasksarray [ 0 ] -> id ;
2020-05-21 15:05:19 +02:00
} else {
2020-04-10 10:59:32 +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 */
/* */
/* *************************************************************************** */
2021-02-26 18:49:22 +01:00
if ( $id > 0 || ! empty ( $ref )) {
if ( $object -> fetch ( $id , $ref ) > 0 ) {
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_TASK ) && method_exists ( $object , 'fetchComments' ) && empty ( $object -> comments )) {
$object -> fetchComments ();
}
2020-10-31 14:32:18 +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
2020-04-10 10:59:32 +02:00
$result = $projectstatic -> fetch ( $object -> fk_project );
2021-02-26 18:49:22 +01:00
if ( ! empty ( $conf -> global -> PROJECT_ALLOW_COMMENT_ON_PROJECT ) && method_exists ( $projectstatic , 'fetchComments' ) && empty ( $projectstatic -> comments )) {
$projectstatic -> fetchComments ();
}
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
2020-04-10 10:59:32 +02:00
$userWrite = $projectstatic -> restrictedProjectArea ( $user , 'write' );
2012-02-15 23:08:20 +01:00
2021-02-26 18:49:22 +01:00
if ( $withproject ) {
2020-10-31 14:32:18 +01:00
// Tabs for project
$tab = 'tasks' ;
$head = project_prepare_head ( $projectstatic );
print dol_get_fiche_head ( $head , $tab , $langs -> trans ( " Project " ), - 1 , ( $projectstatic -> public ? 'projectpub' : 'project' ));
2012-02-15 23:08:20 +01:00
2020-10-31 14:32:18 +01:00
$param = ( $mode == 'mine' ? '&mode=mine' : '' );
2012-02-15 23:08:20 +01:00
2016-10-18 12:16:12 +02:00
// Project card
2017-06-07 10:55:39 +02:00
2020-10-31 14:32:18 +01:00
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs -> trans ( " BackToList " ) . '</a>' ;
$morehtmlref = '<div class="refidno">' ;
// Title
$morehtmlref .= $projectstatic -> title ;
// Thirdparty
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> thirdparty -> id > 0 ) {
2020-10-31 14:32:18 +01:00
$morehtmlref .= '<br>' . $langs -> trans ( 'ThirdParty' ) . ' : ' . $projectstatic -> thirdparty -> getNomUrl ( 1 , 'project' );
}
$morehtmlref .= '</div>' ;
// Define a complementary filter for search of next/prev ref.
2021-10-24 10:02:12 +02:00
if ( empty ( $user -> rights -> projet -> all -> lire )) {
2020-10-31 14:32:18 +01:00
$objectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 0 );
2021-03-22 12:47:23 +01:00
$projectstatic -> next_prev_filter = " rowid IN ( " . $db -> sanitize ( count ( $objectsListId ) ? join ( ',' , array_keys ( $objectsListId )) : '0' ) . " ) " ;
2020-10-31 14:32:18 +01:00
}
dol_banner_tab ( $projectstatic , 'project_ref' , $linkback , 1 , 'ref' , 'ref' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="fichehalfleft">' ;
print '<div class="underbanner clearboth"></div>' ;
print '<table class="border tableforfield centpercent">' ;
// Usage
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES ) || empty ( $conf -> global -> PROJECT_HIDE_TASKS ) || ! empty ( $conf -> eventorganization -> enabled )) {
2021-03-20 12:18:40 +01:00
print '<tr><td class="tdtop">' ;
print $langs -> trans ( " Usage " );
print '</td>' ;
print '<td>' ;
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> global -> PROJECT_USE_OPPORTUNITIES )) {
2021-03-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_opportunity"' . ( GETPOSTISSET ( 'usage_opportunity' ) ? ( GETPOST ( 'usage_opportunity' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> usage_opportunity ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowOpportunity " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowOpportunity " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS )) {
2021-03-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_task"' . ( GETPOSTISSET ( 'usage_task' ) ? ( GETPOST ( 'usage_task' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> usage_task ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectFollowTasks " );
print $form -> textwithpicto ( $langs -> trans ( " ProjectFollowTasks " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( empty ( $conf -> global -> PROJECT_HIDE_TASKS ) && ! empty ( $conf -> global -> PROJECT_BILL_TIME_SPENT )) {
2021-03-20 12:18:40 +01:00
print '<input type="checkbox" disabled name="usage_bill_time"' . ( GETPOSTISSET ( 'usage_bill_time' ) ? ( GETPOST ( 'usage_bill_time' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> usage_bill_time ? ' checked="checked"' : '' )) . '"> ' ;
$htmltext = $langs -> trans ( " ProjectBillTimeDescription " );
print $form -> textwithpicto ( $langs -> trans ( " BillTime " ), $htmltext );
print '<br>' ;
}
2021-03-20 12:42:46 +01:00
if ( ! empty ( $conf -> eventorganization -> enabled )) {
2022-07-21 10:59:15 +02:00
print '<input type="checkbox" disabled name="usage_organize_event"' . ( GETPOSTISSET ( 'usage_organize_event' ) ? ( GETPOST ( 'usage_organize_event' , 'alpha' ) != '' ? ' checked="checked"' : '' ) : ( $projectstatic -> usage_organize_event ? ' checked="checked"' : '' )) . '"> ' ;
2021-03-20 12:42:46 +01:00
$htmltext = $langs -> trans ( " EventOrganizationDescriptionLong " );
print $form -> textwithpicto ( $langs -> trans ( " ManageOrganizeEvent " ), $htmltext );
}
2021-03-20 12:18:40 +01:00
print '</td></tr>' ;
2020-10-31 14:32:18 +01:00
}
// Visibility
print '<tr><td class="titlefield">' . $langs -> trans ( " Visibility " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> public ) {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'SharedProject' ), 'world' , 'class="paddingrightonly"' );
2021-02-26 18:49:22 +01:00
print $langs -> trans ( 'SharedProject' );
} else {
2022-05-16 18:00:59 +02:00
print img_picto ( $langs -> trans ( 'PrivateProject' ), 'private' , 'class="paddingrightonly"' );
2021-02-26 18:49:22 +01:00
print $langs -> trans ( 'PrivateProject' );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
// Date start - end
print '<tr><td>' . $langs -> trans ( " DateStart " ) . ' - ' . $langs -> trans ( " DateEnd " ) . '</td><td>' ;
$start = dol_print_date ( $projectstatic -> date_start , 'day' );
print ( $start ? $start : '?' );
$end = dol_print_date ( $projectstatic -> date_end , 'day' );
print ' - ' ;
print ( $end ? $end : '?' );
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> hasDelay ()) {
print img_warning ( " Late " );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
// Budget
print '<tr><td>' . $langs -> trans ( " Budget " ) . '</td><td>' ;
2021-02-26 18:49:22 +01:00
if ( strcmp ( $projectstatic -> budget_amount , '' )) {
print price ( $projectstatic -> budget_amount , '' , $langs , 1 , 0 , 0 , $conf -> currency );
}
2020-10-31 14:32:18 +01:00
print '</td></tr>' ;
// Other attributes
$cols = 2 ;
//include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
print '</table>' ;
print '</div>' ;
print '<div class="fichehalfright">' ;
print '<div class="underbanner clearboth"></div>' ;
2021-10-23 17:18:35 +02:00
print '<table class="border tableforfield centpercent">' ;
2020-10-31 14:32:18 +01:00
// Description
print '<td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
print nl2br ( $projectstatic -> description );
print '</td></tr>' ;
// Categories
2022-06-09 22:41:59 +02:00
if ( isModEnabled ( 'categorie' )) {
2020-10-31 14:32:18 +01:00
print '<tr><td class="valignmiddle">' . $langs -> trans ( " Categories " ) . '</td><td>' ;
print $form -> showCategories ( $projectstatic -> id , 'project' , 1 );
print " </td></tr> " ;
}
print '</table>' ;
print '</div>' ;
print '</div>' ;
print '<div class="clearboth"></div>' ;
print dol_get_fiche_end ();
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 );
2020-10-22 22:50:03 +02:00
print dol_get_fiche_head ( $head , 'task_contact' , $langs -> trans ( " Task " ), - 1 , 'projecttask' , 0 , '' , 'reposition' );
2010-01-26 17:54:40 +01:00
2020-04-10 10:59:32 +02:00
$param = ( GETPOST ( 'withproject' ) ? '&withproject=1' : '' );
$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
2021-02-26 18:49:22 +01:00
if ( ! GETPOST ( 'withproject' ) || empty ( $projectstatic -> id )) {
2020-10-31 14:32:18 +01:00
$projectsListId = $projectstatic -> getProjectsAuthorizedForUser ( $user , 0 , 1 );
2021-03-22 12:47:23 +01:00
$object -> next_prev_filter = " fk_projet IN ( " . $db -> sanitize ( $projectsListId ) . " ) " ;
2021-02-26 18:49:22 +01:00
} else {
$object -> next_prev_filter = " fk_projet = " . $projectstatic -> id ;
}
2017-06-07 10:55:39 +02:00
2020-04-10 10:59:32 +02:00
$morehtmlref = '' ;
2017-06-07 10:55:39 +02:00
2017-05-18 12:12:36 +02:00
// Project
2021-02-26 18:49:22 +01:00
if ( empty ( $withproject )) {
2020-10-31 14:32:18 +01:00
$result = $projectstatic -> fetch ( $object -> fk_project );
$morehtmlref .= '<div class="refidno">' ;
$morehtmlref .= $langs -> trans ( " Project " ) . ': ' ;
$morehtmlref .= $projectstatic -> getNomUrl ( 1 );
$morehtmlref .= '<br>' ;
// Third party
$morehtmlref .= $langs -> trans ( " ThirdParty " ) . ': ' ;
if ( $projectstatic -> socid > 0 ) {
$projectstatic -> fetch_thirdparty ();
$morehtmlref .= $projectstatic -> thirdparty -> getNomUrl ( 1 );
}
$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 );
2020-10-27 18:19:31 +01:00
print dol_get_fiche_end ();
2010-01-26 17:54:40 +01:00
/*
2018-12-10 12:32:26 +01:00
* Lines of contacts
2010-01-26 17:54:40 +01:00
*/
2019-10-20 11:59:21 +02:00
/*
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 )
{
2021-02-26 18:49:22 +01:00
$res =@ include dol_buildpath ( $reldir . '/contacts.tpl.php' );
if ( $res ) break ;
2014-02-04 20:49:07 +01:00
}
2019-10-20 11:59:21 +02:00
*/
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
*/
2021-02-02 15:35:40 +01:00
print '<form action="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $id . '" method="POST">' ;
print '<input type="hidden" name="token" value="' . newToken () . '">' ;
print '<input type="hidden" name="action" value="addcontact">' ;
print '<input type="hidden" name="id" value="' . $id . '">' ;
2021-02-26 18:49:22 +01:00
if ( $withproject ) {
print '<input type="hidden" name="withproject" value="' . $withproject . '">' ;
}
2021-02-02 15:35:40 +01:00
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">' ;
2015-06-03 21:01:50 +02:00
2021-02-26 18:49:22 +01:00
if ( $action != 'editline' && $user -> rights -> projet -> creer ) {
2010-01-26 17:54:40 +01:00
print '<tr class="liste_titre">' ;
2020-04-15 14:54:54 +02:00
print '<td>' . $langs -> trans ( " NatureOfContact " ) . '</td>' ;
2014-05-09 13:39:10 +02:00
print '<td>' . $langs -> trans ( " ThirdParty " ) . '</td>' ;
2018-12-10 12:32:26 +01:00
print '<td>' . $langs -> trans ( " Users " ) . '</td>' ;
2010-01-26 17:54:40 +01:00
print '<td>' . $langs -> trans ( " ContactType " ) . '</td>' ;
print '<td colspan="3"> </td>' ;
print " </tr> \n " ;
// Ligne ajout pour contact interne
2020-04-15 14:54:54 +02:00
print '<tr class="oddeven nohover">' ;
2010-01-26 17:54:40 +01:00
2013-04-25 01:13:13 +02:00
print '<td class="nowrap">' ;
2019-01-27 11:55:16 +01:00
print img_object ( '' , 'user' ) . ' ' . $langs -> trans ( " Users " );
2010-01-26 17:54:40 +01:00
print '</td>' ;
2020-04-25 17:18:57 +02:00
print '<td>' ;
2010-01-26 17:54:40 +01:00
print $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
print '</td>' ;
2020-04-25 17:18:57 +02:00
print '<td>' ;
2010-01-26 17:54:40 +01:00
// On recupere les id des users deja selectionnes
2021-02-26 18:49:22 +01:00
if ( $object -> project -> public ) {
$contactsofproject = '' ; // Everybody
} else {
$contactsofproject = $projectstatic -> getListContactId ( 'internal' );
}
2021-02-02 15:35:40 +01:00
print $form -> select_dolusers (( GETPOSTISSET ( 'userid' ) ? GETPOST ( 'userid' , 'int' ) : $user -> id ), 'userid' , 0 , '' , 0 , '' , $contactsofproject , 0 , 0 , 0 , '' , 1 , $langs -> trans ( " ResourceNotAssignedToProject " ));
2010-01-26 17:54:40 +01:00
print '</td>' ;
print '<td>' ;
2023-06-11 00:42:29 +02:00
$formcompany -> selectTypeContact ( $object , '' , 'type' , 'internal' , 'position' );
2010-01-26 17:54:40 +01:00
print '</td>' ;
2021-08-24 17:04:17 +02:00
print '<td class="right" colspan="3" ><input type="submit" class="button button-add" value="' . $langs -> trans ( " Add " ) . '" name="addsourceinternal"></td>' ;
2010-01-26 17:54:40 +01:00
print '</tr>' ;
2010-02-07 03:39:01 +01:00
// Line to add an external contact. Only if project linked to a third party.
2021-02-26 18:49:22 +01:00
if ( $projectstatic -> socid ) {
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">' ;
2019-01-27 11:55:16 +01:00
print img_object ( '' , 'contact' ) . ' ' . $langs -> trans ( " ThirdPartyContacts " );
2010-02-07 03:39:01 +01:00
print '</td>' ;
2020-04-25 17:18:57 +02:00
print '<td>' ;
2020-04-10 10:59:32 +02:00
$thirdpartyofproject = $projectstatic -> getListContactId ( 'thirdparty' );
$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>' ;
2020-04-25 17:18:57 +02:00
print '<td>' ;
2020-04-10 10:59:32 +02:00
$contactofproject = $projectstatic -> getListContactId ( 'external' );
2021-02-02 15:35:40 +01:00
print $form -> selectcontacts ( $selectedCompany , '' , 'contactid' , 0 , '' , $contactofproject , 0 , '' , false , 0 , 0 );
2020-11-30 12:35:05 +01:00
$nbofcontacts = $form -> num ;
2010-02-07 03:39:01 +01:00
print '</td>' ;
print '<td>' ;
2023-06-11 00:42:29 +02:00
$formcompany -> selectTypeContact ( $object , '' , 'typecontact' , 'external' , 'position' );
2010-02-07 03:39:01 +01:00
print '</td>' ;
2021-02-02 15:35:40 +01:00
print '<td class="right" colspan="3" ><input type="submit" class="button" id="add-customer-contact" name="addsourceexternal" value="' . $langs -> trans ( " Add " ) . '"' ;
2021-02-26 18:49:22 +01:00
if ( ! $nbofcontacts ) {
print ' disabled' ;
}
2010-02-07 03:39:01 +01:00
print '></td>' ;
print '</tr>' ;
2010-05-09 17:04:16 +02:00
}
2010-01-26 17:54:40 +01:00
}
2020-10-12 12:33:58 +02:00
// List of contact line
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>' ;
2019-02-23 22:24:26 +01:00
print '<td class="center">' . $langs -> trans ( " Status " ) . '</td>' ;
2010-01-26 17:54:40 +01:00
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
2021-02-26 18:49:22 +01:00
foreach ( array ( 'internal' , 'external' ) as $source ) {
2019-01-27 11:55:16 +01:00
$tab = $object -> liste_contact ( - 1 , $source );
2020-11-30 15:18:58 +01:00
2020-04-10 10:59:32 +02:00
$num = count ( $tab );
2010-01-26 17:54:40 +01:00
$i = 0 ;
2021-02-26 18:49:22 +01:00
while ( $i < $num ) {
2018-07-19 16:48:20 +02:00
print '<tr class="oddeven" valign="top">' ;
2010-01-26 17:54:40 +01:00
// Source
2019-01-21 10:04:43 +01:00
print '<td class="left">' ;
2021-02-26 18:49:22 +01:00
if ( $tab [ $i ][ 'source' ] == 'internal' ) {
print $langs -> trans ( " User " );
}
if ( $tab [ $i ][ 'source' ] == 'external' ) {
print $langs -> trans ( " ThirdPartyContact " );
}
2010-01-26 17:54:40 +01:00
print '</td>' ;
// Societe
2019-01-21 10:04:43 +01:00
print '<td class="left">' ;
2021-02-26 18:49:22 +01:00
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
}
2021-02-26 18:49:22 +01:00
if ( $tab [ $i ][ 'socid' ] < 0 ) {
2010-01-26 17:54:40 +01:00
print $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
}
2021-02-26 18:49:22 +01:00
if ( ! $tab [ $i ][ 'socid' ]) {
2010-01-26 17:54:40 +01:00
print ' ' ;
}
print '</td>' ;
// Contact
print '<td>' ;
2021-02-26 18:49:22 +01:00
if ( $tab [ $i ][ 'source' ] == 'internal' ) {
2020-10-31 14:32:18 +01:00
$userstatic -> id = $tab [ $i ][ 'id' ];
$userstatic -> lastname = $tab [ $i ][ 'lastname' ];
$userstatic -> firstname = $tab [ $i ][ 'firstname' ];
$userstatic -> photo = $tab [ $i ][ 'photo' ];
$userstatic -> login = $tab [ $i ][ 'login' ];
$userstatic -> email = $tab [ $i ][ 'email' ];
2020-11-30 15:18:58 +01:00
$userstatic -> statut = $tab [ $i ][ 'statuscontact' ];
2020-10-31 14:32:18 +01:00
print $userstatic -> getNomUrl ( - 1 );
}
2021-02-26 18:49:22 +01:00
if ( $tab [ $i ][ 'source' ] == 'external' ) {
2020-10-31 14:32:18 +01:00
$contactstatic -> id = $tab [ $i ][ 'id' ];
$contactstatic -> lastname = $tab [ $i ][ 'lastname' ];
$contactstatic -> firstname = $tab [ $i ][ 'firstname' ];
$contactstatic -> email = $tab [ $i ][ 'email' ];
2020-11-30 15:18:58 +01:00
$contactstatic -> statut = $tab [ $i ][ 'statuscontact' ];
2020-10-31 14:32:18 +01:00
print $contactstatic -> getNomUrl ( 1 );
}
2010-01-26 17:54:40 +01:00
print '</td>' ;
// Type de contact
print '<td>' . $tab [ $i ][ 'libelle' ] . '</td>' ;
// Statut
2019-02-23 22:24:26 +01:00
print '<td class="center">' ;
2010-01-26 17:54:40 +01:00
// Activation desativation du contact
2021-02-26 18:49:22 +01:00
if ( $object -> statut >= 0 ) {
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=swapstatut&ligne=' . $tab [ $i ][ 'rowid' ] . ( $withproject ? '&withproject=1' : '' ) . '">' ;
}
2019-01-27 11:55:16 +01:00
print $contactstatic -> LibStatut ( $tab [ $i ][ 'status' ], 3 );
2021-02-26 18:49:22 +01:00
if ( $object -> statut >= 0 ) {
print '</a>' ;
}
2010-01-26 17:54:40 +01:00
print '</td>' ;
// Icon update et delete
2019-02-23 22:24:26 +01:00
print '<td class="center nowrap">' ;
2021-02-26 18:49:22 +01:00
if ( $user -> rights -> projet -> creer ) {
2010-01-26 17:54:40 +01:00
print ' ' ;
2020-10-01 10:50:54 +02:00
print '<a href="' . $_SERVER [ " PHP_SELF " ] . '?id=' . $object -> id . '&action=deleteline&token=' . newToken () . '&lineid=' . $tab [ $i ][ 'rowid' ] . ( $withproject ? '&withproject=1' : '' ) . '">' ;
2018-12-10 12:32:26 +01:00
print img_picto ( $langs -> trans ( 'Unlink' ), 'unlink' );
2010-01-26 17:54:40 +01:00
print '</a>' ;
}
print '</td>' ;
print " </tr> \n " ;
2020-04-10 10:59:32 +02:00
$i ++ ;
2010-01-26 17:54:40 +01:00
}
}
print " </table> " ;
2021-02-02 15:35:40 +01:00
print " </form> " ;
2020-05-21 15:05:19 +02:00
} else {
2010-01-26 17:54:40 +01:00
print " ErrorRecordNotFound " ;
}
}
2021-02-26 18:49:22 +01:00
if ( is_object ( $hookmanager )) {
2016-03-30 21:09:27 +02:00
$hookmanager -> initHooks ( array ( 'contacttpl' ));
2020-04-10 10:59:32 +02:00
$parameters = array ();
$reshook = $hookmanager -> executeHooks ( 'formContactTpl' , $parameters , $object , $action );
2016-03-30 21:09:27 +02:00
}
2018-08-15 12:48:13 +02:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2012-02-15 23:08:20 +01:00
$db -> close ();