dolibarr 21.0.0-alpha
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 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
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 3 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 <https://www.gnu.org/licenses/>.
18 */
19
26// Load Dolibarr environment
27require '../../main.inc.php';
28require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
30
31// Load translation files required by the page
32$langs->loadLangs(array('products', 'stocks', 'companies'));
33
34$id = GETPOSTINT('id');
35
36// Security check
37$result = restrictedArea($user, 'stock');
38
39
40/*
41 * View
42 */
43
44$form = new Form($db);
45
46$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
47llxHeader("", $langs->trans("WarehouseCard"), $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_fiche_valo');
48
49if ($id > 0) {
50 $entrepot = new Entrepot($db);
51 $result = $entrepot->fetch($id);
52 if ($result < 0) {
53 dol_print_error($db);
54 }
55
56 $head = stock_prepare_head($entrepot);
57
58 print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
59
60
61 print '<table class="border centpercent">';
62
63 // Ref
64 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
65 print $form->showrefnav($entrepot, 'id', '', 1, 'rowid', 'libelle');
66 print '</td>';
67
68 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
69
70 // Description
71 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
72
73 print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
74 print $entrepot->address;
75 print '</td></tr>';
76
77 print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
78 print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
79
80 print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
81 print $entrepot->country;
82 print '</td></tr>';
83
84 // Statut
85 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
86
87 $calcproducts = $entrepot->nb_products();
88
89 // Nb of products
90 print '<tr><td class="tdtop">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
91 print empty($calcproducts['nb']) ? '0' : $calcproducts['nb'];
92 print "</td></tr>";
93
94 // Value
95 print '<tr><td class="tdtop">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
96 print empty($calcproducts['value']) ? '0' : $calcproducts['value'];
97 print "</td></tr>";
98
99 print "</table>";
100 print '</div>';
101
102
103 /* ************************************************************************** */
104 /* */
105 /* Graph */
106 /* */
107 /* ************************************************************************** */
108
109 print "<div class=\"graph\">\n";
110 $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
111
112 $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
113
114 // TODO Build graph in $file from a table called llx_stock_log
115
116
117
118
119
120
121 if (file_exists($file)) {
122 $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
123 print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">';
124
125 if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.((int) $year - 1).'.png')) {
126 $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.((int) $year - 1).'.png';
127 print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.((int) $year - 1).'">';
128 }
129 } else {
130 $langs->load("errors");
131 print $langs->trans("FeatureNotYetAvailable");
132 }
133
134 print "</div>";
135}
136
137// End of page
138llxFooter();
139$db->close();
$id
Definition account.php:39
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:70
Class to manage warehouses.
Class to manage generation of HTML components Only common components must be here.
llxFooter()
Footer empty.
Definition document.php:107
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_now($mode='auto')
Return date for now.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
stock_prepare_head($object)
Prepare array with list of tabs.
Definition stock.lib.php:31