dolibarr  16.0.5
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 require '../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
31 require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
32 
33 $hookmanager = new HookManager($db);
34 
35 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
36 $hookmanager->initHooks(array('mrpindex'));
37 
38 // Load translation files required by the page
39 $langs->loadLangs(array("companies", "mrp"));
40 
41 // Security check
42 $result = restrictedArea($user, 'bom|mrp');
43 
44 
45 /*
46  * View
47  */
48 
49 $staticbom = new BOM($db);
50 $staticmo = new Mo($db);
51 
52 llxHeader('', $langs->trans("MRP"), '');
53 
54 print load_fiche_titre($langs->trans("MRPArea"), '', 'mrp');
55 
56 
57 print '<div class="fichecenter"><div class="fichethirdleft">';
58 
59 
60 /*
61  * Statistics
62  */
63 
64 if ($conf->use_javascript_ajax) {
65  $sql = "SELECT COUNT(t.rowid) as nb, status";
66  $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
67  $sql .= " GROUP BY t.status";
68  $sql .= " ORDER BY t.status ASC";
69  $resql = $db->query($sql);
70 
71  if ($resql) {
72  $num = $db->num_rows($resql);
73  $i = 0;
74 
75  $totalnb = 0;
76  $dataseries = array();
77  $colorseries = array();
78  $vals = array();
79 
80  include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
81 
82  while ($i < $num) {
83  $obj = $db->fetch_object($resql);
84  if ($obj) {
85  $vals[$obj->status] = $obj->nb;
86 
87  $totalnb += $obj->nb;
88  }
89  $i++;
90  }
91  $db->free($resql);
92 
93  print '<div class="div-table-responsive-no-min">';
94  print '<table class="noborder nohover centpercent">';
95  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th></tr>'."\n";
96  $listofstatus = array(0, 1, 2, 3, 9);
97  foreach ($listofstatus as $status) {
98  $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
99  if ($status == Mo::STATUS_DRAFT) {
100  $colorseries[$status] = '-'.$badgeStatus0;
101  }
102  if ($status == Mo::STATUS_VALIDATED) {
103  $colorseries[$status] = $badgeStatus1;
104  }
105  if ($status == Mo::STATUS_INPROGRESS) {
106  $colorseries[$status] = $badgeStatus4;
107  }
108  if ($status == Mo::STATUS_PRODUCED) {
109  $colorseries[$status] = $badgeStatus6;
110  }
111  if ($status == Mo::STATUS_CANCELED) {
112  $colorseries[$status] = $badgeStatus9;
113  }
114 
115  if (empty($conf->use_javascript_ajax)) {
116  print '<tr class="oddeven">';
117  print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
118  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
119  print "</tr>\n";
120  }
121  }
122  if ($conf->use_javascript_ajax) {
123  print '<tr><td class="center" colspan="2">';
124 
125  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
126  $dolgraph = new DolGraph();
127  $dolgraph->SetData($dataseries);
128  $dolgraph->SetDataColor(array_values($colorseries));
129  $dolgraph->setShowLegend(2);
130  $dolgraph->setShowPercent(1);
131  $dolgraph->SetType(array('pie'));
132  $dolgraph->SetHeight('200');
133  $dolgraph->draw('idgraphstatus');
134  print $dolgraph->show($totalnb ? 0 : 1);
135 
136  print '</td></tr>';
137  }
138  print "</table>";
139  print "</div>";
140 
141  print "<br>";
142  } else {
143  dol_print_error($db);
144  }
145 }
146 
147 print '<br>';
148 
149 
150 print '</div><div class="fichetwothirdright">';
151 
152 /*
153  * Last modified BOM
154  */
155 
156 $max = 5;
157 
158 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
159 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
160 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
161 $sql .= $db->order("a.tms", "DESC");
162 $sql .= $db->plimit($max, 0);
163 
164 $resql = $db->query($sql);
165 if ($resql) {
166  print '<div class="div-table-responsive-no-min">';
167  print '<table class="noborder centpercent">';
168  print '<tr class="liste_titre">';
169  print '<th colspan="4">'.$langs->trans("LatestBOMModified", $max).'</th></tr>';
170 
171  $num = $db->num_rows($resql);
172  if ($num) {
173  $i = 0;
174  while ($i < $num) {
175  $obj = $db->fetch_object($resql);
176 
177  $staticbom->id = $obj->rowid;
178  $staticbom->ref = $obj->ref;
179  $staticbom->fk_product = $obj->fk_product;
180  $staticbom->date_modification = $obj->datem;
181  $staticbom->status = $obj->status;
182 
183  print '<tr class="oddeven">';
184  print '<td>'.$staticbom->getNomUrl(1, 32).'</td>';
185  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
186  print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
187  print '</tr>';
188  $i++;
189  }
190  } else {
191  print '<tr class="oddeven">';
192  print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
193  print '</tr>';
194  }
195  print "</table></div>";
196  print "<br>";
197 } else {
198  dol_print_error($db);
199 }
200 
201 /*
202  * Last modified MOs
203  */
204 
205 $max = 5;
206 
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 $resql = $db->query($sql);
214 if ($resql) {
215  print '<div class="div-table-responsive-no-min">';
216  print '<table class="noborder centpercent">';
217  print '<tr class="liste_titre">';
218  print '<th colspan="4">'.$langs->trans("LatestMOModified", $max).'</th></tr>';
219 
220  $num = $db->num_rows($resql);
221  if ($num) {
222  $i = 0;
223  while ($i < $num) {
224  $obj = $db->fetch_object($resql);
225 
226  $staticmo->id = $obj->rowid;
227  $staticmo->ref = $obj->ref;
228  $staticmo->date_modification = $obj->datem;
229  $staticmo->status = $obj->status;
230 
231  print '<tr class="oddeven">';
232  print '<td>'.$staticmo->getNomUrl(1, 32).'</td>';
233  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
234  print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
235  print '</tr>';
236  $i++;
237  }
238  } else {
239  print '<tr class="oddeven">';
240  print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
241  print '</tr>';
242  }
243  print "</table></div>";
244  print "<br>";
245 } else {
246  dol_print_error($db);
247 }
248 
249 print '</div></div>';
250 
251 $parameters = array(
252  //'type' => $type,
253  'user' => $user,
254 );
255 $reshook = $hookmanager->executeHooks('dashboardMRP', $parameters);
256 
257 // End of page
258 llxFooter();
259 $db->close();
restrictedArea
restrictedArea($user, $features, $objectid=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.
Definition: security.lib.php:234
load_fiche_titre
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
Definition: functions.lib.php:5204
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
DolGraph
Class to build graphs.
Definition: dolgraph.class.php:40
Mo
Class for Mo.
Definition: mo.class.php:35
BOM
Class for BOM.
Definition: bom.class.php:34
llxFooter
llxFooter()
Footer empty.
Definition: index.php:71
llxHeader
if(!defined('NOTOKENRENEWAL')) if(!defined('NOLOGIN')) if(!defined('NOCSRFCHECK')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) if(!defined('NOIPCHECK')) if(!defined('NOBROWSERNOTIF')) llxHeader()
Header empty.
Definition: index.php:63
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30