Browse Source

Fix several troubles into numbering modules.
Prefix for takepos moved from TK to TC (TK was already used for tasks)

Laurent Destailleur 5 years ago
parent
commit
dbac97a908
26 changed files with 129 additions and 122 deletions
  1. 3 3
      htdocs/core/modules/bom/mod_bom_standard.php
  2. 3 3
      htdocs/core/modules/cheque/mod_chequereceipt_mint.php
  3. 3 3
      htdocs/core/modules/commande/mod_commande_marbre.php
  4. 2 2
      htdocs/core/modules/contract/mod_contract_serpis.php
  5. 2 2
      htdocs/core/modules/expedition/mod_expedition_safor.php
  6. 2 2
      htdocs/core/modules/expensereport/mod_expensereport_jade.php
  7. 4 5
      htdocs/core/modules/facture/mod_facture_mars.php
  8. 6 5
      htdocs/core/modules/facture/mod_facture_terre.php
  9. 3 3
      htdocs/core/modules/fichinter/mod_pacific.php
  10. 2 2
      htdocs/core/modules/holiday/mod_holiday_madonna.php
  11. 3 3
      htdocs/core/modules/livraison/mod_livraison_jade.php
  12. 3 3
      htdocs/core/modules/mrp/mod_mo_standard.php
  13. 3 3
      htdocs/core/modules/payment/mod_payment_cicada.php
  14. 3 3
      htdocs/core/modules/project/mod_project_simple.php
  15. 3 3
      htdocs/core/modules/project/task/mod_task_simple.php
  16. 3 3
      htdocs/core/modules/propale/mod_propale_marbre.php
  17. 2 2
      htdocs/core/modules/reception/mod_reception_beryl.php
  18. 2 2
      htdocs/core/modules/societe/mod_codeclient_monkey.php
  19. 7 7
      htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php
  20. 3 3
      htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php
  21. 3 3
      htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php
  22. 3 3
      htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php
  23. 7 3
      htdocs/core/modules/takepos/mod_takepos_ref_simple.php
  24. 3 3
      htdocs/core/modules/ticket/mod_ticket_simple.php
  25. 48 45
      htdocs/modulebuilder/template/admin/setup.php
  26. 3 3
      htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php

+ 3 - 3
htdocs/core/modules/bom/mod_bom_standard.php

@@ -83,7 +83,7 @@ class mod_bom_standard extends ModeleNumRefboms
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bom";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -116,8 +116,8 @@ class mod_bom_standard extends ModeleNumRefboms
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 9;
+		// First we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bom_bom";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/cheque/mod_chequereceipt_mint.php

@@ -80,7 +80,7 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
 
 		$payyymm = ''; $max = '';
 
-		$posindice = 9;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -113,8 +113,8 @@ class mod_chequereceipt_mint extends ModeleNumRefChequeReceipts
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 9;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque";
 		$sql .= " WHERE ref like '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/commande/mod_commande_marbre.php

@@ -83,7 +83,7 @@ class mod_commande_marbre extends ModeleNumRefCommandes
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -116,8 +116,8 @@ class mod_commande_marbre extends ModeleNumRefCommandes
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."commande";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/contract/mod_contract_serpis.php

@@ -93,7 +93,7 @@ class mod_contract_serpis extends ModelNumRefContracts
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."contrat";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -126,7 +126,7 @@ class mod_contract_serpis extends ModelNumRefContracts
 	{
 		global $db, $conf;
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."contrat";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/expedition/mod_expedition_safor.php

@@ -88,7 +88,7 @@ class mod_expedition_safor extends ModelNumRefExpedition
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -121,7 +121,7 @@ class mod_expedition_safor extends ModelNumRefExpedition
 	{
 		global $db, $conf;
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."expedition";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/expensereport/mod_expensereport_jade.php

@@ -89,7 +89,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."expensereport";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -174,7 +174,7 @@ class mod_expensereport_jade extends ModeleNumRefExpenseReport
 		}
 
 		// First we get the max value
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."expensereport";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 4 - 5
htdocs/core/modules/facture/mod_facture_mars.php

@@ -98,7 +98,7 @@ class mod_facture_mars extends ModeleNumRefFactures
 		// Check invoice num
 		$fayymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixinvoice) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
@@ -120,7 +120,7 @@ class mod_facture_mars extends ModeleNumRefFactures
 		// Check credit note num
 		$fayymm = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixcreditnote) + 6;
 		$sql = "SELECT MAX(SUBSTRING(ref FROM ".$posindice.")) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
@@ -152,15 +152,14 @@ class mod_facture_mars extends ModeleNumRefFactures
 	public function getNextValue($objsoc, $invoice, $mode = 'next')
 	{
 		global $db;
-		$prefix = $this->prefixinvoice;
 
+		$prefix = $this->prefixinvoice;
 		if ($invoice->type == 1) $prefix = $this->prefixreplacement;
 		elseif ($invoice->type == 2) $prefix = $this->prefixcreditnote;
 		elseif ($invoice->type == 3) $prefix = $this->prefixdeposit;
-		else $prefix = $this->prefixinvoice;
 
 		// First we get the max value
-		$posindice = 8;
+		$posindice = strlen($prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$prefix."____-%'";

+ 6 - 5
htdocs/core/modules/facture/mod_facture_terre.php

@@ -108,7 +108,7 @@ class mod_facture_terre extends ModeleNumRefFactures
 		// Check invoice num
 		$fayymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixinvoice) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
@@ -130,7 +130,7 @@ class mod_facture_terre extends ModeleNumRefFactures
 		// Check credit note num
 		$fayymm = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixcreditnote) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
@@ -151,7 +151,7 @@ class mod_facture_terre extends ModeleNumRefFactures
 		// Check deposit num
 		$fayymm = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixdeposit) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
@@ -186,11 +186,12 @@ class mod_facture_terre extends ModeleNumRefFactures
 
 		dol_syslog(get_class($this)."::getNextValue mode=".$mode, LOG_DEBUG);
 
+		$prefix = $this->prefixinvoice;
 		if ($invoice->type == 2) $prefix = $this->prefixcreditnote;
 		elseif ($invoice->type == 3) $prefix = $this->prefixdeposit;
-		else $prefix = $this->prefixinvoice;
+
 		// First we get the max value
-		$posindice = 8;
+		$posindice = strlen($prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture";
 		$sql .= " WHERE ref LIKE '".$prefix."____-%'";

+ 3 - 3
htdocs/core/modules/fichinter/mod_pacific.php

@@ -91,7 +91,7 @@ class mod_pacific extends ModeleNumRefFicheinter
 
 		$fayymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -126,8 +126,8 @@ class mod_pacific extends ModeleNumRefFicheinter
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."fichinter";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/holiday/mod_holiday_madonna.php

@@ -94,7 +94,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."holiday";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -127,7 +127,7 @@ class mod_holiday_madonna extends ModelNumRefHolidays
 	{
 		global $db, $conf;
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."holiday";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/livraison/mod_livraison_jade.php

@@ -96,7 +96,7 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
 		// Check invoice num
 		$fayymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -129,8 +129,8 @@ class mod_livraison_jade extends ModeleNumRefDeliveryOrder
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."livraison";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/mrp/mod_mo_standard.php

@@ -83,7 +83,7 @@ class mod_mo_standard extends ModeleNumRefMos
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -116,8 +116,8 @@ class mod_mo_standard extends ModeleNumRefMos
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 9;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."mrp_mo";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/payment/mod_payment_cicada.php

@@ -90,7 +90,7 @@ class mod_payment_cicada extends ModeleNumRefPayments
 
 		$payyymm = ''; $max = '';
 
-		$posindice = 9;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."paiement";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -123,8 +123,8 @@ class mod_payment_cicada extends ModeleNumRefPayments
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 9;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."paiement";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/project/mod_project_simple.php

@@ -92,7 +92,7 @@ class mod_project_simple extends ModeleNumRefProjects
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."projet";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -127,8 +127,8 @@ class mod_project_simple extends ModeleNumRefProjects
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."projet";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/project/task/mod_task_simple.php

@@ -92,7 +92,7 @@ class mod_task_simple extends ModeleNumRefTask
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(task.ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task AS task, ";
 		$sql .= MAIN_DB_PREFIX."projet AS project WHERE task.fk_projet=project.rowid";
@@ -128,8 +128,8 @@ class mod_task_simple extends ModeleNumRefTask
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."projet_task";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/propale/mod_propale_marbre.php

@@ -92,7 +92,7 @@ class mod_propale_marbre extends ModeleNumRefPropales
 
 		$pryymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."propal";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -128,8 +128,8 @@ class mod_propale_marbre extends ModeleNumRefPropales
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."propal";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/reception/mod_reception_beryl.php

@@ -68,7 +68,7 @@ class mod_reception_beryl extends ModelNumRefReception
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."reception";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -101,7 +101,7 @@ class mod_reception_beryl extends ModelNumRefReception
 	{
 		global $db, $conf;
 
-		$posindice = 9;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."reception";
 		$sql .= " WHERE ref like '".$db->escape($this->prefix)."____-%'";

+ 2 - 2
htdocs/core/modules/societe/mod_codeclient_monkey.php

@@ -129,8 +129,8 @@ class mod_codeclient_monkey extends ModeleThirdPartyCode
             return -1;
         }
 
-        // D'abord on recupere la valeur max (reponse immediate car champ indexe)
-		$posindice = 8;
+        // First, we get the max value (reponse immediate car champ indexe)
+        $posindice = strlen($prefix) + 6;
         $sql = "SELECT MAX(CAST(SUBSTRING(".$field." FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."societe";
 		$sql .= " WHERE ".$field." LIKE '".$prefix."____-%'";

+ 7 - 7
htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_cactus.php

@@ -101,7 +101,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
 		// Check invoice num
 		$siyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixinvoice) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixinvoice)."____-%'";
@@ -122,7 +122,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
 		// Check credit note num
 		$siyymm = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixcreditnote) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixcreditnote)."____-%'";
@@ -143,7 +143,7 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
 		// Check deposit num
 		$siyymm = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefixdeposit) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefixdeposit)."____-%'";
@@ -174,12 +174,12 @@ class mod_facture_fournisseur_cactus extends ModeleNumRefSuppliersInvoices
     {
         global $db, $conf;
 
+        $prefix = $this->prefixinvoice;
         if ($object->type == 2) $prefix = $this->prefixcreditnote;
-        elseif ($facture->type == 3) $prefix = $this->prefixdeposit;
-        else $prefix = $this->prefixinvoice;
+        elseif ($object->type == 3) $prefix = $this->prefixdeposit;
 
-        // D'abord on recupere la valeur max
-        $posindice = 8;
+        // First, we get the max value
+        $posindice = strlen($prefix) + 6;
         $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
         $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn";
         $sql .= " WHERE ref LIKE '".$prefix."____-%'";

+ 3 - 3
htdocs/core/modules/supplier_order/mod_commande_fournisseur_muguet.php

@@ -102,7 +102,7 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -136,8 +136,8 @@ class mod_commande_fournisseur_muguet extends ModeleNumRefSuppliersOrders
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseur";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/supplier_payment/mod_supplier_payment_bronan.php

@@ -90,7 +90,7 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
 
 		$payyymm = ''; $max = '';
 
-		$posindice = 9;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -123,8 +123,8 @@ class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 10;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 3 - 3
htdocs/core/modules/supplier_proposal/mod_supplier_proposal_marbre.php

@@ -92,7 +92,7 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
 
 		$pryymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -128,8 +128,8 @@ class mod_supplier_proposal_marbre extends ModeleNumRefSupplierProposal
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
 		$sql .= " FROM ".MAIN_DB_PREFIX."supplier_proposal";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";

+ 7 - 3
htdocs/core/modules/takepos/mod_takepos_ref_simple.php

@@ -41,7 +41,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
 	 * Prefix
 	 * @var string
 	 */
-	public $prefix = 'TK';
+	public $prefix = 'TC';
 
 	/**
 	 * @var string Error code (or message)
@@ -89,7 +89,11 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
         $pryymm = '';
         $max = '';
 
-        $posindice = 8;
+        $pos_source = 0;
+
+        // First, we get the max value
+        $posindice = strlen($this->prefix.$pos_source.'-____-') + 1;
+
         $sql  = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
         $sql .= " FROM ".MAIN_DB_PREFIX."facture";
         $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -127,7 +131,7 @@ class mod_takepos_ref_simple extends ModeleNumRefTakepos
 
         $pos_source = is_object($invoice) && $invoice->pos_source > 0 ? $invoice->pos_source : 0;
 
-        // D'abord on recupere la valeur max
+        // First, we get the max value
         $posindice = strlen($this->prefix.$pos_source.'-____-') + 1;
         $sql  = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; // This is standard SQL
         $sql .= " FROM ".MAIN_DB_PREFIX."facture";

+ 3 - 3
htdocs/core/modules/ticket/mod_ticket_simple.php

@@ -89,7 +89,7 @@ class mod_ticket_simple extends ModeleNumRefTicket
 		$coyymm = '';
 		$max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."ticket";
 		$search = $this->prefix."____-%";
@@ -123,8 +123,8 @@ class mod_ticket_simple extends ModeleNumRefTicket
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 8;
+		// First, we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."ticket";
 		$search = $this->prefix."____-%";

+ 48 - 45
htdocs/modulebuilder/template/admin/setup.php

@@ -61,6 +61,7 @@ $arrayofparameters = array(
 );
 
 $error = 0;
+$setupnotempty = 0;
 
 
 /*
@@ -168,8 +169,8 @@ elseif ($action == 'setdoc')
 	// TODO Check if numbering module chosen can be activated
 	// by calling method canBeActivated
 	$tmpobjectkey = GETPOST('object');
-
-	dolibarr_set_const($db, strtoupper($tmpobjectkey)."_ADDON", $value, 'chaine', 0, '', $conf->entity);
+	$constforval = 'MYMODULE_'.strtoupper($tmpobjectkey)."_ADDON";
+	dolibarr_set_const($db, $constforval, $value, 'chaine', 0, '', $conf->entity);
 }
 
 
@@ -222,9 +223,7 @@ if ($action == 'edit')
 
 	print '</form>';
 	print '<br>';
-}
-else
-{
+} else {
 	if (!empty($arrayofparameters))
 	{
 		print '<table class="noborder centpercent">';
@@ -232,6 +231,8 @@ else
 
 		foreach ($arrayofparameters as $key => $val)
 		{
+			$setupnotempty++;
+
 			print '<tr class="oddeven"><td>';
 			$tooltiphelp = (($langs->trans($key.'Tooltip') != $key.'Tooltip') ? $langs->trans($key.'Tooltip') : '');
 			print $form->textwithpicto($langs->trans($key), $tooltiphelp);
@@ -256,15 +257,15 @@ $myTmpObjects = array();
 $myTmpObjects['MyObject']=array('includerefgeneration'=>0, 'includedocgeneration'=>0);
 
 
-
 foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 	if ($myTmpObjectArray['includerefgeneration']) {
 		/*
 		 * Orders Numbering model
 		 */
-		
+		$setupnotempty++;
+
 		print load_fiche_titre($langs->trans("NumberingModules", $myTmpObjectKey), '', '');
-		
+
 		print '<table class="noborder centpercent">';
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans("Name").'</td>';
@@ -273,13 +274,13 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 		print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
 		print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
 		print '</tr>'."\n";
-		
+
 		clearstatcache();
-		
+
 		foreach ($dirmodels as $reldir)
 		{
 			$dir = dol_buildpath($reldir."core/modules/".$moduledir);
-			
+
 			if (is_dir($dir))
 			{
 				$handle = opendir($dir);
@@ -290,23 +291,23 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 						if (strpos($file, 'mod_'.strtolower($myTmpObjectKey).'_') === 0 && substr($file, dol_strlen($file) - 3, 3) == 'php')
 						{
 							$file = substr($file, 0, dol_strlen($file) - 4);
-							
+
 							require_once $dir.'/'.$file.'.php';
-							
+
 							$module = new $file($db);
-							
+
 							// Show modules according to features level
 							if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
 							if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
-							
+
 							if ($module->isEnabled())
 							{
 								dol_include_once('/'.$moduledir.'/class/'.strtolower($myTmpObjectKey).'.class.php');
-								
+
 								print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
 								print $module->info();
 								print '</td>';
-								
+
 								// Show example of numbering model
 								print '<td class="nowrap">';
 								$tmp = $module->getExample();
@@ -314,26 +315,26 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 								elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
 								else print $tmp;
 								print '</td>'."\n";
-								
+
 								print '<td class="center">';
 								$constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON';
 								if ($conf->global->$constforvar == $file)
 								{
 									print img_picto($langs->trans("Activated"), 'switch_on');
 								} else {
-									print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&object='.strtolower($myTmpObjectKey).'&value='.$file.'">';
 									print img_picto($langs->trans("Disabled"), 'switch_off');
 									print '</a>';
 								}
 								print '</td>';
-								
+
 								$mytmpinstance = new $myTmpObjectKey($db);
 								$mytmpinstance->initAsSpecimen();
-								
+
 								// Info
 								$htmltooltip = '';
 								$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-								
+
 								$nextval = $module->getNextValue($mytmpinstance);
 								if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
 									$htmltooltip .= ''.$langs->trans("NextValue").': ';
@@ -345,11 +346,11 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 										$htmltooltip .= $langs->trans($module->error).'<br>';
 									}
 								}
-								
+
 								print '<td class="center">';
 								print $form->textwithpicto('', $htmltooltip, 1, 0);
 								print '</td>';
-								
+
 								print "</tr>\n";
 							}
 						}
@@ -360,16 +361,16 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 		}
 		print "</table><br>\n";
 	}
-	
-	
+
 	if ($myTmpObjectArray['includedocgeneration']) {
 		/*
 		 * Document templates generators
 		 */
+		$setupnotempty++;
 		$type = strtolower($myTmpObjectKey);
-		
+
 		print load_fiche_titre($langs->trans("DocumentModules", $myTmpObjectKey), '', '');
-		
+
 		// Load array def with activated templates
 		$def = array();
 		$sql = "SELECT nom";
@@ -390,8 +391,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 		} else {
 			dol_print_error($db);
 		}
-		
-		
+
 		print "<table class=\"noborder\" width=\"100%\">\n";
 		print "<tr class=\"liste_titre\">\n";
 		print '<td>'.$langs->trans("Name").'</td>';
@@ -401,16 +401,16 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 		print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
 		print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
 		print "</tr>\n";
-		
+
 		clearstatcache();
-		
+
 		foreach ($dirmodels as $reldir)
 		{
 			foreach (array('', '/doc') as $valdir)
 			{
 				$realpath = $reldir."core/modules/".$moduledir.$valdir;
 				$dir = dol_buildpath($realpath);
-				
+
 				if (is_dir($dir))
 				{
 					$handle = opendir($dir);
@@ -422,7 +422,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 						}
 						closedir($handle);
 						arsort($filelist);
-						
+
 						foreach ($filelist as $file)
 						{
 							if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
@@ -431,14 +431,14 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 								{
 									$name = substr($file, 4, dol_strlen($file) - 16);
 									$classname = substr($file, 0, dol_strlen($file) - 12);
-									
+
 									require_once $dir.'/'.$file;
 									$module = new $classname($db);
-									
+
 									$modulequalified = 1;
 									if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified = 0;
 									if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified = 0;
-									
+
 									if ($modulequalified)
 									{
 										print '<tr class="oddeven"><td width="100">';
@@ -447,7 +447,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 										if (method_exists($module, 'info')) print $module->info($langs);
 										else print $module->description;
 										print '</td>';
-										
+
 										// Active
 										if (in_array($name, $def))
 										{
@@ -461,7 +461,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 											print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
 											print "</td>";
 										}
-										
+
 										// Default
 										print '<td class="center">';
 										$constforvar = 'MYMODULE_'.strtoupper($myTmpObjectKey).'_ADDON';
@@ -472,7 +472,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 											print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
 										}
 										print '</td>';
-										
+
 										// Info
 										$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
 										$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
@@ -481,15 +481,15 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 											$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
 										}
 										$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-										
+
 										$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
 										$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
 										$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-										
+
 										print '<td class="center">';
 										print $form->textwithpicto('', $htmltooltip, 1, 0);
 										print '</td>';
-										
+
 										// Preview
 										print '<td class="center">';
 										if ($module->type == 'pdf')
@@ -499,7 +499,7 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 											print img_object($langs->trans("PreviewNotAvailable"), 'generic');
 										}
 										print '</td>';
-										
+
 										print "</tr>\n";
 									}
 								}
@@ -509,11 +509,14 @@ foreach($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 				}
 			}
 		}
-		
+
 		print '</table>';
 	}
 }
 
+if (empty($setupnotempty)) {
+	print '<br>'.$langs->trans("NothingToSetup");
+}
 
 // Page end
 dol_fiche_end();

+ 3 - 3
htdocs/modulebuilder/template/core/modules/mymodule/mod_myobject_standard.php

@@ -85,7 +85,7 @@ class mod_myobject_standard extends ModeleNumRefMyObject
 
 		$coyymm = ''; $max = '';
 
-		$posindice = 8;
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";
@@ -122,8 +122,8 @@ class mod_myobject_standard extends ModeleNumRefMyObject
 	{
 		global $db, $conf;
 
-		// D'abord on recupere la valeur max
-		$posindice = 9;
+		// first we get the max value
+		$posindice = strlen($this->prefix) + 6;
 		$sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max";
 		$sql .= " FROM ".MAIN_DB_PREFIX."mymodule_myobject";
 		$sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'";