ticket.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. }
  47. $result=restrictedArea($user, 'contrat', $id);
  48. /*
  49. * View
  50. */
  51. llxHeader("", $langs->trans("Tickets"), "Contrat");
  52. $form = new Form($db);
  53. $userstatic=new User($db);
  54. $object= new Contrat($db);
  55. $result=$object->fetch($id, $ref);
  56. $ret=$object->fetch_thirdparty();
  57. $head = contract_prepare_head($object);
  58. dol_fiche_head($head, 'ticket', $langs->trans("Contract"), -1, 'contract');
  59. $linkback = '<a href="'.DOL_URL_ROOT.'/contrat/list.php'.(! empty($socid) ? '?socid='.$socid : '').'">';
  60. $linkback.= $langs->trans("BackToList").'</a>';
  61. $morehtmlref='';
  62. $morehtmlref.=$object->ref;
  63. $morehtmlref.='<div class="refidno">';
  64. // Ref customer
  65. $morehtmlref.=$form->editfieldkey(
  66. "RefCustomer",
  67. 'ref_customer',
  68. $object->ref_customer,
  69. $object,
  70. 0,
  71. 'string',
  72. '',
  73. 0,
  74. 1
  75. );
  76. $morehtmlref.=$form->editfieldval(
  77. "RefCustomer",
  78. 'ref_customer',
  79. $object->ref_customer,
  80. $object,
  81. 0,
  82. 'string',
  83. '',
  84. null,
  85. null,
  86. '',
  87. 1
  88. );
  89. // Ref supplier
  90. $morehtmlref.='<br>';
  91. $morehtmlref.=$form->editfieldkey(
  92. "RefSupplier",
  93. 'ref_supplier',
  94. $object->ref_supplier,
  95. $object,
  96. 0,
  97. 'string',
  98. '',
  99. 0,
  100. 1
  101. );
  102. $morehtmlref.=$form->editfieldval(
  103. "RefSupplier",
  104. 'ref_supplier',
  105. $object->ref_supplier,
  106. $object,
  107. 0,
  108. 'string',
  109. '',
  110. null,
  111. null,
  112. '',
  113. 1
  114. );
  115. // Thirdparty
  116. $morehtmlref.='<br>'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1);
  117. // Project
  118. if (! empty($conf->projet->enabled)) {
  119. require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
  120. $langs->load("projects");
  121. $morehtmlref.='<br>'.$langs->trans('Project') . ' : ';
  122. if (! empty($object->fk_project)) {
  123. $proj = new Project($db);
  124. $proj->fetch($object->fk_project);
  125. $morehtmlref.='<a href="'.DOL_URL_ROOT.'/projet/card.php?id=';
  126. $morehtmlref.=$object->fk_project . '" title="' . $langs->trans('ShowProject') . '">';
  127. $morehtmlref.=$proj->ref;
  128. $morehtmlref.='</a>';
  129. } else {
  130. $morehtmlref.='';
  131. }
  132. }
  133. $morehtmlref.='</div>';
  134. dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'none', $morehtmlref);
  135. print '<div class="underbanner clearboth"></div>';
  136. /*
  137. * Referers types
  138. */
  139. $title=$langs->trans("ListTicketsLinkToContract");
  140. print '<table class="noborder" width="100%">';
  141. print '<tr class="liste_titre">';
  142. print '<td >'.$langs->trans("Ref").'</td>';
  143. print '<td width="300">'.$langs->trans("Subject").'</td>';
  144. print '<td align="left">'.$langs->trans("Type").'</td>';
  145. print '<td align="left" nowrap >'.$langs->trans("TicketCategory").'</td>';
  146. print '<td align="left">'.$langs->trans("Severity").'</td>';
  147. print '<td align="center">'.$langs->trans("Date").'</td>';
  148. print '<td align="center" nowrap >'.$langs->trans("DateEnd").'</td>';
  149. print '<td align="right">'.$langs->trans("Progress").'</td>';
  150. print '<td align="right" width="100">'.$langs->trans("Status").'</td>';
  151. print '</tr>';
  152. // on récupère la totalité des tickets liés au contrat
  153. $allticketarray = $object->getTicketsArray();
  154. if (is_array($allticketarray) && count($allticketarray) > 0) {
  155. foreach ($allticketarray as $key => $value) {
  156. $total_ht = 0;
  157. $total_ttc = 0;
  158. $element = $value;
  159. print "<tr>";
  160. // Ref
  161. print '<td align="left">';
  162. print $element->getNomUrl(1);
  163. print "</td>\n";
  164. // Information
  165. print '<td align="left">'.$value->subject.'</td>';
  166. print '<td align="left">'.$value->type_label.'</td>';
  167. print '<td align="left">'.$value->category_label.'</td>';
  168. print '<td align="left">'.$value->severity_label.'</td>';
  169. // Date
  170. print '<td align="center">'.dol_print_date($element->datec, 'day').'</td>';
  171. print '<td align="center">'.dol_print_date($element->date_close, 'day').'</td>';
  172. // Duration
  173. print '<td align="right">';
  174. print(isset($element->progress) ? $element->progress.'%' : '');
  175. print '</td>';
  176. // Status
  177. print '<td align="right">'.$element->getLibStatut(5).'</td>';
  178. print '</tr>';
  179. }
  180. }
  181. print "</table>";
  182. llxFooter();
  183. $db->close();