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';
47$langs->loadLangs(array(
'products',
'stocks',
'orders'));
49$contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'replenishorders';
51$sall =
GETPOST(
'search_all',
'alphanohtml');
52$sref =
GETPOST(
'search_ref',
'alpha');
53$snom =
GETPOST(
'search_nom',
'alpha');
54$suser =
GETPOST(
'search_user',
'alpha');
55$sttc =
GETPOST(
'search_ttc',
'alpha');
58$search_dateyear =
GETPOSTINT(
'search_dateyear');
59$search_datemonth =
GETPOSTINT(
'search_datemonth');
61$search_date =
dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear);
62$optioncss =
GETPOST(
'optioncss',
'alpha');
65$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
66$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
71 $sortfield =
'cf.date_creation';
77$offset = $limit * $page;
81 $socid = $user->socid;
90if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
97 $search_datemonth =
'';
99 $search_dateyear =
'';
109$form =
new Form($db);
111$helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
112$texte = $langs->trans(
'ReplenishmentOrders');
114llxHeader(
'', $texte, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock_replenishorders');
120$head[0][0] = DOL_URL_ROOT.
'/product/stock/replenish.php';
121$head[0][1] = $langs->trans(
'MissingStocks');
122$head[0][2] =
'replenish';
124$head[1][0] = DOL_URL_ROOT.
'/product/stock/replenishorders.php';
126$head[1][2] =
'replenishorders';
132$sql =
'SELECT s.rowid as socid, s.nom as name, cf.date_creation as dc,';
133$sql .=
' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,';
135$sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'commande_fournisseur as cf';
136$sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON cf.fk_user_author = u.rowid';
137if (!$user->hasRight(
'societe',
'client',
'voir')) {
138 $sql .=
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
140$sql .=
' WHERE cf.fk_soc = s.rowid ';
141$sql .=
' AND cf.entity = '.$conf->entity;
143 $sql .=
' AND cf.fk_statut < 3';
145 $sql .=
' AND cf.fk_statut < 6';
147 $sql .=
' AND cf.fk_statut < 5';
149if (!$user->hasRight(
'societe',
'client',
'voir')) {
150 $sql .=
' AND s.rowid = sc.fk_soc AND sc.fk_user = '.((int) $user->id);
159 natural_search(array(
'u.lastname',
'u.firstname',
'u.login'), $suser);
164$sql .=
dolSqlDateFilter(
'cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear);
169 $sql .=
' AND s.rowid = '.((int) $socid);
172 $sql .=
' AND fk_statut = '.GETPOSTINT(
'statut');
174$sql .=
' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut';
175$sql .=
', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom';
176$sql .= $db->order($sortfield, $sortorder);
177if (!$search_product) {
178 $sql .= $db->plimit($limit + 1, $offset);
181$resql = $db->query($sql);
183 $num = $db->num_rows($resql);
186 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
187 print
'<input type="hidden" name="token" value="'.newToken().
'">';
189 print
'<span class="opacitymedium hideonsmartphone">'.$langs->trans(
"ReplenishmentOrdersDesc").
'</span><br class="hideonsmartphone">';
191 print_barre_liste(
'', $page, $_SERVER[
"PHP_SELF"],
'', $sortfield, $sortorder,
'', $num, 0,
'');
194 if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
195 $param .=
'&contextpage='.urlencode($contextpage);
197 if ($limit > 0 && $limit !=
$conf->liste_limit) {
198 $param .=
'&limit='.((int) $limit);
201 $param .=
'&search_ref='.urlencode($sref);
204 $param .=
'&search_nom='.urlencode($snom);
207 $param .=
'&search_user='.urlencode($suser);
210 $param .=
'&search_ttc='.urlencode($sttc);
212 if ($search_dateyear) {
213 $param .=
'&search_dateyear='.urlencode((
string) ($search_dateyear));
215 if ($search_datemonth) {
216 $param .=
'&search_datemonth='.urlencode((
string) ($search_datemonth));
218 if ($search_dateday) {
219 $param .=
'&search_dateday='.urlencode((
string) ($search_dateday));
221 if ($optioncss !=
'') {
222 $param .=
'&optioncss='.urlencode($optioncss);
225 print
'<div class="div-table-responsive-no-min">';
226 print
'<table class="noborder centpercent">';
228 print
'<tr class="liste_titre_filter">';
229 print
'<td class="liste_titre">';
230 print
'<input type="text" class="flat maxwidth100" name="search_ref" value="'.dol_escape_htmltag($sref).
'">';
232 print
'<td class="liste_titre">';
233 print
'<input type="text" class="flat maxwidth100" name="search_nom" value="'.dol_escape_htmltag($snom).
'">';
235 print
'<td class="liste_titre">';
236 print
'<input type="text" class="flat maxwidth100" name="search_user" value="'.dol_escape_htmltag($suser).
'">';
238 print
'<td class="liste_titre right">';
239 print
'<input type="text" class="flat width75" name="search_ttc" value="'.dol_escape_htmltag($sttc).
'">';
241 print
'<td class="liste_titre center">';
242 print $form->selectDate($search_date,
'search_date', 0, 0, 1,
'', 1, 0, 0,
'');
244 print
'<td class="liste_titre right">';
245 $searchpicto = $form->showFilterAndCheckAddButtons(0);
250 print
'<tr class="liste_titre">';
253 $_SERVER[
'PHP_SELF'],
263 $_SERVER[
'PHP_SELF'],
273 $_SERVER[
'PHP_SELF'],
283 $_SERVER[
'PHP_SELF'],
294 $_SERVER[
'PHP_SELF'],
305 $_SERVER[
'PHP_SELF'],
316 $userstatic =
new User($db);
318 while ($i < min($num, $search_product ? $num :
$conf->liste_limit)) {
319 $obj = $db->fetch_object($resql);
324 $href = DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$obj->rowid;
330 print
'<a href="'.$href.
'">'.
img_object($langs->trans(
'ShowOrder'),
'order').
' '.$obj->ref.
'</a>';
334 $href = DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid;
335 print
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->name).
'"><a href="'.$href.
'">'.
img_object($langs->trans(
'ShowCompany'),
'company').
' '.$obj->name.
'</a></td>';
338 $userstatic->id = $obj->fk_user_author;
339 $userstatic->login = $obj->login;
340 if ($userstatic->id) {
341 $txt = $userstatic->getLoginUrl(1);
345 print
'<td>'.$txt.
'</td>';
348 print
'<td class="right"><span class="amount">'.price($obj->total_ttc).
'</span></td>';
352 $date =
dol_print_date($db->jdate($obj->dc),
'dayhour',
'tzuserrel');
356 print
'<td class="center">'.$date.
'</td>';
359 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.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
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.