dolibarr  13.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 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 {
66  $sql = "SELECT COUNT(t.rowid) as nb, status";
67  $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as t";
68  $sql .= " GROUP BY t.status";
69  $sql .= " ORDER BY t.status ASC";
70  $resql = $db->query($sql);
71 
72  if ($resql)
73  {
74  $num = $db->num_rows($resql);
75  $i = 0;
76 
77  $totalnb = 0;
78  $dataseries = array();
79  $colorseries = array();
80  $vals = array();
81 
82  include_once DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
83 
84  while ($i < $num)
85  {
86  $obj = $db->fetch_object($resql);
87  if ($obj)
88  {
89  $vals[$obj->status] = $obj->nb;
90 
91  $totalnb += $obj->nb;
92  }
93  $i++;
94  }
95  $db->free($resql);
96 
97  print '<div class="div-table-responsive-no-min">';
98  print '<table class="noborder nohover centpercent">';
99  print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("ManufacturingOrder").'</th></tr>'."\n";
100  $listofstatus = array(0, 1, 2, 3, 9);
101  foreach ($listofstatus as $status)
102  {
103  $dataseries[] = array($staticmo->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
104  if ($status == Mo::STATUS_DRAFT) $colorseries[$status] = '-'.$badgeStatus0;
105  if ($status == Mo::STATUS_VALIDATED) $colorseries[$status] = $badgeStatus1;
106  if ($status == Mo::STATUS_INPROGRESS) $colorseries[$status] = $badgeStatus4;
107  if ($status == Mo::STATUS_PRODUCED) $colorseries[$status] = $badgeStatus6;
108  if ($status == Mo::STATUS_CANCELED) $colorseries[$status] = $badgeStatus9;
109 
110  if (empty($conf->use_javascript_ajax))
111  {
112  print '<tr class="oddeven">';
113  print '<td>'.$staticmo->LibStatut($status, 0).'</td>';
114  print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
115  print "</tr>\n";
116  }
117  }
118  if ($conf->use_javascript_ajax)
119  {
120  print '<tr><td class="center" colspan="2">';
121 
122  include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
123  $dolgraph = new DolGraph();
124  $dolgraph->SetData($dataseries);
125  $dolgraph->SetDataColor(array_values($colorseries));
126  $dolgraph->setShowLegend(2);
127  $dolgraph->setShowPercent(1);
128  $dolgraph->SetType(array('pie'));
129  $dolgraph->SetHeight('200');
130  $dolgraph->draw('idgraphstatus');
131  print $dolgraph->show($totalnb ? 0 : 1);
132 
133  print '</td></tr>';
134  }
135  print "</table>";
136  print "</div>";
137 
138  print "<br>";
139  } else {
140  dol_print_error($db);
141  }
142 }
143 
144 print '<br>';
145 
146 
147 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
148 
149 /*
150  * Last modified BOM
151  */
152 
153 $max = 5;
154 
155 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
156 $sql .= " FROM ".MAIN_DB_PREFIX."bom_bom as a";
157 $sql .= " WHERE a.entity IN (".getEntity('bom').")";
158 $sql .= $db->order("a.tms", "DESC");
159 $sql .= $db->plimit($max, 0);
160 
161 $resql = $db->query($sql);
162 if ($resql)
163 {
164  print '<div class="div-table-responsive-no-min">';
165  print '<table class="noborder centpercent">';
166  print '<tr class="liste_titre">';
167  print '<th colspan="4">'.$langs->trans("LatestBOMModified", $max).'</th></tr>';
168 
169  $num = $db->num_rows($resql);
170  if ($num)
171  {
172  $i = 0;
173  while ($i < $num)
174  {
175  $obj = $db->fetch_object($resql);
176 
177  $staticbom->id = $obj->rowid;
178  $staticbom->ref = $obj->ref;
179  $staticbom->date_modification = $obj->datem;
180  $staticbom->status = $obj->status;
181 
182  print '<tr class="oddeven">';
183  print '<td>'.$staticbom->getNomUrl(1, 32).'</td>';
184  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
185  print '<td class="right">'.$staticbom->getLibStatut(3).'</td>';
186  print '</tr>';
187  $i++;
188  }
189  } else {
190  print '<tr class="oddeven">';
191  print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
192  print '</tr>';
193  }
194  print "</table></div>";
195  print "<br>";
196 } else {
197  dol_print_error($db);
198 }
199 
200 /*
201  * Last modified MOs
202  */
203 
204 $max = 5;
205 
206 $sql = "SELECT a.rowid, a.status, a.ref, a.tms as datem, a.status";
207 $sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo as a";
208 $sql .= " WHERE a.entity IN (".getEntity('mo').")";
209 $sql .= $db->order("a.tms", "DESC");
210 $sql .= $db->plimit($max, 0);
211 
212 $resql = $db->query($sql);
213 if ($resql)
214 {
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  {
223  $i = 0;
224  while ($i < $num)
225  {
226  $obj = $db->fetch_object($resql);
227 
228  $staticmo->id = $obj->rowid;
229  $staticmo->ref = $obj->ref;
230  $staticmo->date_modification = $obj->datem;
231  $staticmo->status = $obj->status;
232 
233  print '<tr class="oddeven">';
234  print '<td>'.$staticmo->getNomUrl(1, 32).'</td>';
235  print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
236  print '<td class="right">'.$staticmo->getLibStatut(3).'</td>';
237  print '</tr>';
238  $i++;
239  }
240  } else {
241  print '<tr class="oddeven">';
242  print '<td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
243  print '</tr>';
244  }
245  print "</table></div>";
246  print "<br>";
247 } else {
248  dol_print_error($db);
249 }
250 
251 print '</div></div></div>';
252 
253 $parameters = array(
254  //'type' => $type,
255  'user' => $user,
256 );
257 $reshook = $hookmanager->executeHooks('dashboardMRP', $parameters);
258 
259 // End of page
260 llxFooter();
261 $db->close();
Class for BOM.
Definition: bom.class.php:32
Class for Mo.
Definition: mo.class.php:34
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
print
Draft customers invoices.
Definition: index.php:89
Class to build graphs.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
llxFooter()
Empty footer.
Definition: wrapper.php:59