';
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 3c24df1084c..8e303ac0f1a 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -7136,12 +7136,36 @@ abstract class CommonObject
var parent = $(this).find("option[parent]:first").attr("parent");
var infos = parent.split(":");
var parent_list = infos[0];
+
+ //Hide daughters lists
+ if ($("#"+child_list).val() == 0 && $("#"+parent_list).val() == 0){
+ $("#"+child_list).hide();
+ //Show mother lists
+ } else if ($("#"+parent_list).val() != 0){
+ $("#"+parent_list).show();
+ }
+ //Show the child list if the parent list value is selected
+ $("select[name=\""+parent_list+"\"]").click(function() {
+ if ($(this).val() != 0){
+ $("#"+child_list).show()
+ }
+ });
+
+ //When we change parent list
+ $("select[name=\""+parent_list+"\"]").change(function() {
+ showOptions(child_list, parent_list, orig_select[child_list]);
+ //Select the value 0 on child list after a change on the parent list
+ $("#"+child_list).val(0).trigger("change");
+ //Hide child lists if the parent value is set to 0
+ if ($(this).val() == 0){
+ $("#"+child_list).hide();
+ }
+
$("select[name=\""+parent_list+"\"]").change(function() {
showOptions(child_list, parent_list, orig_select[child_list]);
});
});
}
-
setListDependencies();
});
'."\n";
diff --git a/htdocs/core/modules/barcode/mod_barcode_product_standard.php b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
index 3f18d536122..c09239a8d68 100644
--- a/htdocs/core/modules/barcode/mod_barcode_product_standard.php
+++ b/htdocs/core/modules/barcode/mod_barcode_product_standard.php
@@ -99,9 +99,9 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
$tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("BarCode"), $langs->transnoentities("BarCode"));
$tooltip .= $langs->trans("GenericMaskCodes3");
$tooltip .= ''.$langs->trans("Example").': ';
- $tooltip .= '020{000000000} (for internal use) ';
- $tooltip .= '9771234{00000} (example of ISSN code with prefix 1234) ';
- $tooltip .= '9791234{00000} (example of ISMN code with prefix 1234) ';
+ $tooltip .= '020{000000000}? (for internal use) ';
+ $tooltip .= '9771234{00000}? (example of ISSN code with prefix 1234) ';
+ $tooltip .= '9791234{00000}? (example of ISMN code with prefix 1234) ';
//$tooltip.=$langs->trans("GenericMaskCodes5");
// Mask parameter
@@ -140,7 +140,37 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
return $examplebarcode;
}
+ /**
+ * Return literal barcode type code from numerical rowid type of barcode
+ *
+ * @param Database $db Database
+ * @param int $type Type of barcode (EAN, ISBN, ...) as rowid
+ * @return string
+ */
+ public function literalBarcodeType($db, $type = '')
+ {
+ global $conf;
+ $out = '';
+ $sql = "SELECT rowid, code, libelle as label";
+ $sql .= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
+ $sql .= " WHERE rowid = '".$db->escape($type)."'";
+ $sql .= " AND entity = ".((int) $conf->entity);
+ $result = $db->query($sql);
+ if ($result) {
+ $num = $db->num_rows($result);
+
+ if ($num > 0) {
+ $obj = $db->fetch_object($result);
+ $out .= $obj->label; //take the label corresponding to the type rowid in the database
+ }
+ }
+ else {
+ dol_print_error($db);
+ }
+
+ return $out;
+ }
/**
* Return next value
*
@@ -153,6 +183,11 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
global $db, $conf;
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+ require_once DOL_DOCUMENT_ROOT.'/core/lib/barcode.lib.php'; // to be able to call function barcode_gen_ean_sum($ean)
+
+ if (empty($type)) {
+ $type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
+ } //get barcode type configuration for products if $type not set
// TODO
@@ -171,7 +206,28 @@ class mod_barcode_product_standard extends ModeleNumRefBarCode
$now = dol_now();
$numFinal = get_next_value($db, $mask, 'product', $field, $where, '', $now);
-
+ //Begin barcode with key: for barcode with key (EAN13...) calculate and substitute the last character (* or ?) used in the mask by the key
+ if ((substr($numFinal, -1)=='*') or (substr($numFinal, -1)=='?')) // if last mask character is * or ? a joker, probably we have to calculate a key as last character (EAN13...)
+ {
+ $literaltype = '';
+ $literaltype = $this->literalBarcodeType($db, $type);//get literal_Barcode_Type
+ switch ($literaltype)
+ {
+ case 'EAN13': //EAN13 rowid = 2
+ if (strlen($numFinal)==13)// be sure that the mask length is correct for EAN13
+ {
+ $ean = substr($numFinal, 0, 12); //take first 12 digits
+ $eansum = barcode_gen_ean_sum($ean);
+ $ean .= $eansum; //substitute the las character by the key
+ $numFinal = $ean;
+ }
+ break;
+ // Other barcode cases with key could be written here
+ default:
+ break;
+ }
+ }
+ //End barcode with key
return $numFinal;
}
diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
index fd65ab02827..287a568c646 100644
--- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
+++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql
@@ -30,6 +30,11 @@
-- Missing in v13 or lower
+ALTER TABLE llx_supplier_proposal_extrafields ADD INDEX idx_supplier_proposal_extrafields (fk_object);
+ALTER TABLE llx_supplier_proposaldet_extrafields ADD INDEX idx_supplier_proposaldet_extrafields (fk_object);
+
+ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object);
+
-- For v14
ALTER TABLE llx_c_availability ADD COLUMN position integer NOT NULL DEFAULT 0;
@@ -63,21 +68,21 @@ ALTER TABLE llx_propal DROP FOREIGN KEY llx_propal_fk_warehouse;
CREATE TABLE llx_workstation_workstation(
-- BEGIN MODULEBUILDER FIELDS
- rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
ref varchar(128) DEFAULT '(PROV)' NOT NULL,
label varchar(255),
type varchar(7),
note_public text,
entity int DEFAULT 1,
- note_private text,
- date_creation datetime NOT NULL,
- tms timestamp,
- fk_user_creat integer NOT NULL,
- fk_user_modif integer,
- import_key varchar(14),
- status smallint NOT NULL,
- nb_operators_required integer,
- thm_operator_estimated double,
+ note_private text,
+ date_creation datetime NOT NULL,
+ tms timestamp,
+ fk_user_creat integer NOT NULL,
+ fk_user_modif integer,
+ import_key varchar(14),
+ status smallint NOT NULL,
+ nb_operators_required integer,
+ thm_operator_estimated double,
thm_machine_estimated double
-- END MODULEBUILDER FIELDS
) ENGINE=innodb;
@@ -88,16 +93,16 @@ ALTER TABLE llx_workstation_workstation ADD CONSTRAINT fk_workstation_workstatio
ALTER TABLE llx_workstation_workstation ADD INDEX idx_workstation_workstation_status (status);
CREATE TABLE llx_workstation_workstation_resource(
- rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
- tms timestamp,
- fk_resource integer,
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ tms timestamp,
+ fk_resource integer,
fk_workstation integer
) ENGINE=innodb;
CREATE TABLE llx_workstation_workstation_usergroup(
- rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
- tms timestamp,
- fk_usergroup integer,
+ rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL,
+ tms timestamp,
+ fk_usergroup integer,
fk_workstation integer
) ENGINE=innodb;
diff --git a/htdocs/install/mysql/tables/llx_asset_extrafields.key.sql b/htdocs/install/mysql/tables/llx_asset_extrafields.key.sql
new file mode 100644
index 00000000000..fe6bb053ed6
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_asset_extrafields.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2021 Frédéric France
+--
+-- 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 .
+--
+-- ===================================================================
+
+
+ALTER TABLE llx_asset_extrafields ADD INDEX idx_asset_extrafields (fk_object);
diff --git a/htdocs/install/mysql/tables/llx_supplier_proposal_extrafields.key.sql b/htdocs/install/mysql/tables/llx_supplier_proposal_extrafields.key.sql
new file mode 100644
index 00000000000..4f365d85f55
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_supplier_proposal_extrafields.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2021 Frédéric France
+--
+-- 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 .
+--
+-- ===================================================================
+
+
+ALTER TABLE llx_supplier_proposal_extrafields ADD INDEX idx_supplier_proposal_extrafields (fk_object);
diff --git a/htdocs/install/mysql/tables/llx_supplier_proposaldet_extrafields.key.sql b/htdocs/install/mysql/tables/llx_supplier_proposaldet_extrafields.key.sql
new file mode 100644
index 00000000000..278bda52c63
--- /dev/null
+++ b/htdocs/install/mysql/tables/llx_supplier_proposaldet_extrafields.key.sql
@@ -0,0 +1,20 @@
+-- ===================================================================
+-- Copyright (C) 2021 Frédéric France
+--
+-- 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 .
+--
+-- ===================================================================
+
+
+ALTER TABLE llx_supplier_proposaldet_extrafields ADD INDEX idx_supplier_proposaldet_extrafields (fk_object);
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index af5b6c52bed..7b94a67e500 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -349,7 +349,7 @@ UpdateServerOffline=Update server offline
WithCounter=Manage a counter
GenericMaskCodes=You may enter any numbering mask. In this mask, the following tags could be used: {000000} corresponds to a number which will be incremented on each %s. Enter as many zeros as the desired length of the counter. The counter will be completed by zeros from the left in order to have as many zeros as the mask. {000000+000} same as previous but an offset corresponding to the number to the right of the + sign is applied starting on first %s. {000000@x} same as previous but the counter is reset to zero when month x is reached (x between 1 and 12, or 0 to use the early months of fiscal year defined in your configuration, or 99 to reset to zero every month). If this option is used and x is 2 or higher, then sequence {yy}{mm} or {yyyy}{mm} is also required. {dd} day (01 to 31). {mm} month (01 to 12). {yy}, {yyyy} or {y} year over 2, 4 or 1 numbers.
GenericMaskCodes2={cccc} the client code on n characters {cccc000} the client code on n characters is followed by a counter dedicated for customer. This counter dedicated to customer is reset at same time than global counter. {tttt} The code of third party type on n characters (see menu Home - Setup - Dictionary - Types of third parties). If you add this tag, the counter will be different for each type of third party.
-GenericMaskCodes3=All other characters in the mask will remain intact. Spaces are not allowed.
+GenericMaskCodes3=All other characters in the mask will remain intact (except * or ? in 13th position in EAN13). Spaces are not allowed. In EAN13 the last character after the last } in 13th position should be * or ? it will be replaced by the calculated key.
GenericMaskCodes4a=Example on the 99th %s of the third party TheCompany, with date 2007-01-31:
GenericMaskCodes4b=Example on third party created on 2007-03-01:
GenericMaskCodes4c=Example on product created on 2007-03-01:
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 93eaaea1772..2cff05c65db 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -349,7 +349,7 @@ UpdateServerOffline=Serveur de mise à jour hors ligne
WithCounter=Gérer un compteur
GenericMaskCodes=Vous pouvez saisir tout masque de numérotation. Dans ce masque, les balises suivantes peuvent être utilisées: {000000} correspond à un numéro qui sera incrémenté à chaque %s. Mettre autant de zéro que la longueur désirée du compteur. Le compteur sera complété par des 0 à gauche afin d'avoir autant de zéro que dans le masque. {000000+000} idem que précédemment mais un décalage correspondant au nombre à droite du + est appliqué dès la première %s. {000000@x} idem que précédemment mais le compteur est remis à zéro le xème mois de l'année (x entre 1 et 12, ou 0 pour utiliser le mois de début d'exercice fiscal défini dans votre configuration, ou 99 pour remise à zéro chaque mois). Si cette option est utilisée et x vaut 2 ou plus, alors la séquence {yy}{mm} ou {yyyy}{mm} est obligatoire. {dd} jour (01 à 31). {mm} mois (01 à 12). {yy}, {yyyy} ou {y} année sur 2, 4 ou 1 chiffres.
GenericMaskCodes2={cccc} : code client sur n caractères {cccc000} : code client sur n caractères suivi d'un compteur propre au client. Ce compteur propre au client est remis à zéro en même temps que le compteur général. {tttt} code du type de tiers sur n caractères (Voir menu Accueil > Configuration > Dictionnaires > Types de tiers). Si vous ajoutez cet élément au masque de numérotation, le compteur sera différent pour chaque type de tiers.
-GenericMaskCodes3=Tout autre caractère dans le masque sera laissé inchangé. Les espaces ne sont pas permis.
+GenericMaskCodes3=Tout autre caractère dans le masque sera laissé inchangé (sauf * ou ? en 13ème position en EAN13). Les espaces ne sont pas permis. En EAN13 le dernier caractère après la dernière } se plaçant en 13ème position devra être * ou ? il sera remplacé par la clé calculée.
GenericMaskCodes4a=Exemple sur la 99eme %s du tiers LaCompanie faite le 31/01/2007:
GenericMaskCodes4b=Exemple sur un tiers créé le 31/03/2007 :
GenericMaskCodes4c=Exemple sur un produit/service créé le 31/03/2007 :
diff --git a/htdocs/product/card.php b/htdocs/product/card.php
index e8b8fbdd5a1..c6dfd68d2c4 100644
--- a/htdocs/product/card.php
+++ b/htdocs/product/card.php
@@ -1052,7 +1052,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
if ($conf->browser->layout == 'phone') print '