dolibarr  13.0.2
index.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3  * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
4  * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
5  * Copyright (C) 2018 Quentin Vial-Gouteyron <quentin.vial-gouteyron@atm-consulting.fr>
6  * Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
28 require '../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/reception/class/reception.class.php';
31 
32 $hookmanager = new HookManager($db);
33 
34 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
35 $hookmanager->initHooks(array('receptionindex'));
36 
37 $langs->loadLangs(array("orders", "receptions"));
38 
39 /*
40  * View
41  */
42 
43 $orderstatic = new CommandeFournisseur($db);
44 $companystatic = new Societe($db);
45 $reception = new Reception($db);
46 
47 $helpurl = 'EN:Module_Receptions|FR:Module_Receptions|ES:M&oacute;dulo_Receptiones';
48 llxHeader('', $langs->trans("Reception"), $helpurl);
49 
50 print load_fiche_titre($langs->trans("ReceptionsArea"), '', 'dollyrevert');
51 
52 
53 print '<div class="fichecenter"><div class="fichethirdleft">';
54 
55 
56 if (!empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS)) // This is useless due to the global search combo
57 {
58  print '<form method="post" action="list.php">';
59  print '<input type="hidden" name="token" value="'.newToken().'">';
60  print '<div class="div-table-responsive-no-min">';
61  print '<table class="noborder nohover centpercent">';
62  print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Search").'</td></tr>';
63  print '<tr class="oddeven"><td>';
64  print $langs->trans("Reception").':</td><td><input type="text" class="flat" name="sall" size="18"></td><td><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
65  print "</table></div></form><br>\n";
66 }
67 
68 
69 /*
70  * Draft receptions
71  */
72 
73 $clause = " WHERE ";
74 
75 $sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
76 $sql .= " s.nom as name, s.rowid as socid,";
77 $sql .= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
78 $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
79 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception'";
80 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid";
81 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
82 if (!$user->rights->societe->client->voir && !$socid)
83 {
84  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
85  $sql .= $clause." sc.fk_user = ".$user->id;
86  $clause = " AND ";
87 }
88 $sql .= $clause." e.fk_statut = 0";
89 $sql .= " AND e.entity IN (".getEntity('reception').")";
90 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
91 
92 $resql = $db->query($sql);
93 if ($resql)
94 {
95  print '<div class="div-table-responsive-no-min">';
96  print '<table class="noborder centpercent">';
97  print '<tr class="liste_titre">';
98  print '<th colspan="3">'.$langs->trans("ReceptionsToValidate").'</th></tr>';
99 
100  $num = $db->num_rows($resql);
101  if ($num)
102  {
103  $i = 0;
104  while ($i < $num)
105  {
106  $obj = $db->fetch_object($resql);
107 
108  $reception->id = $obj->rowid;
109  $reception->ref = $obj->ref;
110  $reception->ref_supplier = $obj->ref_supplier;
111 
112  print '<tr class="oddeven"><td class="nowrap">';
113  print $reception->getNomUrl(1);
114  print "</td>";
115  print '<td>';
116  print '<a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name.'</a>';
117  print '</td>';
118  print '<td>';
119  if ($obj->commande_fournisseur_id) print '<a href="'.DOL_URL_ROOT.'/commande_fournisseur/card.php?id='.$obj->commande_fournisseur_id.'">'.$obj->commande_fournisseur_ref.'</a>';
120  print '</td></tr>';
121  $i++;
122  }
123  } else {
124  print '<tr><td><span class="opacitymedium">'.$langs->trans("None").'</span></td><td></td><td></td></tr>';
125  }
126 
127  print "</table></div><br>";
128 }
129 
130 
131 //print '</td><td valign="top" width="70%">';
132 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
133 
134 $max = 5;
135 
136 /*
137  * Latest receptions
138  */
139 
140 $sql = "SELECT e.rowid, e.ref, e.ref_supplier,";
141 $sql .= " s.nom as name, s.rowid as socid,";
142 $sql .= " c.ref as commande_fournisseur_ref, c.rowid as commande_fournisseur_id";
143 $sql .= " FROM ".MAIN_DB_PREFIX."reception as e";
144 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_element as el ON e.rowid = el.fk_target AND el.targettype = 'reception' AND el.sourcetype IN ('order_supplier')";
145 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur as c ON el.fk_source = c.rowid AND el.sourcetype IN ('order_supplier') AND el.targettype = 'reception'";
146 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = e.fk_soc";
147 if (!$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
148 $sql .= " WHERE e.entity IN (".getEntity('reception').")";
149 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND sc.fk_user = ".$user->id;
150 $sql .= " AND e.fk_statut = 1";
151 if ($socid) $sql .= " AND c.fk_soc = ".$socid;
152 $sql .= " ORDER BY e.date_delivery DESC";
153 $sql .= $db->plimit($max, 0);
154 
155 $resql = $db->query($sql);
156 if ($resql)
157 {
158  $num = $db->num_rows($resql);
159  if ($num)
160  {
161  $i = 0;
162  print '<div class="div-table-responsive-no-min">';
163  print '<table class="noborder centpercent">';
164  print '<tr class="liste_titre">';
165  print '<th colspan="3">'.$langs->trans("LastReceptions", $num).'</th></tr>';
166  while ($i < $num)
167  {
168  $obj = $db->fetch_object($resql);
169 
170  $reception->id = $obj->rowid;
171  $reception->ref = $obj->ref;
172  $reception->ref_supplier = $obj->ref_supplier;
173 
174  print '<tr class="oddeven"><td>';
175  print $reception->getNomUrl(1);
176  print '</td>';
177  print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
178  print '<td>';
179  if ($obj->commande_fournisseur_id > 0)
180  {
181  $orderstatic->id = $obj->commande_fournisseur_id;
182  $orderstatic->ref = $obj->commande_fournisseur_ref;
183  print $orderstatic->getNomUrl(1);
184  } else print '&nbsp;';
185  print '</td></tr>';
186  $i++;
187  }
188  print "</table></div><br>";
189  }
190  $db->free($resql);
191 } else dol_print_error($db);
192 
193 
194 
195 /*
196  * Open pruchase orders to process
197  */
198 
199 $sql = "SELECT c.rowid, c.ref, c.ref_supplier as ref_supplier, c.fk_statut as status, c.billed as billed, s.nom as name, s.rowid as socid";
200 $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c,";
201 $sql .= " ".MAIN_DB_PREFIX."societe as s";
202 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
203 $sql .= " WHERE c.fk_soc = s.rowid";
204 $sql .= " AND c.entity IN (".getEntity('supplier_order').")";
205 $sql .= " AND c.fk_statut IN (".CommandeFournisseur::STATUS_ORDERSENT.", ".CommandeFournisseur::STATUS_RECEIVED_PARTIALLY.")";
206 if ($socid > 0) $sql .= " AND c.fk_soc = ".$socid;
207 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
208 $sql .= " ORDER BY c.rowid ASC";
209 $resql = $db->query($sql);
210 if ($resql)
211 {
212  $num = $db->num_rows($resql);
213  if ($num)
214  {
215  $langs->load("orders");
216 
217  $i = 0;
218  print '<div class="div-table-responsive-no-min">';
219  print '<table class="noborder centpercent">';
220  print '<tr class="liste_titre">';
221  print '<th colspan="3">'.$langs->trans("SuppliersOrdersToProcess").' <span class="badge">'.$num.'</span></th></tr>';
222  while ($i < $num)
223  {
224  $obj = $db->fetch_object($resql);
225 
226  $orderstatic->id = $obj->rowid;
227  $orderstatic->ref = $obj->ref;
228  $orderstatic->ref_supplier = $obj->ref_supplier;
229  $orderstatic->statut = $obj->status;
230  $orderstatic->facturee = $obj->billed;
231 
232  $companystatic->name = $obj->name;
233  $companystatic->id = $obj->socid;
234 
235  print '<tr class="oddeven">';
236  print '<td class="nowrap">';
237  print $orderstatic->getNomUrl(1);
238  print '</td>';
239  print '<td>';
240  print $companystatic->getNomUrl(1, 'customer', 32);
241  print '</td>';
242  print '<td class="right">';
243  print $orderstatic->getLibStatut(3);
244  print '</td>';
245  print '</tr>';
246  $i++;
247  }
248  print "</table></div><br>";
249  }
250 }
251 
252 print '</div></div></div>';
253 
254 $parameters = array('user' => $user);
255 $reshook = $hookmanager->executeHooks('dashboardWarehouseReceptions', $parameters, $object); // Note that $action and $object may have been modified by hook
256 
257 llxFooter();
258 $db->close();
llxHeader()
Empty header.
Definition: wrapper.php:45
Class to manage hooks.
Class to manage third parties objects (customers, suppliers, prospects...)
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
const STATUS_RECEIVED_PARTIALLY
Received partially.
Class to manage receptions.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
Class to manage predefined suppliers products.
print
Draft customers invoices.
Definition: index.php:89
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
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.