dolibarr 24.0.0-beta
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-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
9 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
31// Load Dolibarr environment
32require '../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
34require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
35
44// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
45$hookmanager->initHooks(array('mrpindex'));
46
47// Load translation files required by the page
48$langs->loadLangs(array("companies", "mrp"));
49
50// Security check
51$result = restrictedArea($user, 'bom|mrp');
52
53$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
54
55
56/*
57 * View
58 */
59
60$staticbom = new BOM($db);
61$staticmo = new Mo($db);
62
63$title = $langs->trans('MRP');
64$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
65
66llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-index');
67
68print load_fiche_titre($langs->trans("MRPArea"), '', 'mrp');
69
70
71print '<div class="fichecenter">';
72
73print '<div class="twocolumns">';
74
75print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
76
77
78/*
79 * Statistics
80 */
81
82if (isModEnabled('mrp') && $conf->use_javascript_ajax) {
83 $sql = "SELECT COUNT(t.rowid) as nb, status";
84 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
85 $sql .= " GROUP BY t.status";
86 $sql .= " ORDER BY t.status ASC";
87 $resql = $db->query($sql);
88
89 if ($resql) {
90 $num = $db->num_rows($resql);
91 $i = 0;
92
93 $totalnb = 0;
94 $dataseries = array();
95 $colorseries = array();
96 $vals = array();
97
107 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
108
109 while ($i < $num) {
110 $obj = $db->fetch_object($resql);
111 if ($obj) {
112 $vals[$obj->status] = $obj->nb;
113
114 $totalnb += $obj->nb;
115 }
116 $i++;
117 }
118 $db->free($resql);
119
120 print '<div class="div-table-responsive-no-min">';
121 print '<table class="noborder nohover centpercent">';
122 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th>';
123 print '</tr>'."\n";
124 $listofstatus = array(0, 1, 2, 3, 9);
125 foreach ($listofstatus as $status) {
126 $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
127 if ($status == Mo::STATUS_DRAFT) {
128 $colorseries[$status] = '-'.$badgeStatus0;
129 }
130 if ($status == Mo::STATUS_VALIDATED) {
131 $colorseries[$status] = $badgeStatus1;
132 }
133 if ($status == Mo::STATUS_INPROGRESS) {
134 $colorseries[$status] = $badgeStatus4;
135 }
136 if ($status == Mo::STATUS_PRODUCED) {
137 $colorseries[$status] = $badgeStatus6;
138 }
139 if ($status == Mo::STATUS_CANCELED) {
140 $colorseries[$status] = $badgeStatus9;
141 }
142
143 if (empty($conf->use_javascript_ajax)) {
144 print '<tr class="oddeven">';
145 print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
146 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
147 print "</tr>\n";
148 }
149 }
150 if ($conf->use_javascript_ajax) {
151 print '<tr><td class="center" colspan="2">';
152
153 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
154 $dolgraph = new DolGraph();
155 $dolgraph->SetData($dataseries);
156 $dolgraph->SetDataColor(array_values($colorseries));
157 $dolgraph->setShowLegend(2);
158 $dolgraph->setShowPercent(1);
159 $dolgraph->SetType(array('pie'));
160 $dolgraph->SetHeight('200');
161 $dolgraph->draw('idgraphstatus');
162 print $dolgraph->show($totalnb ? 0 : 1);
163
164 print '</td></tr>';
165 }
166 print "</table>";
167 print "</div>";
168
169 print "<br>";
170 } else {
172 }
173}
174
175print '<br>';
176
177
178print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
179
180
181/*
182 * Last modified BOM
183 */
184
185if (isModEnabled('bom')) {
186 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
187 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
188 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
189 $sql .= $db->order("a.tms", "DESC");
190 $sql .= $db->plimit($max, 0);
191
192 $resql = $db->query($sql);
193 if ($resql) {
194 print '<div class="div-table-responsive-no-min">';
195 print '<table class="noborder centpercent">';
196 print '<tr class="liste_titre">';
197 print '<th colspan="2">'.$langs->trans("LatestBOMModified", $max);
198 $lastmodified = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
199 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
200 $lastmodified .= '</a>';
201 print $lastmodified;
202 print '</th>';
203 print '<th class="right">';
204 //print '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'bom');
205 print '</th>';
206 print '</tr>';
207
208 $num = $db->num_rows($resql);
209 if ($num) {
210 $i = 0;
211 while ($i < $num) {
212 $obj = $db->fetch_object($resql);
213
214 $staticbom->id = $obj->rowid;
215 $staticbom->ref = $obj->ref;
216 $staticbom->fk_product = $obj->fk_product;
217 $staticbom->date_modification = $obj->datem;
218 $staticbom->status = $obj->status;
219
220 print '<tr class="oddeven">';
221 print '<td>'.$staticbom->getNomUrl(1, '32').'</td>';
222 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
223 print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
224 print '</tr>';
225 $i++;
226 }
227 } else {
228 print '<tr class="oddeven">';
229 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
230 print '</tr>';
231 }
232 print '</table>';
233 print '</div>';
234 print '<br>';
235 } else {
237 }
238}
239
240
241/*
242 * Last modified MOs
243 */
244
245if (isModEnabled('mrp')) {
246 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
247 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
248 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
249 $sql .= $db->order("a.tms", "DESC");
250 $sql .= $db->plimit($max, 0);
251
252 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
253 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
254 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
255 $sql .= $db->order("a.tms", "DESC");
256 $sql .= $db->plimit($max, 0);
257
258 $resql = $db->query($sql);
259 if ($resql) {
260 print '<div class="div-table-responsive-no-min">';
261 print '<table class="noborder centpercent">';
262 print '<tr class="liste_titre">';
263 print '<th colspan="2">'.$langs->trans("LatestMOModified", $max);
264 $lastmodified = '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
265 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
266 $lastmodified .= '</a>';
267 print $lastmodified;
268 print '</th>';
269 print '<th class="right">';
270 //print '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'mrp');
271 print '</th>';
272 print '</tr>';
273
274 $num = $db->num_rows($resql);
275 if ($num) {
276 $i = 0;
277 while ($i < $num) {
278 $obj = $db->fetch_object($resql);
279
280 $staticmo->id = $obj->rowid;
281 $staticmo->ref = $obj->ref;
282 $staticmo->date_modification = $obj->datem;
283 $staticmo->status = $obj->status;
284
285 print '<tr class="oddeven">';
286 print '<td>'.$staticmo->getNomUrl(1, '32').'</td>';
287 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
288 print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
289 print '</tr>';
290 $i++;
291 }
292 } else {
293 print '<tr class="oddeven">';
294 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
295 print '</tr>';
296 }
297 print '</table>';
298 print '</div>';
299 print '<br>';
300 } else {
302 }
303}
304
305print '</div></div></div>';
306
307$object = new stdClass();
308$parameters = array(
309 //'type' => $type,
310 'user' => $user,
311);
312$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
313
314// End of page
315llxFooter();
316$db->close();
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
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:73
Class for BOM.
Definition bom.class.php:42
Class to build graphs.
Class for Mo.
Definition mo.class.php:35
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
isModEnabled($module)
Is Dolibarr module enabled.
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.