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