dolibarr 25.0.0-alpha
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-2026 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';
35require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
36require_once DOL_DOCUMENT_ROOT.'/core/lib/dashboard.lib.php';
37
46// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
47$hookmanager->initHooks(array('mrpindex'));
48
49// Load translation files required by the page
50$langs->loadLangs(array("companies", "mrp"));
51
52// Security check
53$result = restrictedArea($user, 'bom|mrp');
54
55$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
56
57
58/*
59 * Actions
60 */
61
62// Add box (when submit is done from a form when ajax disabled)
63include DOL_DOCUMENT_ROOT.'/core/actions_addbox.inc.php';
64
65
66/*
67 * View
68 */
69
70$staticbom = new BOM($db);
71$staticmo = new Mo($db);
72
73$title = $langs->trans('MRP');
74$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
75
76// Load $resultboxes
77$resultboxes = FormOther::getBoxesArea($user, "6");
78
79llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-index');
80
81print load_fiche_titre($langs->trans("MRPArea"), $resultboxes['selectboxlist'], 'mrp');
82
83
84print '<div class="fichecenter">';
85
86print '<div class="twocolumns">';
87
88print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
89
90
91/*
92 * Statistics
93 */
94
95if (isModEnabled('mrp')) {
96 $sql = "SELECT COUNT(t.rowid) as nb, status";
97 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
98 $sql .= " WHERE t.entity IN (".getEntity('mo').")";
99 $sql .= " GROUP BY t.status";
100 $sql .= " ORDER BY t.status ASC";
101 $resql = $db->query($sql);
102
103 if ($resql) {
104 $vals = array();
105 while ($obj = $db->fetch_object($resql)) {
106 $vals[$obj->status] = $obj->nb;
107 }
108 $db->free($resql);
109
110 $colors = getThemeBadgeStatusColors();
111 $colorofstatus = array(
112 Mo::STATUS_DRAFT => '-'.$colors[0],
113 Mo::STATUS_VALIDATED => $colors[1],
114 Mo::STATUS_INPROGRESS => $colors[4],
115 Mo::STATUS_PRODUCED => $colors[6],
116 Mo::STATUS_CANCELED => $colors[9],
117 );
118 $series = array();
119 foreach (array(0, 1, 2, 3, 9) as $status) {
120 $series[] = array(
121 'label' => $staticmo->LibStatut($status, 1),
122 'labelnojs' => $staticmo->LibStatut($status, 0),
123 'nb' => (isset($vals[$status]) ? (int) $vals[$status] : 0),
124 'color' => $colorofstatus[$status],
125 'url' => 'mo_list.php?search_status='.$status,
126 );
127 }
128 print getStatusPieChart($langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder"), $series, array('total' => false));
129 } else {
130 dol_print_error($db);
131 }
132}
133
134print '<br>';
135
136
137print $resultboxes['boxlista'];
138
139print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
140
141
142/*
143 * Last modified BOM
144 */
145
146if (isModEnabled('bom')) {
147 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
148 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
149 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
150 $sql .= $db->order("a.tms", "DESC");
151 $sql .= $db->plimit($max, 0);
152
153 $resql = $db->query($sql);
154 if ($resql) {
155 print '<div class="div-table-responsive-no-min">';
156 print '<table class="noborder centpercent">';
157 print '<tr class="liste_titre">';
158 print '<th colspan="2">'.$langs->trans("LatestBOMModified", $max);
159 $lastmodified = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
160 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
161 $lastmodified .= '</a>';
162 print $lastmodified;
163 print '</th>';
164 print '<th class="right">';
165 //print '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'bom');
166 print '</th>';
167 print '</tr>';
168
169 $num = $db->num_rows($resql);
170 if ($num) {
171 $i = 0;
172 while ($i < $num) {
173 $obj = $db->fetch_object($resql);
174
175 $staticbom->id = $obj->rowid;
176 $staticbom->ref = $obj->ref;
177 $staticbom->fk_product = $obj->fk_product;
178 $staticbom->date_modification = $obj->datem;
179 $staticbom->status = $obj->status;
180
181 print '<tr class="oddeven">';
182 print '<td>'.$staticbom->getNomUrl(1, '32').'</td>';
183 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
184 print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
185 print '</tr>';
186 $i++;
187 }
188 } else {
189 print '<tr class="oddeven">';
190 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
191 print '</tr>';
192 }
193 print '</table>';
194 print '</div>';
195 print '<br>';
196 } else {
197 dol_print_error($db);
198 }
199}
200
201
202/*
203 * Last modified MOs
204 */
205
206if (isModEnabled('mrp')) {
207 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
208 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
209 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
210 $sql .= $db->order("a.tms", "DESC");
211 $sql .= $db->plimit($max, 0);
212
213 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
214 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
215 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
216 $sql .= $db->order("a.tms", "DESC");
217 $sql .= $db->plimit($max, 0);
218
219 $resql = $db->query($sql);
220 if ($resql) {
221 print '<div class="div-table-responsive-no-min">';
222 print '<table class="noborder centpercent">';
223 print '<tr class="liste_titre">';
224 print '<th colspan="2">'.$langs->trans("LatestMOModified", $max);
225 $lastmodified = '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
226 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
227 $lastmodified .= '</a>';
228 print $lastmodified;
229 print '</th>';
230 print '<th class="right">';
231 //print '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'mrp');
232 print '</th>';
233 print '</tr>';
234
235 $num = $db->num_rows($resql);
236 if ($num) {
237 $i = 0;
238 while ($i < $num) {
239 $obj = $db->fetch_object($resql);
240
241 $staticmo->id = $obj->rowid;
242 $staticmo->ref = $obj->ref;
243 $staticmo->date_modification = $obj->datem;
244 $staticmo->status = $obj->status;
245
246 print '<tr class="oddeven">';
247 print '<td>'.$staticmo->getNomUrl(1, '32').'</td>';
248 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
249 print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
250 print '</tr>';
251 $i++;
252 }
253 } else {
254 print '<tr class="oddeven">';
255 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
256 print '</tr>';
257 }
258 print '</table>';
259 print '</div>';
260 print '<br>';
261 } else {
262 dol_print_error($db);
263 }
264}
265
266print $resultboxes['boxlistb'];
267
268print '</div></div></div>';
269
270$object = new stdClass();
271$parameters = array(
272 //'type' => $type,
273 'user' => $user,
274);
275$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
276
277// End of page
278llxFooter();
279$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
static getBoxesArea($user, $areacode)
Get array with HTML tabs with widgets/boxes of a particular area including personalized choices of us...
Class for Mo.
Definition mo.class.php:35
getThemeBadgeStatusColors()
Return the colors of status badges defined by the current theme (theme_vars.inc.php)
getStatusPieChart($title, $series, $options=array())
Return the HTML table with a pie chart of values by status, as shown on the home page of a module.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
isModEnabled($module)
Is Dolibarr module enabled.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.