31require
'../../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.commande.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/productlot.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formother.class.php';
39$langs->loadLangs(array(
'companies',
'bills',
'products',
'orders'));
43$batch =
GETPOST(
'batch',
'alpha');
47$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
48$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
50if (!empty($user->socid)) {
51 $socid = $user->socid;
55$hookmanager->initHooks(array(
'batchproductstatssupplierorder'));
57$showmessage =
GETPOST(
'showmessage');
61$sortfield =
GETPOST(
'sortfield',
'aZ09comma');
62$sortorder =
GETPOST(
'sortorder',
'aZ09comma');
64if (empty($page) || $page == -1) {
67$offset = $limit * $page;
74 $sortfield =
"cf.date_commande";
80if (
GETPOST(
'button_removefilter_x',
'alpha') ||
GETPOST(
'button_removefilter',
'alpha')) {
85if (!$user->hasRight(
'produit',
'lire')) {
95$societestatic =
new Societe($db);
100if ($id > 0 || !empty($ref)) {
103 $tmp = explode(
'_', $ref);
107 $result =
$object->fetch($id, $objectid, $batch);
109 $parameters = array(
'id' => $id);
110 $reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
117 $title = $langs->trans(
'Batch').
" ".$shortlabel.
" - ".$langs->trans(
'Referers');
118 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
120 llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-stock-stats_commande_fournisseur');
124 $titre = $langs->trans(
"CardProduct".
$object->type);
128 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
129 print $hookmanager->resPrint;
134 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/stock/productlot_list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
137 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
141 dol_banner_tab(
$object,
'id', $linkback, $shownav,
'rowid',
'batch', $morehtmlref);
143 print
'<div class="fichecenter">';
145 print
'<div class="underbanner clearboth"></div>';
146 print
'<table class="border centpercent tableforfield" width="100%">';
150 print
'<tr><td class="titlefield">'.$langs->trans(
"Product").
'</td><td>';
151 $producttmp =
new Product($db);
152 $producttmp->fetch(
$object->fk_product);
153 print $producttmp->getNomUrl(1,
'stock').
" - ".$producttmp->label;
204 print
'<table class="border centpercent tableforfield" width="100%">';
211 print
'<div class="clearboth"></div>';
215 if ($showmessage && $nboflines > 1) {
216 print
'<span class="opacitymedium">'.$langs->trans(
"ClinkOnALinkOfColumn", $langs->transnoentitiesnoconv(
"Referers")).
'</span>';
217 } elseif ($user->hasRight(
'fournisseur',
'commande',
'lire')) {
218 $sql =
"SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_fournisseur,";
219 $sql .=
" cf.ref, cf.date_commande, cf.date_livraison as delivery_date, cf.fk_statut as statut, cf.rowid as facid,";
220 $sql .=
" cfd.rowid, SUM(cfdi.qty) as qty";
222 if (!$user->hasRight(
'societe',
'client',
'voir')) {
223 $sql .=
", sc.fk_soc, sc.fk_user ";
225 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe as s";
226 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"commande_fournisseur as cf ON (cf.fk_soc = s.rowid)";
227 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"commande_fournisseurdet as cfd ON (cfd.fk_commande = cf.rowid)";
228 $sql .=
" INNER JOIN ".MAIN_DB_PREFIX.
"receptiondet_batch as cfdi ON (cfdi.fk_elementdet = cfd.rowid)";
229 if (!$user->hasRight(
'societe',
'client',
'voir')) {
230 $sql .=
", ".MAIN_DB_PREFIX.
"societe_commerciaux as sc";
232 $sql .=
" WHERE cf.entity IN (".getEntity(
'product').
")";
233 $sql .=
" AND cfdi.batch = '".($db->escape(
$object->batch)).
"'";
234 if (!empty($search_month)) {
235 $sql .=
' AND MONTH(cf.date_commande) IN ('.$db->sanitize($search_month).
')';
237 if (!empty($search_year)) {
238 $sql .=
' AND YEAR(cf.date_commande) IN ('.$db->sanitize($search_year).
')';
240 if (!$user->hasRight(
'societe',
'client',
'voir')) {
241 $sql .=
" AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
244 $sql .=
" AND cf.fk_soc = ".((int) $socid);
246 $sql .=
" GROUP BY cf.rowid";
247 $sql .= $db->order($sortfield, $sortorder);
250 $total_ht_pondere = 0;
254 $totalofrecords =
'';
256 $result = $db->query($sql);
257 $totalofrecords = $db->num_rows($result);
260 $sql .= $db->plimit($limit + 1, $offset);
262 $result = $db->query($sql);
264 $num = $db->num_rows($result);
266 $option .=
'&id='.$object->id;
268 if ($limit > 0 && $limit != $conf->liste_limit) {
269 $option .=
'&limit='.((int) $limit);
271 if (!empty($search_month)) {
272 $option .=
'&search_month='.urlencode((
string) ($search_month));
274 if (!empty($search_year)) {
275 $option .=
'&search_year='.urlencode((
string) ($search_year));
278 print
'<form method="post" action="'.$_SERVER [
'PHP_SELF'].
'?id='.
$object->id.
'" name="search_form">'.
"\n";
279 print
'<input type="hidden" name="token" value="'.newToken().
'">';
280 if (!empty($sortfield)) {
281 print
'<input type="hidden" name="sortfield" value="'.$sortfield.
'"/>';
283 if (!empty($sortorder)) {
284 print
'<input type="hidden" name="sortorder" value="'.$sortorder.
'"/>';
288 print_barre_liste($langs->trans(
"SuppliersOrders"), $page, $_SERVER[
"PHP_SELF"], $option, $sortfield, $sortorder,
'', $num, $totalofrecords,
'', 0,
'',
'', $limit, 0, 0, 1);
291 $option .=
'&page='.urlencode((
string) ($page));
294 print
'<div class="liste_titre liste_titre_bydiv centpercent">';
295 print
'<div class="divsearchfield">';
296 print $langs->trans(
'Period').
' ('.$langs->trans(
"OrderDate").
') - ';
297 print $langs->trans(
'Month').
':<input class="flat" type="text" size="4" name="search_month" value="'.$search_month.
'"> ';
298 print $langs->trans(
'Year').
':'.$formother->selectyear($search_year ? $search_year : - 1,
'search_year', 1, 20, 5);
299 print
'<div style="vertical-align: middle; display: inline-block">';
300 print
'<input type="image" class="liste_titre" name="button_search" src="'.img_picto($langs->trans(
"Search"),
'search.png',
'', 0, 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"Search")).
'" title="'.
dol_escape_htmltag($langs->trans(
"Search")).
'">';
301 print
'<input type="image" class="liste_titre" name="button_removefilter" src="'.img_picto($langs->trans(
"Search"),
'searchclear.png',
'', 0, 1).
'" value="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'" title="'.
dol_escape_htmltag($langs->trans(
"RemoveFilter")).
'">';
307 print
'<div class="div-table-responsive">';
308 print
'<table class="tagtable liste listwithfilterbefore" width="100%">';
309 print
'<tr class="liste_titre">';
312 print_liste_field_titre(
"SupplierCode", $_SERVER[
"PHP_SELF"],
"s.code_fournisseur",
"", $option,
'', $sortfield, $sortorder);
313 print_liste_field_titre(
"OrderDate", $_SERVER[
"PHP_SELF"],
"cf.date_commande",
"", $option,
'align="center"', $sortfield, $sortorder);
314 print_liste_field_titre(
"DateDeliveryPlanned", $_SERVER[
"PHP_SELF"],
"cf.date_livraison",
"", $option,
'align="center"', $sortfield, $sortorder);
315 print_liste_field_titre(
"Qty", $_SERVER[
"PHP_SELF"],
"cfdi.qty",
"", $option,
'align="center"', $sortfield, $sortorder);
317 print_liste_field_titre(
"Status", $_SERVER[
"PHP_SELF"],
"cf.fk_statut",
"", $option,
'align="right"', $sortfield, $sortorder);
321 while ($i < min($num, $limit)) {
322 $objp = $db->fetch_object($result);
325 $objp->qty = -($objp->qty);
329 $total_qty += $objp->qty;
331 $commandefournisseurstatic->id = $objp->facid;
332 $commandefournisseurstatic->ref = $objp->ref;
333 $societestatic->fetch($objp->socid);
336 print
'<tr class="oddeven">';
338 print $commandefournisseurstatic->getNomUrl(1);
340 print
'<td>'.$societestatic->getNomUrl(1).
'</td>';
341 print
"<td>".$objp->code_fournisseur.
"</td>\n";
342 print
'<td class="center">';
343 print
dol_print_date($db->jdate($objp->date_commande),
'dayhour').
"</td>";
344 print
'<td class="center">';
345 print
dol_print_date($db->jdate($objp->delivery_date),
'dayhour').
"</td>";
346 print
'<td class="center">'.$objp->qty.
"</td>\n";
348 print
'<td align="right">'.$commandefournisseurstatic->LibStatut($objp->statut, 5).
'</td>';
353 print
'<tr class="liste_total">';
355 print
'<td class="left">'.$langs->trans(
"Total").
'</td>';
357 print
'<td class="left">'.$langs->trans(
"Totalforthispage").
'</td>';
359 print
'<td colspan="2"></td>';
362 print
'<td class="center">'.$total_qty.
'</td>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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.
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...)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
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.