project.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. require '../main.inc.php';
  24. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  25. $langs->loadLangs(array("contacts", "companies", "projects"));
  26. // Security check
  27. $id = GETPOST('id', 'int');
  28. $result = restrictedArea($user, 'contact', $id, 'socpeople&societe');
  29. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  30. $hookmanager->initHooks(array('projectcontact'));
  31. /*
  32. * Actions
  33. */
  34. $parameters = array('id' => $id);
  35. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  36. if ($reshook < 0) {
  37. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  38. }
  39. /*
  40. * View
  41. */
  42. $form = new Form($db);
  43. if ($id) {
  44. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  45. require_once DOL_DOCUMENT_ROOT.'/core/lib/contact.lib.php';
  46. $object = new Contact($db);
  47. $result = $object->fetch($id);
  48. if (empty($object->thirdparty)) {
  49. $object->fetch_thirdparty();
  50. }
  51. $socid = $object->thirdparty->id;
  52. $title = $langs->trans("Projects");
  53. if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  54. $title = $object->name." - ".$title;
  55. }
  56. llxHeader('', $title);
  57. if (! empty($conf->notification->enabled)) {
  58. $langs->load("mails");
  59. }
  60. $head = contact_prepare_head($object);
  61. print dol_get_fiche_head($head, 'project', $langs->trans("Contact"), -1, 'contact');
  62. $linkback = '<a href="'.DOL_URL_ROOT.'/contact/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  63. $morehtmlref = '<a href="'.DOL_URL_ROOT.'/contact/vcard.php?id='.$object->id.'" class="refid">';
  64. $morehtmlref .= img_picto($langs->trans("Download").' '.$langs->trans("VCard"), 'vcard.png', 'class="valignmiddle marginleftonly paddingrightonly"');
  65. $morehtmlref .= '</a>';
  66. $morehtmlref .= '<div class="refidno">';
  67. if (empty($conf->global->SOCIETE_DISABLE_CONTACTS) && !empty($socid)) {
  68. $object->thirdparty->fetch($socid);
  69. // Thirdparty
  70. $morehtmlref .= $langs->trans('ThirdParty').' : ';
  71. if ($object->thirdparty->id > 0) {
  72. $morehtmlref .= $object->thirdparty->getNomUrl(1, 'contact');
  73. } else {
  74. $morehtmlref .= $langs->trans("ContactNotLinkedToCompany");
  75. }
  76. }
  77. $morehtmlref .= '</div>';
  78. dol_banner_tab($object, 'id', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom', $morehtmlref);
  79. print '<div class="fichecenter">';
  80. print '<div class="underbanner clearboth"></div>';
  81. print '<table class="border centpercent tableforfield">';
  82. // Civility
  83. print '<tr><td class="titlefield">'.$langs->trans("UserTitle").'</td><td>';
  84. print $object->getCivilityLabel();
  85. print '</td></tr>';
  86. print '</table>';
  87. print '</div>';
  88. print dol_get_fiche_end();
  89. print '<br>';
  90. // Projects list
  91. $result = show_contacts_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?id='.$object->id, 1);
  92. }
  93. // End of page
  94. llxFooter();
  95. $db->close();