project.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. /*
  3. * Copyright (C) 2021 VIAL--GOUTEYRON Quentin <quentin.vial-gouteyron@atm-consulting.fr>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/contact/project.php
  20. * \ingroup contact
  21. * \brief Page of third party projects
  22. */
  23. // Load Dolibarr environment
  24. require '../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  26. $langs->loadLangs(array("contacts", "companies", "projects"));
  27. // Security check
  28. $id = GETPOST('id', 'int');
  29. $result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
  30. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  31. $hookmanager->initHooks(array('projectcontact'));
  32. /*
  33. * Actions
  34. */
  35. $parameters = array('id' => $id);
  36. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  37. if ($reshook < 0) {
  38. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  39. }
  40. /*
  41. * View
  42. */
  43. $form = new Form($db);
  44. if ($id) {
  45. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  46. require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
  47. $object = new Contact($db);
  48. $result = $object->fetch($id);
  49. if (empty($object->thirdparty)) {
  50. $object->fetch_thirdparty();
  51. }
  52. $socid = $object->thirdparty->id;
  53. $title = $langs->trans("Projects");
  54. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  55. $title = $object->name." - ".$title;
  56. }
  57. llxHeader('', $title);
  58. if (isModEnabled('notification')) {
  59. $langs->load("mails");
  60. }
  61. $head = contact_prepare_head($object);
  62. print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
  63. $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  64. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
  65. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  66. $morehtmlref .= '</a>';
  67. $morehtmlref .= '<div class="refidno">';
  68. if (empty($conf->global->SOCIETE_DISABLE_CONTACTS)) {
  69. $objsoc = new Societe($db);
  70. $objsoc->fetch($object->socid);
  71. // Thirdparty
  72. if ($objsoc->id > 0) {
  73. $morehtmlref .= $objsoc->getNomUrl(1, 'contact');
  74. } else {
  75. $morehtmlref .= '<span class="opacitymedium">'.$langs->trans("ContactNotLinkedToCompany").'</span>';
  76. }
  77. }
  78. $morehtmlref .= '</div>';
  79. dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
  80. print '<div class="fichecenter">';
  81. print '<div class="underbanner clearboth"></div>';
  82. print '<table class="border centpercent tableforfield">';
  83. // Civility
  84. print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
  85. print $object->getCivilityLabel();
  86. print '</td></tr>';
  87. print '</table>';
  88. print '</div>';
  89. print dol_get_fiche_end();
  90. print '<br>';
  91. // Projects list
  92. $result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
  93. }
  94. // End of page
  95. llxFooter();
  96. $db->close();