29require
'../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/lib/replenishment.lib.php';
36require_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');
50$search_dateyear =
GETPOSTINT(
'search_dateyear');
51$search_datemonth =
GETPOSTINT(
'search_datemonth');
53$search_date =
dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear);
54$optioncss =
GETPOST(
'optioncss',
'alpha');
57$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
58$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
63 $sortfield =
'cf.date_creation';
69$offset = $limit * $page;
73 $socid = $user->socid;
82if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
89 $search_datemonth =
'';
91 $search_dateyear =
'';
101$form =
new Form($db);
103$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
104$texte = $langs->trans(
'ReplenishmentOrders');
106llxHeader(
'', $texte, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_replenishorders');
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';
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';
129if (!$user->hasRight(
'societe',
'client',
'voir')) {
130 $sql .=
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
132$sql .=
' WHERE cf.fk_soc = s.rowid ';
133$sql .=
' AND cf.entity = '.$conf->entity;
135 $sql .=
' AND cf.fk_statut < 3';
137 $sql .=
' AND cf.fk_statut < 6';
139 $sql .=
' AND cf.fk_statut < 5';
141if (!$user->hasRight(
'societe',
'client',
'voir')) {
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);
161 $sql .=
' AND s.rowid = '.((int) $socid);
164 $sql .=
' AND fk_statut = '.GETPOSTINT(
'statut');
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);
169if (!$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='.((int) $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((
string) ($search_dateyear));
207 if ($search_datemonth) {
208 $param .=
'&search_datemonth='.urlencode((
string) ($search_datemonth));
210 if ($search_dateday) {
211 $param .=
'&search_dateday='.urlencode((
string) ($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($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage predefined suppliers products.
Class to manage Dolibarr users.
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 information (by default a local PHP server timestamp) Rep...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
img_object($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
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=null, $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.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.