dolibarr 21.0.0-beta
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 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27// Load Dolibarr environment
28require '../../main.inc.php';
29require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/stock.lib.php';
31
40// Load translation files required by the page
41$langs->loadLangs(array('products', 'stocks', 'companies'));
42
43$id = GETPOSTINT('id');
44
45// Security check
46$result = restrictedArea($user, 'stock');
47
48
49/*
50 * View
51 */
52
53$form = new Form($db);
54
55$help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
56llxHeader("", $langs->trans("WarehouseCard"), $help_url, '', 0, 0, '', '', '', 'mod-product page-stock_fiche_valo');
57
58if ($id > 0) {
59 $entrepot = new Entrepot($db);
60 $result = $entrepot->fetch($id);
61 if ($result < 0) {
62 dol_print_error($db);
63 }
64
65 $head = stock_prepare_head($entrepot);
66
67 print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
68
69
70 print '<table class="border centpercent">';
71
72 // Ref
73 print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
74 print $form->showrefnav($entrepot, 'id', '', 1, 'rowid', 'libelle');
75 print '</td>';
76
77 print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
78
79 // Description
80 print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
81
82 print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
83 print $entrepot->address;
84 print '</td></tr>';
85
86 print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
87 print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
88
89 print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
90 print $entrepot->country;
91 print '</td></tr>';
92
93 // Statut
94 print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
95
96 $calcproducts = $entrepot->nb_products();
97
98 // Nb of products
99 print '<tr><td class="tdtop">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
100 print empty($calcproducts['nb']) ? '0' : $calcproducts['nb'];
101 print "</td></tr>";
102
103 // Value
104 print '<tr><td class="tdtop">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
105 print empty($calcproducts['value']) ? '0' : $calcproducts['value'];
106 print "</td></tr>";
107
108 print "</table>";
109 print '</div>';
110
111
112 /* ************************************************************************** */
113 /* */
114 /* Graph */
115 /* */
116 /* ************************************************************************** */
117
118 print "<div class=\"graph\">\n";
119 $year = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
120
121 $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
122
123 // TODO Build graph in $file from a table called llx_stock_log
124
125
126
127
128
129
130 if (file_exists($file)) {
131 $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
132 print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">';
133
134 if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.((int) $year - 1).'.png')) {
135 $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.((int) $year - 1).'.png';
136 print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.((int) $year - 1).'">';
137 }
138 } else {
139 $langs->load("errors");
140 print $langs->trans("FeatureNotYetAvailable");
141 }
142
143 print "</div>";
144}
145
146// End of page
147llxFooter();
148$db->close();
$id
Definition account.php:48
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:71
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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