dolibarr 21.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-2024 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
43// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
44$hookmanager->initHooks(array('mrpindex'));
45
46// Load translation files required by the page
47$langs->loadLangs(array("companies", "mrp"));
48
49// Security check
50$result = restrictedArea($user, 'bom|mrp');
51
52$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
53
54
55/*
56 * View
57 */
58
59$staticbom = new BOM($db);
60$staticmo = new Mo($db);
61
62$title = $langs->trans('MRP');
63$help_url = 'EN:Module_Manufacturing_Orders|FR:Module_Ordres_de_Fabrication|DE:Modul_Fertigungsauftrag';
64
65llxHeader('', $title, $help_url, '', 0, 0, '', '', '', 'mod-mrp page-index');
66
67print load_fiche_titre($langs->trans("MRPArea"), '', 'mrp');
68
69
70print '<div class="fichecenter">';
71
72print '<div class="twocolumns">';
73
74print '<div class="firstcolumn fichehalfleft boxhalfleft" id="boxhalfleft">';
75
76
77/*
78 * Statistics
79 */
80
81if ($conf->use_javascript_ajax) {
82 $sql = "SELECT COUNT(t.rowid) as nb, status";
83 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
84 $sql .= " GROUP BY t.status";
85 $sql .= " ORDER BY t.status ASC";
86 $resql = $db->query($sql);
87
88 if ($resql) {
89 $num = $db->num_rows($resql);
90 $i = 0;
91
92 $totalnb = 0;
93 $dataseries = array();
94 $colorseries = array();
95 $vals = array();
96
97 include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
98
99 while ($i < $num) {
100 $obj = $db->fetch_object($resql);
101 if ($obj) {
102 $vals[$obj->status] = $obj->nb;
103
104 $totalnb += $obj->nb;
105 }
106 $i++;
107 }
108 $db->free($resql);
109
110 print '<div class="div-table-responsive-no-min">';
111 print '<table class="noborder nohover centpercent">';
112 print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th>';
113 print '</tr>'."\n";
114 $listofstatus = array(0, 1, 2, 3, 9);
115 foreach ($listofstatus as $status) {
116 $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
117 if ($status == Mo::STATUS_DRAFT) {
118 $colorseries[$status] = '-'.$badgeStatus0;
119 }
120 if ($status == Mo::STATUS_VALIDATED) {
121 $colorseries[$status] = $badgeStatus1;
122 }
123 if ($status == Mo::STATUS_INPROGRESS) {
124 $colorseries[$status] = $badgeStatus4;
125 }
126 if ($status == Mo::STATUS_PRODUCED) {
127 $colorseries[$status] = $badgeStatus6;
128 }
129 if ($status == Mo::STATUS_CANCELED) {
130 $colorseries[$status] = $badgeStatus9;
131 }
132
133 if (empty($conf->use_javascript_ajax)) {
134 print '<tr class="oddeven">';
135 print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
136 print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
137 print "</tr>\n";
138 }
139 }
140 if ($conf->use_javascript_ajax) {
141 print '<tr><td class="center" colspan="2">';
142
143 include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
144 $dolgraph = new DolGraph();
145 $dolgraph->SetData($dataseries);
146 $dolgraph->SetDataColor(array_values($colorseries));
147 $dolgraph->setShowLegend(2);
148 $dolgraph->setShowPercent(1);
149 $dolgraph->SetType(array('pie'));
150 $dolgraph->SetHeight('200');
151 $dolgraph->draw('idgraphstatus');
152 print $dolgraph->show($totalnb ? 0 : 1);
153
154 print '</td></tr>';
155 }
156 print "</table>";
157 print "</div>";
158
159 print "<br>";
160 } else {
161 dol_print_error($db);
162 }
163}
164
165print '<br>';
166
167
168print '</div><div class="secondcolumn fichehalfright boxhalfright" id="boxhalfright">';
169
170
171/*
172 * Last modified BOM
173 */
174
175$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
176$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
177$sql .= " WHERE a.entity IN (".getEntity('bom').")";
178$sql .= $db->order("a.tms", "DESC");
179$sql .= $db->plimit($max, 0);
180
181$resql = $db->query($sql);
182if ($resql) {
183 print '<div class="div-table-responsive-no-min">';
184 print '<table class="noborder centpercent">';
185 print '<tr class="liste_titre">';
186 print '<th colspan="2">'.$langs->trans("LatestBOMModified", $max);
187 $lastmodified = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
188 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
189 $lastmodified .= '</a>';
190 print $lastmodified;
191 print '</th>';
192 print '<th class="right">';
193 //print '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'bom');
194 print '</th>';
195 print '</tr>';
196
197 $num = $db->num_rows($resql);
198 if ($num) {
199 $i = 0;
200 while ($i < $num) {
201 $obj = $db->fetch_object($resql);
202
203 $staticbom->id = $obj->rowid;
204 $staticbom->ref = $obj->ref;
205 $staticbom->fk_product = $obj->fk_product;
206 $staticbom->date_modification = $obj->datem;
207 $staticbom->status = $obj->status;
208
209 print '<tr class="oddeven">';
210 print '<td>'.$staticbom->getNomUrl(1, 32).'</td>';
211 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
212 print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
213 print '</tr>';
214 $i++;
215 }
216 } else {
217 print '<tr class="oddeven">';
218 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
219 print '</tr>';
220 }
221 print "</table></div>";
222 print "<br>";
223} else {
224 dol_print_error($db);
225}
226
227/*
228 * Last modified MOs
229 */
230
231
232$sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
233$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
234$sql .= " WHERE a.entity IN (".getEntity('mo').")";
235$sql .= $db->order("a.tms", "DESC");
236$sql .= $db->plimit($max, 0);
237
238$resql = $db->query($sql);
239if ($resql) {
240 print '<div class="div-table-responsive-no-min">';
241 print '<table class="noborder centpercent">';
242 print '<tr class="liste_titre">';
243 print '<th colspan="2">'.$langs->trans("LatestMOModified", $max);
244 $lastmodified = '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
245 $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
246 $lastmodified .= '</a>';
247 print $lastmodified;
248 print '</th>';
249 print '<th class="right">';
250 //print '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'mrp');
251 print '</th>';
252 print '</tr>';
253
254 $num = $db->num_rows($resql);
255 if ($num) {
256 $i = 0;
257 while ($i < $num) {
258 $obj = $db->fetch_object($resql);
259
260 $staticmo->id = $obj->rowid;
261 $staticmo->ref = $obj->ref;
262 $staticmo->date_modification = $obj->datem;
263 $staticmo->status = $obj->status;
264
265 print '<tr class="oddeven">';
266 print '<td>'.$staticmo->getNomUrl(1, 32).'</td>';
267 print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
268 print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
269 print '</tr>';
270 $i++;
271 }
272 } else {
273 print '<tr class="oddeven">';
274 print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
275 print '</tr>';
276 }
277 print "</table></div>";
278 print "<br>";
279} else {
280 dol_print_error($db);
281}
282
283print '</div></div></div>';
284
285$object = new stdClass();
286$parameters = array(
287 //'type' => $type,
288 'user' => $user,
289);
290$reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
291
292// End of page
293llxFooter();
294$db->close();
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:66
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:71
Class for BOM.
Definition bom.class.php:42
Class to build graphs.
Class for Mo.
Definition mo.class.php:34
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...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
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.