27require 
"../../main.inc.php";
 
   28require_once DOL_DOCUMENT_ROOT.
'/projet/class/project.class.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/projet/class/task.class.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/core/lib/project.lib.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
 
   35$langs->loadLangs(array(
'projects', 
'companies'));
 
   39$action = 
GETPOST(
'action', 
'aZ09');
 
   40$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   42$project_ref = 
GETPOST(
'project_ref', 
'alpha');
 
   45$projectstatic = 
new Project($db);
 
   62if ($action == 
'addcontact' && $user->hasRight(
'projet', 
'creer')) {
 
   64  if (
GETPOST(
"addsourceexternal")) {
 
   68  $result = 
$object->fetch($id, $ref);
 
   70  if ($result > 0 && $id > 0) {
 
   71    if ($source == 
'internal') {
 
   76      $typeid = 
GETPOST(
'typecontact');
 
   78    if ($idfortaskuser == -2) {
 
   79      $result = $projectstatic->fetch(
$object->fk_project);
 
   83        $contactsofproject = $projectstatic->getListContactId(
'internal');
 
   84        foreach ($contactsofproject as $key => $val) {
 
   85          $result = 
$object->add_contact($val, $typeid, $source);
 
   89      $result = 
$object->add_contact($idfortaskuser, $typeid, $source);
 
   94    header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ? 
'&withproject=1' : 
''));
 
   97    if (
$object->error == 
'DB_ERROR_RECORD_ALREADY_EXISTS') {
 
   98      $langs->load(
"errors");
 
   99      setEventMessages($langs->trans(
"ErrorThisContactIsAlreadyDefinedAsThisType"), 
null, 
'errors');
 
  107if ($action == 
'swapstatut' && $user->hasRight(
'projet', 
'creer')) {
 
  108  if (
$object->fetch($id, $ref)) {
 
  116if ($action == 
'deleteline' && $user->hasRight(
'projet', 
'creer')) {
 
  121    header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".
$object->id.($withproject ? 
'&withproject=1' : 
''));
 
  129if (!empty($project_ref) && !empty($withproject)) {
 
  130  if ($projectstatic->fetch(0, $project_ref) > 0) {
 
  131    $tasksarray = 
$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
 
  132    if (count($tasksarray) > 0) {
 
  133      $id = $tasksarray[0]->id;
 
  135      header(
"Location: ".DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.($withproject ? 
'&withproject=1' : 
'').(empty($mode) ? 
'' : 
'&mode='.$mode));
 
  144$form = 
new Form($db);
 
  146$contactstatic = 
new Contact($db);
 
  147$userstatic = 
new User($db);
 
  148$result = $projectstatic->fetch(
$object->fk_project);
 
  150$title = 
$object->ref . 
' - ' . $langs->trans(
"Contacts");
 
  151if (!empty($withproject)) {
 
  152  $title .= 
' | ' . $langs->trans(
"Project") . (!empty($projectstatic->ref) ? 
': '.$projectstatic->ref : 
'')  ;
 
  165if ($id > 0 || !empty($ref)) {
 
  166  if (
$object->fetch($id, $ref) > 0) {
 
  167    if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_TASK') && method_exists($object, 
'fetchComments') && empty(
$object->comments)) {
 
  172    if (
getDolGlobalString(
'PROJECT_ALLOW_COMMENT_ON_PROJECT') && method_exists($projectstatic, 
'fetchComments') && empty($projectstatic->comments)) {
 
  173      $projectstatic->fetchComments();
 
  175    if (!empty($projectstatic->socid)) {
 
  176      $projectstatic->fetch_thirdparty();
 
  179    $object->project = clone $projectstatic;
 
  181    $userWrite = $projectstatic->restrictedProjectArea($user, 
'write');
 
  187      print 
dol_get_fiche_head($head, $tab, $langs->trans(
"Project"), -1, ($projectstatic->public ? 
'projectpub' : 
'project'));
 
  189      $param = (!empty($mode) && $mode == 
'mine' ? 
'&mode=mine' : 
'');
 
  193      $linkback = 
'<a href="'.DOL_URL_ROOT.
'/projet/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
 
  195      $morehtmlref = 
'<div class="refidno">';
 
  197      $morehtmlref .= $projectstatic->title;
 
  199      if (isset($projectstatic->thirdparty->id) && $projectstatic->thirdparty->id > 0) {
 
  200        $morehtmlref .= 
'<br>'.$projectstatic->thirdparty->getNomUrl(1, 
'project');
 
  202      $morehtmlref .= 
'</div>';
 
  205      if (!$user->hasRight(
'projet', 
'all', 
'lire')) {
 
  206        $objectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 0);
 
  207        $projectstatic->next_prev_filter = 
"rowid IN (".$db->sanitize(count($objectsListId) ? implode(
',', array_keys($objectsListId)) : 
'0').
")";
 
  210      dol_banner_tab($projectstatic, 
'project_ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref);
 
  212      print 
'<div class="fichecenter">';
 
  213      print 
'<div class="fichehalfleft">';
 
  214      print 
'<div class="underbanner clearboth"></div>';
 
  216      print 
'<table class="border tableforfield centpercent">';
 
  220        print 
'<tr><td class="tdtop">';
 
  221        print $langs->trans(
"Usage");
 
  225          print 
'<input type="checkbox" disabled name="usage_opportunity"'.(GETPOSTISSET(
'usage_opportunity') ? (
GETPOST(
'usage_opportunity', 
'alpha') != 
'' ? 
' checked="checked"' : 
'') : ($projectstatic->usage_opportunity ? 
' checked="checked"' : 
'')).
'"> ';
 
  226          $htmltext = $langs->trans(
"ProjectFollowOpportunity");
 
  227          print $form->textwithpicto($langs->trans(
"ProjectFollowOpportunity"), $htmltext);
 
  231          print 
'<input type="checkbox" disabled name="usage_task"'.(GETPOSTISSET(
'usage_task') ? (
GETPOST(
'usage_task', 
'alpha') != 
'' ? 
' checked="checked"' : 
'') : ($projectstatic->usage_task ? 
' checked="checked"' : 
'')).
'"> ';
 
  232          $htmltext = $langs->trans(
"ProjectFollowTasks");
 
  233          print $form->textwithpicto($langs->trans(
"ProjectFollowTasks"), $htmltext);
 
  237          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"' : 
'')).
'"> ';
 
  238          $htmltext = $langs->trans(
"ProjectBillTimeDescription");
 
  239          print $form->textwithpicto($langs->trans(
"BillTime"), $htmltext);
 
  242        if (isModEnabled(
'eventorganization')) {
 
  243          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"' : 
'')).
'"> ';
 
  244          $htmltext = $langs->trans(
"EventOrganizationDescriptionLong");
 
  245          print $form->textwithpicto($langs->trans(
"ManageOrganizeEvent"), $htmltext);
 
  251      print 
'<tr><td class="titlefield">'.$langs->trans(
"Visibility").
'</td><td>';
 
  252      if ($projectstatic->public) {
 
  253        print 
img_picto($langs->trans(
'SharedProject'), 
'world', 
'class="paddingrightonly"');
 
  254        print $langs->trans(
'SharedProject');
 
  256        print 
img_picto($langs->trans(
'PrivateProject'), 
'private', 
'class="paddingrightonly"');
 
  257        print $langs->trans(
'PrivateProject');
 
  262      print 
'<tr><td>'.$langs->trans(
"Budget").
'</td><td>';
 
  263      if (isset($projectstatic->budget_amount) && strcmp($projectstatic->budget_amount, 
'')) {
 
  264        print 
price($projectstatic->budget_amount, 0, $langs, 1, 0, 0, $conf->currency);
 
  269      print 
'<tr><td>'.$langs->trans(
"Dates").
'</td><td>';
 
  271      print($start ? $start : 
'?');
 
  274      print($end ? $end : 
'?');
 
  275      if ($projectstatic->hasDelay()) {
 
  287      print 
'<div class="fichehalfright">';
 
  288      print 
'<div class="underbanner clearboth"></div>';
 
  290      print 
'<table class="border tableforfield centpercent">';
 
  293      print 
'<td class="titlefield tdtop">'.$langs->trans(
"Description").
'</td><td>';
 
  294      print nl2br($projectstatic->description);
 
  298      if (isModEnabled(
'category')) {
 
  299        print 
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
 
  300        print $form->showCategories($projectstatic->id, 
'project', 1);
 
  309      print 
'<div class="clearboth"></div>';
 
  322    print 
dol_get_fiche_head($head, 
'task_contact', $langs->trans(
"Task"), -1, 
'projecttask', 0, 
'', 
'reposition');
 
  325    $param = (
GETPOST(
'withproject') ? 
'&withproject=1' : 
'');
 
  326    $linkback = 
GETPOST(
'withproject') ? 
'<a href="'.DOL_URL_ROOT.
'/projet/tasks.php?id='.$projectstatic->id.
'">'.$langs->trans(
"BackToList").
'</a>' : 
'';
 
  328    if (!
GETPOST(
'withproject') || empty($projectstatic->id)) {
 
  329      $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user, 0, 1);
 
  330      $object->next_prev_filter = 
"fk_projet IN (".$db->sanitize($projectsListId).
")";
 
  332      $object->next_prev_filter = 
"fk_projet = ".((int) $projectstatic->id);
 
  338    if (empty($withproject)) {
 
  339      $result = $projectstatic->fetch(
$object->fk_project);
 
  340      $morehtmlref .= 
'<div class="refidno">';
 
  341      $morehtmlref .= $langs->trans(
"Project").
': ';
 
  342      $morehtmlref .= $projectstatic->getNomUrl(1);
 
  343      $morehtmlref .= 
'<br>';
 
  346      $morehtmlref .= $langs->trans(
"ThirdParty").
': ';
 
  347      if ($projectstatic->socid > 0) {
 
  348        $projectstatic->fetch_thirdparty();
 
  349        $morehtmlref .= $projectstatic->thirdparty->getNomUrl(1);
 
  352      $morehtmlref .= 
'</div>';
 
  355    dol_banner_tab($object, 
'ref', $linkback, 1, 
'ref', 
'ref', $morehtmlref, $param, 0, 
'', 
'', 1);
 
  375    print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'?id='.$id.
'" method="POST">';
 
  376    print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  377    print 
'<input type="hidden" name="action" value="addcontact">';
 
  378    print 
'<input type="hidden" name="id" value="'.$id.
'">';
 
  380      print 
'<input type="hidden" name="withproject" value="'.$withproject.
'">';
 
  383    print 
'<div class="div-table-responsive">'; 
 
  384    print 
'<table class="noborder centpercent">';
 
  386    if ($action != 
'editline' && $user->hasRight(
'projet', 
'creer')) {
 
  387      print 
'<tr class="liste_titre">';
 
  388      print 
'<td>'.$langs->trans(
"NatureOfContact").
'</td>';
 
  389      print 
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
 
  390      print 
'<td>'.$langs->trans(
"Users").
'</td>';
 
  391      print 
'<td>'.$langs->trans(
"ContactType").
'</td>';
 
  392      print 
'<td colspan="3"> </td>';
 
  396      print 
'<tr class="oddeven nohover">';
 
  398      print 
'<td class="nowrap">';
 
  399      print 
img_object(
'', 
'user').
' '.$langs->trans(
"Users");
 
  403      print $conf->global->MAIN_INFO_SOCIETE_NOM;
 
  408      if (
$object->project->public) {
 
  409        $contactsofproject = 
''; 
 
  411        $contactsofproject = $projectstatic->getListContactId(
'internal');
 
  413      print $form->select_dolusers((GETPOSTISSET(
'userid') ? 
GETPOSTINT(
'userid') : $user->id), 
'userid', 0, 
'', 0, 
'', $contactsofproject, 0, 0, 0, 
'', 1, $langs->trans(
"ResourceNotAssignedToProject"));
 
  416      $formcompany->selectTypeContact($object, 
'', 
'type', 
'internal', 
'position');
 
  418      print 
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" value="'.$langs->trans(
"Add").
'" name="addsourceinternal"></td>';
 
  422      if ($projectstatic->socid) {
 
  423        print 
'<tr class="oddeven">';
 
  425        print 
'<td class="nowrap">';
 
  426        print 
img_object(
'', 
'contact').
' '.$langs->trans(
"ThirdPartyContacts");
 
  430        $thirdpartyofproject = $projectstatic->getListContactId(
'thirdparty');
 
  431        $selectedCompany = GETPOSTISSET(
"newcompany") ? 
GETPOST(
"newcompany") : $projectstatic->socid;
 
  432        $selectedCompany = $formcompany->selectCompaniesForNewContact($object, 
'id', $selectedCompany, 
'newcompany', $thirdpartyofproject, 0, 
'&withproject='.$withproject);
 
  436        $contactofproject = $projectstatic->getListContactId(
'external');
 
  438        print $form->select_contact($selectedCompany, 
'', 
'contactid', 0, 
'', $contactofproject, 0, 
'maxwidth300 widthcentpercentminusx', 
true);
 
  439        $nbofcontacts = $form->num;
 
  442        $formcompany->selectTypeContact($object, 
'', 
'typecontact', 
'external', 
'position');
 
  444        print 
'<td class="right" colspan="3" ><input type="submit" class="button button-add small" id="add-customer-contact" name="addsourceexternal" value="'.$langs->trans(
"Add").
'"';
 
  445        if (!$nbofcontacts) {
 
  454    print 
'<tr class="liste_titre">';
 
  455    print 
'<td>'.$langs->trans(
"Source").
'</td>';
 
  456    print 
'<td>'.$langs->trans(
"ThirdParty").
'</td>';
 
  457    print 
'<td>'.$langs->trans(
"TaskContact").
'</td>';
 
  458    print 
'<td>'.$langs->trans(
"ContactType").
'</td>';
 
  459    print 
'<td class="center">'.$langs->trans(
"Status").
'</td>';
 
  460    print 
'<td colspan="2"> </td>';
 
  463    $companystatic = 
new Societe($db);
 
  465    foreach (array(
'internal', 
'external') as $source) {
 
  466      $tab = 
$object->liste_contact(-1, $source);
 
  472        print 
'<tr class="oddeven" valign="top">';
 
  475        print 
'<td class="left">';
 
  476        if ($tab[$i][
'source'] == 
'internal') {
 
  477          print $langs->trans(
"User");
 
  479        if ($tab[$i][
'source'] == 
'external') {
 
  480          print $langs->trans(
"ThirdPartyContact");
 
  485        print 
'<td class="left">';
 
  486        if ($tab[$i][
'socid'] > 0) {
 
  487          $companystatic->fetch($tab[$i][
'socid']);
 
  488          print $companystatic->getNomUrl(1);
 
  490        if ($tab[$i][
'socid'] < 0) {
 
  491          print $conf->global->MAIN_INFO_SOCIETE_NOM;
 
  493        if (!$tab[$i][
'socid']) {
 
  500        if ($tab[$i][
'source'] == 
'internal') {
 
  501          $userstatic->id = $tab[$i][
'id'];
 
  502          $userstatic->lastname = $tab[$i][
'lastname'];
 
  503          $userstatic->firstname = $tab[$i][
'firstname'];
 
  504          $userstatic->photo = $tab[$i][
'photo'];
 
  505          $userstatic->login = $tab[$i][
'login'];
 
  506          $userstatic->email = $tab[$i][
'email'];
 
  507          $userstatic->gender = $tab[$i][
'gender'];
 
  508          $userstatic->status = $tab[$i][
'statuscontact'];
 
  510          print $userstatic->getNomUrl(-1);
 
  512        if ($tab[$i][
'source'] == 
'external') {
 
  513          $contactstatic->id = $tab[$i][
'id'];
 
  514          $contactstatic->lastname = $tab[$i][
'lastname'];
 
  515          $contactstatic->firstname = $tab[$i][
'firstname'];
 
  516          $contactstatic->email = $tab[$i][
'email'];
 
  517          $contactstatic->statut = $tab[$i][
'statuscontact'];
 
  518          print $contactstatic->getNomUrl(1);
 
  523        print 
'<td>'.$tab[$i][
'libelle'].
'</td>';
 
  526        print 
'<td class="center">';
 
  529          print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=swapstatut&ligne='.$tab[$i][
'rowid'].($withproject ? 
'&withproject=1' : 
'').
'">';
 
  531        print $contactstatic->LibStatut($tab[$i][
'status'], 3);
 
  538        print 
'<td class="center nowrap">';
 
  539        if ($user->hasRight(
'projet', 
'creer')) {
 
  541          print 
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=deleteline&token='.
newToken().
'&lineid='.$tab[$i][
'rowid'].($withproject ? 
'&withproject=1' : 
'').
'">';
 
  542          print 
img_picto($langs->trans(
'Unlink'), 
'unlink');
 
  557    print 
"ErrorRecordNotFound";
 
  561if (is_object($hookmanager)) {
 
  562  $hookmanager->initHooks(array(
'contacttpl'));
 
  563  $parameters = array();
 
  564  $reshook = $hookmanager->executeHooks(
'formContactTpl', $parameters, $object, $action);
 
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
 
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage projects.
 
Class to manage third parties objects (customers, suppliers, prospects...)
 
Class to manage Dolibarr users.
 
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
 
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
 
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
 
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
 
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
 
dol_get_fiche_end($notab=0)
Return tab footer of a card.
 
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
newToken()
Return the value of token currently saved into session with name 'newtoken'.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
 
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
 
task_prepare_head($object)
Prepare array with list of tabs.
 
project_prepare_head(Project $project, $moreparam='')
Prepare array with list of tabs.
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.