project.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. /* Copyright (C) 2001-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Brice Davoleau <brice.davoleau@gmail.com>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2006-2015 Laurent Destailleur <eldy@users.sourceforge.net>
  6. * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
  7. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  8. * Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
  9. * Copyright (C) 2021 Frédéric France <frederic.france@netlogic.fr>
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 3 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  23. */
  24. /**
  25. * \file htdocs/societe/project.php
  26. * \ingroup societe
  27. * \brief Page of third party projects
  28. */
  29. // Load Dolibarr environment
  30. require '../main.inc.php';
  31. require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
  32. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  33. // Load translation files required by the page
  34. $langs->loadLangs(array('companies', 'projects'));
  35. // Security check
  36. $socid = GETPOST('socid', 'int');
  37. if ($user->socid) {
  38. $socid = $user->socid;
  39. }
  40. $result = restrictedArea($user, 'societe', $socid, '&societe');
  41. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  42. $hookmanager->initHooks(array('projectthirdparty'));
  43. /*
  44. * Actions
  45. */
  46. $parameters = array('id'=>$socid);
  47. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  48. if ($reshook < 0) {
  49. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  50. }
  51. /*
  52. * View
  53. */
  54. $contactstatic = new Contact($db);
  55. $form = new Form($db);
  56. if ($socid) {
  57. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  58. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  59. $langs->load("companies");
  60. $object = new Societe($db);
  61. $result = $object->fetch($socid);
  62. $title = $langs->trans("Projects");
  63. if (!empty($conf->global->MAIN_HTML_TITLE) && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  64. $title = $object->name." - ".$title;
  65. }
  66. llxHeader('', $title);
  67. if (isModEnabled('notification')) {
  68. $langs->load("mails");
  69. }
  70. $head = societe_prepare_head($object);
  71. print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
  72. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  73. dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
  74. print '<div class="fichecenter">';
  75. print '<div class="underbanner clearboth"></div>';
  76. print '<table class="border centpercent tableforfield">';
  77. // Type Prospect/Customer/Supplier
  78. print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
  79. print $object->getTypeUrl(1);
  80. print '</td></tr>';
  81. if (!empty($conf->global->SOCIETE_USEPREFIX)) { // Old not used prefix field
  82. print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
  83. }
  84. if ($object->client) {
  85. print '<tr><td class="titlefield">';
  86. print $langs->trans('CustomerCode').'</td><td colspan="3">';
  87. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
  88. $tmpcheck = $object->check_codeclient();
  89. if ($tmpcheck != 0 && $tmpcheck != -5) {
  90. print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
  91. }
  92. print '</td></tr>';
  93. }
  94. if ($object->fournisseur) {
  95. print '<tr><td class="titlefield">';
  96. print $langs->trans('SupplierCode').'</td><td colspan="3">';
  97. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
  98. $tmpcheck = $object->check_codefournisseur();
  99. if ($tmpcheck != 0 && $tmpcheck != -5) {
  100. print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
  101. }
  102. print '</td></tr>';
  103. }
  104. print '</table>';
  105. print '</div>';
  106. print dol_get_fiche_end();
  107. $params = '';
  108. $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
  109. $newcardbutton = dolGetButtonTitle($langs->trans("NewProject"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/projet/card.php?action=create&socid='.$object->id.'&backtopageforcancel='.urlencode($backtopage), '', 1, $params);
  110. print '<br>';
  111. // Projects list
  112. $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
  113. }
  114. // End of page
  115. llxFooter();
  116. $db->close();