30require
'../../../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
38$langs->loadLangs(array(
'companies',
'bills',
'products',
'orders'));
42$batch =
GETPOST(
'batch',
'alpha');
43$objectid =
GETPOST(
'productid',
'int');
46$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
47$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
49if (!empty($user->socid)) {
50 $socid = $user->socid;
54$hookmanager->initHooks(array(
'batchproductstatssupplierorder'));
56$showmessage =
GETPOST(
'showmessage');
59$limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
60$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
61$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
62$page = GETPOSTISSET(
'pageplusone') ? (
GETPOST(
'pageplusone') - 1) :
GETPOST(
"page",
'int');
63if (empty($page) || $page == -1) {
66$offset = $limit * $page;
73 $sortfield =
"cf.date_commande";
76$search_month =
GETPOST(
'search_month',
'int');
77$search_year =
GETPOST(
'search_year',
'int');
79if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
92$societestatic =
new Societe($db);
97if ($id > 0 || !empty($ref)) {
100 $tmp = explode(
'_', $ref);
104 $result = $object->fetch($id, $objectid, $batch);
106 $parameters = array(
'id'=>$id);
107 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
113 $shortlabel =
dol_trunc($object->batch, 16);
114 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
115 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
121 $titre = $langs->trans(
"CardProduct".$object->type);
123 print
dol_get_fiche_head($head,
'referers', $langs->trans(
"Batch"), -1, $object->picto);
125 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
126 print $hookmanager->resPrint;
131 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
134 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
138 dol_banner_tab($object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
140 print
'<div class="fichecenter">';
142 print
'<div class="underbanner clearboth"></div>';
143 print
'<table class="border centpercent tableforfield" width="100%">';
147 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
148 $producttmp =
new Product($db);
149 $producttmp->fetch($object->fk_product);
150 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
201 print
'<table class="border centpercent tableforfield" width="100%">';
208 print
'<div class="clearboth"></div>';
212 if ($showmessage && $nboflines > 1) {
213 print
'<span class="opacitymedium">'.$langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")).
'</span>';
214 } elseif ($user->rights->fournisseur->commande->lire) {
215 $sql =
"SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,";
216 $sql .=
" cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,";
217 $sql .=
" cfd.rowid, SUM(cfdi.qty) as qty";
219 if (empty($user->rights->societe->client->voir) && !$socid) {
220 $sql .=
", sc.fk_soc, sc.fk_user ";
222 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
223 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"commande_fournisseur as cf ON (cf.fk_soc = s.rowid)";
224 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)";
225 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"commande_fournisseur_dispatch as cfdi ON (cfdi.fk_commandefourndet = cfd.rowid)";
226 if (empty($user->rights->societe->client->voir) && !$socid) {
227 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
229 $sql .=
" WHERE cf.entity IN (".getEntity(
'product').
")";
230 $sql .=
" AND cfdi.batch = '".($db->escape($object->batch)).
"'";
231 if (!empty($search_month)) {
232 $sql .=
' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).
')';
234 if (!empty($search_year)) {
235 $sql .=
' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).
')';
237 if (empty($user->rights->societe->client->voir) && !$socid) {
238 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
241 $sql .=
" AND cf.fk_soc = ".((int) $socid);
243 $sql .=
" GROUP BY cf.rowid";
244 $sql .= $db->order($sortfield, $sortorder);
247 $total_ht_pondere = 0;
251 $totalofrecords =
'';
253 $result = $db->query($sql);
254 $totalofrecords = $db->num_rows($result);
257 $sql .= $db->plimit($limit + 1, $offset);
259 $result = $db->query($sql);
261 $num = $db->num_rows($result);
263 $option .=
'&id='.$object->id;
265 if ($limit > 0 && $limit != $conf->liste_limit) {
266 $option .=
'&limit='.((int) $limit);
268 if (!empty($search_month)) {
269 $option .=
'&search_month='.urlencode($search_month);
271 if (!empty($search_year)) {
272 $option .=
'&search_year='.urlencode($search_year);
275 print
'<form method="post" action="'.$_SERVER [
'PHP_SELF'].
'?id='.$object->id.
'" name="search_form">'.
"\n";
276 print
'<input type="hidden" name="token" value="'.newToken().
'">';
277 if (!empty($sortfield)) {
278 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
280 if (!empty($sortorder)) {
281 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
284 print_barre_liste($langs->trans(
"SuppliersOrders"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
287 $option .=
'&page='.urlencode($page);
290 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
291 print
'<div class="divsearchfield">';
292 print $langs->trans(
'Period').
' ('.$langs->trans(
"OrderDate").
') - ';
293 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
294 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? $search_year : - 1,
'search_year', 1, 20, 5);
295 print
'<div style="vertical-align: middle; display: inline-block">';
296 print
'<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'',
'', 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'">';
297 print
'<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans(
"Search"),
'searchclear.png',
'',
'', 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'" title="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'">';
303 print
'<div class="div-table-responsive">';
304 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
305 print
'<tr class="liste_titre">';
308 print_liste_field_titre(
"SupplierCode", $_SERVER[
"PHP_SELF"],
"s.code_fournisseur",
"", $option,
'', $sortfield, $sortorder);
309 print_liste_field_titre(
"OrderDate", $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $option,
'align="center"', $sortfield, $sortorder);
310 print_liste_field_titre(
"DateDeliveryPlanned", $_SERVER[
"PHP_SELF"],
"cf.date_livraison",
"", $option,
'align="center"', $sortfield, $sortorder);
311 print_liste_field_titre(
"Qty", $_SERVER[
"PHP_SELF"],
"cfdi.qty",
"", $option,
'align="center"', $sortfield, $sortorder);
313 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $option,
'align="right"', $sortfield, $sortorder);
317 while ($i < min($num, $limit)) {
318 $objp = $db->fetch_object($result);
321 $objp->qty = -($objp->qty);
325 $total_qty += $objp->qty;
327 $commandefournisseurstatic->id = $objp->facid;
328 $commandefournisseurstatic->ref = $objp->ref;
329 $societestatic->fetch($objp->socid);
332 print
'<tr class="oddeven">';
334 print $commandefournisseurstatic->getNomUrl(1);
336 print
'<td>'.$societestatic->getNomUrl(1).
'</td>';
337 print
"<td>".$objp->code_fournisseur.
"</td>\n";
338 print
'<td class="center">';
339 print
dol_print_date($db->jdate($objp->date_commande),
'dayhour').
"</td>";
340 print
'<td class="center">';
341 print
dol_print_date($db->jdate($objp->delivery_date),
'dayhour').
"</td>";
342 print
'<td class="center">'.$objp->qty.
"</td>\n";
344 print
'<td align="right">'.$commandefournisseurstatic->LibStatut($objp->statut, 5).
'</td>';
349 print
'<tr class="liste_total">';
351 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
353 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
355 print
'<td colspan="2"></td>';
358 print
'<td class="center">'.$total_qty.
'</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.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage products or services.
Class with list of lots and properties.
Class to manage third parties objects (customers, suppliers, prospects...)
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
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_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.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
show_stats_for_batch($batch, $socid)
Show stats for product batch.
productlot_prepare_head($object)
Prepare array with list of tabs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.