note.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php
  2. /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
  5. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  19. */
  20. /**
  21. * \file htdocs/contrat/note.php
  22. * \ingroup contrat
  23. * \brief Fiche de notes sur un contrat
  24. */
  25. // Load Dolibarr environment
  26. require '../main.inc.php';
  27. require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
  28. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  29. if (isModEnabled('project')) {
  30. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  31. }
  32. // Load translation files required by the page
  33. $langs->loadLangs(array('companies', 'contracts'));
  34. $action = GETPOST('action', 'aZ09');
  35. $confirm = GETPOST('confirm', 'alpha');
  36. $socid = GETPOST('socid', 'int');
  37. $id = GETPOST('id', 'int');
  38. $ref = GETPOST('ref', 'alpha');
  39. // Security check
  40. if ($user->socid) {
  41. $socid = $user->socid;
  42. }
  43. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  44. //$hookmanager->initHooks(array('contractcard', 'globalcard')); -> Conflict with contrat\card.php
  45. $hookmanager->initHooks(array('contractnote'));
  46. $result = restrictedArea($user, 'contrat', $id);
  47. $object = new Contrat($db);
  48. $object->fetch($id, $ref);
  49. $permissiontoadd = $user->hasRight('contrat', 'creer'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
  50. $permissionnote = $user->hasRight('contrat', 'creer'); // Used by the include of actions_setnotes.inc.php
  51. /*
  52. * Actions
  53. */
  54. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  55. if ($reshook < 0) {
  56. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  57. }
  58. if (empty($reshook)) {
  59. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  60. }
  61. /*
  62. * View
  63. */
  64. llxHeader('', $langs->trans("Contract"), "");
  65. $form = new Form($db);
  66. if ($id > 0 || !empty($ref)) {
  67. $object->fetch_thirdparty();
  68. $head = contract_prepare_head($object);
  69. $hselected = 2;
  70. print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
  71. // Contract card
  72. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  73. $morehtmlref = '';
  74. //if (!empty($modCodeContract->code_auto)) {
  75. $morehtmlref .= $object->ref;
  76. /*} else {
  77. $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
  78. $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
  79. }*/
  80. $morehtmlref .= '<div class="refidno">';
  81. // Ref customer
  82. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
  83. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
  84. // Ref supplier
  85. $morehtmlref .= '<br>';
  86. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  87. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
  88. // Thirdparty
  89. $morehtmlref .= '<br>'.$object->thirdparty->getNomUrl(1);
  90. // Project
  91. if (isModEnabled('project')) {
  92. $langs->load("projects");
  93. $morehtmlref .= '<br>';
  94. if (0) {
  95. $morehtmlref .= img_picto($langs->trans("Project"), 'project', 'class="pictofixedwidth"');
  96. if ($action != 'classify') {
  97. $morehtmlref .= '<a class="editfielda" href="'.$_SERVER['PHP_SELF'].'?action=classify&token='.newToken().'&id='.$object->id.'">'.img_edit($langs->transnoentitiesnoconv('SetProject')).'</a> ';
  98. }
  99. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, ($action == 'classify' ? 'projectid' : 'none'), 0, 0, 0, 1, '', 'maxwidth300');
  100. } else {
  101. if (!empty($object->fk_project)) {
  102. $proj = new Project($db);
  103. $proj->fetch($object->fk_project);
  104. $morehtmlref .= $proj->getNomUrl(1);
  105. if ($proj->title) {
  106. $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
  107. }
  108. }
  109. }
  110. }
  111. $morehtmlref .= '</div>';
  112. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
  113. print '<div class="fichecenter">';
  114. print '<div class="underbanner clearboth"></div>';
  115. print '<table class="border centpercent tableforfield">';
  116. // Ligne info remises tiers
  117. print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
  118. if ($object->thirdparty->remise_percent) {
  119. print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
  120. } else {
  121. print $langs->trans("CompanyHasNoRelativeDiscount");
  122. }
  123. $absolute_discount = $object->thirdparty->getAvailableDiscounts();
  124. print '. ';
  125. if ($absolute_discount) {
  126. print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency));
  127. } else {
  128. print $langs->trans("CompanyHasNoAbsoluteDiscount");
  129. }
  130. print '.';
  131. print '</td></tr>';
  132. // Date
  133. print '<tr>';
  134. print '<td class="titlefield">';
  135. print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0);
  136. print '</td><td>';
  137. print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker');
  138. print '</td>';
  139. print '</tr>';
  140. print "</table>";
  141. print '</div>';
  142. //print '<br>';
  143. $cssclass='titlefield';
  144. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  145. print dol_get_fiche_end();
  146. }
  147. llxFooter();
  148. $db->close();