dolibarr  13.0.2
fiche-valo.php
Go to the documentation of this file.
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 
25 require '../../main.inc.php';
26 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
28 
29 // Load translation files required by the page
30 $langs->loadLangs(array('products', 'stocks', 'companies'));
31 $mesg = '';
32 
33 // Security check
34 $result = restrictedArea($user, 'stock');
35 
36 
37 /*
38  * View
39  */
40 
41 $form = new Form($db);
42 
43 $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
44 llxHeader("", $langs->trans("WarehouseCard"), $help_url);
45 
46 if ($_GET["id"])
47 {
48  if ($mesg) print $mesg;
49 
50  $entrepot = new Entrepot($db);
51  $result = $entrepot->fetch($_GET["id"]);
52  if ($result < 0)
53  {
54  dol_print_error($db);
55  }
56 
57 
58  $head = stock_prepare_head($entrepot);
59 
60  print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
61 
62 
63  print '<table class="border centpercent">';
64 
65  // Ref
66  print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
67  print $form->showrefnav($entrepot, 'id', '', 1, 'rowid', 'libelle');
68  print '</td>';
69 
70  print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
71 
72  // Description
73  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
74 
75  print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
76  print $entrepot->address;
77  print '</td></tr>';
78 
79  print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
80  print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
81 
82  print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
83  print $entrepot->country;
84  print '</td></tr>';
85 
86  // Statut
87  print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
88 
89  $calcproducts = $entrepot->nb_products();
90 
91  // Nb of products
92  print '<tr><td class="tdtop">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
93  print empty($calcproducts['nb']) ? '0' : $calcproducts['nb'];
94  print "</td></tr>";
95 
96  // Value
97  print '<tr><td class="tdtop">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
98  print empty($calcproducts['value']) ? '0' : $calcproducts['value'];
99  print "</td></tr>";
100 
101  print "</table>";
102  print '</div>';
103 
104 
105  /* ************************************************************************** */
106  /* */
107  /* Graph */
108  /* */
109  /* ************************************************************************** */
110 
111  print "<div class=\"graph\">\n";
112  $year = strftime("%Y", time());
113 
114  $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
115 
116  // TODO Build graph in $file from a table called llx_stock_log
117 
118 
119 
120 
121 
122 
123  if (file_exists($file))
124  {
125  $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
126  print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">';
127 
128  if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png'))
129  {
130  $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year - 1).'.png';
131  print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.($year - 1).'">';
132  }
133  } else {
134  $langs->load("errors");
135  print $langs->trans("FeatureNotYetAvailable");
136  }
137 
138  print "</div>";
139 }
140 
141 // End of page
142 llxFooter();
143 $db->close();
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage generation of HTML components Only common components must be here.
stock_prepare_head($object)
Prepare array with list of tabs.
Definition: stock.lib.php:30
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
Definition: index.php:89
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59
Class to manage warehouses.