2012-08-22 21:27:53 +00:00
|
|
|
<?php
|
2012-07-11 16:13:41 +00:00
|
|
|
/* Copyright (C) 2001-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2019-06-18 12:07:52 +00: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>
|
|
|
|
|
* Copyright (C) 2019 Nicolas ZABOURI <info@inovea-conseil.com>
|
2004-11-29 16:07:35 +00: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
|
2013-01-16 14:36:08 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2004-11-29 16:07:35 +00: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 19:55:30 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2004-11-29 16:07:35 +00:00
|
|
|
*/
|
2005-01-09 17:35:22 +00:00
|
|
|
|
2005-06-11 11:34:38 +00:00
|
|
|
/**
|
2016-09-07 20:25:37 +00:00
|
|
|
* \file htdocs/fourn/commande/index.php
|
|
|
|
|
* \ingroup commande fournisseur
|
|
|
|
|
* \brief Home page of supplier's orders area
|
2008-10-28 20:05:23 +00:00
|
|
|
*/
|
2005-01-09 17:35:22 +00:00
|
|
|
|
2012-08-22 21:24:21 +00:00
|
|
|
require '../../main.inc.php';
|
2012-08-22 21:11:24 +00:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2008-02-25 16:30:43 +00:00
|
|
|
// Security check
|
2012-07-11 16:13:41 +00:00
|
|
|
$orderid = GETPOST('orderid');
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($user->socid) {
|
|
|
|
|
$socid = $user->socid;
|
|
|
|
|
}
|
2013-03-24 20:06:45 +00:00
|
|
|
$result = restrictedArea($user, 'fournisseur', $orderid, '', 'commande');
|
2010-11-13 17:37:22 +00:00
|
|
|
|
2019-06-18 12:07:52 +00:00
|
|
|
$hookmanager = new HookManager($db);
|
|
|
|
|
|
|
|
|
|
// Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
|
|
|
|
|
$hookmanager->initHooks(array('orderssuppliersindex'));
|
|
|
|
|
|
2018-09-16 09:47:56 +00:00
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array("suppliers", "orders"));
|
2008-02-25 16:30:43 +00:00
|
|
|
|
2008-02-24 23:29:30 +00:00
|
|
|
|
|
|
|
|
/*
|
2011-05-21 22:58:09 +00:00
|
|
|
* View
|
2012-07-11 16:13:41 +00:00
|
|
|
*/
|
2008-02-24 23:29:30 +00:00
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
llxHeader('', $langs->trans("SuppliersOrdersArea"));
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2010-12-01 21:16:28 +00:00
|
|
|
$commandestatic = new CommandeFournisseur($db);
|
2019-11-11 23:15:34 +00:00
|
|
|
$userstatic = new User($db);
|
2010-12-01 21:16:28 +00:00
|
|
|
$formfile = new FormFile($db);
|
2004-11-30 19:26:30 +00:00
|
|
|
|
2020-04-25 11:49:44 +00:00
|
|
|
print load_fiche_titre($langs->trans("SuppliersOrdersArea"), '', 'supplier_order');
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2016-09-07 20:25:37 +00:00
|
|
|
print '<div class="fichecenter"><div class="fichethirdleft">';
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2009-07-08 10:10:35 +00:00
|
|
|
/*
|
2011-05-21 22:58:09 +00:00
|
|
|
* Statistics
|
2015-05-10 21:43:18 +00:00
|
|
|
*/
|
2009-07-08 10:10:35 +00:00
|
|
|
|
2020-03-24 18:06:37 +00:00
|
|
|
$sql = "SELECT count(cf.rowid) as nb, fk_statut as status";
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
|
|
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."commande_fournisseur as cf";
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-02-25 22:21:30 +00:00
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " WHERE cf.fk_soc = s.rowid";
|
2020-03-23 14:24:29 +00:00
|
|
|
$sql .= " AND cf.entity IN (".getEntity('supplier_order').")";
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($user->socid) {
|
2021-08-27 22:55:51 +00:00
|
|
|
$sql .= ' AND cf.fk_soc = '.((int) $user->socid);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-08-23 15:41:11 +00:00
|
|
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " GROUP BY cf.fk_statut";
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2005-04-04 12:29:24 +00:00
|
|
|
$resql = $db->query($sql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($resql) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
2019-11-11 23:15:34 +00:00
|
|
|
$total = 0;
|
|
|
|
|
$dataseries = array();
|
|
|
|
|
$vals = array();
|
2016-09-07 20:25:37 +00:00
|
|
|
// 0=Draft -> 1=Validated -> 2=Approved -> 3=Process runing -> 4=Received partially -> 5=Received totally -> (reopen) 4=Received partially
|
|
|
|
|
// -> 7=Canceled/Never received -> (reopen) 3=Process runing
|
|
|
|
|
// -> 6=Canceled -> (reopen) 2=Approved
|
2021-02-25 22:21:30 +00:00
|
|
|
while ($i < $num) {
|
2020-03-24 18:06:37 +00:00
|
|
|
$obj = $db->fetch_object($resql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($obj) {
|
2020-03-24 18:06:37 +00:00
|
|
|
$vals[($obj->status == CommandeFournisseur::STATUS_CANCELED_AFTER_ORDER ? CommandeFournisseur::STATUS_CANCELED : $obj->status)] = $obj->nb;
|
|
|
|
|
|
|
|
|
|
$total += $obj->nb;
|
2016-09-07 20:25:37 +00:00
|
|
|
}
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
$db->free($resql);
|
|
|
|
|
|
2021-04-06 20:18:32 +00:00
|
|
|
include DOL_DOCUMENT_ROOT.'/theme/'.$conf->theme.'/theme_vars.inc.php';
|
2020-03-24 18:06:37 +00:00
|
|
|
|
2019-11-07 10:23:17 +00:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 20:14:22 +00:00
|
|
|
print '<table class="noborder nohover centpercent">';
|
2017-03-07 21:45:22 +00:00
|
|
|
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").' - '.$langs->trans("SuppliersOrders").'</th></tr>';
|
2016-09-07 20:25:37 +00:00
|
|
|
print "</tr>\n";
|
2020-04-10 08:59:32 +00:00
|
|
|
$listofstatus = array(0, 1, 2, 3, 4, 5, 6, 9);
|
2021-02-25 22:21:30 +00:00
|
|
|
foreach ($listofstatus as $status) {
|
2019-11-11 23:15:34 +00:00
|
|
|
$dataseries[] = array($commandestatic->LibStatut($status, 1), (isset($vals[$status]) ? (int) $vals[$status] : 0));
|
2021-02-25 22:21:30 +00: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) {
|
2017-04-14 09:22:48 +00:00
|
|
|
print '<tr class="oddeven">';
|
2019-11-01 22:58:14 +00:00
|
|
|
print '<td>'.$commandestatic->LibStatut($status, 0).'</td>';
|
2019-11-11 23:15:34 +00:00
|
|
|
print '<td class="right"><a href="list.php?statut='.$status.'">'.(isset($vals[$status]) ? $vals[$status] : 0).'</a></td>';
|
2016-09-07 20:25:37 +00:00
|
|
|
print "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($conf->use_javascript_ajax) {
|
2019-03-07 19:46:38 +00:00
|
|
|
print '<tr class="impair"><td class="center" colspan="2">';
|
2017-11-23 19:00:54 +00:00
|
|
|
|
|
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
|
|
|
|
|
$dolgraph = new DolGraph();
|
|
|
|
|
$dolgraph->SetData($dataseries);
|
2020-03-24 18:06:37 +00:00
|
|
|
$dolgraph->SetDataColor(array_values($colorseries));
|
2020-03-05 16:23:19 +00:00
|
|
|
$dolgraph->setShowLegend(2);
|
2017-11-23 19:00:54 +00:00
|
|
|
$dolgraph->setShowPercent(1);
|
|
|
|
|
$dolgraph->SetType(array('pie'));
|
2020-03-05 16:23:19 +00:00
|
|
|
$dolgraph->setHeight('200');
|
2017-11-23 19:00:54 +00:00
|
|
|
$dolgraph->draw('idgraphstatus');
|
2019-11-11 23:15:34 +00:00
|
|
|
print $dolgraph->show($total ? 0 : 1);
|
2017-11-23 19:00:54 +00:00
|
|
|
|
2016-09-07 20:25:37 +00:00
|
|
|
print '</td></tr>';
|
|
|
|
|
}
|
|
|
|
|
//if ($totalinprocess != $total)
|
2019-03-07 19:46:38 +00: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>';
|
2016-09-07 20:25:37 +00:00
|
|
|
|
2019-11-05 20:14:22 +00:00
|
|
|
print "</table></div><br>";
|
2020-05-21 13:05:19 +00:00
|
|
|
} else {
|
2016-09-07 20:25:37 +00:00
|
|
|
dol_print_error($db);
|
2005-04-04 12:29:24 +00:00
|
|
|
}
|
2008-02-24 23:29:30 +00:00
|
|
|
|
2012-04-04 15:43:32 +00:00
|
|
|
/*
|
|
|
|
|
* Draft orders
|
|
|
|
|
*/
|
|
|
|
|
|
2021-04-11 02:24:21 +00:00
|
|
|
if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$sql = "SELECT c.rowid, c.ref, s.nom as name, s.rowid as socid";
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
|
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-02-25 22:21:30 +00:00
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " WHERE c.fk_soc = s.rowid";
|
2020-02-18 21:38:30 +00:00
|
|
|
$sql .= " AND c.entity IN (".getEntity("supplier_order").")"; // Thirdparty sharing is mandatory with supplier order sharing
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " AND c.fk_statut = 0";
|
2021-02-25 22:21:30 +00:00
|
|
|
if (!empty($socid)) {
|
2021-06-09 13:36:47 +00:00
|
|
|
$sql .= " AND c.fk_soc = ".((int) $socid);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-08-23 15:41:11 +00:00
|
|
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($resql) {
|
2019-11-07 11:43:33 +00:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 20:24:41 +00:00
|
|
|
print '<table class="noborder centpercent">';
|
2016-09-07 20:25:37 +00:00
|
|
|
print '<tr class="liste_titre">';
|
2017-03-07 21:45:22 +00:00
|
|
|
print '<th colspan="2">'.$langs->trans("DraftOrders").'</th></tr>';
|
2016-09-07 20:25:37 +00:00
|
|
|
$langs->load("orders");
|
|
|
|
|
$num = $db->num_rows($resql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($num) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$i = 0;
|
2021-02-25 22:21:30 +00:00
|
|
|
while ($i < $num) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$obj = $db->fetch_object($resql);
|
2018-04-22 16:51:03 +00:00
|
|
|
|
2017-04-14 09:22:48 +00:00
|
|
|
print '<tr class="oddeven">';
|
2016-09-07 20:25:37 +00:00
|
|
|
print '<td class="nowrap">';
|
2019-01-27 10:55:16 +00:00
|
|
|
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>';
|
2016-09-07 20:25:37 +00:00
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-05 20:14:22 +00:00
|
|
|
print "</table></div><br>";
|
2016-09-07 20:25:37 +00:00
|
|
|
}
|
2009-07-08 10:10:35 +00:00
|
|
|
}
|
2008-02-24 23:29:30 +00:00
|
|
|
|
2012-04-04 15:43:32 +00:00
|
|
|
|
2010-12-01 21:16:28 +00:00
|
|
|
/*
|
|
|
|
|
* List of users allowed
|
|
|
|
|
*/
|
2020-02-18 21:38:30 +00:00
|
|
|
|
2020-02-17 18:13:37 +00:00
|
|
|
$sql = "SELECT";
|
2020-02-21 16:53:37 +00:00
|
|
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
2020-02-17 18:13:37 +00:00
|
|
|
$sql .= " DISTINCT";
|
|
|
|
|
}
|
2020-02-21 16:53:37 +00:00
|
|
|
$sql .= " u.rowid, u.lastname, u.firstname, u.email, u.statut";
|
|
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
2021-02-25 22:21:30 +00:00
|
|
|
if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
|
2020-02-21 16:53:37 +00:00
|
|
|
$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 13:05:19 +00:00
|
|
|
} else {
|
2020-03-23 14:38:10 +00:00
|
|
|
$sql .= " WHERE (u.entity IN (".getEntity('user')."))";
|
2020-02-17 18:13:37 +00:00
|
|
|
}
|
2020-02-21 16:53:37 +00:00
|
|
|
$sql .= " AND u.fk_soc IS NULL"; // An external user can not approved
|
2005-04-04 12:29:24 +00:00
|
|
|
|
|
|
|
|
$resql = $db->query($sql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($resql) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$num = $db->num_rows($resql);
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
2019-11-07 10:23:17 +00:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 20:24:41 +00:00
|
|
|
print '<table class="liste centpercent">';
|
2017-03-07 21:45:22 +00:00
|
|
|
print '<tr class="liste_titre"><th>'.$langs->trans("UserWithApproveOrderGrant").'</th>';
|
2016-09-07 20:25:37 +00:00
|
|
|
print "</tr>\n";
|
|
|
|
|
|
2021-02-25 22:21:30 +00:00
|
|
|
while ($i < $num) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$obj = $db->fetch_object($resql);
|
2017-11-23 19:00:54 +00:00
|
|
|
|
2020-02-18 07:35:51 +00:00
|
|
|
$userstatic = new User($db);
|
2019-11-11 23:15:34 +00:00
|
|
|
$userstatic->id = $obj->rowid;
|
2020-02-18 07:35:51 +00:00
|
|
|
$userstatic->getrights('fournisseur');
|
|
|
|
|
|
2021-02-25 22:21:30 +00:00
|
|
|
if (!empty($userstatic->rights->fournisseur->commande->approuver)) {
|
2020-02-18 07:35:51 +00:00
|
|
|
print '<tr class="oddeven">';
|
|
|
|
|
print '<td>';
|
|
|
|
|
$userstatic->lastname = $obj->lastname;
|
|
|
|
|
$userstatic->firstname = $obj->firstname;
|
|
|
|
|
$userstatic->email = $obj->email;
|
2020-02-18 08:03:25 +00:00
|
|
|
$userstatic->statut = $obj->statut;
|
2020-02-18 07:35:51 +00:00
|
|
|
print $userstatic->getNomUrl(1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-07 20:25:37 +00:00
|
|
|
$i++;
|
|
|
|
|
}
|
2019-11-05 20:14:22 +00:00
|
|
|
print "</table></div><br>";
|
2016-09-07 20:25:37 +00:00
|
|
|
$db->free($resql);
|
2020-05-21 13:05:19 +00:00
|
|
|
} else {
|
2016-09-07 20:25:37 +00:00
|
|
|
dol_print_error($db);
|
2004-11-29 16:07:35 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2021-10-23 22:37:37 +00:00
|
|
|
print '</div><div class="fichetwothirdright">';
|
2010-12-01 21:16:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Last modified orders
|
2012-04-04 15:43:32 +00:00
|
|
|
*/
|
2019-11-11 23:15:34 +00:00
|
|
|
$max = 5;
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2020-03-24 18:06:37 +00:00
|
|
|
$sql = "SELECT c.rowid, c.ref, c.fk_statut as status, c.tms, c.billed, s.nom as name, s.rowid as socid";
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
|
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."societe as s";
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-02-25 22:21:30 +00:00
|
|
|
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
|
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " WHERE c.fk_soc = s.rowid";
|
2021-08-23 16:56:46 +00:00
|
|
|
$sql .= " AND c.entity IN (".getEntity('supplier_order').")";
|
2010-12-01 21:16:28 +00:00
|
|
|
//$sql.= " AND c.fk_statut > 2";
|
2021-02-25 22:21:30 +00:00
|
|
|
if (!empty($socid)) {
|
2021-06-09 13:36:47 +00:00
|
|
|
$sql .= " AND c.fk_soc = ".((int) $socid);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) {
|
2021-08-23 15:41:11 +00:00
|
|
|
$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
|
2021-02-25 22:21:30 +00:00
|
|
|
}
|
2019-11-11 23:15:34 +00:00
|
|
|
$sql .= " ORDER BY c.tms DESC";
|
|
|
|
|
$sql .= $db->plimit($max, 0);
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2019-11-11 23:15:34 +00:00
|
|
|
$resql = $db->query($sql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($resql) {
|
2019-11-07 10:23:17 +00:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 20:24:41 +00:00
|
|
|
print '<table class="noborder centpercent">';
|
2016-09-07 20:25:37 +00:00
|
|
|
print '<tr class="liste_titre">';
|
2019-01-27 10:55:16 +00:00
|
|
|
print '<th colspan="4">'.$langs->trans("LastModifiedOrders", $max).'</th></tr>';
|
2016-09-07 20:25:37 +00:00
|
|
|
|
|
|
|
|
$num = $db->num_rows($resql);
|
2021-02-25 22:21:30 +00:00
|
|
|
if ($num) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$i = 0;
|
2021-02-25 22:21:30 +00:00
|
|
|
while ($i < $num) {
|
2016-09-07 20:25:37 +00:00
|
|
|
$obj = $db->fetch_object($resql);
|
|
|
|
|
|
2017-04-14 09:22:48 +00:00
|
|
|
print '<tr class="oddeven">';
|
2016-09-07 20:25:37 +00:00
|
|
|
print '<td width="20%" class="nowrap">';
|
|
|
|
|
|
2019-11-11 23:15:34 +00:00
|
|
|
$commandestatic->id = $obj->rowid;
|
|
|
|
|
$commandestatic->ref = $obj->ref;
|
2016-09-07 20:25:37 +00:00
|
|
|
|
|
|
|
|
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 ' ';
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2019-03-07 19:46:38 +00:00
|
|
|
print '<td width="16" class="right nobordernopadding hideonsmartphone">';
|
2019-11-11 23:15:34 +00:00
|
|
|
$filename = dol_sanitizeFileName($obj->ref);
|
|
|
|
|
$filedir = $conf->commande->dir_output.'/'.dol_sanitizeFileName($obj->ref);
|
|
|
|
|
$urlsource = $_SERVER['PHP_SELF'].'?id='.$obj->rowid;
|
2016-09-07 20:25:37 +00:00
|
|
|
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
|
|
|
|
|
print '</td></tr></table>';
|
|
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2019-01-27 10:55:16 +00:00
|
|
|
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 18:06:37 +00:00
|
|
|
print '<td class="right">'.$commandestatic->LibStatut($obj->status, 3, $obj->billed).'</td>';
|
2016-09-07 20:25:37 +00:00
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-05 20:14:22 +00:00
|
|
|
print "</table></div><br>";
|
2021-02-25 22:21:30 +00:00
|
|
|
} else {
|
|
|
|
|
dol_print_error($db);
|
|
|
|
|
}
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2012-04-04 15:43:32 +00:00
|
|
|
|
2012-03-31 15:49:32 +00:00
|
|
|
/*
|
2012-04-04 15:43:32 +00:00
|
|
|
* Orders to process
|
2021-08-23 16:56:46 +00:00
|
|
|
*/
|
2012-04-04 15:43:32 +00:00
|
|
|
/*
|
2014-10-04 15:20:17 +00:00
|
|
|
$sql = "SELECT c.rowid, c.ref, c.fk_statut, s.nom as name, s.rowid as socid";
|
2012-04-04 15:43:32 +00:00
|
|
|
$sql.=" FROM ".MAIN_DB_PREFIX."commande_fournisseur as c";
|
|
|
|
|
$sql.= ", ".MAIN_DB_PREFIX."societe as s";
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
|
2012-04-04 15:43:32 +00:00
|
|
|
$sql.= " WHERE c.fk_soc = s.rowid";
|
2021-08-23 16:56:46 +00:00
|
|
|
$sql.= " AND c.entity IN (".getEntity("supplier_order").")";
|
2012-04-04 15:43:32 +00:00
|
|
|
$sql.= " AND c.fk_statut = 1";
|
2021-06-09 13:36:47 +00:00
|
|
|
if ($socid) $sql.= " AND c.fk_soc = ".((int) $socid);
|
2021-10-22 20:15:59 +00:00
|
|
|
if (empty($user->rights->societe->client->voir) && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .((int) $user->id);
|
2012-04-04 15:43:32 +00:00
|
|
|
$sql.= " ORDER BY c.rowid DESC";
|
|
|
|
|
|
|
|
|
|
$resql=$db->query($sql);
|
|
|
|
|
if ($resql)
|
2012-03-31 15:49:32 +00:00
|
|
|
{
|
2012-04-04 15:43:32 +00:00
|
|
|
$num = $db->num_rows($resql);
|
2012-03-31 15:49:32 +00:00
|
|
|
|
2019-11-05 20:14:22 +00:00
|
|
|
print '<div class="div-table-responsive-no-min">';
|
2019-11-05 20:24:41 +00:00
|
|
|
print '<table class="noborder centpercent">';
|
2012-04-04 15:43:32 +00:00
|
|
|
print '<tr class="liste_titre">';
|
2020-04-15 13:01:00 +00:00
|
|
|
print '<th colspan="3">'.$langs->trans("OrdersToProcess").' <a href="'.DOL_URL_ROOT.'/commande/list.php?search_status=1">('.$num.')</a></th></tr>';
|
2012-04-04 15:43:32 +00:00
|
|
|
|
|
|
|
|
if ($num)
|
|
|
|
|
{
|
|
|
|
|
$i = 0;
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
{
|
|
|
|
|
$obj = $db->fetch_object($resql);
|
2018-04-22 16:51:03 +00:00
|
|
|
|
2017-04-14 09:22:48 +00:00
|
|
|
print '<tr class="oddeven">';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td class="nowrap">';
|
2012-04-04 15:43:32 +00:00
|
|
|
|
|
|
|
|
$commandestatic->id=$obj->rowid;
|
|
|
|
|
$commandestatic->ref=$obj->ref;
|
|
|
|
|
|
|
|
|
|
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td width="96" class="nobordernopadding nowrap">';
|
2012-04-04 15:43:32 +00:00
|
|
|
print $commandestatic->getNomUrl(1);
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2013-04-24 23:13:13 +00:00
|
|
|
print '<td width="16" class="nobordernopadding nowrap">';
|
2012-04-04 15:43:32 +00:00
|
|
|
print ' ';
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2019-03-07 19:46:38 +00:00
|
|
|
print '<td width="16" class="right nobordernopadding hideonsmartphone">';
|
2012-04-04 15:43:32 +00:00
|
|
|
$filename=dol_sanitizeFileName($obj->ref);
|
|
|
|
|
$filedir=$conf->commande->dir_output . '/' . dol_sanitizeFileName($obj->ref);
|
|
|
|
|
$urlsource=$_SERVER['PHP_SELF'].'?id='.$obj->rowid;
|
2012-09-15 07:02:20 +00:00
|
|
|
print $formfile->getDocumentsLink($commandestatic->element, $filename, $filedir);
|
2012-04-04 15:43:32 +00:00
|
|
|
print '</td></tr></table>';
|
|
|
|
|
|
|
|
|
|
print '</td>';
|
|
|
|
|
|
2014-10-04 15:20:17 +00:00
|
|
|
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>';
|
2012-04-04 15:43:32 +00:00
|
|
|
|
2019-03-07 19:46:38 +00:00
|
|
|
print '<td class="right">'.$commandestatic->LibStatut($obj->fk_statut,$obj->facture,5).'</td>';
|
2012-04-04 15:43:32 +00:00
|
|
|
|
|
|
|
|
print '</tr>';
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
2012-03-31 15:49:32 +00:00
|
|
|
}
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2019-11-05 20:14:22 +00:00
|
|
|
print "</table></div><br>";
|
2012-04-04 15:43:32 +00:00
|
|
|
}
|
|
|
|
|
*/
|
2010-12-01 21:16:28 +00:00
|
|
|
|
2021-10-23 22:37:37 +00:00
|
|
|
print '</div></div>';
|
2004-11-29 16:07:35 +00:00
|
|
|
|
2019-06-18 12:07:52 +00: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 20:40:47 +00:00
|
|
|
// End of page
|
2011-08-27 14:24:16 +00:00
|
|
|
llxFooter();
|
2012-04-16 10:03:33 +00:00
|
|
|
$db->close();
|