note.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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@capnetworks.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 <http://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->projet->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','alpha');
  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->societe_id) $socid=$user->societe_id;
  40. $result=restrictedArea($user,'contrat',$id);
  41. $object = new Contrat($db);
  42. $object->fetch($id,$ref);
  43. $permissionnote=$user->rights->contrat->creer; // Used by the include of actions_setnotes.inc.php
  44. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  45. $hookmanager->initHooks(array('contractcard','globalcard'));
  46. /*
  47. * Actions
  48. */
  49. include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not includ_once
  50. /*
  51. * View
  52. */
  53. llxHeader('',$langs->trans("Contract"),"");
  54. $form = new Form($db);
  55. if ($id > 0 || ! empty($ref))
  56. {
  57. $object->fetch_thirdparty();
  58. $head = contract_prepare_head($object);
  59. $hselected = 2;
  60. dol_fiche_head($head, 'note', $langs->trans("Contract"), -1, 'contract');
  61. // Contract card
  62. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  63. $morehtmlref='';
  64. //if (! empty($modCodeContract->code_auto)) {
  65. $morehtmlref.=$object->ref;
  66. /*} else {
  67. $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
  68. $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
  69. }*/
  70. $morehtmlref.='<div class="refidno">';
  71. // Ref customer
  72. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
  73. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
  74. // Ref supplier
  75. $morehtmlref.='<br>';
  76. $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  77. $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  78. // Thirdparty
  79. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  80. // Project
  81. if (! empty($conf->projet->enabled))
  82. {
  83. $langs->load("projects");
  84. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  85. if ($user->rights->contrat->creer)
  86. {
  87. if ($action != 'classify')
  88. //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  89. $morehtmlref.=' : ';
  90. if ($action == 'classify') {
  91. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  92. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  93. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  94. $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  95. $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  96. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  97. $morehtmlref.='</form>';
  98. } else {
  99. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
  100. }
  101. } else {
  102. if (! empty($object->fk_project)) {
  103. $proj = new Project($db);
  104. $proj->fetch($object->fk_project);
  105. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  106. $morehtmlref.=$proj->ref;
  107. $morehtmlref.='</a>';
  108. } else {
  109. $morehtmlref.='';
  110. }
  111. }
  112. }
  113. $morehtmlref.='</div>';
  114. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
  115. print '<div class="fichecenter">';
  116. print '<div class="underbanner clearboth"></div>';
  117. print '<table class="border" width="100%">';
  118. // Ligne info remises tiers
  119. print '<tr><td class="titlefield">'.$langs->trans('Discount').'</td><td colspan="3">';
  120. if ($object->thirdparty->remise_percent) print $langs->trans("CompanyHasRelativeDiscount",$object->thirdparty->remise_percent);
  121. else print $langs->trans("CompanyHasNoRelativeDiscount");
  122. $absolute_discount=$object->thirdparty->getAvailableDiscounts();
  123. print '. ';
  124. if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency));
  125. else print $langs->trans("CompanyHasNoAbsoluteDiscount");
  126. print '.';
  127. print '</td></tr>';
  128. // Date
  129. print '<tr>';
  130. print '<td class="titlefield">';
  131. print $form->editfieldkey("Date",'date_contrat',$object->date_contrat,$object,0);
  132. print '</td><td>';
  133. print $form->editfieldval("Date",'date_contrat',$object->date_contrat,$object,0,'datehourpicker');
  134. print '</td>';
  135. print '</tr>';
  136. print "</table>";
  137. print '</div>';
  138. //print '<br>';
  139. include DOL_DOCUMENT_ROOT.'/core/tpl/notes.tpl.php';
  140. dol_fiche_end();
  141. }
  142. llxFooter();
  143. $db->close();