PageRenderTime 1312ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/htdocs/comm/propal/apercu.php

https://github.com/asterix14/dolibarr
PHP | 210 lines | 120 code | 38 blank | 52 comment | 17 complexity | 635fbdeed015493486a2781f820efda9 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 Eric Seigne <eric.seigne@ryxeo.com>
  4. * Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
  6. * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. /**
  22. * \file htdocs/comm/propal/apercu.php
  23. * \ingroup propal
  24. * \brief Page de l'onglet apercu d'une propal
  25. */
  26. require("../../main.inc.php");
  27. require_once(DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php');
  28. require_once(DOL_DOCUMENT_ROOT."/core/lib/propal.lib.php");
  29. require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
  30. if ($conf->projet->enabled) require_once(DOL_DOCUMENT_ROOT."/projet/class/project.class.php");
  31. $langs->load('propal');
  32. $langs->load("bills");
  33. $langs->load('compta');
  34. // Security check
  35. $socid=0;
  36. $id = GETPOST("id");
  37. $ref = GETPOST("ref");
  38. if ($user->societe_id) $socid=$user->societe_id;
  39. $result = restrictedArea($user, 'propale', $id, 'propal');
  40. /*
  41. * View
  42. */
  43. llxHeader();
  44. $form = new Form($db);
  45. /* *************************************************************************** */
  46. /* */
  47. /* Mode fiche */
  48. /* */
  49. /* *************************************************************************** */
  50. if ($id > 0 || ! empty($ref))
  51. {
  52. $object = new Propal($db);
  53. if ($object->fetch($id,$ref) > 0)
  54. {
  55. $soc = new Societe($db);
  56. $soc->fetch($object->socid);
  57. $head = propal_prepare_head($object);
  58. dol_fiche_head($head, 'preview', $langs->trans('Proposal'), 0, 'propal');
  59. /*
  60. * Propal
  61. */
  62. print '<table class="border" width="100%">';
  63. // Ref
  64. print '<tr><td width="25%">'.$langs->trans('Ref').'</td><td colspan="5">'.$object->ref.'</td></tr>';
  65. // Ref client
  66. print '<tr><td>';
  67. print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
  68. print $langs->trans('RefCustomer').'</td><td align="left">';
  69. print '</td>';
  70. print '</tr></table>';
  71. print '</td><td colspan="5">';
  72. print $object->ref_client;
  73. print '</td>';
  74. print '</tr>';
  75. $rowspan=2;
  76. // Tiers
  77. print '<tr><td>'.$langs->trans('Company').'</td><td colspan="5">'.$soc->getNomUrl(1).'</td>';
  78. print '</tr>';
  79. // Ligne info remises tiers
  80. print '<tr><td>'.$langs->trans('Discounts').'</td><td colspan="5">';
  81. if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client);
  82. else print $langs->trans("CompanyHasNoRelativeDiscount");
  83. $absolute_discount=$soc->getAvailableDiscounts();
  84. print '. ';
  85. if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
  86. else print $langs->trans("CompanyHasNoAbsoluteDiscount");
  87. print '.';
  88. print '</td></tr>';
  89. // ligne
  90. // partie Gauche
  91. print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
  92. print dol_print_date($object->date,'daytext');
  93. print '</td>';
  94. // partie Droite sur $rowspan lignes
  95. print '<td colspan="2" rowspan="'.$rowspan.'" valign="top" width="50%">';
  96. /*
  97. * Documents
  98. */
  99. $objectref = dol_sanitizeFileName($object->ref);
  100. $dir_output = $conf->propale->dir_output . "/";
  101. $filepath = $dir_output . $objectref . "/";
  102. $file = $filepath . $objectref . ".pdf";
  103. $filedetail = $filepath . $objectref . "-detail.pdf";
  104. $relativepath = $objectref.'/'.$objectref.'.pdf';
  105. $relativepathdetail = $objectref.'/'.$objectref.'-detail.pdf';
  106. // Chemin vers png apercus
  107. $fileimage = $file.".png"; // Si PDF d'1 page
  108. $fileimagebis = $file."-0.png"; // Si PDF de plus d'1 page
  109. $relativepathimage = $relativepath.'.png';
  110. $var=true;
  111. // Si fichier PDF existe
  112. if (file_exists($file))
  113. {
  114. $encfile = urlencode($file);
  115. print_titre($langs->trans("Documents"));
  116. print '<table class="border" width="100%">';
  117. print "<tr $bc[$var]><td>".$langs->trans("Propal")." PDF</td>";
  118. print '<td><a href="'.DOL_URL_ROOT . '/document.php?modulepart=propal&file='.urlencode($relativepath).'">'.$object->ref.'.pdf</a></td>';
  119. print '<td align="right">'.dol_print_size(dol_filesize($file)).'</td>';
  120. print '<td align="right">'.dol_print_date(dol_filemtime($file),'dayhour').'</td>';
  121. print '</tr>';
  122. print "</table>\n";
  123. // Conversion du PDF en image png si fichier png non existant
  124. if (! file_exists($fileimage) && ! file_exists($fileimagebis))
  125. {
  126. if (class_exists("Imagick"))
  127. {
  128. $ret = dol_convert_file($file);
  129. if ($ret < 0) $error++;
  130. }
  131. else
  132. {
  133. $langs->load("errors");
  134. print '<font class="error">'.$langs->trans("ErrorNoImagickReadimage").'</font>';
  135. }
  136. }
  137. }
  138. print "</td>";
  139. print '</tr>';
  140. print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
  141. print '<td align="right" colspan="2"><b>'.price($object->price).'</b></td>';
  142. print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
  143. print '</table>';
  144. }
  145. else
  146. {
  147. // Propal non trouvee
  148. print $langs->trans("ErrorPropalNotFound",$_GET["id"]);
  149. }
  150. }
  151. // Si fichier png PDF d'1 page trouve
  152. if (file_exists($fileimage))
  153. {
  154. print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($relativepathimage).'">';
  155. }
  156. // Si fichier png PDF de plus d'1 page trouve
  157. elseif (file_exists($fileimagebis))
  158. {
  159. $multiple = preg_replace('/\.png/','',$relativepath) . "-";
  160. for ($i = 0; $i < 20; $i++)
  161. {
  162. $preview = $multiple.$i.'.png';
  163. if (file_exists($dir_output.$preview))
  164. {
  165. print '<img src="'.DOL_URL_ROOT . '/viewimage.php?modulepart=apercupropal&file='.urlencode($preview).'"><p>';
  166. }
  167. }
  168. }
  169. print '</div>';
  170. $db->close();
  171. llxFooter();
  172. ?>