28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/contact/class/contact.class.php';
36 $socid = $user->socid;
38 $result =
restrictedArea($user,
'fournisseur', $orderid,
'',
'commande');
43 $hookmanager->initHooks(array(
'orderssuppliersindex'));
46 $langs->loadLangs(array(
"suppliers",
"orders"));
53 llxHeader(
'', $langs->trans(
"SuppliersOrdersArea"));
56 $userstatic =
new User($db);
59 print
load_fiche_titre($langs->trans(
"SuppliersOrdersArea"),
'',
'supplier_order');
61 print
'<div class="fichecenter"><div class="fichethirdleft">';
67 $sql =
"SELECT count(cf.rowid) as nb, fk_statut as status";
68 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
69 $sql .=
", ".MAIN_DB_PREFIX.
"commande_fournisseur as cf";
70 if (empty($user->rights->societe->client->voir) && !$socid) {
71 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
73 $sql .=
" WHERE cf.fk_soc = s.rowid";
74 $sql .=
" AND cf.entity IN (".getEntity(
'supplier_order').
")";
76 $sql .=
' AND cf.fk_soc = '.((int) $user->socid);
78 if (empty($user->rights->societe->client->voir) && !$socid) {
79 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
81 $sql .=
" GROUP BY cf.fk_statut";
85 $num = $db->num_rows(
$resql);
89 $dataseries = array();
95 $obj = $db->fetch_object(
$resql);
105 include DOL_DOCUMENT_ROOT.
'/theme/'.$conf->theme.
'/theme_vars.inc.php';
107 print
'<div class="div-table-responsive-no-min">';
108 print
'<table class="noborder nohover centpercent">';
109 print
'<tr class="liste_titre"><th colspan="2">'.$langs->trans(
"Statistics").
' - '.$langs->trans(
"SuppliersOrders").
'</th></tr>';
111 $listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
112 foreach ($listofstatus as $status) {
113 $dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (
int) $vals[$status] : 0));
115 $colorseries[$status] =
'-'.$badgeStatus0;
118 $colorseries[$status] =
'-'.$badgeStatus1;
121 $colorseries[$status] = $badgeStatus1;
124 $colorseries[$status] = $badgeStatus9;
127 $colorseries[$status] = $badgeStatus4;
130 $colorseries[$status] =
'-'.$badgeStatus4;
133 $colorseries[$status] = $badgeStatus6;
136 $colorseries[$status] = $badgeStatus9;
139 if (!$conf->use_javascript_ajax) {
140 print
'<tr class="oddeven">';
141 print
'<td>'.$commandestatic->LibStatut($status, 0).
'</td>';
142 print
'<td class="right"><a href="list.php?statut='.$status.
'">'.(isset($vals[$status]) ? $vals[$status] : 0).
'</a></td>';
146 if ($conf->use_javascript_ajax) {
147 print
'<tr class="impair"><td class="center" colspan="2">';
149 include_once DOL_DOCUMENT_ROOT.
'/core/class/dolgraph.class.php';
151 $dolgraph->SetData($dataseries);
152 $dolgraph->SetDataColor(array_values($colorseries));
153 $dolgraph->setShowLegend(2);
154 $dolgraph->setShowPercent(1);
155 $dolgraph->SetType(array(
'pie'));
156 $dolgraph->setHeight(
'200');
157 $dolgraph->draw(
'idgraphstatus');
158 print $dolgraph->show($total ? 0 : 1);
164 print
'<tr class="liste_total"><td>'.$langs->trans(
"Total").
'</td><td class="right">'.$total.
'</td></tr>';
166 print
"</table></div><br>";
175 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
176 $sql =
"SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
177 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
178 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
179 if (empty($user->rights->societe->client->voir) && !$socid) {
180 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
182 $sql .=
" WHERE c.fk_soc = s.rowid";
183 $sql .=
" AND c.entity IN (".getEntity(
"supplier_order").
")";
184 $sql .=
" AND c.fk_statut = 0";
185 if (!empty($socid)) {
186 $sql .=
" AND c.fk_soc = ".((int) $socid);
188 if (empty($user->rights->societe->client->voir) && !$socid) {
189 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
192 $resql = $db->query($sql);
194 print
'<div class="div-table-responsive-no-min">';
195 print
'<table class="noborder centpercent">';
196 print
'<tr class="liste_titre">';
197 print
'<th colspan="2">'.$langs->trans(
"DraftOrders").
'</th></tr>';
198 $langs->load(
"orders");
199 $num = $db->num_rows(
$resql);
203 $obj = $db->fetch_object(
$resql);
205 print
'<tr class="oddeven">';
206 print
'<td class="nowrap">';
207 print
"<a href=\"card.php?id=".$obj->rowid.
"\">".
img_object($langs->trans(
"ShowOrder"),
"order").
' '.$obj->ref.
"</a></td>";
208 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.
dol_trunc($obj->name, 24).
'</a></td></tr>';
212 print
"</table></div><br>";
222 if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
225 $sql .=
" u.rowid, u.lastname, u.firstname, u.email, u.statut";
226 $sql .=
" FROM ".MAIN_DB_PREFIX.
"user as u";
227 if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
228 $sql .=
",".MAIN_DB_PREFIX.
"usergroup_user as ug";
229 $sql .=
" WHERE ((ug.fk_user = u.rowid";
230 $sql .=
" AND ug.entity IN (".getEntity(
'usergroup').
"))";
231 $sql .=
" OR u.entity = 0)";
233 $sql .=
" WHERE (u.entity IN (".getEntity(
'user').
"))";
235 $sql .=
" AND u.fk_soc IS NULL";
237 $resql = $db->query($sql);
239 $num = $db->num_rows(
$resql);
242 print
'<div class="div-table-responsive-no-min">';
243 print
'<table class="liste centpercent">';
244 print
'<tr class="liste_titre"><th>'.$langs->trans(
"UserWithApproveOrderGrant").
'</th>';
248 $obj = $db->fetch_object(
$resql);
250 $userstatic =
new User($db);
251 $userstatic->id = $obj->rowid;
252 $userstatic->getrights(
'fournisseur');
254 if (!empty($userstatic->rights->fournisseur->commande->approuver)) {
255 print
'<tr class="oddeven">';
257 $userstatic->lastname = $obj->lastname;
258 $userstatic->firstname = $obj->firstname;
259 $userstatic->email = $obj->email;
260 $userstatic->statut = $obj->statut;
261 print $userstatic->getNomUrl(1);
268 print
"</table></div><br>";
275 print
'</div><div class="fichetwothirdright">';
283 $sql =
"SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
284 $sql .=
" FROM ".MAIN_DB_PREFIX.
"commande_fournisseur as c";
285 $sql .=
", ".MAIN_DB_PREFIX.
"societe as s";
286 if (empty($user->rights->societe->client->voir) && !$socid) {
287 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
289 $sql .=
" WHERE c.fk_soc = s.rowid";
290 $sql .=
" AND c.entity IN (".getEntity(
'supplier_order').
")";
292 if (!empty($socid)) {
293 $sql .=
" AND c.fk_soc = ".((int) $socid);
295 if (empty($user->rights->societe->client->voir) && !$socid) {
296 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
298 $sql .=
" ORDER BY c.tms DESC";
299 $sql .= $db->plimit($max, 0);
301 $resql = $db->query($sql);
303 print
'<div class="div-table-responsive-no-min">';
304 print
'<table class="noborder centpercent">';
305 print
'<tr class="liste_titre">';
306 print
'<th colspan="4">'.$langs->trans(
"LastModifiedOrders", $max).
'</th></tr>';
308 $num = $db->num_rows(
$resql);
312 $obj = $db->fetch_object(
$resql);
314 print
'<tr class="oddeven">';
315 print
'<td width="20%" class="nowrap">';
317 $commandestatic->id = $obj->rowid;
318 $commandestatic->ref = $obj->ref;
320 print
'<table class="nobordernopadding"><tr class="nocellnopadd">';
321 print
'<td width="96" class="nobordernopadding nowrap">';
322 print $commandestatic->getNomUrl(1);
325 print
'<td width="16" class="nobordernopadding nowrap">';
329 print
'<td width="16" class="right nobordernopadding hideonsmartphone">';
332 $urlsource = $_SERVER[
'PHP_SELF'].
'?id='.$obj->rowid;
333 print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
334 print
'</td></tr></table>';
338 print
'<td><a href="'.DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid.
'">'.
img_object($langs->trans(
"ShowCompany"),
"company").
' '.$obj->name.
'</a></td>';
339 print
'<td>'.dol_print_date($db->jdate($obj->tms),
'day').
'</td>';
340 print
'<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).
'</td>';
345 print
"</table></div><br>";
420 print
'</div></div>';
422 $parameters = array(
'user' => $user);
423 $reshook = $hookmanager->executeHooks(
'dashboardOrdersSuppliers', $parameters, $object);