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';
36
45// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
46$hookmanager->initHooks(array('mrpindex'));
47
48// Load translation files required by the page
49$langs->loadLangs(array("companies", "mrp"));
50
51// Security check
52$result = restrictedArea($user, 'bom|mrp');
53
54$max = getDolUserInt('MAIN_SIZE_SHORTLIST_LIMIT', getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5));
55
56
57/*
58 * Actions
59 */
60
61if (GETPOST('addbox')) {
62 // Add box (when submit is done from a form when ajax disabled)
63 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
64 $zone = GETPOSTINT('areacode');
65 $userid = GETPOSTINT('userid');
66 $boxorder = GETPOST('boxorder', 'aZ09');
67 $boxorder .= GETPOST('boxcombo', 'aZ09');
68 $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
69 if ($result > 0) {
70 setEventMessages($langs->trans("BoxAdded"), null);
71 }
72}
73
74
75/*
76 * View
77 */
78
79$staticbom = new BOM($db);
80$staticmo = new Mo($db);
81
82$title = $langs->trans('MRP');
83$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
84
85// Load $resultboxes
86$resultboxes = FormOther::getBoxesArea($user, "6");
87
88llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-index');
89
90print load_fiche_titre($langs->trans("MRPArea"), $resultboxes['selectboxlist'], 'mrp');
91
92
93print '<div class="fichecenter">';
94
95print '<div class="twocolumns">';
96
97print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
98
99
100/*
101 * Statistics
102 */
103
104if (isModEnabled('mrp') && $conf->use_javascript_ajax) {
105 $sql = "SELECT COUNT(t.rowid) as nb, status";
106 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
107 $sql .= " GROUP BY t.status";
108 $sql .= " ORDER BY t.status ASC";
109 $resql = $db->query($sql);
110
111 if ($resql) {
112 $num = $db->num_rows($resql);
113 $i = 0;
114
115 $totalnb = 0;
116 $dataseries = array();
117 $colorseries = array();
118 $vals = array();
119
129 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
130
131 while ($i < $num) {
132 $obj = $db->fetch_object($resql);
133 if ($obj) {
134 $vals[$obj->status] = $obj->nb;
135
136 $totalnb += $obj->nb;
137 }
138 $i++;
139 }
140 $db->free($resql);
141
142 print '<div class="div-table-responsive-no-min">';
143 print '<table class="noborder nohover centpercent">';
144 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th>';
145 print '</tr>'."\n";
146 $listofstatus = array(0, 1, 2, 3, 9);
147 foreach ($listofstatus as $status) {
148 $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
149 if ($status == Mo::STATUS_DRAFT) {
150 $colorseries[$status] = '-'.$badgeStatus0;
151 }
152 if ($status == Mo::STATUS_VALIDATED) {
153 $colorseries[$status] = $badgeStatus1;
154 }
155 if ($status == Mo::STATUS_INPROGRESS) {
156 $colorseries[$status] = $badgeStatus4;
157 }
158 if ($status == Mo::STATUS_PRODUCED) {
159 $colorseries[$status] = $badgeStatus6;
160 }
161 if ($status == Mo::STATUS_CANCELED) {
162 $colorseries[$status] = $badgeStatus9;
163 }
164
165 if (empty($conf->use_javascript_ajax)) {
166 print '<tr class="oddeven">';
167 print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
168 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
169 print "</tr>\n";
170 }
171 }
172 if ($conf->use_javascript_ajax) {
173 print '<tr><td class="center" colspan="2">';
174
175 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
176 $dolgraph = new DolGraph();
177 $dolgraph->SetData($dataseries);
178 $dolgraph->SetDataColor(array_values($colorseries));
179 $dolgraph->setShowLegend(2);
180 $dolgraph->setShowPercent(1);
181 $dolgraph->SetType(array('pie'));
182 $dolgraph->SetHeight('200');
183 $dolgraph->draw('idgraphstatus');
184 print $dolgraph->show($totalnb ? 0 : 1);
185
186 print '</td></tr>';
187 }
188 print "</table>";
189 print "</div>";
190
191 print "<br>";
192 } else {
194 }
195}
196
197print '<br>';
198
199
200print $resultboxes['boxlista'];
201
202print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
203
204
205/*
206 * Last modified BOM
207 */
208
209if (isModEnabled('bom')) {
210 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
211 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
212 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
213 $sql .= $db->order("a.tms", "DESC");
214 $sql .= $db->plimit($max, 0);
215
216 $resql = $db->query($sql);
217 if ($resql) {
218 print '<div class="div-table-responsive-no-min">';
219 print '<table class="noborder centpercent">';
220 print '<tr class="liste_titre">';
221 print '<th colspan="2">'.$langs->trans("LatestBOMModified", $max);
222 $lastmodified = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
223 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
224 $lastmodified .= '</a>';
225 print $lastmodified;
226 print '</th>';
227 print '<th class="right">';
228 //print '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'bom');
229 print '</th>';
230 print '</tr>';
231
232 $num = $db->num_rows($resql);
233 if ($num) {
234 $i = 0;
235 while ($i < $num) {
236 $obj = $db->fetch_object($resql);
237
238 $staticbom->id = $obj->rowid;
239 $staticbom->ref = $obj->ref;
240 $staticbom->fk_product = $obj->fk_product;
241 $staticbom->date_modification = $obj->datem;
242 $staticbom->status = $obj->status;
243
244 print '<tr class="oddeven">';
245 print '<td>'.$staticbom->getNomUrl(1, '32').'</td>';
246 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
247 print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
248 print '</tr>';
249 $i++;
250 }
251 } else {
252 print '<tr class="oddeven">';
253 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
254 print '</tr>';
255 }
256 print '</table>';
257 print '</div>';
258 print '<br>';
259 } else {
261 }
262}
263
264
265/*
266 * Last modified MOs
267 */
268
269if (isModEnabled('mrp')) {
270 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
271 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
272 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
273 $sql .= $db->order("a.tms", "DESC");
274 $sql .= $db->plimit($max, 0);
275
276 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
277 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
278 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
279 $sql .= $db->order("a.tms", "DESC");
280 $sql .= $db->plimit($max, 0);
281
282 $resql = $db->query($sql);
283 if ($resql) {
284 print '<div class="div-table-responsive-no-min">';
285 print '<table class="noborder centpercent">';
286 print '<tr class="liste_titre">';
287 print '<th colspan="2">'.$langs->trans("LatestMOModified", $max);
288 $lastmodified = '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
289 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
290 $lastmodified .= '</a>';
291 print $lastmodified;
292 print '</th>';
293 print '<th class="right">';
294 //print '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'mrp');
295 print '</th>';
296 print '</tr>';
297
298 $num = $db->num_rows($resql);
299 if ($num) {
300 $i = 0;
301 while ($i < $num) {
302 $obj = $db->fetch_object($resql);
303
304 $staticmo->id = $obj->rowid;
305 $staticmo->ref = $obj->ref;
306 $staticmo->date_modification = $obj->datem;
307 $staticmo->status = $obj->status;
308
309 print '<tr class="oddeven">';
310 print '<td>'.$staticmo->getNomUrl(1, '32').'</td>';
311 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
312 print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
313 print '</tr>';
314 $i++;
315 }
316 } else {
317 print '<tr class="oddeven">';
318 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
319 print '</tr>';
320 }
321 print '</table>';
322 print '</div>';
323 print '<br>';
324 } else {
326 }
327}
328
329print $resultboxes['boxlistb'];
330
331print '</div></div></div>';
332
333$object = new stdClass();
334$parameters = array(
335 //'type' => $type,
336 'user' => $user,
337);
338$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
339
340// End of page
341llxFooter();
342$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.
static getBoxesArea($user, $areacode)
Get array with HTML tabs with widgets/boxes of a particular area including personalized choices of us...
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
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.
getDolUserInt($key, $default=0, $tmpuser=null)
Return Dolibarr user constant int value.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
isModEnabled($module)
Is Dolibarr module enabled.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
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.