dolibarr/htdocs/fourn/commande/index.php

464 lines
15 KiB
PHP
Raw Permalink Normal View History

2012-08-22 23:27:53 +02:00
<?php
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
2019-06-18 14:07:52 +02:00
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2012 Vinicius Nogueira <viniciusvgn@gmail.com>
2022-09-12 10:08:04 +02:00
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
2024-03-28 20:34:33 +01:00
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
2004-11-29 17:07:35 +01:00
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
2004-11-29 17:07:35 +01:00
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2019-09-23 21:55:30 +02:00
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2004-11-29 17:07:35 +01:00
*/
2005-01-09 18:35:22 +01:00
2005-06-11 13:34:38 +02:00
/**
2022-09-12 10:08:04 +02:00
* \file htdocs/fourn/commande/index.php
2024-12-03 18:26:24 +01:00
* \ingroup supplier order
2022-09-12 10:08:04 +02:00
* \brief Home page of supplier's orders area
2008-10-28 21:05:23 +01:00
*/
2005-01-09 18:35:22 +01:00
2022-09-12 10:08:04 +02:00
2022-09-07 20:08:59 +02:00
// Load Dolibarr environment
require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
2022-09-12 10:08:04 +02:00
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
add baseline exclude for phpstan (#31632) * add baseline exclude for phpstan * update * update * update * update * update * merge * restore one filter * delete old errors * fix * fix * fix * $moreforfilter can t be empty * fix * enable check * refresh baseline * add phpdoc * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * update phpstan baseline * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix * fix --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
2024-11-04 23:53:20 +01:00
/**
* @var Conf $conf
* @var DoliDB $db
* @var HookManager $hookmanager
* @var Translate $langs
* @var User $user
*/
2022-09-12 10:08:04 +02:00
// Load translation files required by the page
$langs->loadLangs(array("suppliers", "orders"));
// Initialize a technical object to manage hooks. Note that conf->hooks_modules contains array
$hookmanager->initHooks(array('orderssuppliersindex'));
$max = getDolGlobalInt('MAIN_SIZE_SHORTLIST_LIMIT', 5);
2004-11-29 17:07:35 +01:00
2008-02-25 17:30:43 +01:00
// Security check
$orderid = GETPOST('orderid');
2024-12-03 18:14:34 +01:00
$socid = GETPOSTINT('socid');
2021-02-25 23:21:30 +01:00
if ($user->socid) {
$socid = $user->socid;
}
$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
/*
2011-05-22 00:58:09 +02:00
* View
*/
llxHeader('', $langs->trans("SuppliersOrdersArea"), '', '', 0, 0, '', '', '', 'mod-supplier-order page-stats');
2004-11-29 17:07:35 +01:00
2010-12-01 22:16:28 +01:00
$commandestatic = new CommandeFournisseur($db);
$userstatic = new User($db);
2010-12-01 22:16:28 +01:00
$formfile = new FormFile($db);
2004-11-30 20:26:30 +01:00
2020-04-25 13:49:44 +02:00
print load_fiche_titre($langs->trans("SuppliersOrdersArea"), '', 'supplier_order');
2004-11-29 17:07:35 +01:00
print '<div class="fichecenter"><div class="fichethirdleft">';
2004-11-29 17:07:35 +01:00
/*
2011-05-22 00:58:09 +02:00
* Statistics
2015-05-10 23:43:18 +02:00
*/
2020-03-24 19:06:37 +01:00
$sql = "SELECT count(cf.rowid) as nb, fk_statut as status";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
2021-02-25 23:21:30 +01:00
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE cf.fk_soc = s.rowid";
2020-03-23 15:24:29 +01:00
$sql .= " AND cf.entity IN (".getEntity('supplier_order').")";
2021-02-25 23:21:30 +01:00
if ($user->socid) {
2021-08-28 00:55:51 +02:00
$sql .= ' AND cf.fk_soc = '.((int) $user->socid);
2021-02-25 23:21:30 +01:00
}
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
2021-02-25 23:21:30 +01:00
}
$sql .= " GROUP BY cf.fk_statut";
2004-11-29 17:07:35 +01:00
$resql = $db->query($sql);
2021-02-25 23:21:30 +01:00
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
$total = 0;
$dataseries = array();
Fix: Initialise array before assigning values (#28728) * Qual: Enable PhanUndeclaredVariableDim # Qual: Enable PhanUndeclaredVariableDim The notifications are fixed in the code so the detection no longer needs to be suppressed in the default flow * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Fix: initialise array before adding fields * Qual: Add type hint to array to avoid phan notification * Qual: Add type hint to array to avoid phan notification * Qual: Enable PhanParamSpecial1 (all resolved) * Qual: Ignore false PhanTypeArraySuspiciousNullable * Qual: Improve typing to fix PhanTypeArraySuspicious * Qual: Fix PhanTypeArraySuspicious by replacing null assignment with empty array * Qual: Fix PhanTypeArraySuspicious by testing as instancof DebugBar * Qual: Fix PhanTypeComparisonToArray with enhanced typing * Qual: Fix PhanTypeComparisonToArray with enhanced typing * Qual: Enable phan messages that no longer appear * Qual: Exclude phan stubs from codesniffer ruleset
2024-03-09 16:32:02 +01:00
$colorseries = array();
$vals = array();
// 0=Draft -> 1=Validated -> 2=Approved -> 3=Process running -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
// -> 7=Canceled/Never received -> (reopen) 3=Process running
// -> 6=Canceled -> (reopen) 2=Approved
2021-02-25 23:21:30 +01:00
while ($i < $num) {
2020-03-24 19:06:37 +01:00
$obj = $db->fetch_object($resql);
2021-02-25 23:21:30 +01:00
if ($obj) {
2020-03-24 19:06:37 +01:00
$vals[($obj->status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER ? CommandeFournisseur::STATUS_CANCELED : $obj->status)] = $obj->nb;
$total += $obj->nb;
}
$i++;
}
$db->free($resql);
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
2024-12-03 18:14:34 +01:00
/**
* @var string $badgeStatus0
* @var string $badgeStatus1
* @var string $badgeStatus4
* @var string $badgeStatus6
* @var string $badgeStatus9
*/
2019-11-07 11:23:17 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:14:22 +01:00
print '<table class="noborder nohover centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'</th></tr>';
print "</tr>\n";
$listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
2021-02-25 23:21:30 +01:00
foreach ($listofstatus as $status) {
$dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
2021-02-25 23:21:30 +01:00
if ($status == CommandeFournisseur::STATUS_DRAFT) {
$colorseries[$status] = '-'.$badgeStatus0;
}
if ($status == CommandeFournisseur::STATUS_VALIDATED) {
$colorseries[$status] = '-'.$badgeStatus1;
}
if ($status == CommandeFournisseur::STATUS_ACCEPTED) {
$colorseries[$status] = $badgeStatus1;
}
if ($status == CommandeFournisseur::STATUS_REFUSED) {
$colorseries[$status] = $badgeStatus9;
}
if ($status == CommandeFournisseur::STATUS_ORDERSENT) {
$colorseries[$status] = $badgeStatus4;
}
if ($status == CommandeFournisseur::STATUS_RECEIVED_PARTIALLY) {
$colorseries[$status] = '-'.$badgeStatus4;
}
if ($status == CommandeFournisseur::STATUS_RECEIVED_COMPLETELY) {
$colorseries[$status] = $badgeStatus6;
}
if ($status == CommandeFournisseur::STATUS_CANCELED || $status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER) {
$colorseries[$status] = $badgeStatus9;
}
if (!$conf->use_javascript_ajax) {
print '<tr class="oddeven">';
2019-11-01 23:58:14 +01:00
print '<td>'.$commandestatic->LibStatut($status, 0).'</td>';
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
print "</tr>\n";
}
}
2021-02-25 23:21:30 +01:00
if ($conf->use_javascript_ajax) {
2019-03-07 20:46:38 +01:00
print '<tr class="impair"><td class="center" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
2020-03-24 19:06:37 +01:00
$dolgraph->SetDataColor(array_values($colorseries));
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total ? 0 : 1);
print '</td></tr>';
}
//if ($totalinprocess != $total)
2019-03-07 20:46:38 +01:00
//print '<tr class="liste_total"><td>'.$langs->trans("Total").' ('.$langs->trans("SuppliersOrdersRunning").')</td><td class="right">'.$totalinprocess.'</td></tr>';
print '<tr class="liste_total"><td>'.$langs->trans("Total").'</td><td class="right">'.$total.'</td></tr>';
2019-11-05 21:14:22 +01:00
print "</table></div><br>";
2020-05-21 15:05:19 +02:00
} else {
dol_print_error($db);
}
/*
* Draft orders
*/
2023-04-18 16:15:13 +02:00
if (isModEnabled("supplier_order")) {
$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
2021-02-25 23:21:30 +01:00
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
$sql .= " AND c.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing
$sql .= " AND c.fk_statut = 0";
2021-02-25 23:21:30 +01:00
if (!empty($socid)) {
2021-06-09 15:36:47 +02:00
$sql .= " AND c.fk_soc = ".((int) $socid);
2021-02-25 23:21:30 +01:00
}
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
2021-02-25 23:21:30 +01:00
}
$resql = $db->query($sql);
2021-02-25 23:21:30 +01:00
if ($resql) {
2019-11-07 12:43:33 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
print '<th colspan="2">'.$langs->trans("DraftOrders").'</th></tr>';
$langs->load("orders");
$num = $db->num_rows($resql);
2021-02-25 23:21:30 +01:00
if ($num) {
$i = 0;
2021-02-25 23:21:30 +01:00
while ($i < $num) {
$obj = $db->fetch_object($resql);
2018-04-22 18:51:03 +02:00
print '<tr class="oddeven">';
print '<td class="nowrap">';
print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowOrder"), "order").' '.$obj->ref."</a></td>";
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>';
$i++;
}
}
2019-11-05 21:14:22 +01:00
print "</table></div><br>";
}
}
2010-12-01 22:16:28 +01:00
/*
* List of users allowed to approve
2010-12-01 22:16:28 +01:00
*/
2020-02-17 19:13:37 +01:00
$sql = "SELECT";
2023-11-27 11:41:05 +01:00
if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
2020-02-17 19:13:37 +01:00
$sql .= " DISTINCT";
}
$sql .= " u.rowid, u.login, u.lastname, u.firstname, u.email, u.photo, u.statut";
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
2023-11-27 11:41:05 +01:00
if (isModEnabled('multicompany') && getDolGlobalString('MULTICOMPANY_TRANSVERSE_MODE')) {
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql .= " WHERE ((ug.fk_user = u.rowid";
$sql .= " AND ug.entity IN (".getEntity('usergroup')."))";
$sql .= " OR u.entity = 0)"; // Show always superadmin
2020-05-21 15:05:19 +02:00
} else {
$sql .= " WHERE (u.entity IN (".getEntity('user')."))";
2020-02-17 19:13:37 +01:00
}
$sql .= " AND u.fk_soc IS NULL"; // An external user can not approve
$resql = $db->query($sql);
2021-02-25 23:21:30 +01:00
if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
2019-11-07 11:23:17 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="liste centpercent">';
print '<tr class="liste_titre"><th>'.$langs->trans("UserWithApproveOrderGrant").'</th>';
print "</tr>\n";
print '<tr class="oddeven">';
print '<td>';
2021-02-25 23:21:30 +01:00
while ($i < $num) {
$obj = $db->fetch_object($resql);
$userstatic = new User($db);
$userstatic->id = $obj->rowid;
$userstatic->loadRights('fournisseur');
2023-10-15 18:12:03 +02:00
if ($userstatic->hasRight('fournisseur', 'commande', 'approuver')) {
if ($i > 0) {
print ', ';
}
$userstatic->lastname = $obj->lastname;
$userstatic->firstname = $obj->firstname;
$userstatic->email = $obj->email;
$userstatic->login = $obj->login;
$userstatic->photo = $obj->photo;
2024-03-28 20:34:33 +01:00
$userstatic->status = $obj->statut;
print $userstatic->getNomUrl(-1);
}
$i++;
}
if ($i == 0) {
print '<span class="opacitymedium">'.$langs->trans("Nobody").'</span>';
}
print '</td>';
print "</tr>\n";
2019-11-05 21:14:22 +01:00
print "</table></div><br>";
$db->free($resql);
2020-05-21 15:05:19 +02:00
} else {
dol_print_error($db);
2004-11-29 17:07:35 +01:00
}
2010-12-01 22:16:28 +01:00
2021-10-24 00:37:37 +02:00
print '</div><div class="fichetwothirdright">';
2010-12-01 22:16:28 +01:00
/*
* Last modified orders
*/
2010-12-01 22:16:28 +01:00
2020-03-24 19:06:37 +01:00
$sql = "SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
2021-02-25 23:21:30 +01:00
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
}
$sql .= " WHERE c.fk_soc = s.rowid";
2021-08-23 18:56:46 +02:00
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
2010-12-01 22:16:28 +01:00
//$sql.= " AND c.fk_statut > 2";
2021-02-25 23:21:30 +01:00
if (!empty($socid)) {
2021-06-09 15:36:47 +02:00
$sql .= " AND c.fk_soc = ".((int) $socid);
2021-02-25 23:21:30 +01:00
}
if (!$user->hasRight("societe", "client", "voir") && !$socid) {
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
2021-02-25 23:21:30 +01:00
}
$sql .= " ORDER BY c.tms DESC";
$sql .= $db->plimit($max, 0);
2010-12-01 22:16:28 +01:00
$resql = $db->query($sql);
2021-02-25 23:21:30 +01:00
if ($resql) {
2019-11-07 11:23:17 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
2024-06-22 02:51:10 +02:00
print '<th colspan="4">'.$langs->trans("LastModifiedOrders", $max).' ';
print '<a href="'.DOL_URL_ROOT.'/fourn/commande/list.php?sortfield=cf.tms&sortorder=DESC">';
print '<span class="badge">...</span>';
print '</a>';
print '</th></tr>';
$num = $db->num_rows($resql);
2021-02-25 23:21:30 +01:00
if ($num) {
$i = 0;
2021-02-25 23:21:30 +01:00
while ($i < $num) {
$obj = $db->fetch_object($resql);
print '<tr class="oddeven">';
print '<td width="20%" class="nowrap">';
$commandestatic->id = $obj->rowid;
$commandestatic->ref = $obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $commandestatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
print '&nbsp;';
print '</td>';
2019-03-07 20:46:38 +01:00
print '<td width="16" class="right nobordernopadding hideonsmartphone">';
$filename = dol_sanitizeFileName($obj->ref);
$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/fourn/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.$obj->name.'</a></td>';
print '<td>'.dol_print_date($db->jdate($obj->tms), 'day').'</td>';
2020-03-24 19:06:37 +01:00
print '<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).'</td>';
print '</tr>';
$i++;
}
}
2019-11-05 21:14:22 +01:00
print "</table></div><br>";
2021-02-25 23:21:30 +01:00
} else {
dol_print_error($db);
}
2010-12-01 22:16:28 +01:00
/*
* Orders to process
2021-08-23 18:56:46 +02:00
*/
/*
$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid";
$sql.=" FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->hasRight("societe", "client", "voir") && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE c.fk_soc = s.rowid";
2021-08-23 18:56:46 +02:00
$sql.= " AND c.entity IN (".getEntity("supplier_order").")";
$sql.= " AND c.fk_statut = 1";
2021-06-09 15:36:47 +02:00
if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
if (!$user->hasRight("societe", "client", "voir") && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id);
$sql.= " ORDER BY c.rowid DESC";
$resql=$db->query($sql);
if ($resql)
{
$num = $db->num_rows($resql);
2019-11-05 21:14:22 +01:00
print '<div class="div-table-responsive-no-min">';
2019-11-05 21:24:41 +01:00
print '<table class="noborder centpercent">';
print '<tr class="liste_titre">';
2020-04-15 15:01:00 +02:00
print '<th colspan="3">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=1">('.$num.')</a></th></tr>';
if ($num)
{
$i = 0;
while ($i < $num)
{
$obj = $db->fetch_object($resql);
2018-04-22 18:51:03 +02:00
print '<tr class="oddeven">';
print '<td class="nowrap">';
$commandestatic->id=$obj->rowid;
$commandestatic->ref=$obj->ref;
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td width="96" class="nobordernopadding nowrap">';
print $commandestatic->getNomUrl(1);
print '</td>';
print '<td width="16" class="nobordernopadding nowrap">';
print '&nbsp;';
print '</td>';
2019-03-07 20:46:38 +01:00
print '<td width="16" class="right nobordernopadding hideonsmartphone">';
$filename=dol_sanitizeFileName($obj->ref);
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
2012-09-15 09:02:20 +02:00
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
print '</td></tr></table>';
print '</td>';
print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"),"company").' '.dol_trunc($obj->name,24).'</a></td>';
2019-03-07 20:46:38 +01:00
print '<td class="right">'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
print '</tr>';
$i++;
}
}
2010-12-01 22:16:28 +01:00
2019-11-05 21:14:22 +01:00
print "</table></div><br>";
}
*/
2010-12-01 22:16:28 +01:00
2021-10-24 00:37:37 +02:00
print '</div></div>';
2004-11-29 17:07:35 +01:00
2019-06-18 14:07:52 +02:00
$parameters = array('user' => $user);
$reshook = $hookmanager->executeHooks('dashboardOrdersSuppliers', $parameters, $object); // Note that $action and $object may have been modified by hook
2018-08-12 22:40:47 +02:00
// End of page
llxFooter();
$db->close();