diff --git a/.github/workflows/stale-issues.yml b/.github/workflows/stale-issues.yml
index 66eb3f0cd40..b50af3ec717 100644
--- a/.github/workflows/stale-issues.yml
+++ b/.github/workflows/stale-issues.yml
@@ -16,7 +16,7 @@ jobs:
stale-issue-label: 'Issue Stale (automatic label)'
exempt-issue-label: 'Priority High / Blocking'
days-before-stale: 365
- days-before-close: 10
+ days-before-close: 15
#stale-pr-message: 'This PR is stale because it has been open 1 year with no activity. If this PR is still mergeable (no conflict, nor Continuous Integration errors), please comment to confirm this merge is still expected. Without comment, this issue will be closed automatically by stale bot in 15 days.'
#stale-pr-label: 'PR Stale (automatic label)'
#exempt-pr-label: 'Priority Top Strategic'
diff --git a/htdocs/adherents/note.php b/htdocs/adherents/note.php
index e232539491b..7e8175793fd 100644
--- a/htdocs/adherents/note.php
+++ b/htdocs/adherents/note.php
@@ -75,7 +75,7 @@ if ($id)
$linkback = ''.$langs->trans("BackToList").'';
- dol_banner_tab($object, 'rowid', $linkback);
+ dol_banner_tab($object, 'id', $linkback);
print '
\n";
if (! empty($conf->multicompany->enabled)) {
print '
';
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 82a898a8ddf..81f86b1642d 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -1094,7 +1094,7 @@ class Cronjob extends CommonObject
$errmsg = '';
if (!is_array($object->errors) || !in_array($object->error, $object->errors)) $errmsg .= $object->error;
- if (is_array($object->errors) && count($object->errors)) $errmsg .= ($errmsg ? ', '.$errmsg : '').join(', ', $object->errors);
+ if (is_array($object->errors) && count($object->errors)) $errmsg .= (($errmsg ? ', ' : '').join(', ', $object->errors));
if (empty($errmsg)) $errmsg = $langs->trans('ErrorUnknown');
dol_syslog(get_class($this)."::run_jobs END result=".$result." error=".$errmsg, LOG_ERR);
diff --git a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
index 0a91f960807..e4d1dd51135 100644
--- a/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
+++ b/htdocs/install/mysql/migration/11.0.0-12.0.0.sql
@@ -181,4 +181,7 @@ INSERT INTO llx_c_ticket_resolution (code, pos, label, active, use_default, desc
DELETE FROM llx_const WHERE name = __ENCRYPT('DONATION_ART885')__;
-ALTER TABLE llx_extrafields ADD COLUMN documentpdf integer DEFAULT 0;
\ No newline at end of file
+ALTER TABLE llx_extrafields MODIFY COLUMN printable integer DEFAULT 0;
+ALTER TABLE llx_extrafields ADD COLUMN printable integer DEFAULT 0;
+
+
diff --git a/htdocs/install/mysql/tables/llx_extrafields.sql b/htdocs/install/mysql/tables/llx_extrafields.sql
index 4fd80c0d9c2..3578414d98b 100644
--- a/htdocs/install/mysql/tables/llx_extrafields.sql
+++ b/htdocs/install/mysql/tables/llx_extrafields.sql
@@ -36,7 +36,7 @@ create table llx_extrafields
alwayseditable integer DEFAULT 0, -- 1 if field can be edited whatever is element status
param text, -- extra parameters to define possible values of field
list varchar(255) DEFAULT '1', -- visibility of field. 0=Never visible, 1=Visible on list and forms, 2=Visible on list only. Using a negative value means field is not shown by default on list but can be selected for viewing
- printable boolean DEFAULT FALSE, -- is the extrafield output on documents
+ printable integer DEFAULT 0, -- is the extrafield output on documents
totalizable boolean DEFAULT FALSE, -- is extrafield totalizable on list
langs varchar(64), -- example: fileofmymodule@mymodule
help text, -- to store help tooltip
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index ee025ede17f..0f10ac291ff 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -1686,6 +1686,8 @@ CashDeskIdWareHouse=Force and restrict warehouse to use for stock decrease
StockDecreaseForPointOfSaleDisabled=Stock decrease from Point of Sale disabled
StockDecreaseForPointOfSaleDisabledbyBatch=Stock decrease in POS is not compatible with module Serial/Lot management (currently active) so stock decrease is disabled.
CashDeskYouDidNotDisableStockDecease=You did not disable stock decrease when making a sale from Point of Sale. Hence a warehouse is required.
+CashDeskForceDecreaseStockLabel=Stock decrease for batch products was forced.
+CashDeskForceDecreaseStockDesc=Decrease first by the oldest eatby and sellby dates.
##### Bookmark #####
BookmarkSetup=Bookmark module setup
BookmarkDesc=This module allows you to manage bookmarks. You can also add shortcuts to any Dolibarr pages or external web sites on your left menu.
diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang
index cc56503c638..47d6cc7a971 100644
--- a/htdocs/langs/en_US/errors.lang
+++ b/htdocs/langs/en_US/errors.lang
@@ -96,7 +96,7 @@ ErrorBadMaskFailedToLocatePosOfSequence=Error, mask without sequence number
ErrorBadMaskBadRazMonth=Error, bad reset value
ErrorMaxNumberReachForThisMask=Maximum number reached for this mask
ErrorCounterMustHaveMoreThan3Digits=Counter must have more than 3 digits
-ErrorSelectAtLeastOne=Error. Select at least one entry.
+ErrorSelectAtLeastOne=Error, select at least one entry.
ErrorDeleteNotPossibleLineIsConsolidated=Delete not possible because record is linked to a bank transaction that is conciliated
ErrorProdIdAlreadyExist=%s is assigned to another third
ErrorFailedToSendPassword=Failed to send password
@@ -230,6 +230,8 @@ ErrorAddAtLeastOneLineFirst=Add at least one line first
ErrorRecordAlreadyInAccountingDeletionNotPossible=Error, record is already transferred in accounting, deletion is not possible.
ErrorLanguageMandatoryIfPageSetAsTranslationOfAnother=Error, language is mandatory if you set the page as a translation of another one.
ErrorLanguageOfTranslatedPageIsSameThanThisPage=Error, language of translated page is same than this one.
+ErrorBatchNoFoundForProductInWarehouse=No lot/serial found for product "%s" in warehouse "%s".
+ErrorBatchNoFoundEnoughQuantityForProductInWarehouse=No enough quantity for this lot/serial for product "%s" in warehouse "%s".
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Your PHP parameter upload_max_filesize (%s) is higher than PHP parameter post_max_size (%s). This is not a consistent setup.
WarningPasswordSetWithNoAccount=A password was set for this member. However, no user account was created. So this password is stored but can't be used to login to Dolibarr. It may be used by an external module/interface but if you don't need to define any login nor password for a member, you can disable option "Manage a login for each member" from Member module setup. If you need to manage a login but don't need any password, you can keep this field empty to avoid this warning. Note: Email can also be used as a login if the member is linked to a user.
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 59950289236..b32dd7ed07e 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -31,7 +31,7 @@ NextYearOfInvoice=Following year of invoice date
DateNextInvoiceBeforeGen=Date of next invoice (before generation)
DateNextInvoiceAfterGen=Date of next invoice (after generation)
GraphInBarsAreLimitedTo3Measures=Grapics are limited to 3 measures in 'Bars' mode. The mode 'Lines' was automatically selected instead.
-OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Only the first selected field has been selected.
+OnlyOneFieldForXAxisIsPossible=Only 1 field is currently possible as X-Axis. Only the first selected field has been selected.
AtLeastOneMeasureIsRequired=At least 1 field for measure is required
AtLeastOneXAxisIsRequired=At least 1 field for X-Axis is required
@@ -278,3 +278,7 @@ LinesToImport=Lines to import
MemoryUsage=Memory usage
RequestDuration=Duration of request
+PopuProp=Products/Services by popularity in Proposals
+PopuCom=Products/Services by popularity in Orders
+ProductStatistics=Products/Services Statistics
+NbOfQtyInOrders=Qty in orders
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 052f77a365e..221d5032bfb 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -1683,6 +1683,8 @@ CashDeskIdWareHouse=Forcer et restreindre l'emplacement/entrepôt à utiliser po
StockDecreaseForPointOfSaleDisabled=Réduction de stock lors de l'utilisation du Point de Vente désactivée
StockDecreaseForPointOfSaleDisabledbyBatch=La décrémentation de stock depuis ce module Point de Vente n'est pas encore compatible avec la gestion des numéros de lots/série.
CashDeskYouDidNotDisableStockDecease=Vous n'avez pas désactivé la réduction de stock lors d'une vente depuis le Point de vente. Par conséquent, un entrepôt est nécessaire.
+CashDeskForceDecreaseStockLabel=Décrémentation des stocks pour les lots a été forcé.
+CashDeskForceDecreaseStockDesc=Décrémentation des lots par DLC et DLUO les plus anciennes.
##### Bookmark #####
BookmarkSetup=Configuration du module Marque-pages
BookmarkDesc=Ce module vous permet de gérer des liens et raccourcis. Il permet aussi d'ajouter n'importe quelle page de Dolibarr ou lien web dans le menu d'accès rapide sur la gauche.
diff --git a/htdocs/langs/fr_FR/errors.lang b/htdocs/langs/fr_FR/errors.lang
index 1142524115c..f7ffea8ed10 100644
--- a/htdocs/langs/fr_FR/errors.lang
+++ b/htdocs/langs/fr_FR/errors.lang
@@ -227,6 +227,8 @@ ErrorNoFieldWithAttributeShowoncombobox=Aucun champ n'a la propriété 'showonco
ErrorFieldRequiredForProduct=Le champ '%s' est obligatoire pour le produit %s
ProblemIsInSetupOfTerminal=Le problème est dans la configuration du terminal %s.
ErrorAddAtLeastOneLineFirst=Ajouter d'abord au moins une ligne
+ErrorBatchNoFoundForProductInWarehouse=Aucun lot trouvé pour le produit "%s" dans l'entrepôt "%s".
+ErrorBatchNoFoundEnoughQuantityForProductInWarehouse=Quantité insuffisante dans les lots pour le produit "%s" dans l'entepôt "%s".
# Warnings
WarningParamUploadMaxFileSizeHigherThanPostMaxSize=Votre paramètre PHP upload_max_filesize (%s) est supérieur au paramètre PHP post_max_size (%s). Ceci n'est pas une configuration cohérente.
WarningPasswordSetWithNoAccount=Un mot de passe a été fixé pour cet adhérent. Cependant, aucun compte d'utilisateur n'a été créé. Donc, ce mot de passe est stocké, mais ne peut être utilisé pour accéder à Dolibarr. Il peut être utilisé par un module/interface externe, mais si vous n'avez pas besoin de définir ni login ni mot de passe pour un adhérent, vous pouvez désactiver l'option «Gérer un login pour chaque adhérent" depuis la configuration du module Adhérents. Si vous avez besoin de gérer un login, mais pas de mot de passe, vous pouvez laisser ce champ vide pour éviter cet avertissement. Remarque: L'email peut également être utilisé comme login si l'adhérent est lié à un utilisateur.
diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php
index 0f1f0e01a87..8c1cdd829de 100644
--- a/htdocs/main.inc.php
+++ b/htdocs/main.inc.php
@@ -1898,13 +1898,15 @@ function top_menu_user()
$( document ).ready(function() {
$(document).on("click", function(event) {
if (!$(event.target).closest("#topmenu-login-dropdown").length) {
- // Hide the menus.
+ //console.log("close login dropdown");
+ // Hide the menus.
$("#topmenu-login-dropdown").removeClass("open");
}
});
$("#topmenu-login-dropdown .dropdown-toggle").on("click", function(event) {
- event.preventDefault();
+ console.log("toggle login dropdown");
+ event.preventDefault();
$("#topmenu-login-dropdown").toggleClass("open");
});
@@ -1954,14 +1956,14 @@ function top_menu_bookmark()
$( document ).ready(function() {
$(document).on("click", function(event) {
if (!$(event.target).closest("#topmenu-bookmark-dropdown").length) {
- console.log("close");
+ //console.log("close bookmark dropdown - we click outside");
// Hide the menus.
$("#topmenu-bookmark-dropdown").removeClass("open");
}
});
$("#topmenu-bookmark-dropdown .dropdown-toggle").on("click", function(event) {
- console.log("toggle");
+ console.log("toggle bookmark dropdown");
openBookMarkDropDown();
});
@@ -2077,7 +2079,7 @@ function top_menu_search()
// close drop down
$(document).on("click", function(event) {
if (!$(event.target).closest("#topmenu-global-search-dropdown").length) {
- console.log("click close");
+ console.log("click close search - we click outside");
// Hide the menus.
$("#topmenu-global-search-dropdown").removeClass("open");
}
@@ -2085,7 +2087,7 @@ function top_menu_search()
// Open drop down
$("#topmenu-global-search-dropdown .dropdown-toggle").on("click", function(event) {
- console.log("click open");
+ console.log("toggle search dropdown");
openGlobalSearchDropDown();
});
diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php
index a0a85bbec94..843bf2aa139 100644
--- a/htdocs/product/class/productbatch.class.php
+++ b/htdocs/product/class/productbatch.class.php
@@ -30,6 +30,11 @@ require_once DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php";
*/
class Productbatch extends CommonObject
{
+ /**
+ * Batches rules
+ */
+ const BATCH_RULE_SELLBY_EATBY_DATES_FIRST = 1;
+
/**
* @var string ID to identify managed object
*/
@@ -540,4 +545,65 @@ class Productbatch extends CommonObject
return -1;
}
}
+
+ /**
+ * Return all batch for a product and a warehouse
+ *
+ * @param DoliDB $db Database object
+ * @param int $fk_product Id of product
+ * @param int $fk_warehouse Id of warehouse
+ * @param int $qty_min [=NULL] Minimum quantity
+ * @param string $sortfield [=NULL] List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb'
+ * @param string $sortorder [=NULL] Sort order, separated by comma. Example: 'ASC,DESC';
+ * @return int|array <0 if KO, array of batch
+ *
+ * @throws Exception
+ */
+ public static function findAllForProduct($db, $fk_product, $fk_warehouse = 0, $qty_min = null, $sortfield = null, $sortorder = null)
+ {
+ $productBatchList = array();
+
+ dol_syslog(__METHOD__ . ' fk_product=' . $fk_product . ', fk_warehouse=' . $fk_warehouse . ', qty_min=' . $qty_min . ', sortfield=' . $sortfield . ', sortorder=' . $sortorder, LOG_DEBUG);
+
+ $sql = "SELECT";
+ $sql .= " pl.rowid";
+ $sql .= ", pl.fk_product";
+ $sql .= ", pl.batch";
+ $sql .= ", pl.sellby";
+ $sql .= ", pl.eatby";
+ $sql .= ", pb.qty";
+ $sql .= " FROM " . MAIN_DB_PREFIX . "product_lot as pl";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product as p ON p.rowid = pl.fk_product";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_batch AS pb ON pl.batch = pb.batch";
+ $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "product_stock AS ps ON ps.rowid = pb.fk_product_stock";
+ $sql .= " WHERE p.entity IN (" . getEntity('product') . ")";
+ $sql .= " AND pl.fk_product = " . $fk_product;
+ if ($fk_warehouse > 0) {
+ $sql .= " AND ps.fk_entrepot = " . $fk_warehouse;
+ }
+ if ($qty_min !== null) {
+ $sql .= " AND pb.qty > " . $qty_min;
+ }
+ $sql .= $db->order($sortfield, $sortorder);
+
+ $resql = $db->query($sql);
+ if ($resql) {
+ while ($obj = $db->fetch_object($resql)) {
+ $productBatch = new self($db);
+ $productBatch->id = $obj->rowid;
+ $productBatch->fk_product = $obj->fk_product;
+ $productBatch->batch = $obj->batch;
+ $productBatch->eatby = $db->jdate($obj->eatby);
+ $productBatch->sellby = $db->jdate($obj->sellby);
+ $productBatch->qty = $obj->qty;
+ $productBatchList[] = $productBatch;
+ }
+ $db->free($resql);
+
+ return $productBatchList;
+ } else {
+ dol_syslog(__METHOD__ . ' Error: ' . $db->lasterror(), LOG_ERR);
+ return -1;
+ }
+ }
}
diff --git a/htdocs/product/popucom.php b/htdocs/product/popucom.php
new file mode 100644
index 00000000000..41f14e25176
--- /dev/null
+++ b/htdocs/product/popucom.php
@@ -0,0 +1,217 @@
+
+ * Copyright (C) 2004-2005 Laurent Destailleur
+ * Copyright (C) 2004 Eric Seigne
+ * Copyright (C) 2005-2012 Regis Houssin
+ * Copyright (C) 2014 Marcos García
+ * Copyright (C) 2015 Jean-François Ferry
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+/**
+ * \file htdocs/product/popucom.php
+ * \ingroup commande, produit
+ * \brief Liste des produits/services par popularite
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+
+// Load translation files required by the page
+//Required to translate NbOfCommande
+$langs->load('commande');
+
+$type=GETPOST("type", "int");
+
+// Security check
+if (! empty($user->socid)) $socid=$user->socid;
+$result=restrictedArea($user, 'produit|service');
+
+$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
+if (! $sortfield) $sortfield="c";
+if (! $sortorder) $sortorder="DESC";
+$offset = $limit * $page ;
+$pageprev = $page - 1;
+$pagenext = $page + 1;
+
+
+$staticproduct=new Product($db);
+
+
+/*
+ * View
+ */
+
+$helpurl='';
+if ($type == '0')
+{
+ $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
+}
+elseif ($type == '1')
+{
+ $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
+}
+else
+{
+ $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
+}
+$title=$langs->trans("Statistics");
+
+
+llxHeader('', $title, $helpurl);
+
+print load_fiche_titre($title, $mesg, 'products');
+
+
+$param = '';
+$title = $langs->trans("ListProductServiceByPopularity");
+if ((string) $type == '1') {
+ $title = $langs->trans("ListServiceByPopularity");
+}
+if ((string) $type == '0') {
+ $title = $langs->trans("ListProductByPopularity");
+}
+
+if ($type != '') $param .= '&type='.$type;
+
+
+$h=0;
+$head = array();
+
+$head[$h][0] = DOL_URL_ROOT.'/product/stats/card.php?id=all';
+$head[$h][1] = $langs->trans("Chart");
+$head[$h][2] = 'chart';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/product/popuprop.php';
+$head[$h][1] = $langs->trans("PopuProp");
+$head[$h][2] = 'popularityprop';
+$h++;
+
+$head[$h][0] = DOL_URL_ROOT.'/product/popucom.php';
+$head[$h][1] = $langs->trans("PopuCom");
+$head[$h][2] = 'popularitycommande';
+$h++;
+
+dol_fiche_head($head, 'popularitycommande', $langs->trans("Statistics"), -1);
+
+
+// Array of liens to show
+$infoprod=array();
+
+
+// Add lines for commande
+$sql = "SELECT p.rowid, p.label, p.ref, p.fk_product_type as type, SUM(pd.qty) as c";
+$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as pd";
+$sql.= ", ".MAIN_DB_PREFIX."product as p";
+$sql.= ' WHERE p.entity IN ('.getEntity('product').')';
+$sql.= " AND p.rowid = pd.fk_product";
+if ($type !== '') {
+ $sql.= " AND fk_product_type = ".$type;
+}
+$sql.= " GROUP BY p.rowid, p.label, p.ref, p.fk_product_type";
+
+$result=$db->query($sql);
+if ($result)
+{
+ $totalnboflines = $db->num_rows($result);
+}
+
+$sql.= $db->order($sortfield, $sortorder);
+$sql.= $db->plimit($limit+1, $offset);
+
+$resql=$db->query($sql);
+if ($resql)
+{
+ $num = $db->num_rows($resql);
+ $i = 0;
+
+ while ($i < $num)
+ {
+ $objp = $db->fetch_object($resql);
+
+ $infoprod[$objp->rowid]=array('type'=>$objp->type, 'ref'=>$objp->ref, 'label'=>$objp->label);
+ $infoprod[$objp->rowid]['nblinecommande']=$objp->c;
+
+ $i++;
+ }
+ $db->free($resql);
+}
+else
+{
+ dol_print_error($db);
+}
+//var_dump($infoprod);
+
+
+print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, "", $num, $totalnboflines, '');
+
+print '