dolibarr 19.0.4
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
4 * Copyright (C) 2004-2019 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7 * Copyright (C) 2019 Frédéric France <frederic.france@netlogic.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
29// Load Dolibarr environment
30require '../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
32require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
33
34$hookmanager = new HookManager($db);
35
36// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
37$hookmanager->initHooks(array('mrpindex'));
38
39// Load translation files required by the page
40$langs->loadLangs(array("companies", "mrp"));
41
42// Security check
43$result = restrictedArea($user, 'bom|mrp');
44
45
46/*
47 * View
48 */
49
50$staticbom = new BOM($db);
51$staticmo = new Mo($db);
52
53llxHeader('', $langs->trans("MRP"), '');
54
55print load_fiche_titre($langs->trans("MRPArea"), '', 'mrp');
56
57
58print '<div class="fichecenter"><div class="fichethirdleft">';
59
60
61/*
62 * Statistics
63 */
64
65if ($conf->use_javascript_ajax) {
66 $sql = "SELECT COUNT(t.rowid) as nb, status";
67 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
68 $sql .= " GROUP BY t.status";
69 $sql .= " ORDER BY t.status ASC";
70 $resql = $db->query($sql);
71
72 if ($resql) {
73 $num = $db->num_rows($resql);
74 $i = 0;
75
76 $totalnb = 0;
77 $dataseries = array();
78 $colorseries = array();
79 $vals = array();
80
81 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
82
83 while ($i < $num) {
84 $obj = $db->fetch_object($resql);
85 if ($obj) {
86 $vals[$obj->status] = $obj->nb;
87
88 $totalnb += $obj->nb;
89 }
90 $i++;
91 }
92 $db->free($resql);
93
94 print '<div class="div-table-responsive-no-min">';
95 print '<table class="noborder nohover centpercent">';
96 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th></tr>'."\n";
97 $listofstatus = array(0, 1, 2, 3, 9);
98 foreach ($listofstatus as $status) {
99 $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
100 if ($status == Mo::STATUS_DRAFT) {
101 $colorseries[$status] = '-'.$badgeStatus0;
102 }
103 if ($status == Mo::STATUS_VALIDATED) {
104 $colorseries[$status] = $badgeStatus1;
105 }
106 if ($status == Mo::STATUS_INPROGRESS) {
107 $colorseries[$status] = $badgeStatus4;
108 }
109 if ($status == Mo::STATUS_PRODUCED) {
110 $colorseries[$status] = $badgeStatus6;
111 }
112 if ($status == Mo::STATUS_CANCELED) {
113 $colorseries[$status] = $badgeStatus9;
114 }
115
116 if (empty($conf->use_javascript_ajax)) {
117 print '<tr class="oddeven">';
118 print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
119 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
120 print "</tr>\n";
121 }
122 }
123 if ($conf->use_javascript_ajax) {
124 print '<tr><td class="center" colspan="2">';
125
126 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
127 $dolgraph = new DolGraph();
128 $dolgraph->SetData($dataseries);
129 $dolgraph->SetDataColor(array_values($colorseries));
130 $dolgraph->setShowLegend(2);
131 $dolgraph->setShowPercent(1);
132 $dolgraph->SetType(array('pie'));
133 $dolgraph->SetHeight('200');
134 $dolgraph->draw('idgraphstatus');
135 print $dolgraph->show($totalnb ? 0 : 1);
136
137 print '</td></tr>';
138 }
139 print "</table>";
140 print "</div>";
141
142 print "<br>";
143 } else {
144 dol_print_error($db);
145 }
146}
147
148print '<br>';
149
150
151print '</div><div class="fichetwothirdright">';
152
153/*
154 * Last modified BOM
155 */
156
157$max = 5;
158
159$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
160$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
161$sql .= " WHERE a.entity IN (".getEntity('bom').")";
162$sql .= $db->order("a.tms", "DESC");
163$sql .= $db->plimit($max, 0);
164
165$resql = $db->query($sql);
166if ($resql) {
167 print '<div class="div-table-responsive-no-min">';
168 print '<table class="noborder centpercent">';
169 print '<tr class="liste_titre">';
170 print '<th colspan="4">'.$langs->trans("LatestBOMModified", $max).'</th></tr>';
171
172 $num = $db->num_rows($resql);
173 if ($num) {
174 $i = 0;
175 while ($i < $num) {
176 $obj = $db->fetch_object($resql);
177
178 $staticbom->id = $obj->rowid;
179 $staticbom->ref = $obj->ref;
180 $staticbom->fk_product = $obj->fk_product;
181 $staticbom->date_modification = $obj->datem;
182 $staticbom->status = $obj->status;
183
184 print '<tr class="oddeven">';
185 print '<td>'.$staticbom->getNomUrl(1, 32).'</td>';
186 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
187 print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
188 print '</tr>';
189 $i++;
190 }
191 } else {
192 print '<tr class="oddeven">';
193 print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
194 print '</tr>';
195 }
196 print "</table></div>";
197 print "<br>";
198} else {
199 dol_print_error($db);
200}
201
202/*
203 * Last modified MOs
204 */
205
206$max = 5;
207
208$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
209$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
210$sql .= " WHERE a.entity IN (".getEntity('mo').")";
211$sql .= $db->order("a.tms", "DESC");
212$sql .= $db->plimit($max, 0);
213
214$resql = $db->query($sql);
215if ($resql) {
216 print '<div class="div-table-responsive-no-min">';
217 print '<table class="noborder centpercent">';
218 print '<tr class="liste_titre">';
219 print '<th colspan="4">'.$langs->trans("LatestMOModified", $max).'</th></tr>';
220
221 $num = $db->num_rows($resql);
222 if ($num) {
223 $i = 0;
224 while ($i < $num) {
225 $obj = $db->fetch_object($resql);
226
227 $staticmo->id = $obj->rowid;
228 $staticmo->ref = $obj->ref;
229 $staticmo->date_modification = $obj->datem;
230 $staticmo->status = $obj->status;
231
232 print '<tr class="oddeven">';
233 print '<td>'.$staticmo->getNomUrl(1, 32).'</td>';
234 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
235 print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
236 print '</tr>';
237 $i++;
238 }
239 } else {
240 print '<tr class="oddeven">';
241 print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
242 print '</tr>';
243 }
244 print "</table></div>";
245 print "<br>";
246} else {
247 dol_print_error($db);
248}
249
250print '</div></div>';
251
252$object = new stdClass();
253$parameters = array(
254 //'type' => $type,
255 'user' => $user,
256);
257$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
258
259// End of page
260llxFooter();
261$db->close();
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Definition wrapper.php:55
llxFooter()
Empty footer.
Definition wrapper.php:69
Class for BOM.
Definition bom.class.php:43
Class to build graphs.
Class to manage hooks.
Class for Mo.
Definition mo.class.php:34
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
dol_print_error($db='', $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.