diff --git a/htdocs/product/stock/replenishorders.php b/htdocs/product/stock/replenishorders.php index c39f498d9b6..5ca7debbef6 100644 --- a/htdocs/product/stock/replenishorders.php +++ b/htdocs/product/stock/replenishorders.php @@ -38,8 +38,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; $langs->loadLangs(array('products', 'stocks', 'orders')); // Security check -if ($user->socid) $socid=$user->socid; -$result=restrictedArea($user, 'produit|service'); +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'produit|service'); $sall = GETPOST('search_all', 'alphanohtml'); $sref = GETPOST('search_ref', 'alpha'); @@ -53,7 +53,7 @@ $search_datemonth = GETPOST('search_datemonth', 'int'); $search_dateday = GETPOST('search_dateday', 'int'); $search_date = dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear); -$limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit; +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); if (!$sortorder) $sortorder = 'DESC'; @@ -69,16 +69,16 @@ $offset = $limit * $page; if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers { - $sall=""; - $sref=""; - $snom=""; - $suser=""; - $sttc=""; - $search_date=''; - $search_datemonth=''; - $search_dateday=''; - $search_dateyear=''; - $sproduct=0; + $sall = ""; + $sref = ""; + $snom = ""; + $suser = ""; + $sttc = ""; + $search_date = ''; + $search_datemonth = ''; + $search_dateday = ''; + $search_dateyear = ''; + $sproduct = 0; } @@ -109,40 +109,40 @@ dol_fiche_head($head, 'replenishorders', '', -1, ''); $commandestatic = new CommandeFournisseur($db); $sql = 'SELECT s.rowid as socid, s.nom as name, cf.date_creation as dc,'; -$sql.= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,'; -$sql.= ' u.login'; -$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; -$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid'; +$sql .= ' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,'; +$sql .= ' u.login'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'commande_fournisseur as cf'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'user as u ON cf.fk_user_author = u.rowid'; if (!$user->rights->societe->client->voir && !$socid) { - $sql.= ', ' . MAIN_DB_PREFIX . 'societe_commerciaux as sc'; + $sql .= ', '.MAIN_DB_PREFIX.'societe_commerciaux as sc'; } -$sql.= ' WHERE cf.fk_soc = s.rowid '; -$sql.= ' AND cf.entity = ' . $conf->entity; +$sql .= ' WHERE cf.fk_soc = s.rowid '; +$sql .= ' AND cf.entity = '.$conf->entity; if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) { $sql .= ' AND cf.fk_statut < 3'; -} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). +} elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { + $sql .= ' AND cf.fk_statut < 6'; // We want also status 5, we will keep them visible if dispatching is not yet finished (tested with function dolDispatchToDo). } else { $sql .= ' AND cf.fk_statut < 5'; } if (!$user->rights->societe->client->voir && !$socid) { - $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = ' . $user->id; + $sql .= ' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id; } if ($sref) $sql .= natural_search('cf.ref', $sref); if ($snom) $sql .= natural_search('s.nom', $snom); if ($suser) $sql .= natural_search('u.login', $suser); if ($sttc) $sql .= natural_search('cf.total_ttc', $sttc, 1); -$sql.= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); -if ($sall) $sql .= natural_search(array('cf.ref','cf.note'), $sall); -if (!empty($socid)) $sql .= ' AND s.rowid = ' . $socid; +$sql .= dolSqlDateFilter('cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear); +if ($sall) $sql .= natural_search(array('cf.ref', 'cf.note'), $sall); +if (!empty($socid)) $sql .= ' AND s.rowid = '.$socid; if (GETPOST('statut', 'int')) { - $sql .= ' AND fk_statut = ' . GETPOST('statut', 'int'); + $sql .= ' AND fk_statut = '.GETPOST('statut', 'int'); } $sql .= ' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut'; $sql .= ', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom'; $sql .= $db->order($sortfield, $sortorder); -if (! $sproduct) { - $sql .= $db->plimit($limit+1, $offset); +if (!$sproduct) { + $sql .= $db->plimit($limit + 1, $offset); } $resql = $db->query($sql); @@ -155,17 +155,17 @@ if ($resql) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, '', $num, 0, ''); - $param=''; - if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.urlencode($contextpage); - if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.urlencode($limit); - if ($sref) $param.='&search_ref='.urlencode($sref); - if ($snom) $param.='&search_nom='.urlencode($snom); - if ($suser) $param.='&search_user='.urlencode($suser); - if ($sttc) $param.='&search_ttc='.urlencode($sttc); - if ($search_dateyear) $param.='&search_dateyear='.urlencode($search_dateyear); - if ($search_datemonth) $param.='&search_datemonth='.urlencode($search_datemonth); - if ($search_dateday) $param.='&search_dateday='.urlencode($search_dateday); - if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); + $param = ''; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($sref) $param .= '&search_ref='.urlencode($sref); + if ($snom) $param .= '&search_nom='.urlencode($snom); + if ($suser) $param .= '&search_user='.urlencode($suser); + if ($sttc) $param .= '&search_ttc='.urlencode($sttc); + if ($search_dateyear) $param .= '&search_dateyear='.urlencode($search_dateyear); + if ($search_datemonth) $param .= '&search_datemonth='.urlencode($search_datemonth); + if ($search_dateday) $param .= '&search_dateday='.urlencode($search_dateday); + if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); print '