note.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. require '../main.inc.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
  27. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  28. if (!empty($conf->project->enabled)) {
  29. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  30. }
  31. // Load translation files required by the page
  32. $langs->loadLangs(array('companies', 'contracts'));
  33. $action = GETPOST('action', 'aZ09');
  34. $confirm = GETPOST('confirm', 'alpha');
  35. $socid = GETPOST('socid', 'int');
  36. $id = GETPOST('id', 'int');
  37. $ref = GETPOST('ref', 'alpha');
  38. // Security check
  39. if ($user->socid) {
  40. $socid = $user->socid;
  41. }
  42. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  43. //$hookmanager->initHooks(array('contractcard', 'globalcard')); -> Conflict with contrat\card.php
  44. $hookmanager->initHooks(array('contractnote'));
  45. $result = restrictedArea($user, 'contrat', $id);
  46. $object = new Contrat($db);
  47. $object->fetch($id, $ref);
  48. $permissionnote = $user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
  49. /*
  50. * Actions
  51. */
  52. $reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
  53. if ($reshook < 0) {
  54. setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
  55. }
  56. if (empty($reshook)) {
  57. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
  58. }
  59. /*
  60. * View
  61. */
  62. llxHeader('', $langs->trans("Contract"), "");
  63. $form = new Form($db);
  64. if ($id > 0 || !empty($ref)) {
  65. $object->fetch_thirdparty();
  66. $head = contract_prepare_head($object);
  67. $hselected = 2;
  68. print dol_get_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
  69. // Contract card
  70. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
  71. $morehtmlref = '';
  72. //if (! empty($modCodeContract->code_auto)) {
  73. $morehtmlref .= $object->ref;
  74. /*} else {
  75. $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
  76. $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
  77. }*/
  78. $morehtmlref .= '<div class="refidno">';
  79. // Ref customer
  80. $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
  81. $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1, 'getFormatedCustomerRef');
  82. // Ref supplier
  83. $morehtmlref .= '<br>';
  84. $morehtmlref .= $form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  85. $morehtmlref .= $form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1, 'getFormatedSupplierRef');
  86. // Thirdparty
  87. $morehtmlref .= '<br>'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1);
  88. // Project
  89. if (!empty($conf->project->enabled)) {
  90. $langs->load("projects");
  91. $morehtmlref .= '<br>'.$langs->trans('Project').' ';
  92. if ($user->rights->contrat->creer) {
  93. if ($action != 'classify') {
  94. //$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&token='.newToken().'&id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  95. $morehtmlref .= ' : ';
  96. }
  97. if ($action == 'classify') {
  98. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  99. $morehtmlref .= '<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  100. $morehtmlref .= '<input type="hidden" name="action" value="classin">';
  101. $morehtmlref .= '<input type="hidden" name="token" value="'.newToken().'">';
  102. $morehtmlref .= $formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  103. $morehtmlref .= '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  104. $morehtmlref .= '</form>';
  105. } else {
  106. $morehtmlref .= $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
  107. }
  108. } else {
  109. if (!empty($object->fk_project)) {
  110. $proj = new Project($db);
  111. $proj->fetch($object->fk_project);
  112. $morehtmlref .= ' : '.$proj->getNomUrl(1);
  113. if ($proj->title) {
  114. $morehtmlref .= ' - '.$proj->title;
  115. }
  116. } else {
  117. $morehtmlref .= '';
  118. }
  119. }
  120. }
  121. $morehtmlref .= '</div>';
  122. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
  123. print '<div class="fichecenter">';
  124. print '<div class="underbanner clearboth"></div>';
  125. print '<table class="border centpercent tableforfield">';
  126. // Ligne info remises tiers
  127. print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
  128. if ($object->thirdparty->remise_percent) {
  129. print $langs->trans("CompanyHasRelativeDiscount", $object->thirdparty->remise_percent);
  130. } else {
  131. print $langs->trans("CompanyHasNoRelativeDiscount");
  132. }
  133. $absolute_discount = $object->thirdparty->getAvailableDiscounts();
  134. print '. ';
  135. if ($absolute_discount) {
  136. print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->trans("Currency".$conf->currency));
  137. } else {
  138. print $langs->trans("CompanyHasNoAbsoluteDiscount");
  139. }
  140. print '.';
  141. print '</td></tr>';
  142. // Date
  143. print '<tr>';
  144. print '<td class="titlefield">';
  145. print $form->editfieldkey("Date", 'date_contrat', $object->date_contrat, $object, 0);
  146. print '</td><td>';
  147. print $form->editfieldval("Date", 'date_contrat', $object->date_contrat, $object, 0, 'datehourpicker');
  148. print '</td>';
  149. print '</tr>';
  150. print "</table>";
  151. print '</div>';
  152. //print '<br>';
  153. $cssclass='titlefield';
  154. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  155. print dol_get_fiche_end();
  156. }
  157. llxFooter();
  158. $db->close();