diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php
index 368b12141bf..2e0335a9bde 100644
--- a/htdocs/product/stock/replenish.php
+++ b/htdocs/product/stock/replenish.php
@@ -34,9 +34,12 @@ $langs->load("stocks");
$langs->load("orders");
// Security check
-if ($user->societe_id) $socid=$user->societe_id;
+if ($user->societe_id) {
+ $socid = $user->societe_id;
+}
$result=restrictedArea($user,'produit|service');
+//checks if a product has been ordered
function ordered($product_id) {
global $db;
$sql = 'SELECT DISTINCT cfd.fk_product, SUM(cfd.qty) from ';
@@ -58,7 +61,7 @@ function ordered($product_id) {
}
}
else {
- $error=$db->lasterror();
+ $error = $db->lasterror();
dol_print_error($db);
dol_syslog('replenish.php: ' . $error, LOG_ERROR);
return $langs->trans('error');
@@ -77,8 +80,14 @@ $tobuy = GETPOST('tobuy');
$sortfield = GETPOST('sortfield','alpha');
$sortorder = GETPOST('sortorder','alpha');
$page = GETPOST('page','int');
-if (! $sortfield) $sortfield = 'stock_physique';
-if (! $sortorder) $sortorder = 'ASC';
+
+if (!$sortfield) {
+ $sortfield = 'stock_physique';
+}
+
+if (!$sortorder) {
+ $sortorder = 'ASC';
+}
$limit = $conf->liste_limit;
$offset = $limit * $page ;
@@ -279,10 +288,12 @@ if ($resql) {
$head[1][2] = 'replenishorders';
dol_fiche_head($head, 'replenish', $title, 0, 'stock');
if ($sref || $snom || $sall || GETPOST('search')) {
+ $filters = '&sref=' . $sref . '&snom=' . $snom;
+ $filters .= '&sall=' . $sall;
print_barre_liste($texte,
$page,
'replenish.php',
- '&sref=' . $sref . '&snom=' . $snom . '&sall=' . $sall,
+ $filters,
$sortfield,
$sortorder,
'',
@@ -290,10 +301,13 @@ if ($resql) {
);
}
else {
+ $filters = '&sref=' . $sref . '&snom=' . $snom;
+ $filters .= '&fourn_id=' . $fourn_id;
+ $filters .= (isset($type)?'&type=' . $type:'');
print_barre_liste($texte,
$page,
'replenish.php',
- '&sref=$sref&snom=$snom&fourn_id=$fourn_id' . (isset($type)?'&type=$type':''),
+ $filters,
$sortfield,
$sortorder,
'',
@@ -336,8 +350,9 @@ if ($resql) {
print '';
}
- $param = (isset($type)? '&type=$type' : '');
- $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom . '&sref=' . $sref;
+ $param = (isset($type)? '&type=' . $type : '');
+ $param .= '&fourn_id=' . $fourn_id . '&snom='. $snom;
+ $param .= '&sref=' . $sref;
// Lignes des titres
print '
';
@@ -566,10 +581,12 @@ if ($resql) {
if ($num > $conf->liste_limit) {
if ($sref || $snom || $sall || GETPOST('search')) {
+ $filters = '&sref=' . $sref . '&snom=' . $snom;
+ $filters .= '&sall=' . $sall;
print_barre_liste('',
$page,
'replenish.php',
- '&sref=' . $sref . '&snom=' . $snom . '&sall=' . $sall,
+ $filters,
$sortfield,
$sortorder,
'',
@@ -579,10 +596,13 @@ if ($resql) {
);
}
else {
+ $filters = '&sref=' . $sref . '&snom=' . $snom;
+ $filters .= '&fourn_id=' . $fourn_id;
+ $filters .= (isset($type)? '&type=' . $type : '');
print_barre_liste('',
$page,
'replenish.php',
- "&sref=$sref&snom=$snom&fourn_id=$fourn_id" . (isset($type)?"&type=$type":""),
+ $filters,
$sortfield,
$sortorder,
'',
diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php
index c06cf405ffa..d7b506dca77 100644
--- a/htdocs/product/stock/replenishorders.php
+++ b/htdocs/product/stock/replenishorders.php
@@ -47,7 +47,10 @@ $head[0][2] = 'replenish';
$head[1][0] = DOL_URL_ROOT.'/product/stock/replenishorders.php';
$head[1][1] = $langs->trans("ReplenishmentOrders");
$head[1][2] = 'replenishorders';
-dol_fiche_head($head, 'replenishorders', $langs->trans("Replenishment"), 0, 'stock');
+dol_fiche_head($head, 'replenishorders',
+ $langs->trans("Replenishment"),
+ 0,
+ 'stock');
$commandestatic = new CommandeFournisseur($db);
$sref = GETPOST('search_ref');
$snom = GETPOST('search_nom');
@@ -59,17 +62,27 @@ $page = GETPOST('page', 'int');
$sortorder = GETPOST('sortorder');
$sortfield = GETPOST('sortfield');
-if(!$sortorder) $sortorder = 'DESC';
-if(!$sortfield) $sortfield = 'cf.date_creation';
+
+if(!$sortorder) {
+ $sortorder = 'DESC';
+}
+
+if(!$sortfield) {
+ $sortfield = 'cf.date_creation';
+}
+
$offset = $conf->liste_limit * $page ;
$sql = 'SELECT s.rowid as socid, s.nom, cf.date_creation as dc,';
$sql .= ' cf.rowid,cf.ref, cf.fk_statut, cf.total_ttc';
$sql .= ", cf.fk_user_author, u.login";
$sql .= ' FROM (' . MAIN_DB_PREFIX . 'societe as s,';
$sql .= ' ' . MAIN_DB_PREFIX . 'commande_fournisseur as cf';
+
if (!$user->rights->societe->client->voir && !$socid) {
$sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc';
+
}
+
$sql .= ') LEFT JOIN ' . MAIN_DB_PREFIX . 'user as u ';
$sql .= 'ON cf.fk_user_author = u.rowid';
$sql .= ' WHERE cf.fk_soc = s.rowid ';
@@ -100,19 +113,18 @@ if ($socid) {
$sql .= ' AND s.rowid = ' . $socid;
}
-if (GETPOST('statut'))
-{
- $sql .= ' AND fk_statut = ' . GETPOST('statut');
+if (GETPOST('statut')) {
+ $sql .= ' AND fk_statut = ' . GETPOST('statut');
}
-$sql .= " ORDER BY $sortfield $sortorder " . $db->plimit($conf->liste_limit+1, $offset);
+$sql .= ' ORDER BY ' . $sortfield . ' ' . $sortorder . ' ';
+$sql .= $db->plimit($conf->liste_limit+1, $offset);
$resql = $db->query($sql);
-if ($resql) {
+if ($resql) {
$num = $db->num_rows($resql);
$i = 0;
-
print_barre_liste($langs->trans('ReplenishmentOrders'),
$page,
'replenishorders.php',
@@ -197,7 +209,7 @@ if ($resql) {
print '| ';
$src = DOL_URL_ROOT . '/theme/' . $conf->theme . '/img/search.png';
$value = dol_escape_htmltag($langs->trans('Search'));
- print '';
+ print '';
print ' | ';
print '
';
@@ -214,32 +226,32 @@ if ($resql) {
$href = DOL_URL_ROOT . '/fourn/commande/fiche.php?id=' . $obj->rowid;
print '';
print img_object($langs->trans('ShowOrder'), 'order') . ' ' . $obj->ref;
- print ''."";
+ print '';
// Company
print '';
$href = DOL_URL_ROOT . '/fourn/fiche.php?socid=' . $obj->socid;
print '';
- print img_object($langs->trans('ShowCompany'), 'company') . ' ' . $obj->nom;
- print ' | '."";
+ print img_object($langs->trans('ShowCompany'), 'company') . ' ';
+ print $obj->nom . '';
// Author
$userstatic->id = $obj->fk_user_author;
$userstatic->login = $obj->login;
print '';
+
if ($userstatic->id) {
print $userstatic->getLoginUrl(1);
}
else {
print ' ';
}
+
print ' | ';
-
// Amount
print '';
print price($obj->total_ttc);
print ' | ';
-
// Date
print '';
if ($obj->dc) {
@@ -249,12 +261,10 @@ if ($resql) {
print '-';
}
print ' | ';
-
// Statut
print '';
print $commandestatic->LibStatut($obj->fk_statut, 5);
print ' | ';
-
print '';
$i++;
}