fiche-valo.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /* Copyright (C) 2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2008-2009 Laurent Destailleur <eldy@users.sourceforge.net>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  17. */
  18. /**
  19. * \file htdocs/product/stock/fiche-valo.php
  20. * \ingroup stock
  21. * \brief Page fiche de valorisation du stock dans l'entrepot
  22. */
  23. // Load Dolibarr environment
  24. require '../../main.inc.php';
  25. require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
  26. require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
  27. // Load translation files required by the page
  28. $langs->loadLangs(array('products', 'stocks', 'companies'));
  29. $id = GETPOST('id', 'int');
  30. // Security check
  31. $result = restrictedArea($user, 'stock');
  32. /*
  33. * View
  34. */
  35. $form = new Form($db);
  36. $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
  37. llxHeader("", $langs->trans("WarehouseCard"), $help_url);
  38. if ($id > 0) {
  39. $entrepot = new Entrepot($db);
  40. $result = $entrepot->fetch($id);
  41. if ($result < 0) {
  42. dol_print_error($db);
  43. }
  44. $head = stock_prepare_head($entrepot);
  45. print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
  46. print '<table class="border centpercent">';
  47. // Ref
  48. print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
  49. print $form->showrefnav($entrepot, 'id', '', 1, 'rowid', 'libelle');
  50. print '</td>';
  51. print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
  52. // Description
  53. print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
  54. print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
  55. print $entrepot->address;
  56. print '</td></tr>';
  57. print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
  58. print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
  59. print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
  60. print $entrepot->country;
  61. print '</td></tr>';
  62. // Statut
  63. print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
  64. $calcproducts = $entrepot->nb_products();
  65. // Nb of products
  66. print '<tr><td class="tdtop">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
  67. print empty($calcproducts['nb']) ? '0' : $calcproducts['nb'];
  68. print "</td></tr>";
  69. // Value
  70. print '<tr><td class="tdtop">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
  71. print empty($calcproducts['value']) ? '0' : $calcproducts['value'];
  72. print "</td></tr>";
  73. print "</table>";
  74. print '</div>';
  75. /* ************************************************************************** */
  76. /* */
  77. /* Graph */
  78. /* */
  79. /* ************************************************************************** */
  80. print "<div class=\"graph\">\n";
  81. $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
  82. $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
  83. // TODO Build graph in $file from a table called llx_stock_log
  84. if (file_exists($file)) {
  85. $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
  86. print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">';
  87. if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) {
  88. $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year - 1).'.png';
  89. print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.($year - 1).'">';
  90. }
  91. } else {
  92. $langs->load("errors");
  93. print $langs->trans("FeatureNotYetAvailable");
  94. }
  95. print "</div>";
  96. }
  97. // End of page
  98. llxFooter();
  99. $db->close();