PageRenderTime 42ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/compta/prelevement/bon.php

https://github.com/asterix14/dolibarr
PHP | 101 lines | 57 code | 20 blank | 24 comment | 9 complexity | f0f6ef12ecc2f1c8af06dd9c60e3ff35 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <?PHP
  2. /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2005 Laurent Destailleur <eldy@users.sourceforge.net>
  4. * Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
  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 2 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/compta/prelevement/bon.php
  21. * \ingroup prelevement
  22. * \brief Fiche apercu du bon de prelevement
  23. */
  24. require("../bank/pre.inc.php");
  25. require_once(DOL_DOCUMENT_ROOT."/core/lib/prelevement.lib.php");
  26. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  27. require_once DOL_DOCUMENT_ROOT."/compta/prelevement/class/bon-prelevement.class.php";
  28. $langs->load("bills");
  29. $langs->load("categories");
  30. // Security check
  31. $socid=0;
  32. $id = GETPOST("id");
  33. $ref = GETPOST("ref");
  34. if ($user->societe_id) $socid=$user->societe_id;
  35. $result = restrictedArea($user, 'prelevement', $id);
  36. llxHeader('','Bon de prelevement');
  37. $form = new Form($db);
  38. if ($id > 0 || ! empty($ref))
  39. {
  40. $object = new BonPrelevement($db,"");
  41. if ($object->fetch($id) == 0)
  42. {
  43. $head = prelevement_prepare_head($object);
  44. dol_fiche_head($head, 'preview', 'Prelevement : '. $object->ref);
  45. print '<table class="border" width="100%">';
  46. print '<tr><td width="20%">'.$langs->trans("Ref").'</td><td>'.$object->ref.'</td></tr>';
  47. print '<tr><td width="20%">'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
  48. print '<tr><td width="20%">'.$langs->trans("File").'</td><td>';
  49. $relativepath = 'bon/'.$object->ref;
  50. print '<a href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$object->ref.'</a>';
  51. print '</td></tr>';
  52. print '</table><br>';
  53. $fileimage = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps.png.0';
  54. $fileps = $conf->prelevement->dir_output.'/receipts/'.$object->ref.'.ps';
  55. // Conversion du PDF en image png si fichier png non existant
  56. if (!file_exists($fileimage))
  57. {
  58. if (class_exists("Imagick"))
  59. {
  60. $ret = dol_convert_file($file);
  61. if ($ret < 0) $error++;
  62. }
  63. else
  64. {
  65. $langs->load("errors");
  66. print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
  67. }
  68. }
  69. if (file_exists($fileimage))
  70. {
  71. print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=prelevement&file='.urlencode(basename($fileimage)).'">';
  72. }
  73. }
  74. else
  75. {
  76. dol_print_error($db);
  77. }
  78. }
  79. print "</div>";
  80. llxFooter();
  81. ?>