dolibarr  20.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@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
30 require '../main.inc.php';
31 require_once DOL_DOCUMENT_ROOT.'/bom/class/bom.class.php';
32 require_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 
55 llxHeader('', $langs->trans("MRP"), '');
56 
57 print load_fiche_titre($langs->trans("MRPArea"), '', 'mrp');
58 
59 
60 print '<div class="fichecenter"><div class="fichethirdleft">';
61 
62 
63 /*
64  * Statistics
65  */
66 
67 if ($conf->use_javascript_ajax) {
68  $sql = "SELECT COUNT(t.rowid) as nb, status";
69  $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
70  $sql .= " GROUP BY t.status";
71  $sql .= " ORDER BY t.status ASC";
72  $resql = $db->query($sql);
73 
74  if ($resql) {
75  $num = $db->num_rows($resql);
76  $i = 0;
77 
78  $totalnb = 0;
79  $dataseries = array();
80  $colorseries = array();
81  $vals = array();
82 
83  include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
84 
85  while ($i < $num) {
86  $obj = $db->fetch_object($resql);
87  if ($obj) {
88  $vals[$obj->status] = $obj->nb;
89 
90  $totalnb += $obj->nb;
91  }
92  $i++;
93  }
94  $db->free($resql);
95 
96  print '<div class="div-table-responsive-no-min">';
97  print '<table class="noborder nohover centpercent">';
98  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th>';
99  print '</tr>'."\n";
100  $listofstatus = array(0, 1, 2, 3, 9);
101  foreach ($listofstatus as $status) {
102  $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
103  if ($status == Mo::STATUS_DRAFT) {
104  $colorseries[$status] = '-'.$badgeStatus0;
105  }
106  if ($status == Mo::STATUS_VALIDATED) {
107  $colorseries[$status] = $badgeStatus1;
108  }
109  if ($status == Mo::STATUS_INPROGRESS) {
110  $colorseries[$status] = $badgeStatus4;
111  }
112  if ($status == Mo::STATUS_PRODUCED) {
113  $colorseries[$status] = $badgeStatus6;
114  }
115  if ($status == Mo::STATUS_CANCELED) {
116  $colorseries[$status] = $badgeStatus9;
117  }
118 
119  if (empty($conf->use_javascript_ajax)) {
120  print '<tr class="oddeven">';
121  print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
122  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
123  print "</tr>\n";
124  }
125  }
126  if ($conf->use_javascript_ajax) {
127  print '<tr><td class="center" colspan="2">';
128 
129  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
130  $dolgraph = new DolGraph();
131  $dolgraph->SetData($dataseries);
132  $dolgraph->SetDataColor(array_values($colorseries));
133  $dolgraph->setShowLegend(2);
134  $dolgraph->setShowPercent(1);
135  $dolgraph->SetType(array('pie'));
136  $dolgraph->SetHeight('200');
137  $dolgraph->draw('idgraphstatus');
138  print $dolgraph->show($totalnb ? 0 : 1);
139 
140  print '</td></tr>';
141  }
142  print "</table>";
143  print "</div>";
144 
145  print "<br>";
146  } else {
147  dol_print_error($db);
148  }
149 }
150 
151 print '<br>';
152 
153 
154 print '</div><div class="fichetwothirdright">';
155 
156 
157 /*
158  * Last modified BOM
159  */
160 
161 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status, a.fk_product";
162 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
163 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
164 $sql .= $db->order("a.tms", "DESC");
165 $sql .= $db->plimit($max, 0);
166 
167 $resql = $db->query($sql);
168 if ($resql) {
169  print '<div class="div-table-responsive-no-min">';
170  print '<table class="noborder centpercent">';
171  print '<tr class="liste_titre">';
172  print '<th colspan="2">'.$langs->trans("LatestBOMModified", $max);
173  $lastmodified = '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
174  $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
175  $lastmodified .= '</a>';
176  print $lastmodified;
177  print '</th>';
178  print '<th class="right">';
179  //print '<a href="'.DOL_URL_ROOT.'/bom/bom_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'bom');
180  print '</th>';
181  print '</tr>';
182 
183  $num = $db->num_rows($resql);
184  if ($num) {
185  $i = 0;
186  while ($i < $num) {
187  $obj = $db->fetch_object($resql);
188 
189  $staticbom->id = $obj->rowid;
190  $staticbom->ref = $obj->ref;
191  $staticbom->fk_product = $obj->fk_product;
192  $staticbom->date_modification = $obj->datem;
193  $staticbom->status = $obj->status;
194 
195  print '<tr class="oddeven">';
196  print '<td>'.$staticbom->getNomUrl(1, 32).'</td>';
197  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
198  print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
199  print '</tr>';
200  $i++;
201  }
202  } else {
203  print '<tr class="oddeven">';
204  print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
205  print '</tr>';
206  }
207  print "</table></div>";
208  print "<br>";
209 } else {
210  dol_print_error($db);
211 }
212 
213 /*
214  * Last modified MOs
215  */
216 
217 
218 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
219 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
220 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
221 $sql .= $db->order("a.tms", "DESC");
222 $sql .= $db->plimit($max, 0);
223 
224 $resql = $db->query($sql);
225 if ($resql) {
226  print '<div class="div-table-responsive-no-min">';
227  print '<table class="noborder centpercent">';
228  print '<tr class="liste_titre">';
229  print '<th colspan="2">'.$langs->trans("LatestMOModified", $max);
230  $lastmodified = '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC" title="'.$langs->trans("FullList").'">';
231  $lastmodified .= '<span class="badge marginleftonlyshort">...</span>';
232  $lastmodified .= '</a>';
233  print $lastmodified;
234  print '</th>';
235  print '<th class="right">';
236  //print '<a href="'.DOL_URL_ROOT.'/mrp/mo_list.php?sortfield=t.tms&sortorder=DESC">'.img_picto($langs->trans("FullList"), 'mrp');
237  print '</th>';
238  print '</tr>';
239 
240  $num = $db->num_rows($resql);
241  if ($num) {
242  $i = 0;
243  while ($i < $num) {
244  $obj = $db->fetch_object($resql);
245 
246  $staticmo->id = $obj->rowid;
247  $staticmo->ref = $obj->ref;
248  $staticmo->date_modification = $obj->datem;
249  $staticmo->status = $obj->status;
250 
251  print '<tr class="oddeven">';
252  print '<td>'.$staticmo->getNomUrl(1, 32).'</td>';
253  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
254  print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
255  print '</tr>';
256  $i++;
257  }
258  } else {
259  print '<tr class="oddeven">';
260  print '<td colspan="3"><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
261  print '</tr>';
262  }
263  print "</table></div>";
264  print "<br>";
265 } else {
266  dol_print_error($db);
267 }
268 
269 print '</div></div>';
270 
271 $object = new stdClass();
272 $parameters = array(
273  //'type' => $type,
274  'user' => $user,
275 );
276 $reshook = $hookmanager->executeHooks('dashboardMRP', $parameters, $object);
277 
278 // End of page
279 llxFooter();
280 $db->close();
if($user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition: card.php:58
Class for BOM.
Definition: bom.class.php:45
Class to build graphs.
Class to manage hooks.
Class for Mo.
Definition: mo.class.php:36
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
Definition: index.php:744
load_fiche_titre($titre, $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...
llxFooter()
Footer empty.
Definition: index.php:72
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:64
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.