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