PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/fichinter/apercu.php

https://github.com/asterix14/dolibarr
PHP | 190 lines | 124 code | 26 blank | 40 comment | 10 complexity | 9f389b4f91ac906961c0965db765709a MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?php
  2. /* Copyright (C) 2002-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
  5. * Copyright (C) 2011 Juanjo Menent <jmenent@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 2 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/fichinter/apercu.php
  22. * \ingroup fichinter
  23. * \brief Page de l'onglet apercu d'une fiche d'intervention
  24. */
  25. require("../main.inc.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/fichinter.lib.php");
  27. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  28. require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php');
  29. if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  30. $langs->load('interventions');
  31. // Security check
  32. $socid=0;
  33. $id = GETPOST("id");
  34. $ref = GETPOST("ref");
  35. if ($user->societe_id) $socid=$user->societe_id;
  36. $result = restrictedArea($user, 'ficheinter', $id, 'fichinter');
  37. llxHeader();
  38. $form = new Form($db);
  39. /* *************************************************************************** */
  40. /* */
  41. /* Mode fiche */
  42. /* */
  43. /* *************************************************************************** */
  44. if ($id > 0 || ! empty($ref))
  45. {
  46. $object = new Fichinter($db);
  47. if ($object->fetch($id,$ref) > 0)
  48. {
  49. $soc = new Societe($db);
  50. $soc->fetch($object->socid);
  51. $head = fichinter_prepare_head($object);
  52. dol_fiche_head($head, 'preview', $langs->trans("InterventionCard"), 0, 'intervention');
  53. /*
  54. * Fiche intervention
  55. */
  56. print '<table class="border" width="100%">';
  57. // Ref
  58. print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
  59. print '<td colspan="2">'.$object->ref.'</td>';
  60. $nbrow=4;
  61. print '<td rowspan="'.$nbrow.'" valign="top" width="50%">';
  62. /*
  63. * Documents
  64. */
  65. $objectref = dol_sanitizeFileName($object->ref);
  66. $dir_output = $conf->ficheinter->dir_output . "/";
  67. $filepath = $dir_output . $objectref . "/";
  68. $file = $filepath . $objectref . ".pdf";
  69. $filedetail = $filepath . $objectref . "-detail.pdf";
  70. $relativepath = "${objectref}/${objectref}.pdf";
  71. $relativepathdetail = "${objectref}/${objectref}-detail.pdf";
  72. // Chemin vers png apercus
  73. $fileimage = $file.".png"; // Si PDF d'1 page
  74. $fileimagebis = $file."-0.png"; // Si PDF de plus d'1 page
  75. $var=true;
  76. // Si fichier PDF existe
  77. if (file_exists($file))
  78. {
  79. $encfile = urlencode($file);
  80. print_titre($langs->trans("Documents"));
  81. print '<table class="border" width="100%">';
  82. print "<tr $bc[$var]><td>".$langs->trans("Intervention")." PDF</td>";
  83. print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
  84. print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
  85. print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
  86. print '</tr>';
  87. // Si fichier detail PDF existe
  88. if (file_exists($filedetail))
  89. {
  90. print "<tr $bc[$var]><td>Fiche d'intervention detaillee</td>";
  91. print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=ficheinter&file='.urlencode($relativepathdetail).'">'.$object->ref.'-detail.pdf</a></td>';
  92. print '<td align="right">'.dol_print_size(dol_filesize($filedetail)).'</td>';
  93. print '<td align="right">'.dol_print_date(dol_filemtime($filedetail),'dayhour').'</td>';
  94. print '</tr>';
  95. }
  96. print "</table>\n";
  97. // Conversion du PDF en image png si fichier png non existant
  98. if (! file_exists($fileimage) && ! file_exists($fileimagebis))
  99. {
  100. if (class_exists("Imagick"))
  101. {
  102. $ret = dol_convert_file($file);
  103. if ($ret < 0) $error++;
  104. }
  105. else
  106. {
  107. $langs->load("errors");
  108. print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
  109. }
  110. }
  111. }
  112. print "</td></tr>";
  113. // Client
  114. print "<tr><td>".$langs->trans("Customer")."</td>";
  115. print '<td colspan="2">';
  116. print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
  117. print '</td>';
  118. print '</tr>';
  119. // Statut
  120. print '<tr><td>'.$langs->trans("Status").'</td>';
  121. print "<td colspan=\"2\">".$object->getLibStatut(4)."</td>\n";
  122. print '</tr>';
  123. // Date
  124. print '<tr><td>'.$langs->trans("Date").'</td>';
  125. print "<td colspan=\"2\">".dol_print_date($object->date,"daytext")."</td>\n";
  126. print '</tr>';
  127. print '</table>';
  128. }
  129. else
  130. {
  131. // Object not found
  132. print $langs->trans("ErrorFichinterNotFound",$id);
  133. }
  134. }
  135. // Si fichier png PDF d'1 page trouve
  136. if (file_exists($fileimage))
  137. {
  138. print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufichinter&file='.urlencode($relativepathimage).'">';
  139. }
  140. // Si fichier png PDF de plus d'1 page trouve
  141. elseif (file_exists($fileimagebis))
  142. {
  143. $multiple = $relativepath . "-";
  144. for ($i = 0; $i < 20; $i++)
  145. {
  146. $preview = $multiple.$i.'.png';
  147. if (file_exists($dir_output.$preview))
  148. {
  149. print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercufichinter&file='.urlencode($preview).'"><p>';
  150. }
  151. }
  152. }
  153. print '</div>';
  154. $db->close();
  155. llxFooter();
  156. ?>