info.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. /* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  3. * Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/contrat/info.php
  20. * \ingroup contrat
  21. * \brief Page des informations d'un contrat
  22. */
  23. require "../main.inc.php";
  24. require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
  25. require_once DOL_DOCUMENT_ROOT.'/core/lib/contract.lib.php';
  26. require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
  27. if (! empty($conf->projet->enabled)) {
  28. require_once DOL_DOCUMENT_ROOT . '/projet/class/project.class.php';
  29. }
  30. // Load translation files required by the page
  31. $langs->load("contracts");
  32. $action = GETPOST('action','alpha');
  33. $confirm = GETPOST('confirm','alpha');
  34. $id = GETPOST('id','int');
  35. $ref = GETPOST('ref','alpha');
  36. // Security check
  37. if ($user->societe_id) $socid=$user->societe_id;
  38. $result = restrictedArea($user, 'contrat', $id, '');
  39. // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
  40. $hookmanager->initHooks(array('contractcard','globalcard'));
  41. /*
  42. * Actions
  43. */
  44. // None
  45. /*
  46. * View
  47. */
  48. $form = new Form($db);
  49. llxHeader('',$langs->trans("Contract"),"");
  50. $object = new Contrat($db);
  51. $object->fetch($id, $ref);
  52. if ($object->id > 0)
  53. {
  54. $object->fetch_thirdparty();
  55. }
  56. $object->info($object->id);
  57. $head = contract_prepare_head($object);
  58. dol_fiche_head($head, 'info', $langs->trans("Contract"), -1, 'contract');
  59. // Contract card
  60. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php?restore_lastsearch_values=1'.(! empty($socid)?'&socid='.$socid:'').'">'.$langs->trans("BackToList").'</a>';
  61. $morehtmlref='';
  62. //if (! empty($modCodeContract->code_auto)) {
  63. $morehtmlref.=$object->ref;
  64. /*} else {
  65. $morehtmlref.=$form->editfieldkey("",'ref',$object->ref,0,'string','',0,3);
  66. $morehtmlref.=$form->editfieldval("",'ref',$object->ref,0,'string','',0,2);
  67. }*/
  68. $morehtmlref.='<div class="refidno">';
  69. // Ref customer
  70. $morehtmlref.=$form->editfieldkey("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', 0, 1);
  71. $morehtmlref.=$form->editfieldval("RefCustomer", 'ref_customer', $object->ref_customer, $object, 0, 'string', '', null, null, '', 1);
  72. // Ref supplier
  73. $morehtmlref.='<br>';
  74. $morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1);
  75. $morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1);
  76. // Thirdparty
  77. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  78. // Project
  79. if (! empty($conf->projet->enabled))
  80. {
  81. $langs->load("projects");
  82. $morehtmlref.='<br>'.$langs->trans('Project') . ' ';
  83. if ($user->rights->contrat->creer)
  84. {
  85. if ($action != 'classify')
  86. //$morehtmlref.='<a href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
  87. $morehtmlref.=' : ';
  88. if ($action == 'classify') {
  89. //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
  90. $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
  91. $morehtmlref.='<input type="hidden" name="action" value="classin">';
  92. $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
  93. $morehtmlref.=$formproject->select_projects($object->thirdparty->id, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
  94. $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
  95. $morehtmlref.='</form>';
  96. } else {
  97. $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->thirdparty->id, $object->fk_project, 'none', 0, 0, 0, 1);
  98. }
  99. } else {
  100. if (! empty($object->fk_project)) {
  101. $proj = new Project($db);
  102. $proj->fetch($object->fk_project);
  103. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=' . $object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  104. $morehtmlref.=$proj->ref;
  105. $morehtmlref.='</a>';
  106. } else {
  107. $morehtmlref.='';
  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 '<br>';
  116. print '<table width="100%"><tr><td>';
  117. dol_print_object_info($object);
  118. print '</td></tr></table>';
  119. print '</div>';
  120. dol_fiche_end();
  121. llxFooter();
  122. $db->close();