ticket.php 5.5 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) 2012-2023 Charlene BENKE <charlene@patas-monkey.com>
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. /**
  20. * \file htdocs/contrat/ticket.php
  21. * \ingroup contrat
  22. * \brief Page of associated ticket
  23. */
  24. require '../main.inc.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 (isModEnabled('project')) {
  28. require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
  29. }
  30. require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
  31. require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
  32. require_once DOL_DOCUMENT_ROOT."/ticket/class/ticket.class.php";
  33. $langs->loadLangs(array('companies', 'contracts', 'tickets'));
  34. $socid=GETPOST('socid', 'int');
  35. $id=GETPOST('id', 'int');
  36. $ref=GETPOST('ref', 'alpha');
  37. $action=GETPOST('action', 'alpha');
  38. if ($id == '' && $ref == '') {
  39. dol_print_error('', 'Bad parameter');
  40. exit;
  41. }
  42. // Security check
  43. $socid=0;
  44. if ($user->socid > 0)
  45. $socid=$user->socid;
  46. $result=restrictedArea($user, 'contrat', $id);
  47. /*
  48. * View
  49. */
  50. llxHeader("", $langs->trans("Tickets"), "Contrat");
  51. $form = new Form($db);
  52. $userstatic=new User($db);
  53. $object= new Contrat($db);
  54. $result=$object->fetch($id, $ref);
  55. $ret=$object->fetch_thirdparty();
  56. $head = contract_prepare_head($object);
  57. dol_fiche_head($head, 'ticket', $langs->trans("Contract"), -1, 'contract');
  58. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid)?'?socid='.$socid:'').'">';
  59. $linkback.= $langs->trans("BackToList").'</a>';
  60. $morehtmlref='';
  61. $morehtmlref.=$object->ref;
  62. $morehtmlref.='<div class="refidno">';
  63. // Ref customer
  64. $morehtmlref.=$form->editfieldkey(
  65. "RefCustomer", 'ref_customer', $object->ref_customer,
  66. $object, 0, 'string', '', 0, 1
  67. );
  68. $morehtmlref.=$form->editfieldval(
  69. "RefCustomer", 'ref_customer', $object->ref_customer,
  70. $object, 0, 'string', '', null, null, '', 1
  71. );
  72. // Ref supplier
  73. $morehtmlref.='<br>';
  74. $morehtmlref.=$form->editfieldkey(
  75. "RefSupplier", 'ref_supplier', $object->ref_supplier,
  76. $object, 0, 'string', '', 0, 1
  77. );
  78. $morehtmlref.=$form->editfieldval(
  79. "RefSupplier", 'ref_supplier', $object->ref_supplier,
  80. $object, 0, 'string', '', null, null, '', 1
  81. );
  82. // Thirdparty
  83. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  84. // Project
  85. if (! empty($conf->projet->enabled)) {
  86. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  87. $langs->load("projects");
  88. $morehtmlref.='<br>'.$langs->trans('Project') . ' : ';
  89. if (! empty($object->fk_project)) {
  90. $proj = new Project($db);
  91. $proj->fetch($object->fk_project);
  92. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=';
  93. $morehtmlref.=$object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  94. $morehtmlref.=$proj->ref;
  95. $morehtmlref.='</a>';
  96. } else {
  97. $morehtmlref.='';
  98. }
  99. }
  100. $morehtmlref.='</div>';
  101. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
  102. print '<div class="underbanner clearboth"></div>';
  103. /*
  104. * Referers types
  105. */
  106. $title=$langs->trans("ListTicketsLinkToContract");
  107. print '<table class="noborder" width="100%">';
  108. print '<tr class="liste_titre">';
  109. print '<td >'.$langs->trans("Ref").'</td>';
  110. print '<td width="300">'.$langs->trans("Subject").'</td>';
  111. print '<td align="left">'.$langs->trans("Type").'</td>';
  112. print '<td align="left" nowrap >'.$langs->trans("TicketCategory").'</td>';
  113. print '<td align="left">'.$langs->trans("Severity").'</td>';
  114. print '<td align="center">'.$langs->trans("Date").'</td>';
  115. print '<td align="center" nowrap >'.$langs->trans("DateEnd").'</td>';
  116. print '<td align="right">'.$langs->trans("Progress").'</td>';
  117. print '<td align="right" width="100">'.$langs->trans("Status").'</td>';
  118. print '</tr>';
  119. // on récupère la totalité des tickets liés au contrat
  120. $allticketarray = $object->getTicketsArray();
  121. if (is_array($allticketarray) && count($allticketarray) > 0) {
  122. foreach ($allticketarray as $key => $value) {
  123. $total_ht = 0;
  124. $total_ttc = 0;
  125. $element = $value;
  126. print "<tr>";
  127. // Ref
  128. print '<td align="left">';
  129. print $element->getNomUrl(1);
  130. print "</td>\n";
  131. // Information
  132. print '<td align="left">'.$value->subject.'</td>';
  133. print '<td align="left">'.$value->type_label.'</td>';
  134. print '<td align="left">'.$value->category_label.'</td>';
  135. print '<td align="left">'.$value->severity_label.'</td>';
  136. // Date
  137. print '<td align="center">'.dol_print_date($element->datec, 'day').'</td>';
  138. print '<td align="center">'.dol_print_date($element->date_close, 'day').'</td>';
  139. // Duration
  140. print '<td align="right">';
  141. print (isset($element->progress) ? $element->progress.'%' : '');
  142. print '</td>';
  143. // Status
  144. print '<td align="right">'.$element->getLibStatut(5).'</td>';
  145. print '</tr>';
  146. }
  147. }
  148. print "</table>";
  149. llxFooter();
  150. $db->close();