29 require 
'../../main.inc.php';
 
   30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
 
   31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
 
   32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
 
   33 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
 
   34 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
 
   35 require_once DOL_DOCUMENT_ROOT.
'/product/stock/lib/replenishment.lib.php';
 
   36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
 
   39 $langs->loadLangs(array(
'products', 
'stocks', 
'orders'));
 
   41 $contextpage = 
GETPOST(
'contextpage', 
'aZ') ? 
GETPOST(
'contextpage', 
'aZ') : 
'replenishorders'; 
 
   43 $sall = 
GETPOST(
'search_all', 
'alphanohtml');
 
   44 $sref = 
GETPOST(
'search_ref', 
'alpha');
 
   45 $snom = 
GETPOST(
'search_nom', 
'alpha');
 
   46 $suser = 
GETPOST(
'search_user', 
'alpha');
 
   47 $sttc = 
GETPOST(
'search_ttc', 
'alpha');
 
   49 $search_product = 
GETPOST(
'search_product', 
'int');
 
   50 $search_dateyear = 
GETPOST(
'search_dateyear', 
'int');
 
   51 $search_datemonth = 
GETPOST(
'search_datemonth', 
'int');
 
   52 $search_dateday = 
GETPOST(
'search_dateday', 
'int');
 
   53 $search_date = 
dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear);
 
   54 $optioncss = 
GETPOST(
'optioncss', 
'alpha');
 
   56 $limit = 
GETPOST(
'limit', 
'int') ?
GETPOST(
'limit', 
'int') : $conf->liste_limit;
 
   57 $sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   58 $sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   63   $sortfield = 
'cf.date_creation';
 
   69 $offset = $limit * $page;
 
   73   $socid = $user->socid;
 
   82 if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) { 
 
   89   $search_datemonth = 
'';
 
   91   $search_dateyear = 
'';
 
  103 $helpurl = 
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
 
  104 $texte = $langs->trans(
'ReplenishmentOrders');
 
  112 $head[0][0] = DOL_URL_ROOT.
'/product/stock/replenish.php';
 
  113 $head[0][1] = $langs->trans(
'MissingStocks');
 
  114 $head[0][2] = 
'replenish';
 
  116 $head[1][0] = DOL_URL_ROOT.
'/product/stock/replenishorders.php';
 
  117 $head[1][1] = $texte;
 
  118 $head[1][2] = 
'replenishorders';
 
  124 $sql = 
'SELECT s.rowid as socid, s.nom as name, cf.date_creation as dc,';
 
  125 $sql .= 
' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,';
 
  127 $sql .= 
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'commande_fournisseur as cf';
 
  128 $sql .= 
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON cf.fk_user_author = u.rowid';
 
  129 if (empty($user->rights->societe->client->voir) && !$socid) {
 
  130   $sql .= 
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
 
  132 $sql .= 
' WHERE cf.fk_soc = s.rowid ';
 
  133 $sql .= 
' AND cf.entity = '.$conf->entity;
 
  134 if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER)) {
 
  135   $sql .= 
' AND cf.fk_statut < 3';
 
  136 } elseif (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
 
  137   $sql .= 
' AND cf.fk_statut < 6'; 
 
  139   $sql .= 
' AND cf.fk_statut < 5';
 
  141 if (empty($user->rights->societe->client->voir) && !$socid) {
 
  142   $sql .= 
' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id);
 
  151   natural_search(array(
'u.lastname', 
'u.firstname', 
'u.login'), $suser);
 
  156 $sql .= 
dolSqlDateFilter(
'cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear);
 
  160 if (!empty($socid)) {
 
  161   $sql .= 
' AND s.rowid = '.((int) $socid);
 
  163 if (
GETPOST(
'statut', 
'int')) {
 
  164   $sql .= 
' AND fk_statut = '.GETPOST(
'statut', 
'int');
 
  166 $sql .= 
' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut';
 
  167 $sql .= 
', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom';
 
  168 $sql .= $db->order($sortfield, $sortorder);
 
  169 if (!$search_product) {
 
  170   $sql .= $db->plimit($limit + 1, $offset);
 
  173 $resql = $db->query($sql);
 
  175   $num = $db->num_rows(
$resql);
 
  178   print 
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
 
  179   print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  181   print 
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ReplenishmentOrdersDesc").
'</span><br class="hideonsmartphone">';
 
  183   print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"], 
'', $sortfield, $sortorder, 
'', $num, 0, 
'');
 
  186   if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
 
  187     $param .= 
'&contextpage='.urlencode($contextpage);
 
  189   if ($limit > 0 && $limit != $conf->liste_limit) {
 
  190     $param .= 
'&limit='.urlencode($limit);
 
  193     $param .= 
'&search_ref='.urlencode($sref);
 
  196     $param .= 
'&search_nom='.urlencode($snom);
 
  199     $param .= 
'&search_user='.urlencode($suser);
 
  202     $param .= 
'&search_ttc='.urlencode($sttc);
 
  204   if ($search_dateyear) {
 
  205     $param .= 
'&search_dateyear='.urlencode($search_dateyear);
 
  207   if ($search_datemonth) {
 
  208     $param .= 
'&search_datemonth='.urlencode($search_datemonth);
 
  210   if ($search_dateday) {
 
  211     $param .= 
'&search_dateday='.urlencode($search_dateday);
 
  213   if ($optioncss != 
'') {
 
  214     $param .= 
'&optioncss='.urlencode($optioncss);
 
  217   print 
'<div class="div-table-responsive-no-min">';
 
  218   print 
'<table class="noborder centpercent">';
 
  220   print 
'<tr class="liste_titre_filter">';
 
  221   print 
'<td class="liste_titre">';
 
  222   print 
'<input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($sref).
'">';
 
  224   print 
'<td class="liste_titre">';
 
  225   print 
'<input type="text" class="flat maxwidth100" name="search_nom" value="'.dol_escape_htmltag($snom).
'">';
 
  227   print 
'<td class="liste_titre">';
 
  228   print 
'<input type="text" class="flat maxwidth100" name="search_user" value="'.dol_escape_htmltag($suser).
'">';
 
  230   print 
'<td class="liste_titre right">';
 
  231   print 
'<input type="text" class="flat width75" name="search_ttc" value="'.dol_escape_htmltag($sttc).
'">';
 
  233   print 
'<td class="liste_titre center">';
 
  234   print 
$form->selectDate($search_date, 
'search_date', 0, 0, 1, 
'', 1, 0, 0, 
'');
 
  236   print 
'<td class="liste_titre right">';
 
  237   $searchpicto = 
$form->showFilterAndCheckAddButtons(0);
 
  242   print 
'<tr class="liste_titre">';
 
  245     $_SERVER[
'PHP_SELF'],
 
  255     $_SERVER[
'PHP_SELF'],
 
  265     $_SERVER[
'PHP_SELF'],
 
  275     $_SERVER[
'PHP_SELF'],
 
  286     $_SERVER[
'PHP_SELF'],
 
  297     $_SERVER[
'PHP_SELF'],
 
  308   $userstatic = 
new User($db);
 
  310   while ($i < min($num, $search_product ? $num : $conf->liste_limit)) {
 
  311     $obj = $db->fetch_object(
$resql);
 
  316       $href = DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$obj->rowid;
 
  322       print 
'<a href="'.$href.
'">'.
img_object($langs->trans(
'ShowOrder'), 
'order').
' '.$obj->ref.
'</a>';
 
  326       $href = DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid;
 
  327       print 
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->name).
'"><a href="'.$href.
'">'.
img_object($langs->trans(
'ShowCompany'), 
'company').
' '.$obj->name.
'</a></td>';
 
  330       $userstatic->id = $obj->fk_user_author;
 
  331       $userstatic->login = $obj->login;
 
  332       if ($userstatic->id) {
 
  333         $txt = $userstatic->getLoginUrl(1);
 
  337       print 
'<td>'.$txt.
'</td>';
 
  340       print 
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
 
  344         $date = 
dol_print_date($db->jdate($obj->dc), 
'dayhour', 
'tzuserrel');
 
  348       print 
'<td class="center">'.$date.
'</td>';
 
  351       print 
'<td class="right">'.$commandestatic->LibStatut($obj->fk_statut, 5).
'</td>';
 
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
 
Class to manage predefined suppliers products.
 
Class to manage Dolibarr users.
 
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
 
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
 
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
 
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
 
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
 
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
 
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
 
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
 
dol_get_fiche_end($notab=0)
Return tab footer of a card.
 
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
 
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
 
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
 
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
 
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
 
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
 
dolDispatchToDo($order_id)
Check if there is still some dispatching of stock to do.
 
getProducts($order_id)
getProducts
 
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.