dolibarr  16.0.5
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 
32 $id = GETPOST('id', 'int');
33 
34 // Security check
35 $result = restrictedArea($user, 'stock');
36 
37 
38 /*
39  * View
40  */
41 
42 $form = new Form($db);
43 
44 $help_url = 'EN:Module_Stocks_En|FR:Module_Stock|ES:M&oacute;dulo_Stocks';
45 llxHeader("", $langs->trans("WarehouseCard"), $help_url);
46 
47 if ($id > 0) {
48  $entrepot = new Entrepot($db);
49  $result = $entrepot->fetch($id);
50  if ($result < 0) {
51  dol_print_error($db);
52  }
53 
54  $head = stock_prepare_head($entrepot);
55 
56  print dol_get_fiche_head($head, 'value', $langs->trans("Warehouse"), 0, 'stock');
57 
58 
59  print '<table class="border centpercent">';
60 
61  // Ref
62  print '<tr><td width="25%">'.$langs->trans("Ref").'</td><td colspan="3">';
63  print $form->showrefnav($entrepot, 'id', '', 1, 'rowid', 'libelle');
64  print '</td>';
65 
66  print '<tr><td>'.$langs->trans("LocationSummary").'</td><td colspan="3">'.$entrepot->lieu.'</td></tr>';
67 
68  // Description
69  print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td colspan="3">'.nl2br($entrepot->description).'</td></tr>';
70 
71  print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3">';
72  print $entrepot->address;
73  print '</td></tr>';
74 
75  print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$entrepot->zip.'</td>';
76  print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$entrepot->town.'</td></tr>';
77 
78  print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
79  print $entrepot->country;
80  print '</td></tr>';
81 
82  // Statut
83  print '<tr><td>'.$langs->trans("Status").'</td><td colspan="3">'.$entrepot->getLibStatut(4).'</td></tr>';
84 
85  $calcproducts = $entrepot->nb_products();
86 
87  // Nb of products
88  print '<tr><td class="tdtop">'.$langs->trans("NumberOfProducts").'</td><td colspan="3">';
89  print empty($calcproducts['nb']) ? '0' : $calcproducts['nb'];
90  print "</td></tr>";
91 
92  // Value
93  print '<tr><td class="tdtop">'.$langs->trans("EstimatedStockValueShort").'</td><td colspan="3">';
94  print empty($calcproducts['value']) ? '0' : $calcproducts['value'];
95  print "</td></tr>";
96 
97  print "</table>";
98  print '</div>';
99 
100 
101  /* ************************************************************************** */
102  /* */
103  /* Graph */
104  /* */
105  /* ************************************************************************** */
106 
107  print "<div class=\"graph\">\n";
108  $year = strftime("%Y", time());
109 
110  $file = $conf->stock->dir_temp.'/entrepot-'.$entrepot->id.'-'.($year).'.png';
111 
112  // TODO Build graph in $file from a table called llx_stock_log
113 
114 
115 
116 
117 
118 
119  if (file_exists($file)) {
120  $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.$year.'.png';
121  print '<img src="'.$url.'" alt="Valorisation du stock annee '.($year).'">';
122 
123  if (file_exists(DOL_DATA_ROOT.'/entrepot/temp/entrepot-'.$entrepot->id.'-'.($year - 1).'.png')) {
124  $url = DOL_URL_ROOT.'/viewimage.php?modulepart=graph_stock&amp;file=entrepot-'.$entrepot->id.'-'.($year - 1).'.png';
125  print '<br><img src="'.$url.'" alt="Valorisation du stock annee '.($year - 1).'">';
126  }
127  } else {
128  $langs->load("errors");
129  print $langs->trans("FeatureNotYetAvailable");
130  }
131 
132  print "</div>";
133 }
134 
135 // End of page
136 llxFooter();
137 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
$help_url
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Definition: agenda.php:116
dol_get_fiche_head
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
Definition: functions.lib.php:1822
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
Entrepot
Class to manage warehouses.
Definition: entrepot.class.php:35
llxHeader
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Definition: wrapper.php:59
stock_prepare_head
stock_prepare_head($object)
Prepare array with list of tabs.
Definition: stock.lib.php:30