project.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
  34. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  35. $form = new Form($db);
  36. // Load translation files required by the page
  37. $langs->loadLangs(array('companies', 'projects'));
  38. $action = GETPOST('action', 'aZ09');
  39. $massaction = GETPOST('massaction', 'alpha');
  40. $confirm = GETPOST('confirm', 'alpha');
  41. $toselect = GETPOST('toselect', 'array');
  42. // Security check
  43. $socid = GETPOST('socid', 'int');
  44. if ($user->socid) {
  45. $socid = $user->socid;
  46. }
  47. $result = restrictedArea($user, 'societe', $socid, '&societe');
  48. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  49. $hookmanager->initHooks(array('projectthirdparty'));
  50. $object = new Societe($db);
  51. $permissiontodelete = $user->hasRight('societe', 'supprimer');
  52. /*
  53. * Actions
  54. */
  55. if (GETPOST('cancel', 'alpha')) {
  56. $massaction = '';
  57. }
  58. if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
  59. $massaction = '';
  60. $massactionbutton = '';
  61. }
  62. $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
  63. if ($reshook < 0) {
  64. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  65. }
  66. $parameters = array('id'=>$socid);
  67. // List of mass actions available
  68. if (!empty($permissiontodelete)) {
  69. $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
  70. }
  71. if (in_array($massaction, array('presend', 'predelete','preaffecttag'))) {
  72. $arrayofmassactions = array();
  73. }
  74. if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete', 'preaffecttag', 'preenable', 'preclose'))) {
  75. $arrayofmassactions = array();
  76. }
  77. // Mass actions
  78. $objectclass = 'Project';
  79. $objectlabel = 'Project';
  80. $uploaddir = $conf->societe->dir_output;
  81. include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
  82. $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
  83. /*
  84. * View
  85. */
  86. unset($_SESSION['pageforbacktolist']['project']);
  87. if ($socid) {
  88. require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
  89. require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
  90. $langs->load("companies");
  91. $result = $object->fetch($socid);
  92. $title = $langs->trans("Projects");
  93. if (getDolGlobalString('MAIN_HTML_TITLE') && preg_match('/thirdpartynameonly/', $conf->global->MAIN_HTML_TITLE) && $object->name) {
  94. $title = $object->name." - ".$title;
  95. }
  96. llxHeader('', $title);
  97. if (isModEnabled('notification')) {
  98. $langs->load("mails");
  99. }
  100. $head = societe_prepare_head($object);
  101. print dol_get_fiche_head($head, 'project', $langs->trans("ThirdParty"), -1, 'company');
  102. $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
  103. dol_banner_tab($object, 'socid', $linkback, ($user->socid ? 0 : 1), 'rowid', 'nom');
  104. print '<div class="fichecenter">';
  105. print '<div class="underbanner clearboth"></div>';
  106. print '<table class="border centpercent tableforfield">';
  107. // Type Prospect/Customer/Supplier
  108. print '<tr><td class="titlefield">'.$langs->trans('NatureOfThirdParty').'</td><td>';
  109. print $object->getTypeUrl(1);
  110. print '</td></tr>';
  111. if (getDolGlobalString('SOCIETE_USEPREFIX')) { // Old not used prefix field
  112. print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
  113. }
  114. if ($object->client) {
  115. print '<tr><td class="titlefield">';
  116. print $langs->trans('CustomerCode').'</td><td colspan="3">';
  117. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client));
  118. $tmpcheck = $object->check_codeclient();
  119. if ($tmpcheck != 0 && $tmpcheck != -5) {
  120. print ' <span class="error">('.$langs->trans("WrongCustomerCode").')</span>';
  121. }
  122. print '</td></tr>';
  123. }
  124. if ($object->fournisseur) {
  125. print '<tr><td class="titlefield">';
  126. print $langs->trans('SupplierCode').'</td><td colspan="3">';
  127. print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_fournisseur));
  128. $tmpcheck = $object->check_codefournisseur();
  129. if ($tmpcheck != 0 && $tmpcheck != -5) {
  130. print ' <span class="error">('.$langs->trans("WrongSupplierCode").')</span>';
  131. }
  132. print '</td></tr>';
  133. }
  134. print '</table>';
  135. print '</div>';
  136. print dol_get_fiche_end();
  137. print '<br>';
  138. $params = '';
  139. $backtopage = $_SERVER['PHP_SELF'].'?socid='.$object->id;
  140. $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);
  141. if (empty($conf->dol_optimize_smallscreen)) {
  142. print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'">';
  143. print '<input type="hidden" name="token" value="'.newToken().'">';
  144. print '<div class="nobordernopadding center valignmiddle col-center">'.$massactionbutton.'</div>';
  145. }
  146. // Projects list
  147. include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
  148. $arrayofselected = is_array($toselect) ? $toselect : array();
  149. $result = show_projects($conf, $langs, $db, $object, $_SERVER["PHP_SELF"].'?socid='.$object->id, 1, $newcardbutton);
  150. print '</form>';
  151. }
  152. // End of page
  153. llxFooter();
  154. $db->close();