28 require
'../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.form.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/stock/lib/replenishment.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
38 $langs->loadLangs(array(
'products',
'stocks',
'orders'));
41 if ($user->socid) $socid = $user->socid;
44 $sall =
GETPOST(
'search_all',
'alphanohtml');
45 $sref =
GETPOST(
'search_ref',
'alpha');
46 $snom =
GETPOST(
'search_nom',
'alpha');
47 $suser =
GETPOST(
'search_user',
'alpha');
48 $sttc =
GETPOST(
'search_ttc',
'alpha');
50 $search_product =
GETPOST(
'search_product',
'int');
51 $search_dateyear =
GETPOST(
'search_dateyear',
'int');
52 $search_datemonth =
GETPOST(
'search_datemonth',
'int');
53 $search_dateday =
GETPOST(
'search_dateday',
'int');
54 $search_date =
dol_mktime(0, 0, 0, $search_datemonth, $search_dateday, $search_dateyear);
56 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
57 $sortfield =
GETPOST(
"sortfield",
'alpha');
58 $sortorder =
GETPOST(
"sortorder",
'alpha');
59 if (!$sortorder) $sortorder =
'DESC';
60 if (!$sortfield) $sortfield =
'cf.date_creation';
62 if ($page < 0) $page = 0;
63 $offset = $limit * $page;
70 if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter.x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha'))
78 $search_datemonth =
'';
80 $search_dateyear =
'';
90 $form =
new Form($db);
92 $helpurl =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
93 $texte = $langs->trans(
'ReplenishmentOrders');
101 $head[0][0] = DOL_URL_ROOT.
'/product/stock/replenish.php';
102 $head[0][1] = $langs->trans(
'MissingStocks');
103 $head[0][2] =
'replenish';
105 $head[1][0] = DOL_URL_ROOT.
'/product/stock/replenishorders.php';
106 $head[1][1] = $texte;
107 $head[1][2] =
'replenishorders';
113 $sql =
'SELECT s.rowid as socid, s.nom as name, cf.date_creation as dc,';
114 $sql .=
' cf.rowid, cf.ref, cf.fk_statut, cf.total_ttc, cf.fk_user_author,';
116 $sql .=
' FROM '.MAIN_DB_PREFIX.
'societe as s, '.MAIN_DB_PREFIX.
'commande_fournisseur as cf';
117 $sql .=
' LEFT JOIN '.MAIN_DB_PREFIX.
'user as u ON cf.fk_user_author = u.rowid';
118 if (!$user->rights->societe->client->voir && !$socid) {
119 $sql .=
', '.MAIN_DB_PREFIX.
'societe_commerciaux as sc';
121 $sql .=
' WHERE cf.fk_soc = s.rowid ';
122 $sql .=
' AND cf.entity = '.$conf->entity;
123 if ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER) {
124 $sql .=
' AND cf.fk_statut < 3';
125 } elseif ($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) {
126 $sql .=
' AND cf.fk_statut < 6';
128 $sql .=
' AND cf.fk_statut < 5';
130 if (!$user->rights->societe->client->voir && !$socid) {
131 $sql .=
' AND s.rowid = sc.fk_soc AND sc.fk_user = '.$user->id;
137 $sql .=
dolSqlDateFilter(
'cf.date_creation', $search_dateday, $search_datemonth, $search_dateyear);
138 if ($sall) $sql .=
natural_search(array(
'cf.ref',
'cf.note'), $sall);
139 if (!empty($socid)) $sql .=
' AND s.rowid = '.$socid;
140 if (
GETPOST(
'statut',
'int')) {
141 $sql .=
' AND fk_statut = '.GETPOST(
'statut',
'int');
143 $sql .=
' GROUP BY cf.rowid, cf.ref, cf.date_creation, cf.fk_statut';
144 $sql .=
', cf.total_ttc, cf.fk_user_author, u.login, s.rowid, s.nom';
145 $sql .= $db->order($sortfield, $sortorder);
146 if (!$search_product) {
147 $sql .= $db->plimit($limit + 1, $offset);
150 $resql = $db->query($sql);
153 $num = $db->num_rows(
$resql);
156 print '<span class="opacitymedium">'.$langs->trans(
"ReplenishmentOrdersDesc").
'</span><br><br>';
158 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="GET">';
163 if (!empty($contextpage) && $contextpage !=
$_SERVER[
"PHP_SELF"]) $param .=
'&contextpage='.urlencode($contextpage);
164 if ($limit > 0 && $limit != $conf->liste_limit) $param .=
'&limit='.urlencode($limit);
165 if ($sref) $param .=
'&search_ref='.urlencode($sref);
166 if ($snom) $param .=
'&search_nom='.urlencode($snom);
167 if ($suser) $param .=
'&search_user='.urlencode($suser);
168 if ($sttc) $param .=
'&search_ttc='.urlencode($sttc);
169 if ($search_dateyear) $param .=
'&search_dateyear='.urlencode($search_dateyear);
170 if ($search_datemonth) $param .=
'&search_datemonth='.urlencode($search_datemonth);
171 if ($search_dateday) $param .=
'&search_dateday='.urlencode($search_dateday);
172 if ($optioncss !=
'') $param .=
'&optioncss='.urlencode($optioncss);
174 print '<table class="noborder centpercent">';
176 print '<tr class="liste_titre_filter">';
177 print '<td class="liste_titre">';
178 print '<input type="text" class="flat" name="search_ref" value="'.dol_escape_htmltag($sref).
'">';
180 print '<td class="liste_titre">';
181 print '<input type="text" class="flat" name="search_nom" value="'.dol_escape_htmltag($snom).
'">';
183 print '<td class="liste_titre">';
184 print '<input type="text" class="flat" name="search_user" value="'.dol_escape_htmltag($suser).
'">';
186 print '<td class="liste_titre">';
187 print '<input type="text" class="flat" name="search_ttc" value="'.dol_escape_htmltag($sttc).
'">';
189 print '<td class="liste_titre">';
190 print $form->selectDate($search_date,
'search_date', 0, 0, 1,
'', 1, 0, 0,
'');
192 print '<td class="liste_titre right">';
193 $searchpicto = $form->showFilterAndCheckAddButtons(0);
198 print '<tr class="liste_titre">';
262 $userstatic =
new User($db);
264 while ($i < min($num, $search_product ? $num : $conf->liste_limit))
266 $obj = $db->fetch_object(
$resql);
272 $href = DOL_URL_ROOT.
'/fourn/commande/card.php?id='.$obj->rowid;
278 print '<a href="'.$href.
'">'.
img_object($langs->trans(
'ShowOrder'),
'order').
' '.$obj->ref.
'</a>';
282 $href = DOL_URL_ROOT.
'/fourn/card.php?socid='.$obj->socid;
283 print '<td><a href="'.$href.
'">'.
img_object($langs->trans(
'ShowCompany'),
'company').
' '.$obj->name.
'</a></td>';
286 $userstatic->id = $obj->fk_user_author;
287 $userstatic->login = $obj->login;
288 if ($userstatic->id) {
289 $txt = $userstatic->getLoginUrl(1);
293 print '<td>'.$txt.
'</td>';
296 print '<td>'.price($obj->total_ttc).
'</td>';
304 print '<td>'.$date.
'</td>';
307 print '<td class="right">'.$commandestatic->LibStatut($obj->fk_statut, 5).
'</td>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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...
dolDispatchToDo($order_id)
Check if there is still some dispatching of stock to do.
Class to manage Dolibarr users.
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
img_object($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0)
Show a picto called object_picto (generic function)
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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...
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0)
Generate a SQL string to make a filter into a range (for second of date until last second of date) ...
Class to manage predefined suppliers products.
print $_SERVER["PHP_SELF"]
Edit parameters.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getProducts($order_id)
getProducts
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.