* Copyright (C) 2012-2015 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/projet/contact.php * \ingroup project * \brief List of all contacts of a project */ // Load Dolibarr environment require '../main.inc.php'; 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'; if (isModEnabled('categorie')) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; } // Load translation files required by the page $langsLoad=array('projects', 'companies'); if (isModEnabled('eventorganization')) { $langsLoad[]='eventorganization'; } $langs->loadLangs($langsLoad); $id = GETPOST('id', 'int'); $ref = GETPOST('ref', 'alpha'); $lineid = GETPOST('lineid', 'int'); $socid = GETPOST('socid', 'int'); $action = GETPOST('action', 'aZ09'); $mine = GETPOST('mode') == 'mine' ? 1 : 0; //if (! $user->rights->projet->all->lire) $mine=1; // Special for projects $object = new Project($db); include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT) && method_exists($object, 'fetchComments') && empty($object->comments)) { $object->fetchComments(); } // Security check $socid = 0; //if ($user->socid > 0) $socid = $user->socid; // For external user, no check is done on company because readability is managed by public status of project and assignement. $result = restrictedArea($user, 'projet', $id, 'projet&project'); $hookmanager->initHooks(array('projectcontactcard', 'globalcard')); /* * Actions */ // Test if we can add contact to the tasks at the same times, if not or not required, make a redirect $formconfirmtoaddtasks = ''; if ($action == 'addcontact') { $form = new Form($db); $source=GETPOST("source", 'aZ09'); $taskstatic = new Task($db); $task_array = $taskstatic->getTasksArray(0, 0, $object->id, 0, 0); $nbTasks = count($task_array); //If no task avaiblable, redirec to to add confirm $type_to = (GETPOST('typecontact') ? 'typecontact='.GETPOST('typecontact') : 'type='.GETPOST('type')); $personToAffect = (GETPOST('userid') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $affect_to = (GETPOST('userid') ? 'userid='.$personToAffect : 'contactid='.$personToAffect); $url_redirect='?id='.$object->id.'&'.$affect_to.'&'.$type_to.'&source='.$source; if ($personToAffect > 0 && (empty($conf->global->PROJECT_HIDE_TASKS) || $nbTasks > 0)) { $text = $langs->trans('AddPersonToTask'); $textbody = $text.' ('.$langs->trans("SelectAll").')'; $formquestion = array('text' => $textbody); $task_to_affect = array(); foreach ($task_array as $task) { $task_already_affected=false; $personsLinked = $task->liste_contact(-1, $source); if (!is_array($personsLinked) && count($personsLinked) < 0) { setEventMessage($object->error, 'errors'); } else { foreach ($personsLinked as $person) { if ($person['id']==$personToAffect) { $task_already_affected = true; break; } } if (!$task_already_affected) { $task_to_affect[$task->id] = $task->id; } } } if (empty($task_to_affect)) { $action = 'addcontact_confirm'; } else { $formcompany = new FormCompany($db); foreach ($task_array as $task) { $key = $task->id; $val = $task->ref . ' '.dol_trunc($task->label); $formquestion[] = array( 'type' => 'other', 'name' => 'person_'.$key.',person_role_'.$key, 'label' => '