From 0587e7327216d7bf329ccf84e67cf4ec83df75cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Jul 2018 15:53:28 +0200 Subject: [PATCH 1/5] FIX Pagination on related item pages --- htdocs/product/stats/commande.php | 60 +++++++++---------- htdocs/product/stats/commande_fournisseur.php | 60 +++++++++---------- htdocs/product/stats/contrat.php | 29 ++++++--- htdocs/product/stats/facture.php | 44 +++++++------- htdocs/product/stats/facture_fournisseur.php | 56 +++++++++-------- htdocs/product/stats/propal.php | 54 ++++++++--------- htdocs/product/stats/supplier_proposal.php | 50 +++++++--------- 7 files changed, 175 insertions(+), 178 deletions(-) diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index dc3d9a9b7d6..3b793d3acd7 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -49,11 +49,13 @@ $hookmanager->initHooks(array('productstatsorder')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; @@ -112,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -142,25 +144,22 @@ if ($id > 0 || ! empty($ref)) $sql.= ' AND YEAR(c.date_commande) IN (' . $search_year . ')'; if (!$user->rights->societe->client->voir && !$socid) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if ($socid) $sql.= " AND c.fk_soc = ".$socid; - $sql.= " ORDER BY $sortfield $sortorder "; - + $sql.= $db->order($sortfield, $sortorder); + //Calcul total qty and amount for global if full scan list $total_ht=0; $total_qty=0; - $totalrecords=0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql.= $db->plimit($conf->liste_limit +1, $offset); - + + $sql .= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { @@ -172,7 +171,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month='.$search_month; if (! empty($search_year)) $option .= '&search_year='.$search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '
' . "\n"; if (! empty($sortfield)) print ''; @@ -183,7 +183,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("CustomersOrders"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,$totalrecords,''); + print_barre_liste($langs->trans("CustomersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period').' ('.$langs->trans("OrderDate") .') - '; @@ -211,20 +211,22 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + + $orderstatic->id=$objp->commandeid; + $orderstatic->ref=$objp->ref; + $orderstatic->ref_client=$objp->ref_client; + $societestatic->fetch($objp->socid); + print ''; print ''; - $orderstatic->id=$objp->commandeid; - $orderstatic->ref=$objp->ref; - $orderstatic->ref_client=$objp->ref_client; print $orderstatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print ''.$societestatic->getNomUrl(1).''; print "".$objp->code_client."\n"; print ''; @@ -234,15 +236,11 @@ if ($id > 0 || ! empty($ref)) print ''.$orderstatic->LibStatut($objp->statut,$objp->facture,5).''; print "\n"; $i++; - - if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print ''.$total_qty.''; print ''.price($total_ht).''; diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 4526af86f96..7c80062da81 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -119,7 +119,7 @@ if ($id > 0 || ! empty($ref)) { print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -153,24 +153,21 @@ if ($id > 0 || ! empty($ref)) { $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND c.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; - + $sql.= $db->order($sortfield, $sortorder); + // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } - } - } - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) { @@ -182,7 +179,8 @@ if ($id > 0 || ! empty($ref)) { $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -193,7 +191,7 @@ if ($id > 0 || ! empty($ref)) { $option .= '&page=' . $page; } - print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("SuppliersOrders"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("OrderDate") . ') - '; @@ -219,20 +217,24 @@ if ($id > 0 || ! empty($ref)) { print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "c.fk_statut", "", $option, 'align="right"', $sortfield, $sortorder); print "\n"; - if ($num > 0) { - $var = True; - while ( $i < $num && $i < $conf->liste_limit ) { + if ($num > 0) + { + while ($i < min($num, $limit)) + { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $supplierorderstatic->id = $objp->commandeid; $supplierorderstatic->ref = $objp->ref; $supplierorderstatic->statut = $objp->statut; + $societestatic->fetch($objp->socid); + + print ''; + print ''; print $supplierorderstatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print '' . $societestatic->getNomUrl(1) . ''; print "" . $objp->code_client . "\n"; print ''; @@ -241,16 +243,12 @@ if ($id > 0 || ! empty($ref)) { print '' . price($objp->total_ht) . "\n"; print '' . $supplierorderstatic->getLibStatut(4) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index ef3723e2e55..fc88010553b 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -46,11 +46,13 @@ $hookmanager->initHooks(array('productstatscontract')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; @@ -102,7 +104,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product,$socid); print "
"; @@ -133,7 +135,20 @@ if ($id > 0 || ! empty($ref)) if ($socid) $sql.= " AND s.rowid = ".$socid; $sql.= " GROUP BY c.rowid, c.ref, c.ref_customer, c.ref_supplier, c.date_contrat, c.statut, s.nom, s.rowid, s.code_client"; $sql.= $db->order($sortfield, $sortorder); - $sql.= $db->plimit($conf->liste_limit +1, $offset); + + //Calcul total qty and amount for global if full scan list + $total_ht=0; + $total_qty=0; + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { + $result = $db->query($sql); + $totalofrecords = $db->num_rows($result); + } + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -145,7 +160,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -156,7 +172,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Contrats"),$page,$_SERVER["PHP_SELF"],"&id=$product->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("Contrats"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); $i = 0; print '
'; @@ -177,8 +193,7 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 794d939bc6e..6c039b816e2 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -50,15 +50,18 @@ $hookmanager->initHooks(array('productstatsinvoice')); $showmessage=GETPOST('showmessage'); +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="f.datef"; + $search_month = GETPOST('search_month', 'aplha'); $search_year = GETPOST('search_year', 'int'); @@ -129,7 +132,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - $nboflines = show_stats_for_company($product,$socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -164,25 +167,19 @@ if ($id > 0 || ! empty($ref)) if ($socid) $sql.= " AND f.fk_soc = ".$socid; $sql.= $db->order($sortfield, $sortorder); - //Calcul total qty and amount for global if full scan list + // Calcul total qty and amount for global if full scan list $total_ht=0; $total_qty=0; - $totalrecords=0; + + // Count total nb of records + $totalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { $result = $db->query($sql); - if ($result) - { - $totalrecords = $db->num_rows($result); - while ($objp = $db->fetch_object($result)) - { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - $sql.= $db->plimit($conf->liste_limit + 1, $offset); + $sql.= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -194,7 +191,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($search_month)) $option .= '&search_month='.$search_month; if (! empty($search_year)) - $option .= '&search_year='.$search_year; + $option .= '&search_year='.$search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); print '' . "\n"; if (! empty($sortfield)) @@ -206,7 +204,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("CustomersInvoices"),$page,$_SERVER["PHP_SELF"],"&id=".$product->id,$sortfield,$sortorder,'',$num,$totalrecords,''); + print_barre_liste($langs->trans("CustomersInvoices"), $page, $_SERVER["PHP_SELF"],"&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period').' ('.$langs->trans("DateInvoice") .') - '; @@ -234,11 +232,13 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var=True; - while ($i < min($num,$conf->liste_limit)) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $invoicestatic->id=$objp->facid; $invoicestatic->ref=$objp->facnumber; $societestatic->fetch($objp->socid); @@ -257,15 +257,11 @@ if ($id > 0 || ! empty($ref)) print ''.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).''; print "\n"; $i++; - - if (!empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht+=$objp->total_ht; - $total_qty+=$objp->qty; - } } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print ''.$total_qty.''; print ''.price($total_ht).''; diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 2e6b8d19677..a08486975ee 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -51,11 +51,13 @@ $hookmanager->initHooks(array('productstatssupplyinvoice')); $mesg = ''; +// Load variable for pagination +$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit; $sortfield = GETPOST("sortfield", 'alpha'); $sortorder = GETPOST("sortorder", 'alpha'); $page = GETPOST("page", 'int'); if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 -$offset = $conf->liste_limit * $page; +$offset = $limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder = "DESC"; @@ -114,7 +116,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -149,20 +151,17 @@ if ($id > 0 || ! empty($ref)) // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql .= $db->plimit($conf->liste_limit + 1, $offset); - + + $sql.= $db->plimit($limit + 1, $offset); + $result = $db->query($sql); if ($result) { @@ -174,7 +173,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -185,7 +185,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("SuppliersInvoices"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DateInvoice") . ') - '; @@ -213,19 +213,21 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->total_ht; + $total_qty+=$objp->qty; + $supplierinvoicestatic->id = $objp->facid; $supplierinvoicestatic->ref = $objp->facnumber; + $societestatic->fetch($objp->socid); + + print ''; + print ''; print $supplierinvoicestatic->getNomUrl(1); print "\n"; - $societestatic->fetch($objp->socid); print '' . $societestatic->getNomUrl(1) . ''; print "" . $objp->code_client . "\n"; print ''; @@ -234,16 +236,12 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->total_ht) . "\n"; print '' . $supplierinvoicestatic->LibStatut($objp->paye, $objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 3173a04ee55..34c64964c23 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND p.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; + $sql.= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->amount; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -178,7 +175,8 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; - + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); + print '' . "\n"; if (! empty($sortfield)) print ''; @@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; @@ -216,20 +214,22 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->amount; + $total_qty+=$objp->qty; + $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; $propalstatic->ref_client=$objp->ref_client; - print $propalstatic->getNomUrl(1); - print "\n"; $societestatic->fetch($objp->socid); + + print ''; + print ''; + print $propalstatic->getNomUrl(1); + print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; print dol_print_date($db->jdate($objp->datep), 'dayhour') . ""; @@ -237,17 +237,13 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->amount) . '' . "\n"; print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; diff --git a/htdocs/product/stats/supplier_proposal.php b/htdocs/product/stats/supplier_proposal.php index 07e8015d846..a50c8bab832 100644 --- a/htdocs/product/stats/supplier_proposal.php +++ b/htdocs/product/stats/supplier_proposal.php @@ -114,7 +114,7 @@ if ($id > 0 || ! empty($ref)) print '
'; print ''; - show_stats_for_company($product, $socid); + $nboflines = show_stats_for_company($product, $socid); print "
"; @@ -148,24 +148,21 @@ if ($id > 0 || ! empty($ref)) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = " . $user->id; if ($socid) $sql .= " AND p.fk_soc = " . $socid; - $sql .= " ORDER BY $sortfield $sortorder "; + $sql.= $db->order($sortfield, $sortorder); // Calcul total qty and amount for global if full scan list $total_ht = 0; $total_qty = 0; - $totalrecords = 0; - if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { + + // Count total nb of records + $totalofrecords = ''; + if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) + { $result = $db->query($sql); - if ($result) { - $totalrecords = $db->num_rows($result); - while ( $objp = $db->fetch_object($result) ) { - $total_ht += $objp->amount; - $total_qty += $objp->qty; - } - } + $totalofrecords = $db->num_rows($result); } - $sql .= $db->plimit($conf->liste_limit + 1, $offset); + $sql .= $db->plimit($limit + 1, $offset); $result = $db->query($sql); if ($result) @@ -178,6 +175,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&search_month=' . $search_month; if (! empty($search_year)) $option .= '&search_year=' . $search_year; + if ($limit > 0 && $limit != $conf->liste_limit) $option.='&limit='.urlencode($limit); print '' . "\n"; if (! empty($sortfield)) @@ -189,7 +187,7 @@ if ($id > 0 || ! empty($ref)) $option .= '&page=' . $page; } - print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=$product->id", $sortfield, $sortorder, '', $num, $totalrecords, ''); + print_barre_liste($langs->trans("Proposals"), $page, $_SERVER["PHP_SELF"], "&id=".$product->id, $sortfield, $sortorder, '', $num, $totalofrecords, '', 0, '', '', $limit); print '
'; print '
'; print $langs->trans('Period') . ' (' . $langs->trans("DatePropal") . ') - '; @@ -216,19 +214,21 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { - $var = True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < min($num, $limit)) { $objp = $db->fetch_object($result); - $var = ! $var; - print ''; - print ''; + $total_ht+=$objp->amount; + $total_qty+=$objp->qty; + $propalstatic->id=$objp->propalid; $propalstatic->ref=$objp->ref; - print $propalstatic->getNomUrl(1); - print "\n"; $societestatic->fetch($objp->socid); + + print ''; + print ''; + print $propalstatic->getNomUrl(1); + print "\n"; print ''.$societestatic->getNomUrl(1).''; print ''; print dol_print_date($db->jdate($objp->date_valid), 'dayhour') . ""; @@ -236,17 +236,13 @@ if ($id > 0 || ! empty($ref)) print '' . price($objp->amount) . '' . "\n"; print '' . $propalstatic->LibStatut($objp->statut, 5) . ''; print "\n"; - $i ++; - - if (! empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { - $total_ht += $objp->total_ht; - $total_qty += $objp->qty; - } + $i++; } } print ''; - print '' . $langs->trans('Total') . ''; + if ($num < $limit) print ''.$langs->trans("Total").''; + else print ''.$langs->trans("Totalforthispage").''; print ''; print '' . $total_qty . ''; print '' . price($total_ht) . ''; From af3ab84ebb2edbe758cda86062e51e68aae59126 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Jul 2018 22:15:55 +0200 Subject: [PATCH 2/5] Fix backward compatibility with old multicompany module --- htdocs/user/card.php | 100 ++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e5c24fbac04..635e14f7bd4 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1053,22 +1053,23 @@ if ($action == 'create' || $action == 'adduserldap') } // Multicompany - // This is now done with hook formObjectOptions - /* - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode - { - print "".''.$langs->trans("Entity").''; - print "".$mc->select_entities($conf->entity); - print "\n"; - } - else - { - print ''; - } - } - */ + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module + if (! method_exists($mc, 'formObjectOptions')) + { + if (empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) // condition must be same for create and edit mode + { + print "".''.$langs->trans("Entity").''; + print "".$mc->select_entities($conf->entity); + print "\n"; + } + else + { + print ''; + } + } + } // Other attributes $parameters=array('objectsrc' => $objectsrc, 'colspan' => ' colspan="3"'); @@ -1558,23 +1559,25 @@ else print ''.dol_print_date($object->datepreviouslogin,"dayhour").''; print "\n"; - // Multicompany - // This is now done with hook formObjectOptions (included into /core/tpl/extrafields_view.tpl.php) - /* - if (! empty($conf->multicompany->enabled) && is_object($mc)) - { - if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) - { - print '' . $langs->trans("Entity") . ''; - if (empty($object->entity)) { - print $langs->trans("AllEntities"); - } else { - $mc->getInfo($object->entity); - print $mc->label; - } - print "\n"; - } - }*/ + // Multicompany + if (! empty($conf->multicompany->enabled) && is_object($mc)) + { + // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module + if (! method_exists($mc, 'formObjectOptions')) + { + if (! empty($conf->multicompany->enabled) && empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print '' . $langs->trans("Entity") . ''; + if (empty($object->entity)) { + print $langs->trans("AllEntities"); + } else { + $mc->getInfo($object->entity); + print $mc->label; + } + print "\n"; + } + } + } // Other attributes include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; @@ -1731,7 +1734,7 @@ else } } } - + print "
\n"; @@ -2322,24 +2325,25 @@ else print "\n"; } - // Multicompany - // This is now done with hook formObjectOptions - /* + // Multicompany // TODO check if user not linked with the current entity before change entity (thirdparty, invoice, etc.) !! if (! empty($conf->multicompany->enabled) && is_object($mc)) { - if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + // This is now done with hook formObjectOptions. Keep this code for backward compatibility with old multicompany module + if (! method_exists($mc, 'formObjectOptions')) { - print "".''.$langs->trans("Entity").''; - print "".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' - print "\n"; - } - else - { - print ''; - } - } - */ + if (empty($conf->multicompany->transverse_mode) && $conf->entity == 1 && $user->admin && ! $user->entity) + { + print "".''.$langs->trans("Entity").''; + print "".$mc->select_entities($object->entity, 'entity', '', 0, 1); // last parameter 1 means, show also a choice 0=>'all entities' + print "\n"; + } + else + { + print ''; + } + } + } // Other attributes $parameters=array('colspan' => ' colspan="2"'); From bb792578278841c2cc17e37abdb26746377f50a1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jul 2018 12:00:12 +0200 Subject: [PATCH 3/5] Prepare Changelog --- ChangeLog | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/ChangeLog b/ChangeLog index 4adf6192acd..9ef351271e9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,174 @@ English Dolibarr ChangeLog ***** ChangeLog for 8.0.0 compared to 7.0.3 ***** +For Users: +NEW: Experimental module: Ticket +NEW: Experimental module: WebDAV +NEW: Accept anonmymous events (no user assigned) +NEW: Accountancy - Add import on general ledger +NEW: Accountancy - Show journal name on journal page and hide button draft export (Add an option in admin) +NEW: Can create event from record card of a company and member +NEW: Add a button to create Stripe customer from the Payment mode tab +NEW: Add accounting account number on product tooltip +NEW: add any predefined mail content +NEW: Add arrows to navigate into containers in website module +NEW: Add a tab to specify accountant/auditor of the company +NEW: Add Date delivery and Availability on Propals List +NEW: Add date in goods reception supplier order table +NEW: Add delivery_time_days of suppliers in export profile +NEW: Add Docments'tab to expedition module +NEW: Use dol_print_phone in thirdparty list page to format phone +NEW: Add entry for the GDPR contact +NEW: Add extrafield type "html" +NEW: Add file number in accountant card and update export filename +NEW: Add files management on products lot +NEW: add filter on project task list +NEW: Add hidden option COMPANY_AQUARIUM_CLEAN_REGEX to clean generated +NEW: add internal stripe payment page for invoice +NEW: Add key __USER_REMOTE_IP__ into available substitution variables +NEW: Add link between credit note invoice and origin +NEW: Add linked file tab to vat +NEW: add link to stripe's info in bank menu +NEW: Add margin filters +NEW: Add mass action enable/disable on cron job list +NEW: Add mass action on project's list to close projects +NEW: Add method to register distributed payments on invoices +NEW: Add multicurrency support for product buy price for supplier propales, orders and invoices +NEW: Add name of day in the timesheet input page per day. +NEW: add new parameters for tcpf encryption +NEW: add optional esign field in pdf propal +NEW: Add option BANK_ACCOUNT_ALLOW_EXTERNAL_DOWNLOAD +NEW: Add option CONTRACT_SYNC_PLANNED_DATE_OF_SERVICES +NEW: Add param $dolibarr_main_restrict_ip in config file to limit ips +NEW: add pdf function to check if pdf file is protected/encrypted +NEW: Add pdf template for stock/warehouse module +NEW: Add phone format for a lot of countries +NEW: Add product and product categories filters on customer margins +NEW: Add product categories filter on product margin +NEW: Add romanian chart of accounts +NEW: Add stats in salaries module +NEW: add stripe transaction +NEW: Add tab contact on supplier proposals +NEW: Add total of time spent in timespent page at top of page too. +NEW: Add trigger CONTRACT_MODIFY +NEW: Add triggers on ECM object and add fill src_object_type/id fields +NEW: Add type of website container/page into dictionary +NEW: advance target filtering can be used everywhere with tpl and fk_element +NEW: Allow negative quantity for dispatch (supplier order) +NEW: bank reconcile: checkbox to select all bank operations +NEW: Better performance with openldap +NEW: Can add filter actiontype and notactiontype on event ical export +NEW: Can add product in supplier order/invoice even w/o predefined price +NEW: cancel orders on massaction +NEW: Can crop image files attached in "document" tabs of a member +NEW: Can delete dir content in media and ECM module recursively +NEW: Can dispatch if more than ordered (if hidden option set) +NEW: Can edit the text color for title line of tables +NEW: Can enter time spent from the list of time spent of project +NEW: Can export leave requests +NEW: Can filter on account range in general ledger grouped by account +NEW: Can filter on country and taxid into the binding page +NEW: Can filter on progression in timesheet +NEW: Can fix the bank account of a payment if payment not conciliated +NEW: Can force usage of shared link for photo of products +NEW: Can get template of email from its label +NEW: Can see Unit Purchase Value of product in stock movement +NEW: Can select from the user list into send form email (For field to and CC) +NEW: Can select sample to use when creating a new page +NEW: can send mail from project card +NEW: Can set position of images in module tickets +NEW: Can set the reply-to into email sent +NEW: Can set the start/end date of service line in invoice templates +NEW: Can share any file from the "Document" tab. +NEW: Can sort on priority in task scheduler list +NEW: Can sort order of files in attach tab for leave and expensereport +NEW: Can use setValueFrom without user modification field +NEW: Cat set the encryption algorithm for extrafields of type password +NEW: check idprof1 for country pt +NEW: default add action: new param $backurlforcard to redirect to card +NEW: default warehouse field for products + prefill warehouses when dispatching supplier orders +NEW: Display price HT on all commercial area boards +NEW: display total on contract service list +NEW: display weight volume in proposal +NEW: Edit of extrafields position page on the edit form +NEW: Experimental DAV module provides a public and private directory +NEW: export filter models can be share or not by user +NEW: Externalsite module can accept iframe content. +NEW: Filter export model is now by user +NEW: Finish implementation of option PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES +NEW: generalize use of button to create new element from list +NEW: hidden conf AGENDA_NB_WEEKS_IN_VIEW_PER_USER to set nb weeks to show into per user view +NEW: hidden conf to assign category to thirparty that are not customer nor prospect nor supplier +NEW: hidden conf to set nb weeks to show into user view +NEW: hidden option MAIN_DISABLE_FREE_LINES +NEW: improve way of adding users/sales representative to thirdparty +NEW: Introduce option THIRDPARTY_QUICKSEARCH_ON_FIELDS to personalize fields use to search on quick search. +NEW: Introduce permission "approve" for "leave request" like for "expense report" +NEW: Load product data optional fields to the line -> enables to use "line_options_{extrafield}" +NEW: Look and feel v8 - Show Picto "+" on all links "Add record" +NEW: Look and feel v8: Use a different picto for delete and unlink +NEW: mail templates for projects +NEW: Module variant supported on services +NEW: monthly VAT report show "Claimed for the period" + "Paid during this +NEW: Mutualize code for action="update_extras" +NEW: On invoice card, show accounting account linked +NEW: Online payment of invoice and subscription record the payment +NEW: OnSearchAndListGoOnCustomerOrSupplierCard conf +NEW: Optimize load of hooks classes (save 1-5Kb of memory) +NEW: Option MAIN_SHOW_REGION_IN_STATE renamed into MAIN_SHOW_REGION_IN_STATE_SELECT are more complete +NEW: Option to force all emails recipient +NEW: Hidden option to send to salaries into emails forms +NEW: order minimum amount +NEW: add price in burger menu on mouvement list +NEW: Report a list of leave requests for a month +NEW: Section of files generated by mass action not visible if empty +NEW: send mails from project card +NEW: Show also size in bytes in tooltip if visible unit is not bytes +NEW: Show keyboard shortcut of nav arrow into tooltip +NEW: Show last result code of cron jobs in error in red +NEW: Show region in company info & Global option to show state code MAIN_SHOW_STATE_CODE +NEW: Show total number of records by category +NEW: Show total of time consumed in week in time spent entry page +NEW: Stripe online payments reuse the same stripe customer account +NEW: Suggest link to pay online for customer orders +NEW: supplier credit notes is now supported like for customer credit notes +NEW: supplier order/order lines export: add supplier product ref +NEW: supplier relative discounts +NEW: Support alternative aliases of page name in website +NEW: syslog file autoclean +NEW: thirdparty categ filter on lists +NEW: Use a css style for weekend in time spent +NEW: Use common substitution rule for language to get translation in ODT +NEW: Variable __ONLINE_PAYMENT_URL__ available in email templates + +For developers: +NEW: class reposition can also work on POST (not only GET) +NEW: add a hook in dol_print_phone +NEW: The field "visible" on extrafield can accept expression as condition +NEW: Upgrade of Stripe lib to 6.4.1 +NEW: work on CommonObject 'array' field typeNew common object array +NEW: method Form::selectArrayFilter() + use in left menu search +NEW: [REST API] Add the possibility to remove a category from a thirdparty +NEW: doActions on categorycard +NEW: add "moreHtmlRef" hook +NEW: add hook for more permissions control +NEW: add hook moreHtmlStatus to complete to status on banners +NEW: Add hook printEmail +NEW: Add hook setContentSecurityPolicy +NEW: Add password_hash as a hash algorithm +NEW: Add dol_is_link function +NEW: Adds a contact to an invoice with REST API +NEW: Adds a payment for the list of invoices given as parameter +NEW: adds billing contacts ids to REST API returns +NEW: Add showempty parameter in country selection +NEW: add printUserListWhere hook +NEW: add "printUserPasswordField" hooks +NEW: Call to trigger on payment social contribution creation +NEW: Call to trigger on social contribution creation +NEW: hook getnomurltooltip is replaced with hook getNomUrl more powerfull + + + WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: From 653134e179f59e1c3b8b18366f29128901a3a6cf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jul 2018 12:06:16 +0200 Subject: [PATCH 4/5] Fix changelog --- ChangeLog | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9ef351271e9..ceb1d847ddb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ English Dolibarr ChangeLog -------------------------------------------------------------- -***** ChangeLog for 8.0.0 compared to 7.0.3 ***** +***** ChangeLog for 8.0.0 compared to 7.0.0 ***** For Users: NEW: Experimental module: Ticket @@ -170,8 +170,6 @@ NEW: Call to trigger on payment social contribution creation NEW: Call to trigger on social contribution creation NEW: hook getnomurltooltip is replaced with hook getNomUrl more powerfull - - WARNING: Following changes may create regressions for some external modules, but were necessary to make Dolibarr better: @@ -192,6 +190,8 @@ Following changes may create regressions for some external modules, but were nec * Hook getnomurltooltip provide a duplicate feature compared to hook getNomUrl so all hooks getnomurltooltip are now replaced with hook getNomUrl. + + ***** ChangeLog for 7.0.3 compared to 7.0.2 ***** FIX: 7.0 task contact card without withproject parameters FIX: #8722 From 6c5264fabb72003eb1bafbd2281fb0d82aadb952 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Jul 2018 12:45:20 +0200 Subject: [PATCH 5/5] Fix label --- htdocs/compta/facture/card.php | 4 ++-- htdocs/langs/en_US/bills.lang | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 457f03c6afc..d5835f96781 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1290,7 +1290,7 @@ if (empty($reshook)) { $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); $descline = $langs->trans('Deposit'); - $descline.= ' - '.$langs->trans($arraylist[$typeamount]); + //$descline.= ' - '.$langs->trans($arraylist[$typeamount]); if ($typeamount=='amount') { $descline.= ' ('. price($valuedeposit, '', $langs, 0, - 1, - 1, (!empty($object->multicurrency_code) ? $object->multicurrency_code : $conf->currency)).')'; } elseif ($typeamount=='variable') { @@ -2873,7 +2873,7 @@ if ($action == 'create') if (($origin == 'propal') || ($origin == 'commande')) { print ''; - $arraylist = array('amount' => 'FixAmount','variable' => 'VarAmount'); + $arraylist = array('amount' => $langs->transnoentitiesnoconv('FixAmount'), 'variable' => $langs->transnoentitiesnoconv('VarAmountOneLine', $langs->transnoentitiesnoconv('Deposit'))); print $form->selectarray('typedeposit', $arraylist, GETPOST('typedeposit'), 0, 0, 0, '', 1); print ''; print '' . $langs->trans('Value') . ':'; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 3b59e46219a..7a260e6dbc6 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -394,6 +394,7 @@ PaymentConditionShort14DENDMONTH=14 days of month-end PaymentCondition14DENDMONTH=Within 14 days following the end of the month FixAmount=Fix amount VarAmount=Variable amount (%% tot.) +VarAmountOneLine=Variable amount (%% tot.) - 1 line with label '%s' # PaymentType PaymentTypeVIR=Bank transfer PaymentTypeShortVIR=Bank transfer