瀏覽代碼

Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
Scrutinizer Auto-Fixer 4 年之前
父節點
當前提交
b78ff67d7e
共有 100 個文件被更改,包括 14638 次插入14638 次删除
  1. 53 53
      htdocs/accountancy/admin/index.php
  2. 33 33
      htdocs/accountancy/customer/lines.php
  3. 3 3
      htdocs/accountancy/customer/list.php
  4. 65 65
      htdocs/accountancy/expensereport/index.php
  5. 43 43
      htdocs/accountancy/expensereport/lines.php
  6. 89 89
      htdocs/accountancy/expensereport/list.php
  7. 57 57
      htdocs/accountancy/supplier/index.php
  8. 32 32
      htdocs/accountancy/supplier/lines.php
  9. 4 4
      htdocs/accountancy/supplier/list.php
  10. 19 19
      htdocs/adherents/admin/adherent_emails.php
  11. 42 42
      htdocs/adherents/card.php
  12. 218 218
      htdocs/adherents/class/adherent_type.class.php
  13. 158 158
      htdocs/adherents/type.php
  14. 161 161
      htdocs/admin/bank.php
  15. 141 141
      htdocs/admin/bom.php
  16. 144 144
      htdocs/admin/boxes.php
  17. 169 169
      htdocs/admin/commande.php
  18. 1 1
      htdocs/admin/company.php
  19. 138 138
      htdocs/admin/contract.php
  20. 46 46
      htdocs/admin/emailcollector_card.php
  21. 124 124
      htdocs/admin/expedition.php
  22. 427 427
      htdocs/admin/facture.php
  23. 143 143
      htdocs/admin/holiday.php
  24. 471 471
      htdocs/admin/mails_templates.php
  25. 141 141
      htdocs/admin/mrp.php
  26. 125 125
      htdocs/admin/reception_setup.php
  27. 143 143
      htdocs/admin/stock.php
  28. 174 174
      htdocs/bom/bom_card.php
  29. 15 15
      htdocs/bom/tpl/objectline_create.tpl.php
  30. 712 712
      htdocs/categories/class/api_categories.class.php
  31. 278 278
      htdocs/categories/class/categorie.class.php
  32. 448 448
      htdocs/comm/action/class/actioncomm.class.php
  33. 270 270
      htdocs/comm/action/index.php
  34. 2 2
      htdocs/comm/action/list.php
  35. 2 2
      htdocs/compta/index.php
  36. 39 39
      htdocs/compta/prelevement/card.php
  37. 9 9
      htdocs/compta/prelevement/class/bonprelevement.class.php
  38. 35 35
      htdocs/compta/prelevement/create.php
  39. 56 56
      htdocs/compta/prelevement/factures.php
  40. 33 33
      htdocs/compta/prelevement/fiche-rejet.php
  41. 544 544
      htdocs/contact/card.php
  42. 23 23
      htdocs/contact/list.php
  43. 14 14
      htdocs/core/actions_addupdatedelete.inc.php
  44. 7 7
      htdocs/core/actions_sendmails.inc.php
  45. 194 194
      htdocs/core/ajax/ajaxdirpreview.php
  46. 157 157
      htdocs/core/class/CMailFile.class.php
  47. 208 208
      htdocs/core/class/commonobject.class.php
  48. 248 248
      htdocs/core/class/html.form.class.php
  49. 251 251
      htdocs/core/class/html.formactions.class.php
  50. 200 200
      htdocs/core/class/html.formcompany.class.php
  51. 75 75
      htdocs/core/class/html.formfile.class.php
  52. 83 83
      htdocs/core/class/html.formmail.class.php
  53. 21 21
      htdocs/core/lib/ajax.lib.php
  54. 512 512
      htdocs/core/lib/company.lib.php
  55. 10 10
      htdocs/core/lib/expedition.lib.php
  56. 4 4
      htdocs/core/lib/files.lib.php
  57. 353 353
      htdocs/core/lib/functions.lib.php
  58. 463 463
      htdocs/core/lib/functions2.lib.php
  59. 1 1
      htdocs/core/lib/functionsnumtoword.lib.php
  60. 19 19
      htdocs/core/lib/hrm.lib.php
  61. 84 84
      htdocs/core/lib/images.lib.php
  62. 111 111
      htdocs/core/lib/member.lib.php
  63. 9 9
      htdocs/core/lib/multicurrency.lib.php
  64. 24 24
      htdocs/core/lib/reception.lib.php
  65. 3 3
      htdocs/core/lib/resource.lib.php
  66. 46 46
      htdocs/core/lib/salaries.lib.php
  67. 2 2
      htdocs/core/lib/security.lib.php
  68. 1 1
      htdocs/core/lib/takepos.lib.php
  69. 526 526
      htdocs/core/lib/ticket.lib.php
  70. 293 293
      htdocs/core/menus/standard/eldy.lib.php
  71. 40 40
      htdocs/core/modules/bank/doc/pdf_ban.modules.php
  72. 92 92
      htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php
  73. 89 89
      htdocs/core/modules/cheque/doc/pdf_blochet.class.php
  74. 104 104
      htdocs/core/modules/contract/doc/pdf_strato.modules.php
  75. 334 334
      htdocs/core/modules/expedition/doc/pdf_espadon.modules.php
  76. 76 76
      htdocs/core/modules/expedition/doc/pdf_merou.modules.php
  77. 154 154
      htdocs/core/modules/expedition/doc/pdf_rouget.modules.php
  78. 151 151
      htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
  79. 162 162
      htdocs/core/modules/facture/doc/pdf_crabe.modules.php
  80. 755 755
      htdocs/core/modules/facture/doc/pdf_sponge.modules.php
  81. 113 113
      htdocs/core/modules/livraison/doc/pdf_typhon.modules.php
  82. 242 242
      htdocs/core/modules/modProduct.class.php
  83. 47 47
      htdocs/core/modules/modRecruitment.class.php
  84. 32 32
      htdocs/core/modules/modSocialNetworks.class.php
  85. 186 186
      htdocs/core/modules/movement/doc/pdf_standard.modules.php
  86. 5 5
      htdocs/core/modules/movement/modules_movement.php
  87. 59 59
      htdocs/core/modules/project/doc/pdf_baleine.modules.php
  88. 405 405
      htdocs/core/modules/project/doc/pdf_beluga.modules.php
  89. 41 41
      htdocs/core/modules/project/doc/pdf_timespent.modules.php
  90. 136 136
      htdocs/core/modules/propale/doc/pdf_azur.modules.php
  91. 461 461
      htdocs/core/modules/propale/doc/pdf_cyan.modules.php
  92. 110 110
      htdocs/core/modules/reception/doc/pdf_squille.modules.php
  93. 29 29
      htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php
  94. 185 185
      htdocs/core/modules/stock/doc/pdf_standard.modules.php
  95. 155 155
      htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php
  96. 351 351
      htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php
  97. 136 136
      htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php
  98. 88 88
      htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
  99. 150 150
      htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php
  100. 1 1
      htdocs/core/tpl/extrafields_list_search_title.tpl.php

+ 53 - 53
htdocs/accountancy/admin/index.php

@@ -46,8 +46,8 @@ $action = GETPOST('action', 'aZ09');
 
 // Parameters ACCOUNTING_* and others
 $list = array(
-    'ACCOUNTING_LENGTH_GACCOUNT',
-    'ACCOUNTING_LENGTH_AACCOUNT',
+	'ACCOUNTING_LENGTH_GACCOUNT',
+	'ACCOUNTING_LENGTH_AACCOUNT',
 //    'ACCOUNTING_LENGTH_DESCRIPTION',         // adjust size displayed for lines description for dol_trunc
 //    'ACCOUNTING_LENGTH_DESCRIPTION_ACCOUNT', // adjust size displayed for select account description for dol_trunc
 );
@@ -67,17 +67,17 @@ if ($action == 'update') {
 
 	if (!$error)
 	{
-	    foreach ($list as $constname)
-	    {
-	        $constvalue = GETPOST($constname, 'alpha');
-
-	        if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
-	            $error++;
-	        }
-	    }
-	    if ($error) {
-	    	setEventMessages($langs->trans("Error"), null, 'errors');
-	    }
+		foreach ($list as $constname)
+		{
+			$constvalue = GETPOST($constname, 'alpha');
+
+			if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
+				$error++;
+			}
+		}
+		if ($error) {
+			setEventMessages($langs->trans("Error"), null, 'errors');
+		}
 
 		foreach ($list_binding as $constname)
 		{
@@ -96,46 +96,46 @@ if ($action == 'update') {
 		}
 	}
 
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    }
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setlistsorttodo') {
-    $setlistsorttodo = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setlistsorttodo = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_TODO", $setlistsorttodo, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setlistsortdone') {
-    $setlistsortdone = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setlistsortdone = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_LIST_SORT_VENTILATION_DONE", $setlistsortdone, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setmanagezero') {
-    $setmanagezero = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setmanagezero = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTING_MANAGE_ZERO", $setmanagezero, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setdisabledirectinput') {
@@ -163,15 +163,15 @@ if ($action == 'setenabledraftexport') {
 }
 
 if ($action == 'setenablesubsidiarylist') {
-    $setenablesubsidiarylist = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0)
-        $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'mesgs');
-    }
+	$setenablesubsidiarylist = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "ACCOUNTANCY_COMBO_FOR_AUX", $setenablesubsidiarylist, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0)
+		$error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'mesgs');
+	}
 }
 
 if ($action == 'setdisablebindingonsales') {

+ 33 - 33
htdocs/accountancy/customer/lines.php

@@ -93,7 +93,7 @@ $formaccounting = new FormAccounting($db);
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
 {
 	$search_societe = '';
-    $search_lineid = '';
+	$search_lineid = '';
 	$search_ref = '';
 	$search_invoice = '';
 	$search_label = '';
@@ -203,7 +203,7 @@ if ($search_societe) {
 	$sql .= natural_search('s.nom', $search_societe);
 }
 if ($search_lineid) {
-    $sql .= natural_search("fd.rowid", $search_lineid, 1);
+	$sql .= natural_search("fd.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
 	$sql .= natural_search("f.ref", $search_invoice);
@@ -251,13 +251,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -309,9 +309,9 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth25" name="search_lineid" value="'.dol_escape_htmltag($search_lineid).'"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_invoice" value="'.dol_escape_htmltag($search_invoice).'"></td>';
 	print '<td class="liste_titre center nowraponall">';
-    if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
-        print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
-    }
+	if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) {
+		print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_day" value="'.dol_escape_htmltag($search_day).'">';
+	}
    	print '<input class="flat valignmiddle maxwidth25" type="text" maxlength="2" name="search_month" value="'.dol_escape_htmltag($search_month).'">';
    	$formother->select_year($search_year, 'search_year', 1, 20, 5);
 	print '</td>';
@@ -349,10 +349,10 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-    $thirdpartystatic = new Societe($db);
-    $facturestatic = new Facture($db);
+	$thirdpartystatic = new Societe($db);
+	$facturestatic = new Facture($db);
 	$productstatic = new Product($db);
-    $accountingaccountstatic = new AccountingAccount($db);
+	$accountingaccountstatic = new AccountingAccount($db);
 
 	$i = 0;
 	while ($i < min($num_lines, $limit)) {
@@ -362,16 +362,16 @@ if ($result) {
 		$facturestatic->id = $objp->facid;
 		$facturestatic->type = $objp->ftype;
 
-        $thirdpartystatic->id = $objp->socid;
-        $thirdpartystatic->name = $objp->name;
-        $thirdpartystatic->client = $objp->client;
-        $thirdpartystatic->fournisseur = $objp->fournisseur;
-        $thirdpartystatic->code_client = $objp->code_client;
-        $thirdpartystatic->code_compta_client = $objp->code_compta_client;
-        $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
-        $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
-        $thirdpartystatic->email = $objp->email;
-        $thirdpartystatic->country_code = $objp->country_code;
+		$thirdpartystatic->id = $objp->socid;
+		$thirdpartystatic->name = $objp->name;
+		$thirdpartystatic->client = $objp->client;
+		$thirdpartystatic->fournisseur = $objp->fournisseur;
+		$thirdpartystatic->code_client = $objp->code_client;
+		$thirdpartystatic->code_compta_client = $objp->code_compta_client;
+		$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
+		$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+		$thirdpartystatic->email = $objp->email;
+		$thirdpartystatic->country_code = $objp->country_code;
 
 		$productstatic->ref = $objp->product_ref;
 		$productstatic->id = $objp->product_id;
@@ -412,7 +412,7 @@ if ($result) {
 		print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
 
 		// Country
 		print '<td>';
@@ -425,7 +425,7 @@ if ($result) {
 		print '<td>'.$objp->tva_intra.'</td>';
 
 		print '<td class="center">';
-        print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
+		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
 		print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
@@ -434,14 +434,14 @@ if ($result) {
 		print '</tr>';
 		$i++;
 	}
-    print '</table>';
-    print "</div>";
+	print '</table>';
+	print "</div>";
 
-    if ($nbtotalofrecords > $limit) {
-        print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
-    }
+	if ($nbtotalofrecords > $limit) {
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+	}
 
-    print '</form>';
+	print '</form>';
 } else {
 	print $db->lasterror();
 }

+ 3 - 3
htdocs/accountancy/customer/list.php

@@ -114,7 +114,7 @@ if (empty($reshook))
 	// Purge search criteria
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 	{
-		$search_societe='';
+		$search_societe = '';
 		$search_lineid = '';
 		$search_ref = '';
 		$search_invoice = '';
@@ -386,7 +386,7 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="flat maxwidth50 right" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
 	//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -582,7 +582,7 @@ if ($result) {
 		print '</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'customer') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'customer').'</td>';
 
 		// Country
         print '<td>';

+ 65 - 65
htdocs/accountancy/expensereport/index.php

@@ -201,16 +201,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -275,16 +275,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -293,60 +293,60 @@ print '</div>';
 
 if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report where results depends on next step (so not yet available) ?
 {
-    print '<br>';
-    print '<br>';
+	print '<br>';
+	print '<br>';
 
-    print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
-    //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
+	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
+	//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
 
 	print '<div class="div-table-responsive-no-min">';
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
-    }
-    print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
-
-    $sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
-    }
-    $sql .= " SUM(erd.total_ht) as total";
-    $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
-    $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
-    $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
-    $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
+	}
+	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+	$sql = "SELECT '".$langs->trans("TotalExpenseReport")."' AS label,";
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		$sql .= " SUM(".$db->ifsql('MONTH(er.date_create)='.$j, 'erd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
+	}
+	$sql .= " SUM(erd.total_ht) as total";
+	$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
+	$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
+	$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
+	$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
 	// Define begin binding date
 	if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 		$sql .= " AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
 	}
-    $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
-    $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
-
-    dol_syslog('htdocs/accountancy/expensereport/index.php');
-    $resql = $db->query($sql);
-    if ($resql) {
-        $num = $db->num_rows($resql);
-
-    	while ($row = $db->fetch_row($resql)) {
-    		print '<tr><td>'.$row[0].'</td>';
-            for ($i = 1; $i <= 12; $i++) {
-    			print '<td class="nowrap right">'.price($row[$i]).'</td>';
-    		}
-    		print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
-    		print '</tr>';
-    	}
-
-    	$db->free($resql);
-    } else {
-    	print $db->lasterror(); // Show last sql error
-    }
-    print "</table>\n";
-    print '</div>';
+	$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
+	$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
+
+	dol_syslog('htdocs/accountancy/expensereport/index.php');
+	$resql = $db->query($sql);
+	if ($resql) {
+		$num = $db->num_rows($resql);
+
+		while ($row = $db->fetch_row($resql)) {
+			print '<tr><td>'.$row[0].'</td>';
+			for ($i = 1; $i <= 12; $i++) {
+				print '<td class="nowrap right">'.price($row[$i]).'</td>';
+			}
+			print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
+			print '</tr>';
+		}
+
+		$db->free($resql);
+	} else {
+		print $db->lasterror(); // Show last sql error
+	}
+	print "</table>\n";
+	print '</div>';
 }
 
 // End of page

+ 43 - 43
htdocs/accountancy/expensereport/lines.php

@@ -86,8 +86,8 @@ $formaccounting = new FormAccounting($db);
 // Purge search criteria
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // Both test are required to be compatible with all browsers
 {
-    $search_login = '';
-    $search_expensereport = '';
+	$search_login = '';
+	$search_expensereport = '';
 	$search_label = '';
 	$search_desc = '';
 	$search_amount = '';
@@ -178,7 +178,7 @@ $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't sha
 $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
 // Add search filter like
 if (strlen(trim($search_login))) {
-    $sql .= natural_search("u.login", $search_login);
+	$sql .= natural_search("u.login", $search_login);
 }
 if (strlen(trim($search_expensereport))) {
 	$sql .= natural_search("er.ref", $search_expensereport);
@@ -207,13 +207,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -228,7 +228,7 @@ if ($result) {
 	$param = '';
 	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-    if ($search_login)       $param .= '&search_login='.urlencode($search_login);
+	if ($search_login)       $param .= '&search_login='.urlencode($search_login);
 	if ($search_expensereport) $param .= "&search_expensereport=".urlencode($search_expensereport);
 	if ($search_label)		$param .= "&search_label=".urlencode($search_label);
 	if ($search_desc)		$param .= "&search_desc=".urlencode($search_desc);
@@ -257,12 +257,12 @@ if ($result) {
 
 	$moreforfilter = '';
 
-    print '<div class="div-table-responsive">';
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 	print '<tr class="liste_titre_filter">';
-    print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
-    print '<td class="liste_titre"></td>';
+	print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
+	print '<td class="liste_titre"></td>';
 	print '<td><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
 		print '<td class="liste_titre"></td>';
@@ -278,14 +278,14 @@ if ($result) {
 	print '<td class="liste_titre center"><input type="text" class="flat maxwidth50" name="search_vat" size="1" placeholder="%" value="'.dol_escape_htmltag($search_vat).'"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_account" value="'.dol_escape_htmltag($search_account).'"></td>';
 	print '<td class="liste_titre center">';
-    $searchpicto = $form->showFilterButtons();
-    print $searchpicto;
-    print '</td>';
+	$searchpicto = $form->showFilterButtons();
+	print $searchpicto;
+	print '</td>';
 	print "</tr>\n";
 
 	print '<tr class="liste_titre">';
-    print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
-    print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
+	print_liste_field_titre("Employees", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
+	print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
 		print_liste_field_titre("DateValidation", $_SERVER["PHP_SELF"], "er.date_valid", "", $param, '', $sortfield, $sortorder, 'center ');
@@ -296,31 +296,31 @@ if ($result) {
 	print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "erd.total_ht", "", $param, '', $sortfield, $sortorder, 'right ');
 	print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], "erd.tva_tx", "", $param, '', $sortfield, $sortorder, 'center ');
 	print_liste_field_titre("AccountAccounting", $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
-    $checkpicto = $form->showCheckAddButtons();
+	$checkpicto = $form->showCheckAddButtons();
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
 	$expensereportstatic = new ExpenseReport($db);
 	$accountingaccountstatic = new AccountingAccount($db);
-    $userstatic = new User($db);
+	$userstatic = new User($db);
 
-    $i = 0;
+	$i = 0;
 	while ($i < min($num_lines, $limit)) {
 		$objp = $db->fetch_object($result);
 
 		$expensereportstatic->ref = $objp->ref;
 		$expensereportstatic->id = $objp->erid;
 
-        $userstatic->id = $objp->rowid;
-        $userstatic->ref = $objp->label;
-        $userstatic->login = $objp->login;
-        $userstatic->statut = $objp->statut;
-        $userstatic->email = $objp->email;
-        $userstatic->gender = $objp->gender;
-        $userstatic->firstname = $objp->firstname;
-        $userstatic->lastname = $objp->lastname;
-        $userstatic->employee = $objp->employee;
-        $userstatic->photo = $objp->photo;
+		$userstatic->id = $objp->rowid;
+		$userstatic->ref = $objp->label;
+		$userstatic->login = $objp->login;
+		$userstatic->statut = $objp->statut;
+		$userstatic->email = $objp->email;
+		$userstatic->gender = $objp->gender;
+		$userstatic->firstname = $objp->firstname;
+		$userstatic->lastname = $objp->lastname;
+		$userstatic->employee = $objp->employee;
+		$userstatic->photo = $objp->photo;
 
 		$accountingaccountstatic->rowid = $objp->fk_compte;
 		$accountingaccountstatic->label = $objp->label;
@@ -329,15 +329,15 @@ if ($result) {
 
 		print '<tr class="oddeven">';
 
-        // Login
-        print '<td class="nowraponall">';
-        print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
-        print '</td>';
+		// Login
+		print '<td class="nowraponall">';
+		print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
+		print '</td>';
 
-        // Line id
+		// Line id
 		print '<td>'.$objp->rowid.'</td>';
 
-        // Ref Expense report
+		// Ref Expense report
 		print '<td>'.$expensereportstatic->getNomUrl(1).'</td>';
 
 		// Date validation
@@ -347,10 +347,10 @@ if ($result) {
 
 		print '<td class="center">'.dol_print_date($db->jdate($objp->date), 'day').'</td>';
 
-        // Fees label
+		// Fees label
 		print '<td class="tdoverflow">'.($langs->trans($objp->type_fees_code) == $objp->type_fees_code ? $objp->type_fees_label : $langs->trans(($objp->type_fees_code))).'</td>';
 
-        // Fees description -- Can be null
+		// Fees description -- Can be null
 		print '<td>';
 		$text = dolGetFirstLineOfText(dol_string_nohtmltag($objp->comments));
 		$trunclength = empty($conf->global->ACCOUNTING_LENGTH_DESCRIPTION) ? 32 : $conf->global->ACCOUNTING_LENGTH_DESCRIPTION;
@@ -360,13 +360,13 @@ if ($result) {
 		// Amount without taxes
 		print '<td class="nowrap right">'.price($objp->total_ht).'</td>';
 
-        // Vat rate
+		// Vat rate
 		print '<td class="center">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Accounting account affected
 		print '<td class="center">';
 		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
-        print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
+		print ' <a class="editfielda reposition marginleftonly marginrightonly" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
 		print '<td class="center"><input type="checkbox" class="checkforaction" name="changeaccount[]" value="'.$objp->rowid.'"/></td>';
@@ -379,7 +379,7 @@ if ($result) {
 	print "</div>";
 
 	if ($nbtotalofrecords > $limit) {
-	    print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
 	}
 
 	print '</form>';

+ 89 - 89
htdocs/accountancy/expensereport/list.php

@@ -102,16 +102,16 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
 // Purge search criteria
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 {
-    $search_login = '';
-    $search_expensereport = '';
-    $search_label = '';
-    $search_desc = '';
-    $search_amount = '';
-    $search_account = '';
-    $search_vat = '';
-    $search_day = '';
-    $search_month = '';
-    $search_year = '';
+	$search_login = '';
+	$search_expensereport = '';
+	$search_label = '';
+	$search_desc = '';
+	$search_amount = '';
+	$search_account = '';
+	$search_vat = '';
+	$search_day = '';
+	$search_month = '';
+	$search_year = '';
 }
 
 // Mass actions
@@ -124,46 +124,46 @@ include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
 
 if ($massaction == 'ventil') {
 	$msg = '';
-    //print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
-    if (!empty($mesCasesCochees)) {
-        $msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
-        $msg .= '<div class="detail">';
-        $cpt = 0;
-        $ok = 0;
-        $ko = 0;
-
-        foreach ($mesCasesCochees as $maLigneCochee) {
-            $maLigneCourante = explode("_", $maLigneCochee);
-            $monId = $maLigneCourante[0];
-            $monCompte = GETPOST('codeventil'.$monId);
-
-            if ($monCompte <= 0)
-            {
-                $msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
-                $ko++;
-            } else {
-                $sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
-                $sql .= " SET fk_code_ventilation = ".$monCompte;
-                $sql .= " WHERE rowid = ".$monId;
-
-                $accountventilated = new AccountingAccount($db);
-                $accountventilated->fetch($monCompte, '');
-
-                dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
-                if ($db->query($sql)) {
-                    $msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
-                    $ok++;
-                } else {
-                    $msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
-                    $ko++;
-                }
-            }
-
-            $cpt++;
-        }
-        $msg .= '</div>';
-        $msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
-    }
+	//print '<div><font color="red">' . $langs->trans("Processing") . '...</font></div>';
+	if (!empty($mesCasesCochees)) {
+		$msg = '<div>'.$langs->trans("SelectedLines").': '.count($mesCasesCochees).'</div>';
+		$msg .= '<div class="detail">';
+		$cpt = 0;
+		$ok = 0;
+		$ko = 0;
+
+		foreach ($mesCasesCochees as $maLigneCochee) {
+			$maLigneCourante = explode("_", $maLigneCochee);
+			$monId = $maLigneCourante[0];
+			$monCompte = GETPOST('codeventil'.$monId);
+
+			if ($monCompte <= 0)
+			{
+				$msg .= '<div><font color="red">'.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NoAccountSelected").'</font></div>';
+				$ko++;
+			} else {
+				$sql = " UPDATE ".MAIN_DB_PREFIX."expensereport_det";
+				$sql .= " SET fk_code_ventilation = ".$monCompte;
+				$sql .= " WHERE rowid = ".$monId;
+
+				$accountventilated = new AccountingAccount($db);
+				$accountventilated->fetch($monCompte, '');
+
+				dol_syslog('accountancy/expensereport/list.php:: sql='.$sql, LOG_DEBUG);
+				if ($db->query($sql)) {
+					$msg .= '<div><font color="green">'.$langs->trans("LineOfExpenseReport").' '.$monId.' - '.$langs->trans("VentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'</font></div>';
+					$ok++;
+				} else {
+					$msg .= '<div><font color="red">'.$langs->trans("ErrorDB").' : '.$langs->trans("Lineofinvoice").' '.$monId.' - '.$langs->trans("NotVentilatedinAccount").' : '.length_accountg($accountventilated->account_number).'<br/> <pre>'.$sql.'</pre></font></div>';
+					$ko++;
+				}
+			}
+
+			$cpt++;
+		}
+		$msg .= '</div>';
+		$msg .= '<div>'.$langs->trans("EndProcessing").'</div>';
+	}
 }
 
 
@@ -181,8 +181,8 @@ if (empty($chartaccountcode))
 {
 	print $langs->trans("ErrorChartOfAccountSystemNotSelected");
 	// End of page
-    llxFooter();
-    $db->close();
+	llxFooter();
+	$db->close();
 	exit;
 }
 
@@ -204,25 +204,25 @@ if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 }
 // Add search filter like
 if (strlen(trim($search_login))) {
-    $sql .= natural_search("u.login", $search_login);
+	$sql .= natural_search("u.login", $search_login);
 }
 if (strlen(trim($search_expensereport))) {
-    $sql .= natural_search("er.ref", $search_expensereport);
+	$sql .= natural_search("er.ref", $search_expensereport);
 }
 if (strlen(trim($search_label))) {
-    $sql .= natural_search("f.label", $search_label);
+	$sql .= natural_search("f.label", $search_label);
 }
 if (strlen(trim($search_desc))) {
-    $sql .= natural_search("erd.comments", $search_desc);
+	$sql .= natural_search("erd.comments", $search_desc);
 }
 if (strlen(trim($search_amount))) {
-    $sql .= natural_search("erd.total_ht", $search_amount, 1);
+	$sql .= natural_search("erd.total_ht", $search_amount, 1);
 }
 if (strlen(trim($search_account))) {
-    $sql .= natural_search("aa.account_number", $search_account);
+	$sql .= natural_search("aa.account_number", $search_account);
 }
 if (strlen(trim($search_vat))) {
-    $sql .= natural_search("erd.tva_tx", $search_vat, 1);
+	$sql .= natural_search("erd.tva_tx", $search_vat, 1);
 }
 $sql .= dolSqlDateFilter('erd.date', $search_day, $search_month, $search_year);
 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
@@ -233,13 +233,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -255,7 +255,7 @@ if ($result) {
 	$param = '';
 	if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-    if ($search_login)       $param .= '&search_login='.urlencode($search_login);
+	if ($search_login)       $param .= '&search_login='.urlencode($search_login);
 	if ($search_lineid)      $param .= '&search_lineid='.urlencode($search_lineid);
 	if ($search_day)         $param .= '&search_day='.urlencode($search_day);
 	if ($search_month)       $param .= '&search_month='.urlencode($search_month);
@@ -267,7 +267,7 @@ if ($result) {
 	if ($search_vat)         $param .= '&search_vat='.urlencode($search_vat);
 
 	$arrayofmassactions = array(
-	    'ventil' => $langs->trans("Ventilate")
+		'ventil' => $langs->trans("Ventilate")
 	);
 	$massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1);
 
@@ -295,12 +295,12 @@ if ($result) {
 
 	$moreforfilter = '';
 
-    print '<div class="div-table-responsive">';
+	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
 	// We add search filter
 	print '<tr class="liste_titre_filter">';
-    print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
+	print '<td class="liste_titre"><input type="text" name="search_login" class="maxwidth50" value="'.$search_login.'"></td>';
 	print '<td class="liste_titre"></td>';
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_expensereport" value="'.dol_escape_htmltag($search_expensereport).'"></td>';
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@@ -324,7 +324,7 @@ if ($result) {
 	print '</tr>';
 
 	print '<tr class="liste_titre">';
-    print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
+	print_liste_field_titre("Employee", $_SERVER['PHP_SELF'], "u.login", $param, "", "", $sortfield, $sortorder);
 	print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "erd.rowid", "", $param, '', $sortfield, $sortorder);
 	print_liste_field_titre("ExpenseReport", $_SERVER["PHP_SELF"], "er.ref", "", $param, '', $sortfield, $sortorder);
 	if (! empty($conf->global->ACCOUNTANCY_USE_EXPENSE_REPORT_VALIDATION_DATE)) {
@@ -356,23 +356,23 @@ if ($result) {
 		$expensereport_static->ref = $objp->ref;
 		$expensereport_static->id = $objp->erid;
 
-        $userstatic->id = $objp->rowid;
-        $userstatic->ref = $objp->label;
-        $userstatic->login = $objp->login;
-        $userstatic->statut = $objp->statut;
-        $userstatic->email = $objp->email;
-        $userstatic->gender = $objp->gender;
-        $userstatic->firstname = $objp->firstname;
-        $userstatic->lastname = $objp->lastname;
-        $userstatic->employee = $objp->employee;
-        $userstatic->photo = $objp->photo;
-
-        print '<tr class="oddeven">';
-
-        // Login
-        print '<td class="nowraponall">';
-        print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
-        print '</td>';
+		$userstatic->id = $objp->rowid;
+		$userstatic->ref = $objp->label;
+		$userstatic->login = $objp->login;
+		$userstatic->statut = $objp->statut;
+		$userstatic->email = $objp->email;
+		$userstatic->gender = $objp->gender;
+		$userstatic->firstname = $objp->firstname;
+		$userstatic->lastname = $objp->lastname;
+		$userstatic->employee = $objp->employee;
+		$userstatic->photo = $objp->photo;
+
+		print '<tr class="oddeven">';
+
+		// Login
+		print '<td class="nowraponall">';
+		print $userstatic->getNomUrl(-1, '', 0, 0, 24, 1, 'login', '', 1);
+		print '</td>';
 
 		// Line id
 		print '<td>'.$objp->rowid.'</td>';
@@ -400,7 +400,7 @@ if ($result) {
 		print $form->textwithtooltip(dol_trunc($text, $trunclength), $objp->comments);
 		print '</td>';
 
-        // Amount without taxes
+		// Amount without taxes
 		print '<td class="nowrap right">';
 		print price($objp->price);
 		print '</td>';

+ 57 - 57
htdocs/accountancy/supplier/index.php

@@ -331,9 +331,9 @@ $sql .= " GROUP BY ffd.fk_code_ventilation,aa.account_number,aa.label";
 dol_syslog('htdocs/accountancy/supplier/index.php');
 $resql = $db->query($sql);
 if ($resql) {
-    $num = $db->num_rows($resql);
+	$num = $db->num_rows($resql);
 
-    while ($row = $db->fetch_row($resql)) {
+	while ($row = $db->fetch_row($resql)) {
 		print '<tr class="oddeven"><td>';
 		if ($row[0] == 'tobind')
 		{
@@ -346,16 +346,16 @@ if ($resql) {
 			print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/supplier/list.php?search_year='.$y, $langs->transnoentitiesnoconv("ToBind"));
 		} else print $row[1];
 		print '</td>';
-    	for ($i = 2; $i <= 12; $i++) {
-            print '<td class="nowrap right">'.price($row[$i]).'</td>';
-        }
-        print '<td class="nowrap right">'.price($row[13]).'</td>';
-        print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
-        print '</tr>';
-    }
-    $db->free($resql);
+		for ($i = 2; $i <= 12; $i++) {
+			print '<td class="nowrap right">'.price($row[$i]).'</td>';
+		}
+		print '<td class="nowrap right">'.price($row[13]).'</td>';
+		print '<td class="nowrap right"><b>'.price($row[14]).'</b></td>';
+		print '</tr>';
+	}
+	$db->free($resql);
 } else {
-    print $db->lasterror(); // Show last sql error
+	print $db->lasterror(); // Show last sql error
 }
 print "</table>\n";
 print '</div>';
@@ -364,60 +364,60 @@ print '</div>';
 
 if ($conf->global->MAIN_FEATURES_LEVEL > 0) // This part of code looks strange. Why showing a report that should rely on result of this step ?
 {
-    print '<br>';
-    print '<br>';
+	print '<br>';
+	print '<br>';
 
-    print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
-    //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
+	print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
+	//print load_fiche_titre($langs->trans("OtherInfo"), '', '');
 
 	print '<div class="div-table-responsive-no-min">';
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
-    }
-    print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
-
-    $sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
-    for ($i = 1; $i <= 12; $i++) {
-    	$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
-    	if ($j > 12) $j -= 12;
-    	$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
-    }
-    $sql .= "  SUM(ffd.total_ht) as total";
-    $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
-    $sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
-    $sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
-    $sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre"><td width="400" class="left">'.$langs->trans("Total").'</td>';
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad($j, 2, '0', STR_PAD_LEFT)).'</td>';
+	}
+	print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
+
+	$sql = "SELECT '".$langs->trans("CAHTF")."' AS label,";
+	for ($i = 1; $i <= 12; $i++) {
+		$j = $i + ($conf->global->SOCIETE_FISCAL_MONTH_START ? $conf->global->SOCIETE_FISCAL_MONTH_START : 1) - 1;
+		if ($j > 12) $j -= 12;
+		$sql .= "  SUM(".$db->ifsql('MONTH(ff.datef)='.$j, 'ffd.total_ht', '0').") AS month".str_pad($j, 2, '0', STR_PAD_LEFT).",";
+	}
+	$sql .= "  SUM(ffd.total_ht) as total";
+	$sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn_det as ffd";
+	$sql .= "  LEFT JOIN ".MAIN_DB_PREFIX."facture_fourn as ff ON ff.rowid = ffd.fk_facture_fourn";
+	$sql .= " WHERE ff.datef >= '".$db->idate($search_date_start)."'";
+	$sql .= "  AND ff.datef <= '".$db->idate($search_date_end)."'";
 	// Define begin binding date
 	if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
 		$sql .= " AND ff.datef >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING)."'";
 	}
-    $sql .= "  AND ff.fk_statut > 0";
+	$sql .= "  AND ff.fk_statut > 0";
 	$sql .= "  AND ffd.product_type <= 2";
-    $sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
-
-    dol_syslog('htdocs/accountancy/supplier/index.php');
-    $resql = $db->query($sql);
-    if ($resql) {
-    	$num = $db->num_rows($resql);
-
-    	while ($row = $db->fetch_row($resql)) {
-    		print '<tr><td>'.$row[0].'</td>';
-            for ($i = 1; $i <= 12; $i++) {
-    			print '<td class="nowrap right">'.price($row[$i]).'</td>';
-    		}
-    		print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
-    		print '</tr>';
-    	}
-        $db->free($resql);
-    } else {
-        print $db->lasterror(); // Show last sql error
-    }
-    print "</table>\n";
-    print '</div>';
+	$sql .= " AND ff.entity IN (".getEntity('facture_fourn', 0).")"; // We don't share object for accountancy
+
+	dol_syslog('htdocs/accountancy/supplier/index.php');
+	$resql = $db->query($sql);
+	if ($resql) {
+		$num = $db->num_rows($resql);
+
+		while ($row = $db->fetch_row($resql)) {
+			print '<tr><td>'.$row[0].'</td>';
+			for ($i = 1; $i <= 12; $i++) {
+				print '<td class="nowrap right">'.price($row[$i]).'</td>';
+			}
+			print '<td class="nowrap right"><b>'.price($row[13]).'</b></td>';
+			print '</tr>';
+		}
+		$db->free($resql);
+	} else {
+		print $db->lasterror(); // Show last sql error
+	}
+	print "</table>\n";
+	print '</div>';
 }
 
 // End of page

+ 32 - 32
htdocs/accountancy/supplier/lines.php

@@ -94,7 +94,7 @@ $formaccounting = new FormAccounting($db);
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers
 {
 	$search_societe = '';
-    $search_lineid = '';
+	$search_lineid = '';
 	$search_ref = '';
 	$search_invoice = '';
 	$search_label = '';
@@ -196,7 +196,7 @@ if ($search_societe) {
 	$sql .= natural_search('s.nom', $search_societe);
 }
 if ($search_lineid) {
-    $sql .= natural_search("l.rowid", $search_lineid, 1);
+	$sql .= natural_search("l.rowid", $search_lineid, 1);
 }
 if (strlen(trim($search_invoice))) {
 	$sql .= natural_search("f.ref", $search_invoice);
@@ -250,13 +250,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$result = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($result);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -318,7 +318,7 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth50" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth150', 'code2', 1, 0, 1);
 	//	print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -348,29 +348,29 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-    $thirdpartystatic = new Societe($db);
+	$thirdpartystatic = new Societe($db);
 	$facturefournisseur_static = new FactureFournisseur($db);
 	$productstatic = new ProductFournisseur($db);
-    $accountingaccountstatic = new AccountingAccount($db);
+	$accountingaccountstatic = new AccountingAccount($db);
 
-    $i = 0;
+	$i = 0;
 	while ($i < min($num_lines, $limit))
-    {
+	{
 		$objp = $db->fetch_object($result);
 
 		$facturefournisseur_static->ref = $objp->ref;
 		$facturefournisseur_static->id = $objp->facid;
 
-        $thirdpartystatic->id = $objp->socid;
-        $thirdpartystatic->name = $objp->name;
-        $thirdpartystatic->client = $objp->client;
-        $thirdpartystatic->fournisseur = $objp->fournisseur;
-        $thirdpartystatic->code_client = $objp->code_client;
-        $thirdpartystatic->code_compta_client = $objp->code_compta_client;
-        $thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
-        $thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
-        $thirdpartystatic->email = $objp->email;
-        $thirdpartystatic->country_code = $objp->country_code;
+		$thirdpartystatic->id = $objp->socid;
+		$thirdpartystatic->name = $objp->name;
+		$thirdpartystatic->client = $objp->client;
+		$thirdpartystatic->fournisseur = $objp->fournisseur;
+		$thirdpartystatic->code_client = $objp->code_client;
+		$thirdpartystatic->code_compta_client = $objp->code_compta_client;
+		$thirdpartystatic->code_fournisseur = $objp->code_fournisseur;
+		$thirdpartystatic->code_compta_fournisseur = $objp->code_compta_fournisseur;
+		$thirdpartystatic->email = $objp->email;
+		$thirdpartystatic->country_code = $objp->country_code;
 
 		$productstatic->ref = $objp->product_ref;
 		$productstatic->id = $objp->product_id;
@@ -415,7 +415,7 @@ if ($result) {
 		print '<td class="right">'.vatrate($objp->tva_tx.($objp->vat_src_code ? ' ('.$objp->vat_src_code.')' : '')).'</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
 
 		// Country
 		print '<td>';
@@ -428,7 +428,7 @@ if ($result) {
 		print '<td>'.$objp->tva_intra.'</td>';
 
 		print '<td class="center">';
-        print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
+		print $accountingaccountstatic->getNomUrl(0, 1, 1, '', 1);
 		print ' <a class="editfielda" href="./card.php?id='.$objp->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($param ? '?'.$param : '')).'">';
 		print img_edit();
 		print '</a></td>';
@@ -437,14 +437,14 @@ if ($result) {
 		print '</tr>';
 		$i++;
 	}
-    print '</table>';
-    print "</div>";
+	print '</table>';
+	print "</div>";
 
-    if ($nbtotalofrecords > $limit) {
-        print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
-    }
+	if ($nbtotalofrecords > $limit) {
+		print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num_lines, $nbtotalofrecords, '', 0, '', '', $limit, 1);
+	}
 
-    print '</form>';
+	print '</form>';
 } else {
 	print $db->lasterror();
 }

+ 4 - 4
htdocs/accountancy/supplier/list.php

@@ -118,7 +118,7 @@ if (empty($reshook))
 	// Purge search criteria
 	if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers
 	{
-		$search_societe='';
+		$search_societe = '';
 		$search_lineid = '';
 		$search_ref = '';
 		$search_invoice = '';
@@ -385,7 +385,7 @@ if ($result) {
 	print '<td class="liste_titre"><input type="text" class="flat maxwidth100" name="search_desc" value="'.dol_escape_htmltag($search_desc).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_amount" value="'.dol_escape_htmltag($search_amount).'"></td>';
 	print '<td class="liste_titre right"><input type="text" class="right flat maxwidth50" name="search_vat" placeholder="%" size="1" value="'.dol_escape_htmltag($search_vat).'"></td>';
-	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="' . dol_escape_htmltag($search_societe) . '"></td>';
+	print '<td class="liste_titre"><input type="text" class="flat maxwidth75imp" name="search_societe" value="'.dol_escape_htmltag($search_societe).'"></td>';
 	print '<td class="liste_titre">';
 	print $form->select_country($search_country, 'search_country', '', 0, 'maxwidth125', 'code2', 1, 0, 1);
 	//print '<input type="text" class="flat maxwidth50" name="search_country" value="' . dol_escape_htmltag($search_country) . '">';
@@ -419,7 +419,7 @@ if ($result) {
 	print_liste_field_titre($checkpicto, '', '', '', '', '', '', '', 'center ');
 	print "</tr>\n";
 
-	$thirdpartystatic=new Societe($db);
+	$thirdpartystatic = new Societe($db);
 	$facturefourn_static = new FactureFournisseur($db);
 	$product_static = new Product($db);
 
@@ -569,7 +569,7 @@ if ($result) {
 		print '</td>';
 
 		// Thirdparty
-		print '<td class="tdoverflowmax100">' . $thirdpartystatic->getNomUrl(1, 'supplier') . '</td>';
+		print '<td class="tdoverflowmax100">'.$thirdpartystatic->getNomUrl(1, 'supplier').'</td>';
 
 		// Country
         print '<td>';

+ 19 - 19
htdocs/adherents/admin/adherent_emails.php

@@ -47,15 +47,15 @@ $error = 0;
 
 // Editing global variables not related to a specific theme
 $constantes = array(
-    'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
-    'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
-    'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
-    'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
-    'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
-    'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
-    'ADHERENT_MAIL_FROM'=>'string',
-    'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
-    'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
+	'MEMBER_REMINDER_EMAIL'=>array('type'=>'yesno', 'label'=>$langs->trans('MEMBER_REMINDER_EMAIL', $langs->transnoentities("Module2300Name"))),
+	'ADHERENT_EMAIL_TEMPLATE_REMIND_EXPIRATION' =>'emailtemplate:member',
+	'ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER'		=>'emailtemplate:member', /* old was ADHERENT_AUTOREGISTER_MAIL */
+	'ADHERENT_EMAIL_TEMPLATE_MEMBER_VALIDATION'	=>'emailtemplate:member', /* old was ADHERENT_MAIL_VALID */
+	'ADHERENT_EMAIL_TEMPLATE_SUBSCRIPTION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_COTIS */
+	'ADHERENT_EMAIL_TEMPLATE_CANCELATION'		=>'emailtemplate:member', /* old was ADHERENT_MAIL_RESIL */
+	'ADHERENT_MAIL_FROM'=>'string',
+	'ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT'=>'string',
+	'ADHERENT_AUTOREGISTER_NOTIF_MAIL'=>'html',
 );
 
 
@@ -66,16 +66,16 @@ $constantes = array(
 
 //
 if ($action == 'updateall') {
-    $db->begin();
-    $res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
-    $res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
-    if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
-        setEventMessages('ErrorFailedToSaveDate', null, 'errors');
-        $db->rollback();
-    } else {
-        setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
-        $db->commit();
-    }
+	$db->begin();
+	$res1 = $res2 = $res3 = $res4 = $res5 = $res6 = 0;
+	$res1 = dolibarr_set_const($db, 'XXXX', GETPOST('ADHERENT_LOGIN_NOT_REQUIRED', 'alpha'), 'chaine', 0, '', $conf->entity);
+	if ($res1 < 0 || $res2 < 0 || $res3 < 0 || $res4 < 0 || $res5 < 0 || $res6 < 0) {
+		setEventMessages('ErrorFailedToSaveDate', null, 'errors');
+		$db->rollback();
+	} else {
+		setEventMessages('RecordModifiedSuccessfully', null, 'mesgs');
+		$db->commit();
+	}
 }
 
 // Action to update or add a constant

+ 42 - 42
htdocs/adherents/card.php

@@ -335,8 +335,8 @@ if (empty($reshook)) {
 							if (!dol_move_uploaded_file($_FILES['photo']['tmp_name'], $newfile, 1, 0, $_FILES['photo']['error']) > 0) {
 								setEventMessages($langs->trans("ErrorFailedToSaveFile"), null, 'errors');
 							} else {
-							    // Create thumbs
-							    $object->addThumbs($newfile);
+								// Create thumbs
+								$object->addThumbs($newfile);
 							}
 						}
 					} else {
@@ -354,8 +354,8 @@ if (empty($reshook)) {
 					}
 				}
 
-	            $rowid = $object->id;
-	            $id = $object->id;
+				$rowid = $object->id;
+				$id = $object->id;
 				$action = '';
 
 				if (!empty($backtopage)) {
@@ -402,7 +402,7 @@ if (empty($reshook)) {
 		// $skype=GETPOST("member_skype", 'alpha');
 		// $twitter=GETPOST("member_twitter", 'alpha');
 		// $facebook=GETPOST("member_facebook", 'alpha');
-        // $linkedin=GETPOST("member_linkedin", 'alpha');
+		// $linkedin=GETPOST("member_linkedin", 'alpha');
 		$email = preg_replace('/\s+/', '', GETPOST("member_email", 'alpha'));
 		$login = GETPOST("member_login", 'alpha');
 		$pass = GETPOST("password", 'alpha');
@@ -755,7 +755,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		if ($result <= 0) dol_print_error('', $object->error);
 	}
    	$objcanvas->assign_values($action, $object->id, $object->ref); // Set value for templates
-    $objcanvas->display_canvas($action); // Show template
+	$objcanvas->display_canvas($action); // Show template
 } else {
 	// -----------------------------------------
 	// When used in standard mode
@@ -778,16 +778,16 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			$object->country = $tmparray['label'];
 		}
 
-        if (!empty($socid)) {
-            $object = new Societe($db);
-            if ($socid > 0) $object->fetch($socid);
+		if (!empty($socid)) {
+			$object = new Societe($db);
+			if ($socid > 0) $object->fetch($socid);
 
-            if (!($object->id > 0)) {
-                $langs->load("errors");
-                print($langs->trans('ErrorRecordNotFound'));
-                exit;
-            }
-        }
+			if (!($object->id > 0)) {
+				$langs->load("errors");
+				print($langs->trans('ErrorRecordNotFound'));
+				exit;
+			}
+		}
 
 		$adht = new AdherentType($db);
 
@@ -829,7 +829,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<input type="hidden" name="socid" value="'.$socid.'">';
 		if ($backtopage) print '<input type="hidden" name="backtopage" value="'.($backtopage != '1' ? $backtopage : $_SERVER["HTTP_REFERER"]).'">';
 
-        dol_fiche_head('');
+		dol_fiche_head('');
 
 		print '<table class="border centpercent">';
 		print '<tbody>';
@@ -934,14 +934,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
 		print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" size="20" value="'.(GETPOSTISSET('phone_mobile') ? GETPOST('phone_mobile', 'alpha') : $object->phone_mobile).'"></td></tr>';
 
-	    if (!empty($conf->socialnetworks->enabled)) {
+		if (!empty($conf->socialnetworks->enabled)) {
 			foreach ($socialnetworks as $key => $value) {
-                if (!$value['active']) break;
+				if (!$value['active']) break;
 				print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="member_'.$key.'" size="40" value="'.(GETPOSTISSET('member_'.$key) ? GETPOST('member_'.$key, 'alpha') : $object->socialnetworks[$key]).'"></td></tr>';
 			}
 		}
 
-	    // Birth Date
+		// Birth Date
 		print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
 		print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
 		print "</td></tr>\n";
@@ -1167,14 +1167,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '<tr><td>'.$langs->trans("PhoneMobile").'</td>';
 		print '<td>'.img_picto('', 'object_phoning_mobile').' <input type="text" name="phone_mobile" value="'.(GETPOSTISSET("phone_mobile") ? GETPOST("phone_mobile") : $object->phone_mobile).'"></td></tr>';
 
-        if (!empty($conf->socialnetworks->enabled)) {
+		if (!empty($conf->socialnetworks->enabled)) {
 			foreach ($socialnetworks as $key => $value) {
-                if (!$value['active']) break;
+				if (!$value['active']) break;
 				print '<tr><td>'.$langs->trans($value['label']).'</td><td><input type="text" name="'.$key.'" class="minwidth100" value="'.(GETPOSTISSET($key) ? GETPOST($key, 'alphanohtml') : $object->socialnetworks[$key]).'"></td></tr>';
 			}
 		}
 
-	    // Birth Date
+		// Birth Date
 		print "<tr><td>".$langs->trans("DateToBirth")."</td><td>\n";
 		print $form->selectDate(($object->birth ? $object->birth : -1), 'birth', '', '', 1, 'formsoc');
 		print "</td></tr>\n";
@@ -1447,10 +1447,10 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 
 		dol_banner_tab($object, 'rowid', $linkback);
 
-        print '<div class="fichecenter">';
-        print '<div class="fichehalfleft">';
+		print '<div class="fichecenter">';
+		print '<div class="fichehalfleft">';
 
-        print '<div class="underbanner clearboth"></div>';
+		print '<div class="underbanner clearboth"></div>';
 		print '<table class="border tableforfield centpercent">';
 
 		// Login
@@ -1483,13 +1483,13 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			print '<tr><td>'.$langs->trans("Password").'</td><td>'.preg_replace('/./i', '*', $object->pass);
 			if ($object->pass) print preg_replace('/./i', '*', $object->pass);
 			else {
-			    if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
-			    else print $langs->trans("Hidden");
+				if ($user->admin) print $langs->trans("Crypted").': '.$object->pass_indatabase_crypted;
+				else print $langs->trans("Hidden");
 			}
 			if ((!empty($object->pass) || !empty($object->pass_crypted)) && empty($object->user_id)) {
-			    $langs->load("errors");
-			    $htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
-			    print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
+				$langs->load("errors");
+				$htmltext = $langs->trans("WarningPasswordSetWithNoAccount");
+				print ' '.$form->textwithpicto('', $htmltext, 1, 'warning');
 			}
 			print '</td></tr>';
 		}
@@ -1503,8 +1503,8 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			}
 		} else {
 			if ($object->need_subscription == 0) {
-                print $langs->trans("SubscriptionNotNeeded");
-            } elseif (!$adht->subscription) {
+				print $langs->trans("SubscriptionNotNeeded");
+			} elseif (!$adht->subscription) {
 				print $langs->trans("SubscriptionNotRecorded");
 				if ($object->statut > 0) print " ".img_warning($langs->trans("Late")); // displays delay Pictogram only if not a draft and not terminated
 			} else {
@@ -1560,14 +1560,14 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		}
 		print '</td></tr>';
 
-        print '</table>';
+		print '</table>';
 
-        print '</div>';
+		print '</div>';
 
-        print '<div class="fichehalfright"><div class="ficheaddleft">';
-        print '<div class="underbanner clearboth"></div>';
+		print '<div class="fichehalfright"><div class="ficheaddleft">';
+		print '<div class="underbanner clearboth"></div>';
 
-        print '<table class="border tableforfield tableforfield" width="100%">';
+		print '<table class="border tableforfield tableforfield" width="100%">';
 
 		// Birth Date
 		print '<tr><td class="titlefield">'.$langs->trans("DateToBirth").'</td><td class="valeur">'.dol_print_date($object->birth, 'day').'</td></tr>';
@@ -1585,12 +1585,12 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 
 		//VCard
 		print '<tr><td>';
-        print $langs->trans("VCard").'</td><td colspan="3">';
+		print $langs->trans("VCard").'</td><td colspan="3">';
 		print '<a href="'.DOL_URL_ROOT.'/adherents/vcard.php?id='.$object->id.'">';
 		print img_picto($langs->trans("Download"), 'vcard.png', 'class="paddingrightonly"');
 		print $langs->trans("Download");
 		print '</a>';
-        print '</td></tr>';
+		print '</td></tr>';
 
 		// Other attributes
 		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php';
@@ -1598,9 +1598,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print "</table>\n";
 
 		print "</div></div></div>\n";
-        print '<div style="clear:both"></div>';
+		print '<div style="clear:both"></div>';
 
-        dol_fiche_end();
+		dol_fiche_end();
 
 
 		/*
@@ -1769,7 +1769,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 			$morehtmlright .= '</a>';
 
 			// List of actions on element
-	        include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+			include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
 			$formactions = new FormActions($db);
 			$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);
 

+ 218 - 218
htdocs/adherents/class/adherent_type.class.php

@@ -62,26 +62,26 @@ class AdherentType extends CommonObject
 	public $libelle;
 
 	/**
-     * @var string Adherent type label
-     */
-    public $label;
+	 * @var string Adherent type label
+	 */
+	public $label;
 
-    /**
-     * @var string Adherent type nature
-     */
-    public $morphy;
+	/**
+	 * @var string Adherent type nature
+	 */
+	public $morphy;
 
-    public $duration;
+	public $duration;
 
-    /*
+	/*
     * type expiration
     */
-    public $duration_value;
+	public $duration_value;
 
-    /**
-     * Expiration unit
-     */
-    public $duration_unit;
+	/**
+	 * Expiration unit
+	 */
+	public $duration_unit;
 
 	/**
 	 * @var int Subsription required (0 or 1)
@@ -101,7 +101,7 @@ class AdherentType extends CommonObject
 	/** @var array Array of members */
 	public $members = array();
 
-    public $multilangs = array();
+	public $multilangs = array();
 
 
 	/**
@@ -115,157 +115,157 @@ class AdherentType extends CommonObject
 		$this->status = 1;
 	}
 
-    /**
-     *    Load array this->multilangs
-     *
-     * @return int        <0 if KO, >0 if OK
-     */
-    public function getMultiLangs()
-    {
-        global $langs;
-
-        $current_lang = $langs->getDefaultLang();
-
-        $sql = "SELECT lang, label, description, email";
-        $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-        $sql .= " WHERE fk_type=".$this->id;
-
-        $result = $this->db->query($sql);
-        if ($result) {
-            while ($obj = $this->db->fetch_object($result)) {
-                //print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
-                if ($obj->lang == $current_lang) {  // si on a les traduct. dans la langue courante on les charge en infos principales.
+	/**
+	 *    Load array this->multilangs
+	 *
+	 * @return int        <0 if KO, >0 if OK
+	 */
+	public function getMultiLangs()
+	{
+		global $langs;
+
+		$current_lang = $langs->getDefaultLang();
+
+		$sql = "SELECT lang, label, description, email";
+		$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+		$sql .= " WHERE fk_type=".$this->id;
+
+		$result = $this->db->query($sql);
+		if ($result) {
+			while ($obj = $this->db->fetch_object($result)) {
+				//print 'lang='.$obj->lang.' current='.$current_lang.'<br>';
+				if ($obj->lang == $current_lang) {  // si on a les traduct. dans la langue courante on les charge en infos principales.
 					$this->label        = $obj->label;
-                    $this->description = $obj->description;
-                    $this->email        = $obj->email;
-                }
-                $this->multilangs["$obj->lang"]["label"] = $obj->label;
-                $this->multilangs["$obj->lang"]["description"] = $obj->description;
-                $this->multilangs["$obj->lang"]["email"] = $obj->email;
-            }
-            return 1;
-        } else {
-            $this->error = "Error: ".$this->db->lasterror()." - ".$sql;
-            return -1;
-        }
-    }
-
-    /**
-     *    Update or add a translation for a product
-     *
-     * @param  User $user Object user making update
-     * @return int        <0 if KO, >0 if OK
-     */
-    public function setMultiLangs($user)
-    {
-        global $conf, $langs;
-
-        $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
-        $current_lang = $langs->getDefaultLang();
-
-        foreach ($langs_available as $key => $value) {
-            if ($key == $current_lang) {
-                $sql = "SELECT rowid";
-                $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-                $sql .= " WHERE fk_type=".$this->id;
-                $sql .= " AND lang='".$key."'";
-
-                $result = $this->db->query($sql);
-
-                if ($this->db->num_rows($result)) { // if there is already a description line for this language
+					$this->description = $obj->description;
+					$this->email        = $obj->email;
+				}
+				$this->multilangs["$obj->lang"]["label"] = $obj->label;
+				$this->multilangs["$obj->lang"]["description"] = $obj->description;
+				$this->multilangs["$obj->lang"]["email"] = $obj->email;
+			}
+			return 1;
+		} else {
+			$this->error = "Error: ".$this->db->lasterror()." - ".$sql;
+			return -1;
+		}
+	}
+
+	/**
+	 *    Update or add a translation for a product
+	 *
+	 * @param  User $user Object user making update
+	 * @return int        <0 if KO, >0 if OK
+	 */
+	public function setMultiLangs($user)
+	{
+		global $conf, $langs;
+
+		$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 0, 2);
+		$current_lang = $langs->getDefaultLang();
+
+		foreach ($langs_available as $key => $value) {
+			if ($key == $current_lang) {
+				$sql = "SELECT rowid";
+				$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+				$sql .= " WHERE fk_type=".$this->id;
+				$sql .= " AND lang='".$key."'";
+
+				$result = $this->db->query($sql);
+
+				if ($this->db->num_rows($result)) { // if there is already a description line for this language
 					$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
-                    $sql2 .= " SET ";
-                    $sql2 .= " label='".$this->db->escape($this->label)."',";
-                    $sql2 .= " description='".$this->db->escape($this->description)."'";
-                    $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
-                } else {
-                    $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
-                    $sql2 .= ")";
-                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
-                    $sql2 .= " '".$this->db->escape($this->description)."'";
-                    $sql2 .= ")";
-                }
-                dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
-                if (!$this->db->query($sql2)) {
-                    $this->error = $this->db->lasterror();
-                    return -1;
-                }
-            } elseif (isset($this->multilangs[$key])) {
-                $sql = "SELECT rowid";
-                $sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-                $sql .= " WHERE fk_type=".$this->id;
-                $sql .= " AND lang='".$key."'";
-
-                $result = $this->db->query($sql);
-
-                if ($this->db->num_rows($result)) { // if there is already a description line for this language
+					$sql2 .= " SET ";
+					$sql2 .= " label='".$this->db->escape($this->label)."',";
+					$sql2 .= " description='".$this->db->escape($this->description)."'";
+					$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
+				} else {
+					$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
+					$sql2 .= ")";
+					$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->label)."',";
+					$sql2 .= " '".$this->db->escape($this->description)."'";
+					$sql2 .= ")";
+				}
+				dol_syslog(get_class($this).'::setMultiLangs key = current_lang = '.$key);
+				if (!$this->db->query($sql2)) {
+					$this->error = $this->db->lasterror();
+					return -1;
+				}
+			} elseif (isset($this->multilangs[$key])) {
+				$sql = "SELECT rowid";
+				$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+				$sql .= " WHERE fk_type=".$this->id;
+				$sql .= " AND lang='".$key."'";
+
+				$result = $this->db->query($sql);
+
+				if ($this->db->num_rows($result)) { // if there is already a description line for this language
 					$sql2 = "UPDATE ".MAIN_DB_PREFIX."adherent_type_lang";
-                    $sql2 .= " SET ";
-                    $sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
-                    $sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
-                    $sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
-                } else {
-                    $sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
-                    $sql2 .= ")";
-                    $sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
-                    $sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
-                    $sql2 .= ")";
-                }
-
-                // We do not save if main fields are empty
-                if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
-                    if (!$this->db->query($sql2)) {
-                        $this->error = $this->db->lasterror();
-                        return -1;
-                    }
-                }
-            } else {
-                // language is not current language and we didn't provide a multilang description for this language
-            }
-        }
-
-        // Call trigger
-        $result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
-        if ($result < 0) {
-            $this->error = $this->db->lasterror();
-            return -1;
-        }
-        // End call triggers
-
-        return 1;
-    }
-
-       /**
-     *    Delete a language for this product
-     *
-     * @param string $langtodelete Language code to delete
-     * @param User   $user         Object user making delete
-     *
-     * @return int                            <0 if KO, >0 if OK
-     */
-    public function delMultiLangs($langtodelete, $user)
-    {
-        $sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
-        $sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
-
-        dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
-        $result = $this->db->query($sql);
-        if ($result) {
-            // Call trigger
-            $result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
-            if ($result < 0) {
-                $this->error = $this->db->lasterror();
-                dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
-                return -1;
-            }
-            // End call triggers
-            return 1;
-        } else {
-            $this->error = $this->db->lasterror();
-            dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
-            return -1;
-        }
-    }
+					$sql2 .= " SET ";
+					$sql2 .= " label='".$this->db->escape($this->multilangs["$key"]["label"])."',";
+					$sql2 .= " description='".$this->db->escape($this->multilangs["$key"]["description"])."'";
+					$sql2 .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($key)."'";
+				} else {
+					$sql2 = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type_lang (fk_type, lang, label, description";
+					$sql2 .= ")";
+					$sql2 .= " VALUES(".$this->id.",'".$this->db->escape($key)."','".$this->db->escape($this->multilangs["$key"]["label"])."',";
+					$sql2 .= " '".$this->db->escape($this->multilangs["$key"]["description"])."'";
+					$sql2 .= ")";
+				}
+
+				// We do not save if main fields are empty
+				if ($this->multilangs["$key"]["label"] || $this->multilangs["$key"]["description"]) {
+					if (!$this->db->query($sql2)) {
+						$this->error = $this->db->lasterror();
+						return -1;
+					}
+				}
+			} else {
+				// language is not current language and we didn't provide a multilang description for this language
+			}
+		}
+
+		// Call trigger
+		$result = $this->call_trigger('MEMBER_TYPE_SET_MULTILANGS', $user);
+		if ($result < 0) {
+			$this->error = $this->db->lasterror();
+			return -1;
+		}
+		// End call triggers
+
+		return 1;
+	}
+
+	   /**
+	    *    Delete a language for this product
+	    *
+	    * @param string $langtodelete Language code to delete
+	    * @param User   $user         Object user making delete
+	    *
+	    * @return int                            <0 if KO, >0 if OK
+	    */
+	public function delMultiLangs($langtodelete, $user)
+	{
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."adherent_type_lang";
+		$sql .= " WHERE fk_type=".$this->id." AND lang='".$this->db->escape($langtodelete)."'";
+
+		dol_syslog(get_class($this).'::delMultiLangs', LOG_DEBUG);
+		$result = $this->db->query($sql);
+		if ($result) {
+			// Call trigger
+			$result = $this->call_trigger('ADHERENT_TYPE_DEL_MULTILANGS', $user);
+			if ($result < 0) {
+				$this->error = $this->db->lasterror();
+				dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
+				return -1;
+			}
+			// End call triggers
+			return 1;
+		} else {
+			$this->error = $this->db->lasterror();
+			dol_syslog(get_class($this).'::delMultiLangs error='.$this->error, LOG_ERR);
+			return -1;
+		}
+	}
 
 	/**
 	 *  Fonction qui permet de creer le status de l'adherent
@@ -337,7 +337,7 @@ class AdherentType extends CommonObject
 	 */
 	public function update($user, $notrigger = 0)
 	{
-        global $langs, $conf, $hookmanager;
+		global $langs, $conf, $hookmanager;
 
 		$error = 0;
 
@@ -359,15 +359,15 @@ class AdherentType extends CommonObject
 
 		$result = $this->db->query($sql);
 		if ($result) {
-            $this->description = $this->db->escape($this->note);
+			$this->description = $this->db->escape($this->note);
 
-            // Multilangs
-            if (!empty($conf->global->MAIN_MULTILANGS)) {
-                if ($this->setMultiLangs($user) < 0) {
-                    $this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
-                    return -2;
-                }
-            }
+			// Multilangs
+			if (!empty($conf->global->MAIN_MULTILANGS)) {
+				if ($this->setMultiLangs($user) < 0) {
+					$this->error = $langs->trans("Error")." : ".$this->db->error()." - ".$sql;
+					return -2;
+				}
+			}
 
 			$action = 'update';
 
@@ -439,7 +439,7 @@ class AdherentType extends CommonObject
 	 */
 	public function fetch($rowid)
 	{
-        global $langs, $conf;
+		global $langs, $conf;
 
 		$sql = "SELECT d.rowid, d.libelle as label, d.morphy, d.statut as status, d.duration, d.subscription, d.mail_valid, d.note, d.vote";
 		$sql .= " FROM ".MAIN_DB_PREFIX."adherent_type as d";
@@ -465,10 +465,10 @@ class AdherentType extends CommonObject
 				$this->note           = $obj->note;
 				$this->vote           = $obj->vote;
 
-                // multilangs
-                if (!empty($conf->global->MAIN_MULTILANGS)) {
-                    $this->getMultiLangs();
-                }
+				// multilangs
+				if (!empty($conf->global->MAIN_MULTILANGS)) {
+					$this->getMultiLangs();
+				}
 			}
 
 			return 1;
@@ -478,7 +478,7 @@ class AdherentType extends CommonObject
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Return list of members' type
 	 *
@@ -487,7 +487,7 @@ class AdherentType extends CommonObject
 	 */
 	public function liste_array($status = -1)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 
 		$adherenttypes = array();
@@ -578,31 +578,31 @@ class AdherentType extends CommonObject
 		//return $morphy;
 	}
 
-    /**
-     *  Return clicable name (with picto eventually)
-     *
-     *  @param		int		$withpicto		0=No picto, 1=Include picto into link, 2=Only picto
-     *  @param		int		$maxlen			length max label
-     *  @param		int  	$notooltip		1=Disable tooltip
-     *  @return		string					String with URL
-     */
-    public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
-    {
-        global $langs;
+	/**
+	 *  Return clicable name (with picto eventually)
+	 *
+	 *  @param		int		$withpicto		0=No picto, 1=Include picto into link, 2=Only picto
+	 *  @param		int		$maxlen			length max label
+	 *  @param		int  	$notooltip		1=Disable tooltip
+	 *  @return		string					String with URL
+	 */
+	public function getNomUrl($withpicto = 0, $maxlen = 0, $notooltip = 0)
+	{
+		global $langs;
 
-        $result = '';
-        $label = $langs->trans("ShowTypeCard", $this->label);
+		$result = '';
+		$label = $langs->trans("ShowTypeCard", $this->label);
 
-        $linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
-        $linkend = '</a>';
+		$linkstart = '<a href="'.DOL_URL_ROOT.'/adherents/type.php?rowid='.$this->id.'" title="'.dol_escape_htmltag($label, 1).'" class="classfortooltip">';
+		$linkend = '</a>';
 
-        $result .= $linkstart;
-        if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
-        if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
-        $result .= $linkend;
+		$result .= $linkstart;
+		if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+		if ($withpicto != 2) $result .= ($maxlen ?dol_trunc($this->label, $maxlen) : $this->label);
+		$result .= $linkend;
 
-        return $result;
-    }
+		return $result;
+	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
@@ -611,7 +611,7 @@ class AdherentType extends CommonObject
 	 *    @param  	int		$mode       0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
 	 *    @return   string     	   		Label of status
 	 */
-    public function getLibStatut($mode = 0)
+	public function getLibStatut($mode = 0)
 	{
 		return $this->LibStatut($this->status, $mode);
 	}
@@ -623,9 +623,9 @@ class AdherentType extends CommonObject
 	 *  @param	int		$mode           0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto, 6=Long label + Picto
 	 *  @return	string          		Status label
 	 */
-    public function LibStatut($status, $mode = 0)
+	public function LibStatut($status, $mode = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs;
 		$langs->load('companies');
 
@@ -640,10 +640,10 @@ class AdherentType extends CommonObject
 		}
 
 		return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode);
-    }
+	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *	Retourne chaine DN complete dans l'annuaire LDAP pour l'objet
 	 *
@@ -655,7 +655,7 @@ class AdherentType extends CommonObject
 	 */
 	public function _load_ldap_dn($info, $mode = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$dn = '';
 		if ($mode == 0) $dn = $conf->global->LDAP_KEY_MEMBERS_TYPES."=".$info[$conf->global->LDAP_KEY_MEMBERS_TYPES].",".$conf->global->LDAP_MEMBER_TYPE_DN;
@@ -665,8 +665,8 @@ class AdherentType extends CommonObject
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *	Initialize the info array (array of LDAP values) that will be used to call LDAP functions
 	 *
@@ -674,7 +674,7 @@ class AdherentType extends CommonObject
 	 */
 	public function _load_ldap_info()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 
 		$info = array();
@@ -766,15 +766,15 @@ class AdherentType extends CommonObject
 	 *
 	 *     @return string     Return mail model content of type or empty
 	 */
-    public function getMailOnResiliate()
-    {
-        global $conf;
+	public function getMailOnResiliate()
+	{
+		global $conf;
 
-        // NOTE mail_resiliate not defined so never used
-        if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) {  // Property not yet defined
+		// NOTE mail_resiliate not defined so never used
+		if (!empty($this->mail_resiliate) && trim(dol_htmlentitiesbr_decode($this->mail_resiliate))) {  // Property not yet defined
 			return $this->mail_resiliate;
-        }
+		}
 
-        return '';
-    }
+		return '';
+	}
 }

+ 158 - 158
htdocs/adherents/type.php

@@ -81,10 +81,10 @@ $extrafields->fetch_name_optionals_label($object->table_element);
 
 if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
 	$search_lastname = "";
-    $search_login = "";
-    $search_email = "";
-    $type = "";
-    $sall = "";
+	$search_login = "";
+	$search_email = "";
+	$type = "";
+	$sall = "";
 }
 
 
@@ -226,8 +226,8 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 
 		$newcardbutton = '';
 		if ($user->rights->adherent->configurer) {
-            $newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
-        }
+			$newcardbutton .= dolGetButtonTitle($langs->trans('NewMemberType'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/adherents/type.php?action=create');
+		}
 
 		print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
 		if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
@@ -247,7 +247,7 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 		print '<tr class="liste_titre">';
 		print '<th>'.$langs->trans("Ref").'</th>';
 		print '<th>'.$langs->trans("Label").'</th>';
-        print '<th class="center">'.$langs->trans("MemberNature").'</th>';
+		print '<th class="center">'.$langs->trans("MemberNature").'</th>';
 		print '<th class="center">'.$langs->trans("SubscriptionRequired").'</th>';
 		print '<th class="center">'.$langs->trans("VoteAllowed").'</th>';
 		print '<th class="center">'.$langs->trans("Status").'</th>';
@@ -270,9 +270,9 @@ if (!$rowid && $action != 'create' && $action != 'edit') {
 			//<a href="'.$_SERVER["PHP_SELF"].'?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowType"),'group').' '.$objp->rowid.'</a>
 			print '</td>';
 			print '<td>'.dol_escape_htmltag($objp->label).'</td>';
-            print '<td class="center">';
+			print '<td class="center">';
 			if ($objp->morphy == 'phy') { print $langs->trans("Physical"); } elseif ($objp->morphy == 'mor') { print $langs->trans("Moral"); } else print $langs->trans("MorPhy");
-            print '</td>';
+			print '</td>';
 			print '<td class="center">'.yn($objp->subscription).'</td>';
 			print '<td class="center">'.yn($objp->vote).'</td>';
 			print '<td class="center">'.$membertype->getLibStatut(5).'</td>';
@@ -308,7 +308,7 @@ if ($action == 'create') {
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="action" value="add">';
 
-    dol_fiche_head('');
+	dol_fiche_head('');
 
 	print '<table class="border centpercent">';
 	print '<tbody>';
@@ -319,10 +319,10 @@ if ($action == 'create') {
   	print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), 1);
   	print '</td></tr>';
 
-    // Morphy
+	// Morphy
   	$morphys = array();
-    $morphys[""] = $langs->trans("MorPhy");
-    $morphys["phy"] = $langs->trans("Physical");
+	$morphys[""] = $langs->trans("MorPhy");
+	$morphys["phy"] = $langs->trans("Physical");
 	$morphys["mor"] = $langs->trans("Moral");
 	print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
 	print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy", 'aZ09') : 'morphy');
@@ -447,11 +447,11 @@ if ($rowid > 0) {
 		}
 
 		// Add
-        if ($user->rights->adherent->configurer && !empty($object->status)) {
-            print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
-        } else {
-		    print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
-        }
+		if ($user->rights->adherent->configurer && !empty($object->status)) {
+			print '<div class="inline-block divButAction"><a class="butAction" href="card.php?action=create&typeid='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.$langs->trans("AddMember").'</a></div>';
+		} else {
+			print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NoAddMember")).'">'.$langs->trans("AddMember").'</a></div>';
+		}
 
 		// Delete
 		if ($user->rights->adherent->configurer) {
@@ -479,7 +479,7 @@ if ($rowid > 0) {
 			$sql .= natural_search(array("f.firstname", "d.lastname", "d.societe", "d.email", "d.login", "d.address", "d.town", "d.note_public", "d.note_private"), $sall);
 		}
 		if ($status != '') {
-		    $sql .= natural_search('d.statut', $status, 2);
+			$sql .= natural_search('d.statut', $status, 2);
 		}
 		if ($action == 'search') {
 			if (GETPOST('search', 'alpha')) {
@@ -495,12 +495,12 @@ if ($rowid > 0) {
 		if (!empty($search_email)) {
 			$sql .= natural_search("d.email", $search_email);
 		}
-        if ($filter == 'uptodate') {
-            $sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
-        }
-        if ($filter == 'outofdate') {
-            $sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
-        }
+		if ($filter == 'uptodate') {
+			$sql .= " AND (datefin >= '".$db->idate($now)."') OR t.subscription = 0)";
+		}
+		if ($filter == 'outofdate') {
+			$sql .= " AND (datefin < '".$db->idate($now)."' AND t.subscription = 1)";
+		}
 
 		$sql .= " ".$db->order($sortfield, $sortorder);
 
@@ -508,71 +508,71 @@ if ($rowid > 0) {
 		$nbtotalofrecords = '';
 		if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
 			$resql = $db->query($sql);
-		    if ($resql) $nbtotalofrecords = $db->num_rows($result);
-		    else dol_print_error($db);
-		    if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
+			if ($resql) $nbtotalofrecords = $db->num_rows($result);
+			else dol_print_error($db);
+			if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
 				$page = 0;
-		    	$offset = 0;
-		    }
+				$offset = 0;
+			}
 		}
 
 		$sql .= " ".$db->plimit($conf->liste_limit + 1, $offset);
 
 		$resql = $db->query($sql);
 		if ($resql) {
-		    $num = $db->num_rows($resql);
-		    $i = 0;
-
-		    $titre = $langs->trans("MembersList");
-            if ($status != '') {
-                if ($status == '-1,1') {
-                    $titre = $langs->trans("MembersListQualified");
-                } elseif ($status == '-1') {
-                    $titre = $langs->trans("MembersListToValid");
-                } elseif ($status == '1' && !$filter) {
-                    $titre = $langs->trans("MembersListValid");
-                } elseif ($status == '1' && $filter == 'uptodate') {
-                    $titre = $langs->trans("MembersListUpToDate");
-                } elseif ($status == '1' && $filter == 'outofdate') {
-                    $titre = $langs->trans("MembersListNotUpToDate");
-                } elseif ($status == '0') {
-                    $titre = $langs->trans("MembersListResiliated");
-                }
-		    } elseif ($action == 'search') {
-		        $titre = $langs->trans("MembersListQualified");
-		    }
-
-		    if ($type > 0) {
+			$num = $db->num_rows($resql);
+			$i = 0;
+
+			$titre = $langs->trans("MembersList");
+			if ($status != '') {
+				if ($status == '-1,1') {
+					$titre = $langs->trans("MembersListQualified");
+				} elseif ($status == '-1') {
+					$titre = $langs->trans("MembersListToValid");
+				} elseif ($status == '1' && !$filter) {
+					$titre = $langs->trans("MembersListValid");
+				} elseif ($status == '1' && $filter == 'uptodate') {
+					$titre = $langs->trans("MembersListUpToDate");
+				} elseif ($status == '1' && $filter == 'outofdate') {
+					$titre = $langs->trans("MembersListNotUpToDate");
+				} elseif ($status == '0') {
+					$titre = $langs->trans("MembersListResiliated");
+				}
+			} elseif ($action == 'search') {
+				$titre = $langs->trans("MembersListQualified");
+			}
+
+			if ($type > 0) {
 				$membertype = new AdherentType($db);
-		        $result = $membertype->fetch($type);
+				$result = $membertype->fetch($type);
 				$titre .= " (".$membertype->label.")";
-		    }
+			}
 
-		    $param = "&rowid=".$object->id;
-		    if (!empty($status))			$param .= "&status=".$status;
-		    if (!empty($search_lastname))	$param .= "&search_lastname=".$search_lastname;
-		    if (!empty($search_firstname))	$param .= "&search_firstname=".$search_firstname;
-		    if (!empty($search_login))		$param .= "&search_login=".$search_login;
-		    if (!empty($search_email))		$param .= "&search_email=".$search_email;
-		    if (!empty($filter))			$param .= "&filter=".$filter;
+			$param = "&rowid=".$object->id;
+			if (!empty($status))			$param .= "&status=".$status;
+			if (!empty($search_lastname))	$param .= "&search_lastname=".$search_lastname;
+			if (!empty($search_firstname))	$param .= "&search_firstname=".$search_firstname;
+			if (!empty($search_login))		$param .= "&search_login=".$search_login;
+			if (!empty($search_email))		$param .= "&search_email=".$search_email;
+			if (!empty($filter))			$param .= "&filter=".$filter;
 
-		    if ($sall) {
-		        print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
-		    }
+			if ($sall) {
+				print $langs->trans("Filter")." (".$langs->trans("Lastname").", ".$langs->trans("Firstname").", ".$langs->trans("EMail").", ".$langs->trans("Address")." ".$langs->trans("or")." ".$langs->trans("Town")."): ".$sall;
+			}
 
 			print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
-            print '<input type="hidden" name="token" value="'.newToken().'">';
+			print '<input type="hidden" name="token" value="'.newToken().'">';
 			print '<input class="flat" type="hidden" name="rowid" value="'.$object->id.'" size="12"></td>';
 
 			print '<br>';
-            print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
+			print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords);
 
-            $moreforfilter = '';
+			$moreforfilter = '';
 
-            print '<div class="div-table-responsive">';
-            print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
+			print '<div class="div-table-responsive">';
+			print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
-            // Fields title search
+			// Fields title search
 			print '<tr class="liste_titre_filter">';
 
 			print '<td class="liste_titre left">';
@@ -590,105 +590,105 @@ if ($rowid > 0) {
 
 			print '<td class="liste_titre right" colspan="2">';
 			print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" name="button_search" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
-		    print '&nbsp; ';
-		    print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
+			print '&nbsp; ';
+			print '<input type="image" class="liste_titre" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" name="button_removefilter" value="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'" title="'.dol_escape_htmltag($langs->trans("RemoveFilter")).'">';
 			print '</td>';
 
 			print "</tr>\n";
 
 			print '<tr class="liste_titre">';
-            print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
-		    print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
-		    print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
-		    print "</tr>\n";
-
-		    while ($i < $num && $i < $conf->liste_limit) {
-		        $objp = $db->fetch_object($resql);
-
-		        $datefin = $db->jdate($objp->datefin);
-
-		        $adh = new Adherent($db);
-		        $adh->lastname = $objp->lastname;
-		        $adh->firstname = $objp->firstname;
-
-		        // Lastname
-		        print '<tr class="oddeven">';
-		        if ($objp->company != '') {
-		            print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
-		        } else {
-		            print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
-		        }
-
-		        // Login
-		        print "<td>".$objp->login."</td>\n";
-
-		        // Type
-		        /*print '<td class="nowrap">';
+			print_liste_field_titre("NameSlashCompany", $_SERVER["PHP_SELF"], "d.lastname", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("Login", $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("MemberNature", $_SERVER["PHP_SELF"], "d.morphy", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "d.email", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "d.statut,d.datefin", $param, "", "", $sortfield, $sortorder);
+			print_liste_field_titre("EndSubscription", $_SERVER["PHP_SELF"], "d.datefin", $param, "", 'align="center"', $sortfield, $sortorder);
+			print_liste_field_titre("Action", $_SERVER["PHP_SELF"], "", $param, "", 'width="60" align="center"', $sortfield, $sortorder);
+			print "</tr>\n";
+
+			while ($i < $num && $i < $conf->liste_limit) {
+				$objp = $db->fetch_object($resql);
+
+				$datefin = $db->jdate($objp->datefin);
+
+				$adh = new Adherent($db);
+				$adh->lastname = $objp->lastname;
+				$adh->firstname = $objp->firstname;
+
+				// Lastname
+				print '<tr class="oddeven">';
+				if ($objp->company != '') {
+					print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 20).' / '.dol_trunc($objp->societe, 12).'</a></td>'."\n";
+				} else {
+					print '<td><a href="card.php?rowid='.$objp->rowid.'">'.img_object($langs->trans("ShowMember"), "user").' '.$adh->getFullName($langs, 0, -1, 32).'</a></td>'."\n";
+				}
+
+				// Login
+				print "<td>".$objp->login."</td>\n";
+
+				// Type
+				/*print '<td class="nowrap">';
 		        $membertypestatic->id=$objp->type_id;
 		        $membertypestatic->label=$objp->type;
 		        print $membertypestatic->getNomUrl(1,12);
 		        print '</td>';
 				*/
 
-		        // Moral/Physique
-		        print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
-
-		        // EMail
-		        print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
-
-		        // Statut
-		        print '<td class="nowrap">';
-		        print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
-		        print "</td>";
-
-		        // Date end subscription
-		        if ($datefin) {
-			        print '<td class="nowrap center">';
-		            if ($datefin < dol_now() && $objp->status > 0) {
-		                print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
-		            } else {
-		                print dol_print_date($datefin, 'day');
-		            }
-		            print '</td>';
-		        } else {
-			        print '<td class="nowrap left">';
-			        if ($objp->subscription == 'yes') {
-		                print $langs->trans("SubscriptionNotReceived");
-		                if ($objp->status > 0) print " ".img_warning();
-			        } else {
-			            print '&nbsp;';
-			        }
-		            print '</td>';
-		        }
-
-		        // Actions
-		        print '<td class="center">';
+				// Moral/Physique
+				print "<td>".$adh->getmorphylib($objp->morphy)."</td>\n";
+
+				// EMail
+				print "<td>".dol_print_email($objp->email, 0, 0, 1)."</td>\n";
+
+				// Statut
+				print '<td class="nowrap">';
+				print $adh->LibStatut($objp->status, $objp->subscription, $datefin, 2);
+				print "</td>";
+
+				// Date end subscription
+				if ($datefin) {
+					print '<td class="nowrap center">';
+					if ($datefin < dol_now() && $objp->status > 0) {
+						print dol_print_date($datefin, 'day')." ".img_warning($langs->trans("SubscriptionLate"));
+					} else {
+						print dol_print_date($datefin, 'day');
+					}
+					print '</td>';
+				} else {
+					print '<td class="nowrap left">';
+					if ($objp->subscription == 'yes') {
+						print $langs->trans("SubscriptionNotReceived");
+						if ($objp->status > 0) print " ".img_warning();
+					} else {
+						print '&nbsp;';
+					}
+					print '</td>';
+				}
+
+				// Actions
+				print '<td class="center">';
 				if ($user->rights->adherent->creer) {
 					print '<a class="editfielda" href="card.php?rowid='.$objp->rowid.'&action=edit&backtopage='.urlencode($_SERVER["PHP_SELF"].'?rowid='.$object->id).'">'.img_edit().'</a>';
 				}
 				print '&nbsp;';
 				if ($user->rights->adherent->supprimer) {
 					print '<a href="card.php?rowid='.$objp->rowid.'&action=resign">'.img_picto($langs->trans("Resiliate"), 'disable.png').'</a>';
-		        }
+				}
 				print "</td>";
 
-		        print "</tr>\n";
-		        $i++;
-		    }
+				print "</tr>\n";
+				$i++;
+			}
 
-		    print "</table>\n";
-            print '</div>';
-            print '</form>';
+			print "</table>\n";
+			print '</div>';
+			print '</form>';
 
 			if ($num > $conf->liste_limit) {
-			    print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
+				print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, '');
 			}
 		} else {
-		    dol_print_error($db);
+			dol_print_error($db);
 		}
 	}
 
@@ -719,18 +719,18 @@ if ($rowid > 0) {
 		print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" size="40" value="'.dol_escape_htmltag($object->label).'"></td></tr>';
 
 		print '<tr><td>'.$langs->trans("Status").'</td><td>';
-    	print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
-    	print '</td></tr>';
-
-        // Morphy
-        $morphys[""] = $langs->trans("MorPhy");
-        $morphys["phy"] = $langs->trans("Physical");
-        $morphys["mor"] = $langs->trans("Moral");
-        print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
-        print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
-        print "</td></tr>";
-
-    	print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
+		print $form->selectarray('status', array('0'=>$langs->trans('ActivityCeased'), '1'=>$langs->trans('InActivity')), $object->status);
+		print '</td></tr>';
+
+		// Morphy
+		$morphys[""] = $langs->trans("MorPhy");
+		$morphys["phy"] = $langs->trans("Physical");
+		$morphys["mor"] = $langs->trans("Moral");
+		print '<tr><td><span>'.$langs->trans("MemberNature").'</span></td><td>';
+		print $form->selectarray("morphy", $morphys, GETPOSTISSET("morphy") ? GETPOST("morphy") : $object->morphy);
+		print "</td></tr>";
+
+		print '<tr><td>'.$langs->trans("SubscriptionRequired").'</td><td>';
 		print $form->selectyesno("subscription", $object->subscription, 1);
 		print '</td></tr>';
 

+ 161 - 161
htdocs/admin/bank.php

@@ -35,7 +35,7 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
 $langs->loadLangs(array("admin", "companies", "bills", "other", "banks"));
 
 if (!$user->admin)
-    accessforbidden();
+	accessforbidden();
 
 $action = GETPOST('action', 'alpha');
 $actionsave = GETPOST('save', 'alpha');
@@ -240,31 +240,31 @@ $i = 0;
 
 $nbofbank = count($bankorder);
 while ($i < $nbofbank) {
-    print '<tr class="oddeven">';
-    print '<td>'.$bankorder[$i][0]."</td><td>\n";
-    print $bankorder[$i][1];
-    print '</td>';
-    print '<td class="nowrap">';
-    $tmparray = explode(' ', $bankorder[$i][2]);
-    foreach ($tmparray as $key => $val) {
-        if ($key > 0)
-            print ', ';
-        print $langs->trans($val);
-    }
-    print "</td>\n";
-
-    if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
-        print '<td class="center">';
-        print img_picto($langs->trans("Activated"), 'on');
-        print '</td>';
-    } else {
-        print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
-        print img_picto($langs->trans("Disabled"), 'off');
-        print '</a></td>';
-    }
-    print '<td>&nbsp;</td>';
-    print '</tr>'."\n";
-    $i++;
+	print '<tr class="oddeven">';
+	print '<td>'.$bankorder[$i][0]."</td><td>\n";
+	print $bankorder[$i][1];
+	print '</td>';
+	print '<td class="nowrap">';
+	$tmparray = explode(' ', $bankorder[$i][2]);
+	foreach ($tmparray as $key => $val) {
+		if ($key > 0)
+			print ', ';
+		print $langs->trans($val);
+	}
+	print "</td>\n";
+
+	if ($conf->global->BANK_SHOW_ORDER_OPTION == $i) {
+		print '<td class="center">';
+		print img_picto($langs->trans("Activated"), 'on');
+		print '</td>';
+	} else {
+		print '<td class="center"><a href="'.$_SERVER['PHP_SELF'].'?action=setbankorder&amp;value='.$i.'">';
+		print img_picto($langs->trans("Disabled"), 'off');
+		print '</a></td>';
+	}
+	print '<td>&nbsp;</td>';
+	print '</tr>'."\n";
+	$i++;
 }
 
 print '</table>'."\n";
@@ -287,15 +287,15 @@ $sql .= " WHERE type = '".$type."'";
 $sql .= " AND entity = ".$conf->entity;
 $resql = $db->query($sql);
 if ($resql) {
-    $i = 0;
-    $num_rows = $db->num_rows($resql);
-    while ($i < $num_rows) {
-        $array = $db->fetch_array($resql);
-        array_push($def, $array[0]);
-        $i++;
-    }
+	$i = 0;
+	$num_rows = $db->num_rows($resql);
+	while ($i < $num_rows) {
+		$array = $db->fetch_array($resql);
+		array_push($def, $array[0]);
+		$i++;
+	}
 } else {
-    dol_print_error($db);
+	dol_print_error($db);
 }
 
 print "<table class=\"noborder\" width=\"100%\">\n";
@@ -311,100 +311,100 @@ print "</tr>\n";
 clearstatcache();
 
 foreach ($dirmodels as $reldir) {
-    foreach (array('', '/doc') as $valdir) {
-        $dir = dol_buildpath($reldir."core/modules/bank".$valdir);
-
-        if (is_dir($dir)) {
-            $handle = opendir($dir);
-            if (is_resource($handle)) {
-                while (($file = readdir($handle)) !== false) {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file) {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
-                        if (file_exists($dir.'/'.$file)) {
-                            $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">';
-                                print(empty($module->name) ? $name : $module->name);
-                                print "</td><td>\n";
-                                if (method_exists($module, 'info'))
-                                    print $module->info($langs);
-                                else print $module->description;
-                                print '</td>';
-
-                                // Active
-                                if (in_array($name, $def)) {
-                                    print '<td class="center">'."\n";
-                                    print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-                                    print img_picto($langs->trans("Enabled"), 'switch_on');
-                                    print '</a>';
-                                    print '</td>';
-                                } else {
-                                    print '<td class="center">'."\n";
-                                    print '<a class="reposition" 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">';
-                                if ($conf->global->BANKADDON_PDF == $name) {
-                                    print img_picto($langs->trans("Default"), 'on');
-                                } else {
-                                    print '<a class="reposition" 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"));
-                                if ($module->type == 'pdf') {
-                                    $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-                                }
-                                $htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-                                $htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
-                                //$htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
-                                //$htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
-                                $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-                                // $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
-                                // $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
-                                //$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
-
-                                print '<td class="center">';
-                                print $form->textwithpicto('', $htmltooltip, 1, 0);
-                                print '</td>';
-
-                                // Preview
-                                print '<td class="center">';
-                                if ($module->type == 'pdf') {
-                                    print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-                                } else {
-                                    print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-                                }
-                                print '</td>';
-
-                                print "</tr>\n";
-                            }
-                        }
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir) {
+		$dir = dol_buildpath($reldir."core/modules/bank".$valdir);
+
+		if (is_dir($dir)) {
+			$handle = opendir($dir);
+			if (is_resource($handle)) {
+				while (($file = readdir($handle)) !== false) {
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file) {
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
+						if (file_exists($dir.'/'.$file)) {
+							$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">';
+								print(empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info'))
+									print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def)) {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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">';
+								if ($conf->global->BANKADDON_PDF == $name) {
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf') {
+									$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+								}
+								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+								$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+								//$htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
+								//$htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								// $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
+								// $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+								//$htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf') {
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 print '</table>';
 //}
@@ -423,38 +423,38 @@ print $langs->trans('BankColorizeMovementDesc');
 print "</td>";
 // Active
 if ($conf->global->BANK_COLORIZE_MOVEMENT) {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
-    print img_picto($langs->trans("Enabled"), 'switch_on');
-    print '</a>';
-    print '</td>';
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetbankcolorizemovement">';
+	print img_picto($langs->trans("Enabled"), 'switch_on');
+	print '</a>';
+	print '</td>';
 } else {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-    print "</td>";
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setbankcolorizemovement">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	print "</td>";
 }
 
 print "</tr>\n";
 
 if (!empty($conf->global->BANK_COLORIZE_MOVEMENT))
 {
-    $i = 1;
-    while ($i <= 2)
-    {
-        $key = $i;
-        $color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
-
-        print '<tr class="oddeven">';
-
-        // Label
-        print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
-        // Color
-        print '<td class="nowrap right">';
-        print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
-        print '</td>';
-        print "</tr>";
-        $i++;
-    }
+	$i = 1;
+	while ($i <= 2)
+	{
+		$key = $i;
+		$color = 'BANK_COLORIZE_MOVEMENT_COLOR'.$key;
+
+		print '<tr class="oddeven">';
+
+		// Label
+		print '<td colspan="4" width="180" class="nowrap">'.$langs->trans("BankColorizeMovementName".$key)."</td>";
+		// Color
+		print '<td class="nowrap right">';
+		print $formother->selectColor((GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) ?GETPOST("BANK_COLORIZE_MOVEMENT_COLOR".$key) : $conf->global->$color), "BANK_COLORIZE_MOVEMENT_COLOR".$key, 'bankmovementcolorconfig', 1, '', 'right hideifnotset');
+		print '</td>';
+		print "</tr>";
+		$i++;
+	}
 }
 print '</table>';
 
@@ -482,15 +482,15 @@ print $langs->trans('AutoReportLastAccountStatement');
 print '</td>';
 // Active
 if ($conf->global->BANK_REPORT_LAST_NUM_RELEVE) {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
-    print img_picto($langs->trans("Enabled"), 'switch_on');
-    print '</a>';
-    print '</td>';
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=unsetreportlastnumreleve">';
+	print img_picto($langs->trans("Enabled"), 'switch_on');
+	print '</a>';
+	print '</td>';
 } else {
-    print '<td class="center">'."\n";
-    print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-    print "</td>";
+	print '<td class="center">'."\n";
+	print '<a href="'.$_SERVER["PHP_SELF"].'?action=setreportlastnumreleve">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	print "</td>";
 }
 
 print "</tr>\n";

+ 141 - 141
htdocs/admin/bom.php

@@ -55,11 +55,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -72,7 +72,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/bom/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -110,7 +110,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
+		if ($conf->global->BOM_ADDON_PDF == "$value") dolibarr_del_const($db, 'BOM_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -144,11 +144,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_BOM_FREE_TEXT')
 {
 	$freetext = GETPOST("BOM_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -158,11 +158,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -211,7 +211,7 @@ foreach ($dirmodels as $reldir)
 		{
 			while (($file = readdir($handle)) !== false)
 			{
-			    if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
+				if (substr($file, 0, 8) == 'mod_bom_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
 					$file = substr($file, 0, dol_strlen($file) - 4);
 
@@ -229,13 +229,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->BOM_ADDON == $file)
@@ -256,16 +256,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$bom->type = 0;
 						$nextval = $module->getNextValue($mysoc, $bom);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -324,108 +324,108 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/bom".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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">';
-	                            if ($conf->global->BOM_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/bom".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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">';
+								if ($conf->global->BOM_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -457,11 +457,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("
 $variablename = 'BOM_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 144 - 144
htdocs/admin/boxes.php

@@ -48,99 +48,99 @@ $boxes = array();
 
 if ($action == 'addconst')
 {
-    dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity);
-    dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_BOXES_MAXLINES", $_POST["MAIN_BOXES_MAXLINES"], '', 0, '', $conf->entity);
+	dolibarr_set_const($db, "MAIN_ACTIVATE_FILECACHE", $_POST["MAIN_ACTIVATE_FILECACHE"], 'chaine', 0, '', $conf->entity);
 }
 
 if ($action == 'add') {
-    $error = 0;
-    $db->begin();
-    if (isset($_POST['boxid']) && is_array($_POST['boxid']))
-    {
-        foreach ($_POST['boxid'] as $boxid)
-        {
-            if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0)	// 0=Home, 1=...
-            {
-                $pos = $boxid['pos'];
-
-                // Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
-                $distinctfkuser = array();
-                if (!$error)
-                {
-                    $sql = "SELECT fk_user";
-                    $sql .= " FROM ".MAIN_DB_PREFIX."user_param";
-                    $sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
-                    $sql .= " AND entity = ".$conf->entity;
-                    dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
-                    $resql = $db->query($sql);
-                    if ($resql)
-                    {
-                        $num = $db->num_rows($resql);
-                        $i = 0;
-                        while ($i < $num)
-                        {
-                            $obj = $db->fetch_object($resql);
-                            $distinctfkuser[$obj->fk_user] = $obj->fk_user;
-                            $i++;
-                        }
-                    } else {
-                        setEventMessages($db->lasterror(), null, 'errors');
-                        $error++;
-                    }
-                }
-
-                $distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
-
-                foreach ($distinctfkuser as $fk_user)
-                {
-                    if (!$error && $fk_user != '')
-                    {
-                    	$arrayofexistingboxid = array();
-                        $nbboxonleft = $nbboxonright = 0;
-                        $sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
-                        $sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
-                        dol_syslog("boxes.php activate box", LOG_DEBUG);
-                        $resql = $db->query($sql);
-                        if ($resql)
-                        {
-                            while ($obj = $db->fetch_object($resql))
-                            {
-                                $boxorder = $obj->box_order;
-                                if (preg_match('/A/', $boxorder)) $nbboxonleft++;
-                                if (preg_match('/B/', $boxorder)) $nbboxonright++;
-                                $arrayofexistingboxid[$obj->box_id] = 1;
-                            }
-                        } else dol_print_error($db);
-
-                        if (empty($arrayofexistingboxid[$boxid['value']])) {
-	                        $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
-	                        $sql .= "box_id, position, box_order, fk_user, entity";
-	                        $sql .= ") values (";
-	                        $sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
-	                        $sql .= ")";
-
-	                        dol_syslog("boxes.php activate box", LOG_DEBUG);
-	                        $resql = $db->query($sql);
-	                        if (!$resql)
-	                        {
-	                            setEventMessages($db->lasterror(), null, 'errors');
-	                            $error++;
-	                        }
-                        } else {
-                        	dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
-                        }
-                    }
-                }
-            }
-        }
-    }
-    if (!$error)
-    {
-        $db->commit();
-        $action = '';
-    } else {
-        $db->rollback();
-    }
+	$error = 0;
+	$db->begin();
+	if (isset($_POST['boxid']) && is_array($_POST['boxid']))
+	{
+		foreach ($_POST['boxid'] as $boxid)
+		{
+			if (is_numeric($boxid['pos']) && $boxid['pos'] >= 0)	// 0=Home, 1=...
+			{
+				$pos = $boxid['pos'];
+
+				// Initialize distinct fk_user with all already existing values of fk_user (user that use a personalized view of boxes for page "pos")
+				$distinctfkuser = array();
+				if (!$error)
+				{
+					$sql = "SELECT fk_user";
+					$sql .= " FROM ".MAIN_DB_PREFIX."user_param";
+					$sql .= " WHERE param = 'MAIN_BOXES_".$db->escape($pos)."' AND value = '1'";
+					$sql .= " AND entity = ".$conf->entity;
+					dol_syslog("boxes.php search fk_user to activate box for", LOG_DEBUG);
+					$resql = $db->query($sql);
+					if ($resql)
+					{
+						$num = $db->num_rows($resql);
+						$i = 0;
+						while ($i < $num)
+						{
+							$obj = $db->fetch_object($resql);
+							$distinctfkuser[$obj->fk_user] = $obj->fk_user;
+							$i++;
+						}
+					} else {
+						setEventMessages($db->lasterror(), null, 'errors');
+						$error++;
+					}
+				}
+
+				$distinctfkuser['0'] = '0'; // Add entry for fk_user = 0. We must use string as key and val
+
+				foreach ($distinctfkuser as $fk_user)
+				{
+					if (!$error && $fk_user != '')
+					{
+						$arrayofexistingboxid = array();
+						$nbboxonleft = $nbboxonright = 0;
+						$sql = "SELECT box_id, box_order FROM ".MAIN_DB_PREFIX."boxes";
+						$sql .= " WHERE position = ".$pos." AND fk_user = ".$fk_user." AND entity = ".$conf->entity;
+						dol_syslog("boxes.php activate box", LOG_DEBUG);
+						$resql = $db->query($sql);
+						if ($resql)
+						{
+							while ($obj = $db->fetch_object($resql))
+							{
+								$boxorder = $obj->box_order;
+								if (preg_match('/A/', $boxorder)) $nbboxonleft++;
+								if (preg_match('/B/', $boxorder)) $nbboxonright++;
+								$arrayofexistingboxid[$obj->box_id] = 1;
+							}
+						} else dol_print_error($db);
+
+						if (empty($arrayofexistingboxid[$boxid['value']])) {
+							$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes (";
+							$sql .= "box_id, position, box_order, fk_user, entity";
+							$sql .= ") values (";
+							$sql .= $boxid['value'].", ".$pos.", '".(($nbboxonleft > $nbboxonright) ? 'B01' : 'A01')."', ".$fk_user.", ".$conf->entity;
+							$sql .= ")";
+
+							dol_syslog("boxes.php activate box", LOG_DEBUG);
+							$resql = $db->query($sql);
+							if (!$resql)
+							{
+								setEventMessages($db->lasterror(), null, 'errors');
+								$error++;
+							}
+						} else {
+							dol_syslog("boxes.php activate box - already exists in database", LOG_DEBUG);
+						}
+					}
+				}
+			}
+		}
+	}
+	if (!$error)
+	{
+		$db->commit();
+		$action = '';
+	} else {
+		$db->rollback();
+	}
 }
 
 if ($action == 'delete')
@@ -150,23 +150,23 @@ if ($action == 'delete')
 
 	$resql = $db->query($sql);
 	$obj = $db->fetch_object($resql);
-    if (!empty($obj->box_id))
-    {
-	    $db->begin();
+	if (!empty($obj->box_id))
+	{
+		$db->begin();
 
-    	// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
-        //	$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
-        //	$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
-        //	$resql = $db->query($sql);
+		// Remove all personalized setup when a box is activated or disabled (why removing all ? We removed only removed boxes)
+		//	$sql = "DELETE FROM ".MAIN_DB_PREFIX."user_param";
+		//	$sql.= " WHERE param LIKE 'MAIN_BOXES_%'";
+		//	$resql = $db->query($sql);
 
-	    $sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
-	    $sql .= " WHERE entity = ".$conf->entity;
-    	$sql .= " AND box_id=".$obj->box_id;
+		$sql = "DELETE FROM ".MAIN_DB_PREFIX."boxes";
+		$sql .= " WHERE entity = ".$conf->entity;
+		$sql .= " AND box_id=".$obj->box_id;
 
-    	$resql = $db->query($sql);
+		$resql = $db->query($sql);
 
-    	$db->commit();
-    }
+		$db->commit();
+	}
 }
 
 if ($action == 'switch')
@@ -184,14 +184,14 @@ if ($action == 'switch')
 	$resultupdateto = 0;
 	if (is_object($objfrom) && is_object($objto))
 	{
-	    $newfirst = $objto->box_order;
+		$newfirst = $objto->box_order;
 		$newsecond = $objfrom->box_order;
-	    if ($newfirst == $newsecond)
-	    {
-	         $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
-	         $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
-	         $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
-	    }
+		if ($newfirst == $newsecond)
+		{
+			 $newsecondchar = preg_replace('/[0-9]+/', '', $newsecond);
+			 $newsecondnum = preg_replace('/[a-zA-Z]+/', '', $newsecond);
+			 $newsecond = sprintf("%s%02d", $newsecondchar ? $newsecondchar : 'A', $newsecondnum + 1);
+		}
 		$sql = "UPDATE ".MAIN_DB_PREFIX."boxes SET box_order='".$newfirst."' WHERE rowid=".$objfrom->rowid;
 		dol_syslog($sql);
 		$resultupdatefrom = $db->query($sql);
@@ -268,7 +268,7 @@ if ($resql)
 
 	if ($decalage)
 	{
-	    // If we have renumbered, we correct the field box_order
+		// If we have renumbered, we correct the field box_order
 		// This occurs just after an insert.
 		$sql = "SELECT box_order";
 		$sql .= " FROM ".MAIN_DB_PREFIX."boxes";
@@ -339,34 +339,34 @@ print "</tr>\n";
 
 foreach ($boxtoadd as $box)
 {
-    if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
-    {
-        $logo = $box->boximg;
-    } else {
-        $logo = preg_replace("/^object_/i", "", $box->boximg);
-    }
-
-    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
-    print '<tr class="oddeven">'."\n";
-    print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
-    if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
-    print '</td>'."\n";
-    print '<td>';
-    if ($box->note == '(WarningUsingThisBoxSlowDown)')
-    {
-    	$langs->load("errors");
-    	print $langs->trans("WarningUsingThisBoxSlowDown");
-    } else print ($box->note ? $box->note : '&nbsp;');
-    print '</td>'."\n";
-    print '<td>'.$box->sourcefile.'</td>'."\n";
-
-    // For each possible position, an activation link is displayed if the box is not already active for that position
-    print '<td class="center">';
-    print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
-    print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
-    print '</td>';
-
-    print '</tr>'."\n";
+	if (preg_match('/^([^@]+)@([^@]+)$/i', $box->boximg))
+	{
+		$logo = $box->boximg;
+	} else {
+		$logo = preg_replace("/^object_/i", "", $box->boximg);
+	}
+
+	print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+	print '<tr class="oddeven">'."\n";
+	print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
+	if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
+	print '</td>'."\n";
+	print '<td>';
+	if ($box->note == '(WarningUsingThisBoxSlowDown)')
+	{
+		$langs->load("errors");
+		print $langs->trans("WarningUsingThisBoxSlowDown");
+	} else print ($box->note ? $box->note : '&nbsp;');
+	print '</td>'."\n";
+	print '<td>'.$box->sourcefile.'</td>'."\n";
+
+	// For each possible position, an activation link is displayed if the box is not already active for that position
+	print '<td class="center">';
+	print $form->selectarray("boxid[".$box->box_id."][pos]", $pos_name, -1, 1, 0, 0, '', 1)."\n";
+	print '<input type="hidden" name="boxid['.$box->box_id.'][value]" value="'.$box->box_id.'">'."\n";
+	print '</td>';
+
+	print '</tr>'."\n";
 }
 if (!count($boxtoadd) && count($boxactivated))
 {
@@ -408,7 +408,7 @@ foreach ($boxactivated as $key => $box)
 		$logo = preg_replace("/^object_/i", "", $box->boximg);
 	}
 
-    print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
+	print "\n".'<!-- Box '.$box->boxcode.' -->'."\n";
 	print '<tr class="oddeven">';
 	print '<td>'.img_object("", $logo, 'height="14px"').' '.$langs->transnoentitiesnoconv($box->boxlabel);
 	if (!empty($box->class) && preg_match('/graph_/', $box->class)) print ' ('.$langs->trans("Graph").')';
@@ -465,10 +465,10 @@ print '</tr>';
 
 // Activate FileCache - Developement
 if ($conf->global->MAIN_FEATURES_LEVEL == 2 || !empty($conf->global->MAIN_ACTIVATE_FILECACHE)) {
-    print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
-    print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
-    print '</td>';
-    print '</tr>';
+	print '<tr class="oddeven"><td width="35%">'.$langs->trans("EnableFileCache").'</td><td>';
+	print $form->selectyesno('MAIN_ACTIVATE_FILECACHE', $conf->global->MAIN_ACTIVATE_FILECACHE, 1);
+	print '</td>';
+	print '</tr>';
 }
 
 print '</table>';

+ 169 - 169
htdocs/admin/commande.php

@@ -64,11 +64,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -81,7 +81,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/commande/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -119,7 +119,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
+		if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -153,11 +153,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_ORDER_FREE_TEXT')
 {
 	$freetext = GETPOST("ORDER_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -167,21 +167,21 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == "setshippableiconinlist") {
-    // Activate Set Shippable Icon In List
-    $setshippableiconinlist = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
-    if (!$res > 0) $error++;
-    if (!$error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	// Activate Set Shippable Icon In List
+	$setshippableiconinlist = GETPOST('value', 'int');
+	$res = dolibarr_set_const($db, "SHIPPABLE_ORDER_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
+	if (!$res > 0) $error++;
+	if (!$error) {
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setribchq')
 {
 	$rib = GETPOST('rib', 'alpha');
@@ -203,31 +203,31 @@ elseif ($action == 'setdoc')
 // Activate ask for payment bank
 elseif ($action == 'set_BANK_ASK_PAYMENT_BANK_DURING_ORDER')
 {
-    $res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "BANK_ASK_PAYMENT_BANK_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
-    if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	if (!$error)
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 // Activate ask for warehouse
 elseif ($action == 'set_WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER')
 {
-    $res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "WAREHOUSE_ASK_WAREHOUSE_DURING_ORDER", $value, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
-    if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	if (!$error)
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -294,13 +294,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->COMMANDE_ADDON == $file)
@@ -321,16 +321,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$commande->type = 0;
 						$nextval = $module->getNextValue($mysoc, $commande);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -389,113 +389,113 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/commande".$valdir;
-    	$dir = dol_buildpath($realpath);
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/commande".$valdir;
+		$dir = dol_buildpath($realpath);
 
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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">';
-	                            if ($conf->global->COMMANDE_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		//$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
-					    		//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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">';
+								if ($conf->global->COMMANDE_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								//$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
+								//$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -636,11 +636,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnOrders"), $langs->trans
 $variablename = 'ORDER_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 1 - 1
htdocs/admin/company.php

@@ -109,7 +109,7 @@ if (($action == 'update' && !GETPOST("cancel", 'alpha'))
 
 	foreach ($arrayofimages as $varforimage)
 	{
-		if ($_FILES[$varforimage]["name"] && ! preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) {	// Logo can be used on a lot of different places. Only jpg and png can be supported.
+		if ($_FILES[$varforimage]["name"] && !preg_match('/(\.jpeg|\.jpg|\.png)$/i', $_FILES[$varforimage]["name"])) {	// Logo can be used on a lot of different places. Only jpg and png can be supported.
 			$langs->load("errors");
 			setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
 			break;

+ 138 - 138
htdocs/admin/contract.php

@@ -41,7 +41,7 @@ $type = 'contract';
 
 if (empty($conf->global->CONTRACT_ADDON))
 {
-    $conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
+	$conf->global->CONTRACT_ADDON = 'mod_contract_serpis';
 }
 
 
@@ -53,18 +53,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconst = GETPOST('maskconstcontract', 'alpha');
-    $maskvalue = GETPOST('maskcontract', 'alpha');
-    if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
+	$maskconst = GETPOST('maskconstcontract', 'alpha');
+	$maskvalue = GETPOST('maskcontract', 'alpha');
+	if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen') // For contract
 {
 	$modele = GETPOST('module', 'alpha');
@@ -77,7 +77,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/contract/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -115,7 +115,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
+		if ($conf->global->CONTRACT_ADDON_PDF == "$value") dolibarr_del_const($db, 'CONTRACT_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -149,17 +149,17 @@ elseif ($action == 'setdoc')
 	$draft = GETPOST('CONTRACT_DRAFT_WATERMARK', 'alpha');
 	$res2 = dolibarr_set_const($db, "CONTRACT_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 
-    $value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
-    $res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
+	$value = GETPOST('activate_hideClosedServiceByDefault', 'alpha');
+	$res3 = dolibarr_set_const($db, "CONTRACT_HIDE_CLOSED_SERVICES_BY_DEFAULT", $value, 'chaine', 0, '', $conf->entity);
 
 	if (!$res1 > 0 || !$res2 > 0 || !$res3 > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $contract);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -319,111 +319,111 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/contract".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->CONTRACT_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/contract".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->CONTRACT_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -457,11 +457,11 @@ print '<br>';
 $variablename = 'CONTRACT_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td></tr>'."\n";
 

+ 46 - 46
htdocs/admin/emailcollector_card.php

@@ -165,19 +165,19 @@ if (GETPOST('addoperation', 'alpha'))
 
 if ($action == 'updateoperation')
 {
-    $emailcollectoroperation = new EmailCollectorAction($db);
-    $emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
+	$emailcollectoroperation = new EmailCollectorAction($db);
+	$emailcollectoroperation->fetch(GETPOST('rowidoperation2', 'int'));
 
-    $emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
+	$emailcollectoroperation->actionparam = GETPOST('operationparam2', 'none');
 
-    $result = $emailcollectoroperation->update($user);
+	$result = $emailcollectoroperation->update($user);
 
-    if ($result > 0)
-    {
-        $object->fetchActions();
-    } else {
-        setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
-    }
+	if ($result > 0)
+	{
+		$object->fetchActions();
+	} else {
+		setEventMessages($emailcollectoroperation->errors, $emailcollectoroperation->error, 'errors');
+	}
 }
 if ($action == 'deleteoperation')
 {
@@ -199,11 +199,11 @@ if ($action == 'confirm_collect')
 	$res = $object->doCollectOneCollector();
 	if ($res > 0)
 	{
-	    $debuginfo = $object->debuginfo;
-	    setEventMessages($object->lastresult, null, 'mesgs');
+		$debuginfo = $object->debuginfo;
+		setEventMessages($object->lastresult, null, 'mesgs');
 	} else {
-	    $debuginfo = $object->debuginfo;
-	    setEventMessages($object->error, null, 'errors');
+		$debuginfo = $object->debuginfo;
+		setEventMessages($object->error, null, 'errors');
 	}
 
 	$action = '';
@@ -475,27 +475,27 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<tr class="oddeven">';
 	print '<td>';
 	$arrayoftypes = array(
-	    'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
-	    'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
-	    // disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
-	    //'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'),                // HEADER key value
-	    //'X1'=>'---',
-	    //'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
-	    //'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
-	    'X2'=>'---',
-	    'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
-	    'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
-	    'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
-	    'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
-	    'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
-	    'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
-	    'X3'=>'---',
-	    'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
-	    'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1),
+		'from'=>array('label'=>'MailFrom', 'data-placeholder'=>$langs->trans('SearchString')),
+		'to'=>array('label'=>'MailTo', 'data-placeholder'=>$langs->trans('SearchString')),
+		'cc'=>array('label'=>'Cc', 'data-placeholder'=>$langs->trans('SearchString')),
+		'bcc'=>array('label'=>'Bcc', 'data-placeholder'=>$langs->trans('SearchString')),
+		'subject'=>array('label'=>'Subject', 'data-placeholder'=>$langs->trans('SearchString')),
+		'body'=>array('label'=>'Body', 'data-placeholder'=>$langs->trans('SearchString')),
+		// disabled because PHP imap_search is not compatible IMAPv4, only IMAPv2
+		//'header'=>array('label'=>'Header', 'data-placeholder'=>'HeaderKey SearchString'),                // HEADER key value
+		//'X1'=>'---',
+		//'notinsubject'=>array('label'=>'SubjectNotIn', 'data-placeholder'=>'SearchString'),
+		//'notinbody'=>array('label'=>'BodyNotIn', 'data-placeholder'=>'SearchString'),
+		'X2'=>'---',
+		'seen'=>array('label'=>'AlreadyRead', 'data-noparam'=>1),
+		'unseen'=>array('label'=>'NotRead', 'data-noparam'=>1),
+		'unanswered'=>array('label'=>'Unanswered', 'data-noparam'=>1),
+		'answered'=>array('label'=>'Answered', 'data-noparam'=>1),
+		'smaller'=>array('label'=>'SmallerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
+		'larger'=>array('label'=>'LargerThan', 'data-placeholder'=>$langs->trans('NumberOfBytes')),
+		'X3'=>'---',
+		'withtrackingid'=>array('label'=>'WithDolTrackingID', 'data-noparam'=>1),
+		'withouttrackingid'=>array('label'=>'WithoutDolTrackingID', 'data-noparam'=>1),
 		'X4'=>'---',
 		'isnotanswer'=>array('label'=>'IsNotAnAnswer', 'data-noparam'=>1),
 		'isanswer'=>array('label'=>'IsAnAnswer', 'data-noparam'=>1)
@@ -559,9 +559,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<tr class="oddeven">';
 	print '<td>';
 	$arrayoftypes = array(
-	    'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
-	    'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
-	    'recordevent'=>'RecordEvent');
+		'loadthirdparty'=>$langs->trans('LoadThirdPartyFromName', $langs->transnoentities("ThirdPartyName")),
+		'loadandcreatethirdparty'=>$langs->trans('LoadThirdPartyFromNameOrCreate', $langs->transnoentities("ThirdPartyName")),
+		'recordevent'=>'RecordEvent');
 	if ($conf->projet->enabled) $arrayoftypes['project'] = 'CreateLeadAndThirdParty';
 	if ($conf->ticket->enabled) $arrayoftypes['ticket'] = 'CreateTicketAndThirdParty';
 	if ($conf->recruitment->enabled) $arrayoftypes['candidature'] = 'CreateCandidature';
@@ -602,7 +602,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		print $langs->trans($arrayoftypes[$ruleaction['type']]);
 		if (in_array($ruleaction['type'], array('recordevent')))
 		{
-            print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
+			print $form->textwithpicto('', $langs->transnoentitiesnoconv('IfTrackingIDFoundEventWillBeLinked'));
 		} elseif (in_array($ruleaction['type'], array('loadthirdparty', 'loadandcreatethirdparty'))) {
 			print $form->textwithpicto('', $langs->transnoentitiesnoconv('EmailCollectorLoadThirdPartyHelp'));
 		}
@@ -610,11 +610,11 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		print '<td class="wordbreak">';
 		if ($action == 'editoperation' && $ruleaction['id'] == $operationid)
 		{
-		    print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
-		    print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
-		    print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
+			print '<input type="text" class="quatrevingtquinzepercent" name="operationparam2" value="'.$ruleaction['actionparam'].'"><br>';
+			print '<input type="hidden" name="rowidoperation2" value="'.$ruleaction['id'].'"><br>';
+			print '<input type="submit" class="button" name="saveoperation2" value="'.$langs->trans("Save").'"> <input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'">';
 		} else {
-		    print $ruleaction['actionparam'];
+			print $ruleaction['actionparam'];
 		}
 		print '</td>';
 		// Move up/down
@@ -641,7 +641,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '</div>';
 
 	if (!empty($conf->use_javascript_ajax)) {
-	    $urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
+		$urltorefreshaftermove = DOL_URL_ROOT.'/admin/emailcollector_card.php?id='.$id;
 		include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
 	}
 
@@ -668,7 +668,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 			print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Edit").'</a></div>';
 
 			// Clone
-		    print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
+			print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;socid='.$object->socid.'&amp;action=clone&amp;object=order">'.$langs->trans("ToClone").'</a></div>';
 
 		    // Collect now
 		    if (count($object->actions) > 0) {
@@ -684,7 +684,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if (!empty($debuginfo))
 	{
-	    print info_admin($debuginfo);
+		print info_admin($debuginfo);
 	}
 
 

+ 124 - 124
htdocs/admin/expedition.php

@@ -48,7 +48,7 @@ $type = 'shipping';
 
 if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
 {
-    $conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
+	$conf->global->EXPEDITION_ADDON_NUMBER = 'mod_expedition_safor';
 }
 
 
@@ -105,7 +105,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/expedition/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -143,7 +143,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
+		if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -231,14 +231,14 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering module
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) {
+						// Show example of numbering module
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) {
 							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
 						} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
@@ -258,16 +258,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $expedition);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -328,107 +328,107 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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><td width="100">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->EXPEDITION_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-			                    }
-					    		$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-					    		$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$dir = dol_buildpath($reldir."core/modules/expedition".$valdir);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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><td width="100">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->EXPEDITION_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+								}
+								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+								$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'sending').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -461,11 +461,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnShippings"), $langs->tr
 $variablename = 'SHIPPING_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print "</td></tr>\n";
 

+ 427 - 427
htdocs/admin/facture.php

@@ -53,66 +53,66 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
-    $maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
-    $maskconstcredit = GETPOST('maskconstcredit', 'alpha');
+	$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
+	$maskconstreplacement = GETPOST('maskconstreplacement', 'alpha');
+	$maskconstcredit = GETPOST('maskconstcredit', 'alpha');
 	$maskconstdeposit = GETPOST('maskconstdeposit', 'alpha');
-    $maskinvoice = GETPOST('maskinvoice', 'alpha');
-    $maskreplacement = GETPOST('maskreplacement', 'alpha');
-    $maskcredit = GETPOST('maskcredit', 'alpha');
+	$maskinvoice = GETPOST('maskinvoice', 'alpha');
+	$maskreplacement = GETPOST('maskreplacement', 'alpha');
+	$maskcredit = GETPOST('maskcredit', 'alpha');
 	$maskdeposit = GETPOST('maskdeposit', 'alpha');
-    if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
-    if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
-    if ($maskconstcredit)  $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
+	if ($maskconstinvoice) $res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
+	if ($maskconstreplacement) $res = dolibarr_set_const($db, $maskconstreplacement, $maskreplacement, 'chaine', 0, '', $conf->entity);
+	if ($maskconstcredit)  $res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
 	if ($maskconstdeposit)  $res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
-    $modele = GETPOST('module', 'alpha');
+	$modele = GETPOST('module', 'alpha');
 
-    $facture = new Facture($db);
-    $facture->initAsSpecimen();
+	$facture = new Facture($db);
+	$facture->initAsSpecimen();
 
 	// Search template files
 	$file = ''; $classname = ''; $filefound = 0;
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
-    	if (file_exists($file))
-    	{
-    		$filefound = 1;
-    		$classname = "pdf_".$modele;
-    		break;
-    	}
-    }
-
-    if ($filefound)
-    {
-    	require_once $file;
-
-    	$module = new $classname($db);
-
-    	if ($module->write_file($facture, $langs) > 0)
-    	{
-    		header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
-    		return;
-    	} else {
-    		setEventMessages($module->error, $module->errors, 'errors');
-    		dol_syslog($module->error, LOG_ERR);
-    	}
-    } else {
-    	setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
-    	dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
-    }
+		$file = dol_buildpath($reldir."core/modules/facture/doc/pdf_".$modele.".modules.php", 0);
+		if (file_exists($file))
+		{
+			$filefound = 1;
+			$classname = "pdf_".$modele;
+			break;
+		}
+	}
+
+	if ($filefound)
+	{
+		require_once $file;
+
+		$module = new $classname($db);
+
+		if ($module->write_file($facture, $langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=facture&file=SPECIMEN.pdf");
+			return;
+		} else {
+			setEventMessages($module->error, $module->errors, 'errors');
+			dol_syslog($module->error, LOG_ERR);
+		}
+	} else {
+		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
 }
 // Activate a model
 elseif ($action == 'set')
@@ -123,7 +123,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
+		if ($conf->global->FACTURE_ADDON_PDF == "$value") dolibarr_del_const($db, 'FACTURE_ADDON_PDF', $conf->entity);
 	}
 }
 // Set default model
@@ -144,89 +144,89 @@ elseif ($action == 'setdoc')
 	}
 } elseif ($action == 'setmod')
 {
-    // TODO Verifier si module numerotation choisi peut etre active
-    // par appel methode canBeActivated
+	// TODO Verifier si module numerotation choisi peut etre active
+	// par appel methode canBeActivated
 
-    dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
+	dolibarr_set_const($db, "FACTURE_ADDON", $value, 'chaine', 0, '', $conf->entity);
 } elseif ($action == 'setribchq')
 {
 	$rib = GETPOST('rib', 'alpha');
 	$chq = GETPOST('chq', 'alpha');
 
 	$res = dolibarr_set_const($db, "FACTURE_RIB_NUMBER", $rib, 'chaine', 0, '', $conf->entity);
-    $res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FACTURE_CHQ_NUMBER", $chq, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_FACTURE_DRAFT_WATERMARK')
 {
 	$draft = GETPOST('FACTURE_DRAFT_WATERMARK', 'alpha');
 
-    $res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FACTURE_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_INVOICE_FREE_TEXT')
 {
 	$freetext = GETPOST('INVOICE_FREE_TEXT', 'none'); // No alpha here, we want exact string
 
-    $res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "INVOICE_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setforcedate')
 {
 	$forcedate = GETPOST('forcedate', 'alpha');
 
-    $res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
+	$res = dolibarr_set_const($db, "FAC_FORCE_DATE_VALIDATION", $forcedate, 'chaine', 0, '', $conf->entity);
 
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'setDefaultPDFModulesByType')
 {
-    $invoicetypemodels = GETPOST('invoicetypemodels');
-
-    if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
-    {
-        $error = 0;
-
-        foreach ($invoicetypemodels as $type => $value)
-        {
-            $res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
-            if (!$res > 0) $error++;
-        }
-
-        if (!$error)
-        {
-            setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-        } else {
-            setEventMessages($langs->trans("Error"), null, 'errors');
-        }
-    }
+	$invoicetypemodels = GETPOST('invoicetypemodels');
+
+	if (!empty($invoicetypemodels) && is_array($invoicetypemodels))
+	{
+		$error = 0;
+
+		foreach ($invoicetypemodels as $type => $value)
+		{
+			$res = dolibarr_set_const($db, 'FACTURE_ADDON_PDF_'.intval($type), $value, 'chaine', 0, '', $conf->entity);
+			if (!$res > 0) $error++;
+		}
+
+		if (!$error)
+		{
+			setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+		} else {
+			setEventMessages($langs->trans("Error"), null, 'errors');
+		}
+	}
 }
 
 
@@ -267,144 +267,144 @@ clearstatcache();
 foreach ($dirmodels as $reldir)
 {
 	$dir = dol_buildpath($reldir."core/modules/facture/");
-    if (is_dir($dir))
-    {
-        $handle = opendir($dir);
-        if (is_resource($handle))
-        {
-            while (($file = readdir($handle)) !== false)
-            {
-                if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
-                {
-                    $filebis = $file;
-                    $classname = preg_replace('/\.php$/', '', $file);
-                    // For compatibility
-                    if (!is_file($dir.$filebis))
-                    {
-                        $filebis = $file."/".$file.".modules.php";
-                        $classname = "mod_facture_".$file;
-                    }
-                    // Check if there is a filter on country
-                    preg_match('/\-(.*)_(.*)$/', $classname, $reg);
-                    if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
-
-                    $classname = preg_replace('/\-.*$/', '', $classname);
-                    if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
-                    {
-                        // Charging the numbering class
-                        require_once $dir.$filebis;
-
-                        $module = new $classname($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())
-                        {
-                            print '<tr class="oddeven"><td width="100">';
-                            echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
-                            print "</td><td>\n";
-
-                            print $module->info();
-
-                            print '</td>';
-
-                            // Show example of numbering module
-                            print '<td class="nowrap">';
-                            $tmp = $module->getExample();
-                            if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                            elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                            else print $tmp;
-                            print '</td>'."\n";
-
-                            print '<td class="center">';
-                            //print "> ".$conf->global->FACTURE_ADDON." - ".$file;
-                            if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
-                            {
-                                print img_picto($langs->trans("Activated"), 'switch_on');
-                            } else {
-                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-                            }
-                            print '</td>';
-
-                            $facture = new Facture($db);
-                            $facture->initAsSpecimen();
-
-                            // Example for standard invoice
-                            $htmltooltip = '';
-                            $htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
-                            $facture->type = 0;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForInvoices").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-                            // Example for remplacement
-                            $facture->type = 1;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForReplacements").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-
-                            // Example for credit invoice
-                            $facture->type = 2;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval.'<br>';
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error).'<br>';
-                                }
-                            }
-                            // Example for deposit invoice
-                            $facture->type = 3;
-                            $nextval = $module->getNextValue($mysoc, $facture);
-                            if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                                $htmltooltip .= $langs->trans("NextValueForDeposit").': ';
-                                if ($nextval) {
-                                    if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                        $nextval = $langs->trans($nextval);
-                                    $htmltooltip .= $nextval;
-                                } else {
-                                    $htmltooltip .= $langs->trans($module->error);
-                                }
-                            }
-
-                            print '<td class="center">';
-                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-
-                            if ($conf->global->FACTURE_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
-                            {
-                                if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
-                            }
-
-                            print '</td>';
-
-                            print "</tr>\n";
-                        }
-                    }
-                }
-            }
-            closedir($handle);
-        }
-    }
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			while (($file = readdir($handle)) !== false)
+			{
+				if (!is_dir($dir.$file) || (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS'))
+				{
+					$filebis = $file;
+					$classname = preg_replace('/\.php$/', '', $file);
+					// For compatibility
+					if (!is_file($dir.$filebis))
+					{
+						$filebis = $file."/".$file.".modules.php";
+						$classname = "mod_facture_".$file;
+					}
+					// Check if there is a filter on country
+					preg_match('/\-(.*)_(.*)$/', $classname, $reg);
+					if (!empty($reg[2]) && $reg[2] != strtoupper($mysoc->country_code)) continue;
+
+					$classname = preg_replace('/\-.*$/', '', $classname);
+					if (!class_exists($classname) && is_readable($dir.$filebis) && (preg_match('/mod_/', $filebis) || preg_match('/mod_/', $classname)) && substr($filebis, dol_strlen($filebis) - 3, 3) == 'php')
+					{
+						// Charging the numbering class
+						require_once $dir.$filebis;
+
+						$module = new $classname($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())
+						{
+							print '<tr class="oddeven"><td width="100">';
+							echo preg_replace('/\-.*$/', '', preg_replace('/mod_facture_/', '', preg_replace('/\.php$/', '', $file)));
+							print "</td><td>\n";
+
+							print $module->info();
+
+							print '</td>';
+
+							// Show example of numbering module
+							print '<td class="nowrap">';
+							$tmp = $module->getExample();
+							if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+							elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+							else print $tmp;
+							print '</td>'."\n";
+
+							print '<td class="center">';
+							//print "> ".$conf->global->FACTURE_ADDON." - ".$file;
+							if ($conf->global->FACTURE_ADDON == $file || $conf->global->FACTURE_ADDON.'.php' == $file)
+							{
+								print img_picto($langs->trans("Activated"), 'switch_on');
+							} else {
+								print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&value='.preg_replace('/\.php$/', '', $file).'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+							}
+							print '</td>';
+
+							$facture = new Facture($db);
+							$facture->initAsSpecimen();
+
+							// Example for standard invoice
+							$htmltooltip = '';
+							$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+							$facture->type = 0;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForInvoices").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+							// Example for remplacement
+							$facture->type = 1;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForReplacements").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+
+							// Example for credit invoice
+							$facture->type = 2;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForCreditNotes").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval.'<br>';
+								} else {
+									$htmltooltip .= $langs->trans($module->error).'<br>';
+								}
+							}
+							// Example for deposit invoice
+							$facture->type = 3;
+							$nextval = $module->getNextValue($mysoc, $facture);
+							if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+								$htmltooltip .= $langs->trans("NextValueForDeposit").': ';
+								if ($nextval) {
+									if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+										$nextval = $langs->trans($nextval);
+									$htmltooltip .= $nextval;
+								} else {
+									$htmltooltip .= $langs->trans($module->error);
+								}
+							}
+
+							print '<td class="center">';
+							print $form->textwithpicto('', $htmltooltip, 1, 0);
+
+							if ($conf->global->FACTURE_ADDON.'.php' == $file)  // If module is the one used, we show existing errors
+							{
+								if (!empty($module->error)) dol_htmloutput_mesg($module->error, '', 'error', 1);
+							}
+
+							print '</td>';
+
+							print "</tr>\n";
+						}
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
 }
 
 print '</table>';
@@ -426,16 +426,16 @@ $sql .= " AND entity = ".$conf->entity;
 $resql = $db->query($sql);
 if ($resql)
 {
-    $i = 0;
-    $num_rows = $db->num_rows($resql);
-    while ($i < $num_rows)
-    {
-        $array = $db->fetch_array($resql);
-        array_push($def, $array[0]);
-        $i++;
-    }
+	$i = 0;
+	$num_rows = $db->num_rows($resql);
+	while ($i < $num_rows)
+	{
+		$array = $db->fetch_array($resql);
+		array_push($def, $array[0]);
+		$i++;
+	}
 } else {
-    dol_print_error($db);
+	dol_print_error($db);
 }
 
 print '<table class="noborder centpercent">';
@@ -454,156 +454,156 @@ $activatedModels = array();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/facture".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>';
-	                                print "</td>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->FACTURE_ADDON_PDF == "$name")
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>';
-	                            }
-	                            print '</td>';
-
-	                            // Info
-	                            $htmltooltip = ''.$langs->trans("Name").': '.$module->name;
-	                            $htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
-	                            if ($module->type == 'pdf')
-	                            {
-	                                $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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-	                            $htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/facture".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("SetAsDefault"), 'switch_off').'</a>';
+									print "</td>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->FACTURE_ADDON_PDF == "$name")
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&scan_dir='.$module->scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("SetAsDefault"), 'off').'</a>';
+								}
+								print '</td>';
+
+								// Info
+								$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+								$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
+								if ($module->type == 'pdf')
+								{
+									$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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftInvoices").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 print '</table>';
 
 if (!empty($conf->global->INVOICE_USE_DEFAULT_DOCUMENT)) // Hidden conf
 {
-    /*
+	/*
      *  Document templates generators
      */
-    print '<br>';
-    print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
-    print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
-    print '<input type="hidden" name="token" value="'.newToken().'" />';
-    print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
-    print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
-    print '<tr class="liste_titre">';
-    print '<td>'.$langs->trans("Type").'</td>';
-    print '<td>'.$langs->trans("Name").'</td>';
-    print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
-    print "</tr>\n";
-
-    $listtype = array(
-        Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
-        Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
-        Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
-        Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
-    );
-    if (!empty($conf->global->INVOICE_USE_SITUATION))
-    {
-        $listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
-    }
-
-    foreach ($listtype as $type => $trans)
-    {
-        $thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
-        $current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
-        print '<tr >';
-        print '<td>'.$trans.'</td>';
-        print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
-        print "</tr>\n";
-    }
-
-    print '</table>';
-    print "</form>";
+	print '<br>';
+	print load_fiche_titre($langs->trans("BillsPDFModulesAccordindToInvoiceType"), '', '');
+	print '<form action="'.$_SERVER["PHP_SELF"].'#default-pdf-modules-by-type-table" method="POST">';
+	print '<input type="hidden" name="token" value="'.newToken().'" />';
+	print '<input type="hidden" name="action" value="setDefaultPDFModulesByType" >';
+	print '<table id="default-pdf-modules-by-type-table" class="noborder centpercent">';
+	print '<tr class="liste_titre">';
+	print '<td>'.$langs->trans("Type").'</td>';
+	print '<td>'.$langs->trans("Name").'</td>';
+	print '<td class="right"><input type="submit" class="button" value="'.$langs->trans("Modify").'"></td>';
+	print "</tr>\n";
+
+	$listtype = array(
+		Facture::TYPE_STANDARD=>$langs->trans("InvoiceStandard"),
+		Facture::TYPE_REPLACEMENT=>$langs->trans("InvoiceReplacement"),
+		Facture::TYPE_CREDIT_NOTE=>$langs->trans("InvoiceAvoir"),
+		Facture::TYPE_DEPOSIT=>$langs->trans("InvoiceDeposit"),
+	);
+	if (!empty($conf->global->INVOICE_USE_SITUATION))
+	{
+		$listtype[Facture::TYPE_SITUATION] = $langs->trans("InvoiceSituation");
+	}
+
+	foreach ($listtype as $type => $trans)
+	{
+		$thisTypeConfName = 'FACTURE_ADDON_PDF_'.$type;
+		$current = !empty($conf->global->{$thisTypeConfName}) ? $conf->global->{$thisTypeConfName}:$conf->global->FACTURE_ADDON_PDF;
+		print '<tr >';
+		print '<td>'.$trans.'</td>';
+		print '<td colspan="2" >'.$form->selectarray('invoicetypemodels['.$type.']', ModelePDFFactures::liste_modeles($db), $current, 0, 0, 0).'</td>';
+		print "</tr>\n";
+	}
+
+	print '</table>';
+	print "</form>";
 }
 
 /*
@@ -629,37 +629,37 @@ print "<td>".$langs->trans("SuggestPaymentByRIBOnAccount")."</td>";
 print "<td>";
 if (!empty($conf->banque->enabled))
 {
-    $sql = "SELECT rowid, label";
-    $sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
-    $sql .= " WHERE clos = 0";
-    $sql .= " AND courant = 1";
-    $sql .= " AND entity IN (".getEntity('bank_account').")";
-    $resql = $db->query($sql);
-    if ($resql)
-    {
-        $num = $db->num_rows($resql);
-        $i = 0;
-        if ($num > 0)
-        {
-        	print '<select name="rib" class="flat" id="rib">';
-        	print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
-            while ($i < $num)
-            {
-                $row = $db->fetch_row($resql);
-
-                print '<option value="'.$row[0].'"';
-                print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
-                print '>'.$row[1].'</option>';
-
-                $i++;
-            }
-            print "</select>";
-        } else {
-        	print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
-        }
-    }
+	$sql = "SELECT rowid, label";
+	$sql .= " FROM ".MAIN_DB_PREFIX."bank_account";
+	$sql .= " WHERE clos = 0";
+	$sql .= " AND courant = 1";
+	$sql .= " AND entity IN (".getEntity('bank_account').")";
+	$resql = $db->query($sql);
+	if ($resql)
+	{
+		$num = $db->num_rows($resql);
+		$i = 0;
+		if ($num > 0)
+		{
+			print '<select name="rib" class="flat" id="rib">';
+			print '<option value="0">'.$langs->trans("DoNotSuggestPaymentMode").'</option>';
+			while ($i < $num)
+			{
+				$row = $db->fetch_row($resql);
+
+				print '<option value="'.$row[0].'"';
+				print $conf->global->FACTURE_RIB_NUMBER == $row[0] ? ' selected' : '';
+				print '>'.$row[1].'</option>';
+
+				$i++;
+			}
+			print "</select>";
+		} else {
+			print '<span class="opacitymedium">'.$langs->trans("NoActiveBankAccountDefined").'</span>';
+		}
+	}
 } else {
-    print $langs->trans("BankModuleNotActive");
+	print $langs->trans("BankModuleNotActive");
 }
 print "</td></tr>";
 
@@ -679,18 +679,18 @@ $sql .= " AND entity IN (".getEntity('bank_account').")";
 $resql = $db->query($sql);
 if ($resql)
 {
-    $num = $db->num_rows($resql);
-    $i = 0;
-    while ($i < $num)
-    {
-        $row = $db->fetch_row($resql);
-
-        print '<option value="'.$row[0].'"';
-        print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
-        print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
-
-        $i++;
-    }
+	$num = $db->num_rows($resql);
+	$i = 0;
+	while ($i < $num)
+	{
+		$row = $db->fetch_row($resql);
+
+		print '<option value="'.$row[0].'"';
+		print $conf->global->FACTURE_CHQ_NUMBER == $row[0] ? ' selected' : '';
+		print '>'.$langs->trans("OwnerOfBankAccount", $row[1]).'</option>';
+
+		$i++;
+	}
 }
 print "</select>";
 print "</td></tr>";
@@ -735,11 +735,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnInvoices"), $langs->tra
 $variablename = 'INVOICE_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'" />';

+ 143 - 143
htdocs/admin/holiday.php

@@ -43,7 +43,7 @@ $type = 'contract';
 
 if (empty($conf->global->HOLIDAY_ADDON))
 {
-    $conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
+	$conf->global->HOLIDAY_ADDON = 'mod_holiday_madonna';
 }
 
 
@@ -55,18 +55,18 @@ include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 
 if ($action == 'updateMask')
 {
-    $maskconst = GETPOST('maskconstholiday', 'alpha');
-    $maskvalue = GETPOST('maskholiday', 'alpha');
-    if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
+	$maskconst = GETPOST('maskconstholiday', 'alpha');
+	$maskvalue = GETPOST('maskholiday', 'alpha');
+	if ($maskconst) $res = dolibarr_set_const($db, $maskconst, $maskvalue, 'chaine', 0, '', $conf->entity);
 
-    if (!$res > 0) $error++;
+	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen') // For contract
 {
 	$modele = GETPOST('module', 'alpha');
@@ -79,7 +79,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -117,7 +117,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
+		if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -154,11 +154,11 @@ elseif ($action == 'setdoc')
 	if (!$res1 > 0 || !$res2 > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -251,16 +251,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $holiday);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -282,11 +282,11 @@ print '<br>';
 
 
 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
-    dol_fiche_end();
-    // End of page
-    llxFooter();
-    $db->close();
-    exit;
+	dol_fiche_end();
+	// End of page
+	llxFooter();
+	$db->close();
+	exit;
 }
 
 /*
@@ -304,8 +304,8 @@ $sql .= " AND entity = ".$conf->entity;
 $resql = $db->query($sql);
 if ($resql)
 {
-    $i = 0;
-    $num_rows = $db->num_rows($resql);
+	$i = 0;
+	$num_rows = $db->num_rows($resql);
 	while ($i < $num_rows)
 	{
 		$array = $db->fetch_array($resql);
@@ -332,111 +332,111 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/holiday".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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">';
-	                            if ($conf->global->HOLIDAY_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/holiday".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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">';
+								if ($conf->global->HOLIDAY_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'contract').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -473,11 +473,11 @@ print '<br>';
 $variablename = 'HOLIDAY_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td></tr>'."\n";
 

File diff suppressed because it is too large
+ 471 - 471
htdocs/admin/mails_templates.php


+ 141 - 141
htdocs/admin/mrp.php

@@ -56,11 +56,11 @@ if ($action == 'updateMask')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'specimen')
 {
 	$modele = GETPOST('module', 'alpha');
@@ -73,7 +73,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -111,7 +111,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
+		if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -145,11 +145,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 } elseif ($action == 'set_MRP_MO_FREE_TEXT')
 {
 	$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none'); // No alpha here, we want exact string
@@ -159,11 +159,11 @@ elseif ($action == 'setdoc')
 	if (!$res > 0) $error++;
 
  	if (!$error)
-    {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
+	{
+		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+	} else {
+		setEventMessages($langs->trans("Error"), null, 'errors');
+	}
 }
 
 
@@ -212,7 +212,7 @@ foreach ($dirmodels as $reldir)
 		{
 			while (($file = readdir($handle)) !== false)
 			{
-			    if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
+				if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file) - 3, 3) == 'php')
 				{
 					$file = substr($file, 0, dol_strlen($file) - 4);
 
@@ -230,13 +230,13 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering model
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
-                        elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						// Show example of numbering model
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+						elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->MRP_MO_ADDON == $file)
@@ -257,16 +257,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$mrp->type = 0;
 						$nextval = $module->getNextValue($mysoc, $mrp);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -325,108 +325,108 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/mrp".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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">';
-	                            if ($conf->global->MRP_MO_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/mrp".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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">';
+								if ($conf->global->MRP_MO_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';
@@ -458,11 +458,11 @@ print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("A
 $variablename = 'MRP_MO_FREE_TEXT';
 if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
 {
-    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
 } else {
-    include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-    print $doleditor->Create();
+	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+	print $doleditor->Create();
 }
 print '</td><td class="right">';
 print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';

+ 125 - 125
htdocs/admin/reception_setup.php

@@ -45,13 +45,13 @@ $type = 'reception';
 
 if (!empty($conf->reception->enabled) && empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 {
-    // This option should always be set to on when module is on.
-    dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
+	// This option should always be set to on when module is on.
+	dolibarr_set_const($db, "MAIN_SUBMODULE_RECEPTION", "1", 'chaine', 0, '', $conf->entity);
 }
 
 if (empty($conf->global->RECEPTION_ADDON_NUMBER))
 {
-    $conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
+	$conf->global->RECEPTION_ADDON_NUMBER = 'mod_reception_beryl';
 }
 
 
@@ -108,7 +108,7 @@ if ($action == 'updateMask')
 	$dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 	foreach ($dirmodels as $reldir)
 	{
-	    $file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
+		$file = dol_buildpath($reldir."core/modules/reception/doc/pdf_".$modele.".modules.php", 0);
 		if (file_exists($file))
 		{
 			$filefound = 1;
@@ -146,7 +146,7 @@ elseif ($action == 'set')
 	$ret = delDocumentModel($value, $type);
 	if ($ret > 0)
 	{
-        if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
+		if ($conf->global->RECEPTION_ADDON_PDF == "$value") dolibarr_del_const($db, 'RECEPTION_ADDON_PDF', $conf->entity);
 	}
 }
 
@@ -236,14 +236,14 @@ foreach ($dirmodels as $reldir)
 						print $module->info();
 						print '</td>';
 
-                        // Show example of numbering module
-                        print '<td class="nowrap">';
-                        $tmp = $module->getExample();
-                        if (preg_match('/^Error/', $tmp)) {
+						// Show example of numbering module
+						print '<td class="nowrap">';
+						$tmp = $module->getExample();
+						if (preg_match('/^Error/', $tmp)) {
 							$langs->load("errors"); print '<div class="error">'.$langs->trans($tmp).'</div>';
 						} elseif ($tmp == 'NotConfigured') print $langs->trans($tmp);
-                        else print $tmp;
-                        print '</td>'."\n";
+						else print $tmp;
+						print '</td>'."\n";
 
 						print '<td class="center">';
 						if ($conf->global->RECEPTION_ADDON_NUMBER == "$file")
@@ -263,16 +263,16 @@ foreach ($dirmodels as $reldir)
 						$htmltooltip = '';
 						$htmltooltip .= ''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
 						$nextval = $module->getNextValue($mysoc, $reception);
-                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
-                            $htmltooltip .= ''.$langs->trans("NextValue").': ';
-                            if ($nextval) {
-                                if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
-                                    $nextval = $langs->trans($nextval);
-                                $htmltooltip .= $nextval.'<br>';
-                            } else {
-                                $htmltooltip .= $langs->trans($module->error).'<br>';
-                            }
-                        }
+						if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+							$htmltooltip .= ''.$langs->trans("NextValue").': ';
+							if ($nextval) {
+								if (preg_match('/^Error/', $nextval) || $nextval == 'NotConfigured')
+									$nextval = $langs->trans($nextval);
+								$htmltooltip .= $nextval.'<br>';
+							} else {
+								$htmltooltip .= $langs->trans($module->error).'<br>';
+							}
+						}
 
 						print '<td class="center">';
 						print $form->textwithpicto('', $htmltooltip, 1, 0);
@@ -333,110 +333,110 @@ clearstatcache();
 
 foreach ($dirmodels as $reldir)
 {
-    foreach (array('', '/doc') as $valdir)
-    {
-    	$realpath = $reldir."core/modules/reception".$valdir;
-    	$dir = dol_buildpath($realpath);
-
-        if (is_dir($dir))
-        {
-            $handle = opendir($dir);
-            if (is_resource($handle))
-            {
-                while (($file = readdir($handle)) !== false)
-                {
-                    $filelist[] = $file;
-                }
-                closedir($handle);
-                arsort($filelist);
-
-                foreach ($filelist as $file)
-                {
-                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                    {
-                    	if (file_exists($dir.'/'.$file))
-                    	{
-                    		$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><td width="100">';
-	                            print (empty($module->name) ? $name : $module->name);
-	                            print "</td><td>\n";
-	                            if (method_exists($module, 'info')) print $module->info($langs);
-	                            else print $module->description;
-	                            print '</td>';
-
-	                            // Active
-	                            if (in_array($name, $def))
-	                            {
-	                            	print '<td class="center">'."\n";
-	                            	print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-	                            	print img_picto($langs->trans("Enabled"), 'switch_on');
-	                            	print '</a>';
-	                            	print '</td>';
-	                            } else {
-	                                print '<td class="center">'."\n";
-	                                print '<a class="reposition" 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>";
-	                            }
-
-	                            // Defaut
-	                            print '<td class="center">';
-	                            if ($conf->global->RECEPTION_ADDON_PDF == $name)
-	                            {
-	                                print img_picto($langs->trans("Default"), 'on');
-	                            } else {
-	                                print '<a class="reposition" 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"));
-			                    if ($module->type == 'pdf')
-			                    {
-			                        $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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-					    		$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-	                            print '<td class="center">';
-	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-	                            print '</td>';
-
-	                            // Preview
-	                            print '<td class="center">';
-	                            if ($module->type == 'pdf')
-	                            {
-	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>';
-	                            } else {
-	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-	                            }
-	                            print '</td>';
-
-	                            print "</tr>\n";
-	                        }
-                    	}
-                    }
-                }
-            }
-        }
-    }
+	foreach (array('', '/doc') as $valdir)
+	{
+		$realpath = $reldir."core/modules/reception".$valdir;
+		$dir = dol_buildpath($realpath);
+
+		if (is_dir($dir))
+		{
+			$handle = opendir($dir);
+			if (is_resource($handle))
+			{
+				while (($file = readdir($handle)) !== false)
+				{
+					$filelist[] = $file;
+				}
+				closedir($handle);
+				arsort($filelist);
+
+				foreach ($filelist as $file)
+				{
+					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+					{
+						if (file_exists($dir.'/'.$file))
+						{
+							$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><td width="100">';
+								print (empty($module->name) ? $name : $module->name);
+								print "</td><td>\n";
+								if (method_exists($module, 'info')) print $module->info($langs);
+								else print $module->description;
+								print '</td>';
+
+								// Active
+								if (in_array($name, $def))
+								{
+									print '<td class="center">'."\n";
+									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+									print img_picto($langs->trans("Enabled"), 'switch_on');
+									print '</a>';
+									print '</td>';
+								} else {
+									print '<td class="center">'."\n";
+									print '<a class="reposition" 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>";
+								}
+
+								// Defaut
+								print '<td class="center">';
+								if ($conf->global->RECEPTION_ADDON_PDF == $name)
+								{
+									print img_picto($langs->trans("Default"), 'on');
+								} else {
+									print '<a class="reposition" 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"));
+								if ($module->type == 'pdf')
+								{
+									$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("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+								print '<td class="center">';
+								print $form->textwithpicto('', $htmltooltip, 1, 0);
+								print '</td>';
+
+								// Preview
+								print '<td class="center">';
+								if ($module->type == 'pdf')
+								{
+									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_object($langs->trans("Preview"), 'reception').'</a>';
+								} else {
+									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+								}
+								print '</td>';
+
+								print "</tr>\n";
+							}
+						}
+					}
+				}
+			}
+		}
+	}
 }
 
 print '</table>';

+ 143 - 143
htdocs/admin/stock.php

@@ -51,42 +51,42 @@ $reg = array();
 
 if (preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg))
 {
-    $code = $reg[1];
-
-    // If constant is for a unique choice, delete other choices
-    if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
-    }
-    if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
-    	dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
-    }
-
-    if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
-    {
-    	header("Location: ".$_SERVER["PHP_SELF"]);
-        exit;
-    } else {
-        dol_print_error($db);
-    }
+	$code = $reg[1];
+
+	// If constant is for a unique choice, delete other choices
+	if (in_array($code, array('STOCK_CALCULATE_ON_BILL', 'STOCK_CALCULATE_ON_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_SHIPMENT', 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE'))) {
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_BILL', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_VALIDATE_ORDER', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SHIPMENT_CLOSE', $conf->entity);
+	}
+	if (in_array($code, array('STOCK_CALCULATE_ON_SUPPLIER_BILL', 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', 'STOCK_CALCULATE_ON_RECEPTION', 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER'))) {
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_BILL', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_RECEPTION_CLOSE', $conf->entity);
+		dolibarr_del_const($db, 'STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', $conf->entity);
+	}
+
+	if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
+	{
+		header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	} else {
+		dol_print_error($db);
+	}
 }
 
 if (preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg))
 {
-    $code = $reg[1];
-    if (dolibarr_del_const($db, $code, $conf->entity) > 0)
-    {
-        header("Location: ".$_SERVER["PHP_SELF"]);
-        exit;
-    } else {
-        dol_print_error($db);
-    }
+	$code = $reg[1];
+	if (dolibarr_del_const($db, $code, $conf->entity) > 0)
+	{
+		header("Location: ".$_SERVER["PHP_SELF"]);
+		exit;
+	} else {
+		dol_print_error($db);
+	}
 }
 
 if ($action == 'warehouse')
@@ -224,14 +224,14 @@ print '<td>'.$langs->trans("DeStockOnBill").'</td>';
 print '<td class="right">';
 if (!empty($conf->facture->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_BILL', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_BILL);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module30Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -242,14 +242,14 @@ print '<td>'.$langs->trans("DeStockOnValidateOrder").'</td>';
 print '<td class="right">';
 if (!empty($conf->commande->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_VALIDATE_ORDER);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module25Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -262,14 +262,14 @@ print '<td>'.$langs->trans("DeStockOnShipment").'</td>';
 print '<td class="right">';
 if (!empty($conf->expedition->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -280,14 +280,14 @@ print '<td>'.$langs->trans("DeStockOnShipmentOnClosing").'</td>';
 print '<td class="right">';
 if (!empty($conf->expedition->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SHIPMENT_CLOSE', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SHIPMENT_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_SHIPMENT_CLOSE);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module80Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -312,14 +312,14 @@ print '<td>'.$langs->trans("ReStockOnBill").'</td>';
 print '<td class="right">';
 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -331,14 +331,14 @@ print '<td>'.$langs->trans("ReStockOnValidateOrder").'</td>';
 print '<td class="right">';
 if (!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_order->enabled) || !empty($conf->supplier_invoice->enabled))
 {
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
+	}
 } else {
-    print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
+	print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 }
 print "</td>\n</tr>\n";
 $found++;
@@ -347,43 +347,43 @@ if (!empty($conf->reception->enabled))
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockOnReception").'</td>';
-    print '<td class="right">';
+	print '<td class="right">';
 
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
-    }
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
+	}
 
 	print "</td>\n</tr>\n";
 	$found++;
 
 
-    print '<tr class="oddeven">';
+	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockOnReceptionOnClosing").'</td>';
-    print '<td class="right">';
-
-    if ($conf->use_javascript_ajax) {
-    	print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1);
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
-    }
+	print '<td class="right">';
+
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 0, 2, 1);
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
+	}
 	print "</td>\n</tr>\n";
 	$found++;
 } else {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("ReStockOnDispatchOrder").'</td>';
-    print '<td class="right">';
+	print '<td class="right">';
 	if (!empty($conf->fournisseur->enabled))
 	{
-        if ($conf->use_javascript_ajax) {
-        	print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
-        } else {
-            $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-            print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
-        }
+		if ($conf->use_javascript_ajax) {
+			print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 0, 2, 1);
+		} else {
+			$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+			print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
+		}
 	} else {
 		print $langs->trans("ModuleMustBeEnabledFirst", $langs->transnoentitiesnoconv("Module40Name"));
 	}
@@ -406,10 +406,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("WarehouseAllowNegativeTransfer").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
+	print ajax_constantonoff('STOCK_ALLOW_NEGATIVE_TRANSFER');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALLOW_NEGATIVE_TRANSFER", $arrval, $conf->global->STOCK_ALLOW_NEGATIVE_TRANSFER);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -419,28 +419,28 @@ if ($conf->invoice->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForInvoice").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
-    }
-    print "</td>\n";
-    print "</tr>\n";
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_INVOICE');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_INVOICE", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_INVOICE);
+	}
+	print "</td>\n";
+	print "</tr>\n";
 }
 
 if ($conf->order->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForOrder").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_ORDER');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_ORDER", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_ORDER);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 }
@@ -449,13 +449,13 @@ if ($conf->expedition->enabled)
 {
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("StockMustBeEnoughForShipment").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT", $arrval, $conf->global->STOCK_MUST_BE_ENOUGH_FOR_SHIPMENT);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 }
@@ -471,26 +471,26 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT)
 	|| !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)
 	|| !empty($conf->mrp->enabled))
 {
-    $virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
+	$virtualdiffersfromphysical = 1; // According to increase/decrease stock options, virtual and physical stock may differs.
 }
 
 if ($virtualdiffersfromphysical)
 {
-    print '<table class="noborder centpercent">';
-    print '<tr class="liste_titre">';
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre">';
 	print "<td>".$langs->trans("RuleForStockReplenishment")." ".img_help('help', $langs->trans("VirtualDiffersFromPhysical"))."</td>\n";
-    print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
+	print '<td class="right">'.$langs->trans("Status").'</td>'."\n";
 	print '</tr>'."\n";
 
 	print '<tr class="oddeven">';
 	print '<td>'.$langs->trans("UseVirtualStockByDefault").'</td>';
-    print '<td class="right">';
-    if ($conf->use_javascript_ajax) {
-        print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK');
-    } else {
-        $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-        print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK);
-    }
+	print '<td class="right">';
+	if ($conf->use_javascript_ajax) {
+		print ajax_constantonoff('STOCK_USE_VIRTUAL_STOCK');
+	} else {
+		$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+		print $form->selectarray("STOCK_USE_VIRTUAL_STOCK", $arrval, $conf->global->STOCK_USE_VIRTUAL_STOCK);
+	}
 	print "</td>\n";
 	print "</tr>\n";
 	print '</table>';
@@ -725,10 +725,10 @@ print $form->textwithpicto($langs->trans("StockSupportServices"), $langs->trans(
 print '</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
+	print ajax_constantonoff('STOCK_SUPPORTS_SERVICES');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_SUPPORTS_SERVICES", $arrval, $conf->global->STOCK_SUPPORTS_SERVICES);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -737,10 +737,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("AllowAddLimitStockByWarehouse").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
+	print ajax_constantonoff('STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE", $arrval, $conf->global->STOCK_ALLOW_ADD_LIMIT_STOCK_BY_WAREHOUSE);
 }
 print "</td>\n";
 print "</tr>\n";
@@ -749,10 +749,10 @@ print '<tr class="oddeven">';
 print '<td>'.$langs->trans("AlwaysShowFullArbo").'</td>';
 print '<td class="right">';
 if ($conf->use_javascript_ajax) {
-    print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
+	print ajax_constantonoff('STOCK_ALWAYS_SHOW_FULL_ARBO');
 } else {
-    $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
-    print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("STOCK_ALWAYS_SHOW_FULL_ARBO", $arrval, $conf->global->STOCK_ALWAYS_SHOW_FULL_ARBO);
 }
 print "</td>\n";
 print "</tr>\n";

+ 174 - 174
htdocs/bom/bom_card.php

@@ -61,7 +61,7 @@ $search_all = GETPOST("search_all", 'alpha');
 $search = array();
 foreach ($object->fields as $key => $val)
 {
-    if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
+	if (GETPOST('search_'.$key, 'alpha')) $search[$key] = GETPOST('search_'.$key, 'alpha');
 }
 
 if (empty($action) && empty($id) && empty($ref)) $action = 'view';
@@ -92,18 +92,18 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
-    $error = 0;
+	$error = 0;
 
-    $backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
+	$backurlforlist = DOL_URL_ROOT.'/bom/bom_list.php';
 
-    if (empty($backtopage) || ($cancel && empty($id))) {
-    	if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
-    		if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
-    		else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
-    	}
-    }
+	if (empty($backtopage) || ($cancel && empty($id))) {
+		if (empty($backtopage) || ($cancel && strpos($backtopage, '__ID__'))) {
+			if (empty($id) && (($action != 'add' && $action != 'create') || $cancel)) $backtopage = $backurlforlist;
+			else $backtopage = dol_buildpath('/bom/bom_card.php', 1).'?id='.($id > 0 ? $id : '__ID__');
+		}
+	}
 
-    $triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
+	$triggermodname = 'BOM_MODIFY'; // Name of trigger action code to execute when we modify record
 
 	// Actions cancel, add, update, delete or clone
 	include DOL_DOCUMENT_ROOT.'/core/actions_addupdatedelete.inc.php';
@@ -149,39 +149,39 @@ if (empty($reshook))
 		}
 
 		if ($object->fk_product == $idprod) {
-		    setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
-		    $error++;
+			setEventMessages($langs->trans('TheProductXIsAlreadyTheProductToProduce'), null, 'errors');
+			$error++;
 		}
 
 		if (!$error)
 		{
 			$lastposition = 0;
 
-    		$bomline = new BOMLine($db);
-    		$bomline->fk_bom = $id;
-    		$bomline->fk_product = $idprod;
-    		$bomline->qty = $qty;
-    		$bomline->qty_frozen = (int) $qty_frozen;
-    		$bomline->disable_stock_change = (int) $disable_stock_change;
-    		$bomline->efficiency = $efficiency;
+			$bomline = new BOMLine($db);
+			$bomline->fk_bom = $id;
+			$bomline->fk_product = $idprod;
+			$bomline->qty = $qty;
+			$bomline->qty_frozen = (int) $qty_frozen;
+			$bomline->disable_stock_change = (int) $disable_stock_change;
+			$bomline->efficiency = $efficiency;
 
-    		// Rang to use
+			// Rang to use
    			$rangmax = $object->line_max(0);
    			$ranktouse = $rangmax + 1;
 
    			$bomline->position = ($ranktouse + 1);
 
-    		$result = $bomline->create($user);
-    		if ($result <= 0)
-    		{
-    			setEventMessages($bomline->error, $bomline->errors, 'errors');
-    			$action = '';
-    		} else {
-    			unset($_POST['idprod']);
-    			unset($_POST['qty']);
-    			unset($_POST['qty_frozen']);
-    		    unset($_POST['disable_stock_change']);
-    		}
+			$result = $bomline->create($user);
+			if ($result <= 0)
+			{
+				setEventMessages($bomline->error, $bomline->errors, 'errors');
+				$action = '';
+			} else {
+				unset($_POST['idprod']);
+				unset($_POST['qty']);
+				unset($_POST['qty_frozen']);
+				unset($_POST['disable_stock_change']);
+			}
 		}
 	}
 
@@ -218,9 +218,9 @@ if (empty($reshook))
 			unset($_POST['idprod']);
 			unset($_POST['qty']);
 			unset($_POST['qty_frozen']);
-		    unset($_POST['disable_stock_change']);
+			unset($_POST['disable_stock_change']);
 
-		    $object->fetchLines();
+			$object->fetchLines();
 		}
 	}
 }
@@ -290,7 +290,7 @@ if (($id || $ref) && $action == 'edit')
 	print load_fiche_titre($langs->trans("BillOfMaterials"), '', 'cubes');
 
 	print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
-    print '<input type="hidden" name="token" value="'.newToken().'">';
+	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="action" value="update">';
 	print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
 	print '<input type="hidden" name="id" value="'.$object->id.'">';
@@ -321,7 +321,7 @@ if (($id || $ref) && $action == 'edit')
 // Part to show record
 if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create')))
 {
-    $res = $object->fetch_optionals();
+	$res = $object->fetch_optionals();
 
 	$head = bomPrepareHead($object);
 	dol_fiche_head($head, 'card', $langs->trans("BillOfMaterials"), -1, 'bom');
@@ -331,7 +331,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	// Confirmation to delete
 	if ($action == 'delete')
 	{
-	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteBillOfMaterials'), $langs->trans('ConfirmDeleteBillOfMaterials'), 'confirm_delete', '', 0, 1);
 	}
 	// Confirmation to delete line
 	if ($action == 'deleteline')
@@ -451,7 +451,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 		$text = $langs->trans('ConfirmSetToDraft', $object->ref);
 
 		$formquestion = array();
-	    $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
+		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('SetToDraft'), $text, 'confirm_setdraft', $formquestion, 0, 1, 220);
 	}
 
 	// Call Hook formConfirm
@@ -543,129 +543,129 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if (!empty($object->table_element_line))
 	{
-	    print '	<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST">
+		print '	<form name="addproduct" id="addproduct" action="'.$_SERVER["PHP_SELF"].'?id='.$object->id.(($action != 'editline') ? '#addline' : '').'" method="POST">
     	<input type="hidden" name="token" value="' . newToken().'">
     	<input type="hidden" name="action" value="' . (($action != 'editline') ? 'addline' : 'updateline').'">
     	<input type="hidden" name="mode" value="">
     	<input type="hidden" name="id" value="' . $object->id.'">
     	';
 
-	    if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
-	        include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
-	    }
-
-	    print '<div class="div-table-responsive-no-min">';
-	    if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
-	    {
-	        print '<table id="tablelines" class="noborder noshadow" width="100%">';
-	    }
+		if (!empty($conf->use_javascript_ajax) && $object->status == 0) {
+			include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php';
+		}
 
-	    if (!empty($object->lines))
-	    {
-	        $object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
-	    }
+		print '<div class="div-table-responsive-no-min">';
+		if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
+		{
+			print '<table id="tablelines" class="noborder noshadow" width="100%">';
+		}
 
-	    // Form to add new line
-	    if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
-	    {
-	        if ($action != 'editline')
-	        {
-	            // Add products/services form
-	            $object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
+		if (!empty($object->lines))
+		{
+			$object->printObjectLines($action, $mysoc, null, GETPOST('lineid', 'int'), 1, '/bom/tpl');
+		}
 
-	            $parameters = array();
-	            $reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-	        }
-	    }
+		// Form to add new line
+		if ($object->status == 0 && $permissiontoadd && $action != 'selectlines')
+		{
+			if ($action != 'editline')
+			{
+				// Add products/services form
+				$object->formAddObjectLine(1, $mysoc, null, '/bom/tpl');
+
+				$parameters = array();
+				$reshook = $hookmanager->executeHooks('formAddObjectLine', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+			}
+		}
 
-	    if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
-	    {
-	        print '</table>';
-	    }
-	    print '</div>';
+		if (!empty($object->lines) || ($object->status == $object::STATUS_DRAFT && $permissiontoadd && $action != 'selectlines' && $action != 'editline'))
+		{
+			print '</table>';
+		}
+		print '</div>';
 
-	    print "</form>\n";
+		print "</form>\n";
 	}
 
 
 	// Buttons for actions
 
 	if ($action != 'presend' && $action != 'editline') {
-    	print '<div class="tabsAction">'."\n";
-    	$parameters = array();
-    	$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
-    	if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-
-    	if (empty($reshook))
-    	{
-    	    // Send
-    		//if (empty($user->socid)) {
-    		//	print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
-    		//}
-
-    		// Back to draft
-    		if ($object->status == $object::STATUS_VALIDATED)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
-	    		}
-    		}
+		print '<div class="tabsAction">'."\n";
+		$parameters = array();
+		$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
-            // Modify
-    		if ($object->status == $object::STATUS_DRAFT)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
-	    		} else {
-	    			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
-	    		}
-    		}
-
-    		// Validate
-    		if ($object->status == $object::STATUS_DRAFT)
-    		{
-	    		if ($permissiontoadd)
-	    		{
-	    			if (is_array($object->lines) && count($object->lines) > 0)
-	    			{
-	    				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
-	    			} else {
-	    				$langs->load("errors");
-	    				print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
-	    			}
-	    		}
-    		}
-
-    		// Close / Cancel
-    		if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
-    		}
-
-    		// Re-open
-    		if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
-    		}
-
-    		// Create MO
-    		if ($conf->mrp->enabled)
-    		{
-	    		if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
-	    		{
-	    			print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
-	    		}
-    		}
-
-    		// Clone
-    		if ($permissiontoadd)
-    		{
-    			print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
-    		}
-
-    		/*
+		if (empty($reshook))
+		{
+			// Send
+			//if (empty($user->socid)) {
+			//	print '<a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&action=presend&mode=init#formmailbeforetitle">' . $langs->trans('SendMail') . '</a>'."\n";
+			//}
+
+			// Back to draft
+			if ($object->status == $object::STATUS_VALIDATED)
+			{
+				if ($permissiontoadd)
+				{
+					print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=setdraft">'.$langs->trans("SetToDraft").'</a>';
+				}
+			}
+
+			// Modify
+			if ($object->status == $object::STATUS_DRAFT)
+			{
+				if ($permissiontoadd)
+				{
+					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=edit">'.$langs->trans("Modify").'</a>'."\n";
+				} else {
+					print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Modify').'</a>'."\n";
+				}
+			}
+
+			// Validate
+			if ($object->status == $object::STATUS_DRAFT)
+			{
+				if ($permissiontoadd)
+				{
+					if (is_array($object->lines) && count($object->lines) > 0)
+					{
+						print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=validate">'.$langs->trans("Validate").'</a>';
+					} else {
+						$langs->load("errors");
+						print '<a class="butActionRefused" href="" title="'.$langs->trans("ErrorAddAtLeastOneLineFirst").'">'.$langs->trans("Validate").'</a>';
+					}
+				}
+			}
+
+			// Close / Cancel
+			if ($permissiontoadd && $object->status == $object::STATUS_VALIDATED)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=close">'.$langs->trans("Disable").'</a>';
+			}
+
+			// Re-open
+			if ($permissiontoadd && $object->status == $object::STATUS_CANCELED)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
+			}
+
+			// Create MO
+			if ($conf->mrp->enabled)
+			{
+				if ($object->status == $object::STATUS_VALIDATED && !empty($user->rights->mrp->write))
+				{
+					print '<a class="butAction" href="'.DOL_URL_ROOT.'/mrp/mo_card.php?action=create&fk_bom='.$object->id.'&backtopageforcancel='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("CreateMO").'</a>';
+				}
+			}
+
+			// Clone
+			if ($permissiontoadd)
+			{
+				print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&action=clone&object=bom">'.$langs->trans("ToClone").'</a>';
+			}
+
+			/*
     		if ($user->rights->bom->write)
     		{
     			if ($object->status == 1)
@@ -679,14 +679,14 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
     		}
     		*/
 
-    		if ($permissiontodelete)
-    		{
-    			print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
-    		} else {
-    			print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
-    		}
-    	}
-    	print '</div>'."\n";
+			if ($permissiontodelete)
+			{
+				print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=delete">'.$langs->trans('Delete').'</a>'."\n";
+			} else {
+				print '<a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("NotEnoughPermissions")).'">'.$langs->trans('Delete').'</a>'."\n";
+			}
+		}
+		print '</div>'."\n";
 	}
 
 
@@ -697,41 +697,41 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 
 	if ($action != 'presend')
 	{
-	    print '<div class="fichecenter"><div class="fichehalfleft">';
-	    print '<a name="builddoc"></a>'; // ancre
+		print '<div class="fichecenter"><div class="fichehalfleft">';
+		print '<a name="builddoc"></a>'; // ancre
 
-	    // Documents
-	    $objref = dol_sanitizeFileName($object->ref);
-	    $relativepath = $objref.'/'.$objref.'.pdf';
-	    $filedir = $conf->bom->dir_output.'/'.$objref;
-	    $urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
-	    $genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
-	    $delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
-	    print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
+		// Documents
+		$objref = dol_sanitizeFileName($object->ref);
+		$relativepath = $objref.'/'.$objref.'.pdf';
+		$filedir = $conf->bom->dir_output.'/'.$objref;
+		$urlsource = $_SERVER["PHP_SELF"]."?id=".$object->id;
+		$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
+		$delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
+		print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $langs->defaultlang);
 
-	    // Show links to link elements
-	    $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
-	    $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
+		// Show links to link elements
+		$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
+		$somethingshown = $form->showLinkedObjectBlock($object, $linktoelem);
 
 
-	    print '</div><div class="fichehalfright"><div class="ficheaddleft">';
+		print '</div><div class="fichehalfright"><div class="ficheaddleft">';
 
-	    $MAXEVENT = 10;
+		$MAXEVENT = 10;
 
-	    $morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">';
-	    $morehtmlright .= $langs->trans("SeeAll");
-	    $morehtmlright .= '</a>';
+		$morehtmlright = '<a href="'.dol_buildpath('/bom/bom_agenda.php', 1).'?id='.$object->id.'">';
+		$morehtmlright .= $langs->trans("SeeAll");
+		$morehtmlright .= '</a>';
 
-	    // List of actions on element
-	    include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
-	    $formactions = new FormActions($db);
-	    $somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
+		// List of actions on element
+		include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php';
+		$formactions = new FormActions($db);
+		$somethingshown = $formactions->showactions($object, 'bom', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
 
-	    print '</div></div></div>';
+		print '</div></div></div>';
 	}
 
 	//Select mail models is same action as presend
-    if (GETPOST('modelselected')) $action = 'presend';
+	if (GETPOST('modelselected')) $action = 'presend';
 
 	// Presend form
 	$modelmail = 'bom';

+ 15 - 15
htdocs/bom/tpl/objectline_create.tpl.php

@@ -31,8 +31,8 @@
 
 // Protection to avoid direct call of template
 if (empty($object) || !is_object($object)) {
-    print "Error: this template page cannot be called directly as an URL";
-    exit;
+	print "Error: this template page cannot be called directly as an URL";
+	exit;
 }
 
 
@@ -52,34 +52,34 @@ print "<!-- BEGIN PHP TEMPLATE objectline_create.tpl.php -->\n";
 
 $nolinesbefore = (count($this->lines) == 0 || $forcetoshowtitlelines);
 if ($nolinesbefore) {
-    print '<tr class="liste_titre nodrag nodrop">';
-    if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
-        print '<td class="linecolnum center"></td>';
-    }
-    print '<td class="linecoldescription minwidth500imp">';
+	print '<tr class="liste_titre nodrag nodrop">';
+	if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
+		print '<td class="linecolnum center"></td>';
+	}
+	print '<td class="linecoldescription minwidth500imp">';
 	print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
 	print '</td>';
 	print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
 	if ($conf->global->PRODUCT_USE_UNITS)
 	{
-	    print '<td class="linecoluseunit left">';
-	    print '<span id="title_units">';
-	    print $langs->trans('Unit');
-	    print '</span></td>';
+		print '<td class="linecoluseunit left">';
+		print '<span id="title_units">';
+		print $langs->trans('Unit');
+		print '</span></td>';
 	}
 	print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
 	print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
 	print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
 	print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
-    print '</tr>';
+	print '</tr>';
 }
 print '<tr class="pair nodrag nodrop nohoverpair'.(($nolinesbefore || $object->element == 'contrat') ? '' : ' liste_titre_create').'">';
 $coldisplay = 0;
 
 // Adds a line numbering column
 if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) {
-    $coldisplay++;
-    echo '<td class="bordertop nobottom linecolnum center"></td>';
+	$coldisplay++;
+	echo '<td class="bordertop nobottom linecolnum center"></td>';
 }
 
 $coldisplay++;
@@ -111,7 +111,7 @@ print '</td>';
 
 if ($conf->global->PRODUCT_USE_UNITS)
 {
-    $coldisplay++;
+	$coldisplay++;
 	print '<td class="nobottom linecoluseunit left">';
 	print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
 	print '</td>';

File diff suppressed because it is too large
+ 712 - 712
htdocs/categories/class/api_categories.class.php


File diff suppressed because it is too large
+ 278 - 278
htdocs/categories/class/categorie.class.php


File diff suppressed because it is too large
+ 448 - 448
htdocs/comm/action/class/actioncomm.class.php


+ 270 - 270
htdocs/comm/action/index.php

@@ -76,7 +76,7 @@ if (!$user->rights->agenda->myactions->read) accessforbidden();
 if (!$user->rights->agenda->allactions->read) $canedit = 0;
 if (!$user->rights->agenda->allactions->read || $filter == 'mine')  // If no permission to see all, we show only affected to me
 {
-    $filtert = $user->id;
+	$filtert = $user->id;
 }
 
 $action = GETPOST('action', 'alpha');
@@ -91,19 +91,19 @@ $type = GETPOST("search_type", 'aZ09') ?GETPOST("search_type", 'aZ09') : GETPOST
 $maxprint = (isset($_GET["maxprint"]) ?GETPOST("maxprint") : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW);
 $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print')
 
-$dateselect=dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
+$dateselect = dol_mktime(0, 0, 0, GETPOST('dateselectmonth', 'int'), GETPOST('dateselectday', 'int'), GETPOST('dateselectyear', 'int'));
 if ($dateselect > 0)
 {
-	$day=GETPOST('dateselectday', 'int');
-	$month=GETPOST('dateselectmonth', 'int');
-	$year=GETPOST('dateselectyear', 'int');
+	$day = GETPOST('dateselectday', 'int');
+	$month = GETPOST('dateselectmonth', 'int');
+	$year = GETPOST('dateselectyear', 'int');
 }
 
 // Set actioncode (this code must be same for setting actioncode into peruser, listacton and index)
 if (GETPOST('search_actioncode', 'array'))
 {
-    $actioncode = GETPOST('search_actioncode', 'array', 3);
-    if (!count($actioncode)) $actioncode = '0';
+	$actioncode = GETPOST('search_actioncode', 'array', 3);
+	if (!count($actioncode)) $actioncode = '0';
 } else {
 	$actioncode = GETPOST("search_actioncode", "alpha", 3) ?GETPOST("search_actioncode", "alpha", 3) : (GETPOST("search_actioncode") == '0' ? '0' : (empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_TYPE));
 }
@@ -119,13 +119,13 @@ if ($action == 'default')	// When action is default, we want a calendar view and
 	$action = (($defaultview != 'show_list') ? $defaultview : 'show_month');
 }
 if (GETPOST('viewcal', 'none') && GETPOST('action', 'alpha') != 'show_day' && GETPOST('action', 'alpha') != 'show_week') {
-    $action = 'show_month'; $day = '';
+	$action = 'show_month'; $day = '';
 } // View by month
 if (GETPOST('viewweek', 'none') || GETPOST('action', 'alpha') == 'show_week') {
-    $action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
+	$action = 'show_week'; $week = ($week ? $week : date("W")); $day = ($day ? $day : date("d"));
 } // View by week
 if (GETPOST('viewday', 'none') || GETPOST('action', 'alpha') == 'show_day') {
-    $action = 'show_day'; $day = ($day ? $day : date("d"));
+	$action = 'show_day'; $day = ($day ? $day : date("d"));
 } // View by day
 
 // Load translation files required by the page
@@ -141,46 +141,46 @@ $hookmanager->initHooks(array('agenda'));
 
 if (GETPOST("viewlist", 'alpha') || $action == 'show_list')
 {
-    $param = '';
-    if (is_array($_POST))
-    {
-        foreach ($_POST as $key => $val)
-        {
-            if ($key == 'token') continue;
-            $param .= '&'.$key.'='.urlencode($val);
-        }
-    }
-    if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
-    //print $param;
-    header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
-    exit;
+	$param = '';
+	if (is_array($_POST))
+	{
+		foreach ($_POST as $key => $val)
+		{
+			if ($key == 'token') continue;
+			$param .= '&'.$key.'='.urlencode($val);
+		}
+	}
+	if (! preg_match('/action=/', $param)) $param .= ($param ? '&' : '').'action=show_list';
+	//print $param;
+	header("Location: ".DOL_URL_ROOT.'/comm/action/list.php?'.$param);
+	exit;
 }
 
 if (GETPOST("viewperuser", 'alpha') || $action == 'show_peruser')
 {
-    $param = '';
-    if (is_array($_POST))
-    {
-        foreach ($_POST as $key => $val)
-        {
-            if ($key == 'token') continue;
-            $param .= '&'.$key.'='.urlencode($val);
-        }
-    }
-    //print $param;
-    header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
-    exit;
+	$param = '';
+	if (is_array($_POST))
+	{
+		foreach ($_POST as $key => $val)
+		{
+			if ($key == 'token') continue;
+			$param .= '&'.$key.'='.urlencode($val);
+		}
+	}
+	//print $param;
+	header("Location: ".DOL_URL_ROOT.'/comm/action/peruser.php?'.$param);
+	exit;
 }
 
 if ($action == 'delete_action')
 {
-    $event = new ActionComm($db);
-    $event->fetch($actionid);
-    $event->fetch_optionals();
-    $event->fetch_userassigned();
-    $event->oldcopy = clone $event;
+	$event = new ActionComm($db);
+	$event->fetch($actionid);
+	$event->fetch_optionals();
+	$event->fetch_userassigned();
+	$event->oldcopy = clone $event;
 
-    $result = $event->delete();
+	$result = $event->delete();
 }
 
 
@@ -226,21 +226,21 @@ $listofextcals = array();
 // Define list of external calendars (global admin setup)
 if (empty($conf->global->AGENDA_DISABLE_EXT))
 {
-    $i = 0;
-    while ($i < $MAXAGENDA)
-    {
-        $i++;
-        $source = 'AGENDA_EXT_SRC'.$i;
-        $name = 'AGENDA_EXT_NAME'.$i;
-        $offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
-        $color = 'AGENDA_EXT_COLOR'.$i;
-        $buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
-        if (!empty($conf->global->$source) && !empty($conf->global->$name))
-        {
-        	// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
-        	$listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
-        }
-    }
+	$i = 0;
+	while ($i < $MAXAGENDA)
+	{
+		$i++;
+		$source = 'AGENDA_EXT_SRC'.$i;
+		$name = 'AGENDA_EXT_NAME'.$i;
+		$offsettz = 'AGENDA_EXT_OFFSETTZ'.$i;
+		$color = 'AGENDA_EXT_COLOR'.$i;
+		$buggedfile = 'AGENDA_EXT_BUGGEDFILE'.$i;
+		if (!empty($conf->global->$source) && !empty($conf->global->$name))
+		{
+			// Note: $conf->global->buggedfile can be empty or 'uselocalandtznodaylight' or 'uselocalandtzdaylight'
+			$listofextcals[] = array('src'=>$conf->global->$source, 'name'=>$conf->global->$name, 'offsettz'=>$conf->global->$offsettz, 'color'=>$conf->global->$color, 'buggedfile'=>(isset($conf->global->buggedfile) ? $conf->global->buggedfile : 0));
+		}
+	}
 }
 // Define list of external calendars (user setup)
 if (empty($user->conf->AGENDA_DISABLE_EXT))
@@ -251,7 +251,7 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
 		$i++;
 		$source = 'AGENDA_EXT_SRC_'.$user->id.'_'.$i;
 		$name = 'AGENDA_EXT_NAME_'.$user->id.'_'.$i;
-        $offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
+		$offsettz = 'AGENDA_EXT_OFFSETTZ_'.$user->id.'_'.$i;
 		$color = 'AGENDA_EXT_COLOR_'.$user->id.'_'.$i;
 		$enabled = 'AGENDA_EXT_ENABLED_'.$user->id.'_'.$i;
 		$buggedfile = 'AGENDA_EXT_BUGGEDFILE_'.$user->id.'_'.$i;
@@ -265,65 +265,65 @@ if (empty($user->conf->AGENDA_DISABLE_EXT))
 
 if (empty($action) || $action == 'show_month')
 {
-    $prev = dol_get_prev_month($month, $year);
-    $prev_year  = $prev['year'];
-    $prev_month = $prev['month'];
-    $next = dol_get_next_month($month, $year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-
-    $max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
-    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
-    // tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
-    $tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
-    $tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
-    if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
-    $next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
-    if ($next_day < 6) $next_day += 7;
-    $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
+	$prev = dol_get_prev_month($month, $year);
+	$prev_year  = $prev['year'];
+	$prev_month = $prev['month'];
+	$next = dol_get_next_month($month, $year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+
+	$max_day_in_prev_month = date("t", dol_mktime(0, 0, 0, $prev_month, 1, $prev_year)); // Nb of days in previous month
+	$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year)); // Nb of days in next month
+	// tmpday is a negative or null cursor to know how many days before the 1st to show on month view (if tmpday=0, 1st is monday)
+	$tmpday = -date("w", dol_mktime(12, 0, 0, $month, 1, $year, true)) + 2; // date('w') is 0 fo sunday
+	$tmpday += ((isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1) - 1);
+	if ($tmpday >= 1) $tmpday -= 7; // If tmpday is 0 we start with sunday, if -6, we start with monday of previous week.
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $max_day_in_prev_month + $tmpday, $prev_year);
+	$next_day = 7 - ($max_day_in_month + 1 - $tmpday) % 7;
+	if ($next_day < 6) $next_day += 7;
+	$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
 }
 if ($action == 'show_week')
 {
-    $prev = dol_get_first_day_week($day, $month, $year);
-    $prev_year  = $prev['prev_year'];
-    $prev_month = $prev['prev_month'];
-    $prev_day   = $prev['prev_day'];
-    $first_day  = $prev['first_day'];
-    $first_month = $prev['first_month'];
-    $first_year = $prev['first_year'];
-
-    $week = $prev['week'];
-
-    $day = (int) $day;
-    $next = dol_get_next_week($first_day, $week, $first_month, $first_year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-    $next_day   = $next['day'];
-
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
+	$prev = dol_get_first_day_week($day, $month, $year);
+	$prev_year  = $prev['prev_year'];
+	$prev_month = $prev['prev_month'];
+	$prev_day   = $prev['prev_day'];
+	$first_day  = $prev['first_day'];
+	$first_month = $prev['first_month'];
+	$first_year = $prev['first_year'];
+
+	$week = $prev['week'];
+
+	$day = (int) $day;
+	$next = dol_get_next_week($first_day, $week, $first_month, $first_year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+	$next_day   = $next['day'];
+
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $first_month, $first_day, $first_year);
 	$lastdaytoshow = dol_time_plus_duree($firstdaytoshow, 7, 'd');
 
-    $max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
+	$max_day_in_month = date("t", dol_mktime(0, 0, 0, $month, 1, $year));
 
-    $tmpday = $first_day;
+	$tmpday = $first_day;
 }
 if ($action == 'show_day')
 {
-    $prev = dol_get_prev_day($day, $month, $year);
-    $prev_year  = $prev['year'];
-    $prev_month = $prev['month'];
-    $prev_day   = $prev['day'];
-    $next = dol_get_next_day($day, $month, $year);
-    $next_year  = $next['year'];
-    $next_month = $next['month'];
-    $next_day   = $next['day'];
-
-    // Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
-    $firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year);
-    $lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
+	$prev = dol_get_prev_day($day, $month, $year);
+	$prev_year  = $prev['year'];
+	$prev_month = $prev['month'];
+	$prev_day   = $prev['day'];
+	$next = dol_get_next_day($day, $month, $year);
+	$next_year  = $next['year'];
+	$next_month = $next['month'];
+	$next_day   = $next['day'];
+
+	// Define firstdaytoshow and lastdaytoshow (warning: lastdaytoshow is last second to show + 1)
+	$firstdaytoshow = dol_mktime(0, 0, 0, $prev_month, $prev_day, $prev_year);
+	$lastdaytoshow = dol_mktime(0, 0, 0, $next_month, $next_day, $next_year);
 }
 //print 'xx'.$prev_year.'-'.$prev_month.'-'.$prev_day;
 //print 'xx'.$next_year.'-'.$next_month.'-'.$next_day;
@@ -356,30 +356,30 @@ $param .= "&maxprint=".urlencode($maxprint);
 // Show navigation bar
 if (empty($action) || $action == 'show_month')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendar';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, 1, $year), "%b %Y");
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendar';
 }
 if ($action == 'show_week')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendarweek';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\" title=\"".dol_escape_htmltag($langs->trans("Previous"))."\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $first_month, $first_day, $first_year), "%Y").", ".$langs->trans("Week")." ".$week;
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\" title=\"".dol_escape_htmltag($langs->trans("Next"))."\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendarweek';
 }
 if ($action == 'show_day')
 {
-    $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
-    $nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
-    $nav .= " </span>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
-    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
-    $picto = 'calendarday';
+	$nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev_day.$param."\"><i class=\"fa fa-chevron-left\"></i></a> &nbsp;\n";
+	$nav .= " <span id=\"month_name\">".dol_print_date(dol_mktime(0, 0, 0, $month, $day, $year), "daytextshort");
+	$nav .= " </span>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$next_year."&amp;month=".$next_month."&amp;day=".$next_day.$param."\"><i class=\"fa fa-chevron-right\"></i></a>\n";
+	$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
+	$picto = 'calendarday';
 }
 
 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
@@ -471,21 +471,21 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
 	$s .= 'jQuery(".family_birthday").toggle();'."\n";
 	if ($action == "show_week" || $action == "show_month" || empty($action))
 	{
-        // Code to enable drag and drop
+		// Code to enable drag and drop
 		$s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n";
-        // Code to submit form
+		// Code to submit form
 		$s .= 'console.log("submit form to record new event");'."\n";
-        //$s.='console.log(event.target);';
+		//$s.='console.log(event.target);';
 		$s .= 'var newval = jQuery(event.target).closest("div.dayevent").attr("id");'."\n";
 		$s .= 'console.log("found parent div.dayevent with id = "+newval);'."\n";
 		$s .= 'var frm=jQuery("#searchFormList");'."\n";
 		$s .= 'var newurl = ui.item.find("a.cal_event").attr("href");'."\n";
 		$s .= 'console.log(newurl);'."\n";
 		$s .= 'frm.attr("action", newurl).children("#newdate").val(newval);frm.submit();}'."\n";
-        $s .= '});'."\n";
-    }
-    $s .= '});'."\n";
-    $s .= '</script>'."\n";
+		$s .= '});'."\n";
+	}
+	$s .= '});'."\n";
+	$s .= '</script>'."\n";
 
 	// Local calendar
 	$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
@@ -513,26 +513,26 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
 	$s .= '<div class="nowrap inline-block"><input type="checkbox" id="check_birthday" name="check_birthday" class="check_birthday"> <span class="check_birthday_text">'.$langs->trans("AgendaShowBirthdayEvents").'</span> &nbsp; </div>';
 
 	// Calendars from hooks
-    $parameters = array(); $object = null;
+	$parameters = array(); $object = null;
 	$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
-    if (empty($reshook))
-    {
+	if (empty($reshook))
+	{
 		$s .= $hookmanager->resPrint;
-    } elseif ($reshook > 1)
+	} elseif ($reshook > 1)
 	{
-    	$s = $hookmanager->resPrint;
-    }
+		$s = $hookmanager->resPrint;
+	}
 } else // If javascript off
 {
 	$newparam = $param; // newparam is for birthday links
-    $newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
-    if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1';
-    $link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
-    $link .= '?'.dol_escape_htmltag($newparam);
-    $link .= '">';
-    if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents");
-    else $link .= $langs->trans("AgendaHideBirthdayEvents");
-    $link .= '</a>';
+	$newparam = preg_replace('/showbirthday=[0-1]/i', 'showbirthday='.(empty($showbirthday) ? 1 : 0), $newparam);
+	if (!preg_match('/showbirthday=/i', $newparam)) $newparam .= '&showbirthday=1';
+	$link = '<a href="'.dol_escape_htmltag($_SERVER['PHP_SELF']);
+	$link .= '?'.dol_escape_htmltag($newparam);
+	$link .= '">';
+	if (empty($showbirthday)) $link .= $langs->trans("AgendaShowBirthdayEvents");
+	else $link .= $langs->trans("AgendaHideBirthdayEvents");
+	$link .= '</a>';
 }
 
 // Load events from database into $eventarray
@@ -561,26 +561,26 @@ $sql .= ' AND a.entity IN ('.getEntity('agenda').')';
 // Condition on actioncode
 if (!empty($actioncode))
 {
-    if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
-    {
-        if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
-        elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        else {
-            if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
-            if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        }
-    } else {
-        if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
-        elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
-        else {
-            if (is_array($actioncode))
-            {
-	        	$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
-            } else {
-	        	$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
-            }
-        }
-    }
+	if (empty($conf->global->AGENDA_USE_EVENT_TYPE))
+	{
+		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
+		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		else {
+			if ($actioncode == 'AC_OTH') $sql .= " AND ca.type != 'systemauto'";
+			if ($actioncode == 'AC_OTH_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		}
+	} else {
+		if ($actioncode == 'AC_NON_AUTO') $sql .= " AND ca.type != 'systemauto'";
+		elseif ($actioncode == 'AC_ALL_AUTO') $sql .= " AND ca.type = 'systemauto'";
+		else {
+			if (is_array($actioncode))
+			{
+				$sql .= " AND ca.code IN ('".implode("','", $actioncode)."')";
+			} else {
+				$sql .= " AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
+			}
+		}
+	}
 }
 if ($resourceid > 0) $sql .= " AND r.element_type = 'action' AND r.element_id = a.id AND r.resource_id = ".$db->escape($resourceid);
 if ($pid) $sql .= " AND a.fk_project=".$db->escape($pid);
@@ -590,28 +590,28 @@ if ($socid > 0) $sql .= ' AND a.fk_soc = '.$socid;
 if ($filtert > 0 || $usergroup > 0) $sql .= " AND ar.fk_actioncomm = a.id AND ar.element_type='user'";
 if ($action == 'show_day')
 {
-    $sql .= " AND (";
-    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
-    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
-    $sql .= ')';
+	$sql .= " AND (";
+	$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."'";
+	$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."')";
+	$sql .= ')';
 } else {
-    // To limit array
-    $sql .= " AND (";
-    $sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
-    $sql .= " OR ";
-    $sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
-    $sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
-    $sql .= " OR ";
-    $sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
-    $sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
-    $sql .= ')';
+	// To limit array
+	$sql .= " AND (";
+	$sql .= " (a.datep BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'"; // Start 7 days before
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')"; // End 7 days after + 3 to go from 28 to 31
+	$sql .= " OR ";
+	$sql .= " (a.datep2 BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
+	$sql .= " AND '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
+	$sql .= " OR ";
+	$sql .= " (a.datep < '".$db->idate(dol_mktime(0, 0, 0, $month, 1, $year) - (60 * 60 * 24 * 7))."'";
+	$sql .= " AND a.datep2 > '".$db->idate(dol_mktime(23, 59, 59, $month, 28, $year) + (60 * 60 * 24 * 10))."')";
+	$sql .= ')';
 }
 if ($type) $sql .= " AND ca.id = ".$type;
 if ($status == '0') { $sql .= " AND a.percent = 0"; }
@@ -622,10 +622,10 @@ if ($status == 'todo') { $sql .= " AND (a.percent >= 0 AND a.percent < 100)"; }
 // We must filter on assignement table
 if ($filtert > 0 || $usergroup > 0)
 {
-    $sql .= " AND (";
-    if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
-    if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
-    $sql .= ")";
+	$sql .= " AND (";
+	if ($filtert > 0) $sql .= "ar.fk_element = ".$filtert;
+	if ($usergroup > 0) $sql .= ($filtert > 0 ? " OR " : "")." ugu.fk_usergroup = ".$usergroup;
+	$sql .= ")";
 }
 // Sort on date
 $sql .= ' ORDER BY datep';
@@ -1090,8 +1090,8 @@ if (count($listofextcals))
                     // Transparency (see https://www.kanzaki.com/docs/ical/transp.html)
                     if ($icalevent['TRANSP'])
                     {
-                        if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0;     // 0 = available / free
-                        if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1;          // 1 = busy
+                        if ($icalevent['TRANSP'] == "TRANSPARENT") $event->transparency = 0; // 0 = available / free
+                        if ($icalevent['TRANSP'] == "OPAQUE") $event->transparency = 1; // 1 = busy
 
                         // TODO: MS outlook states
                         // X-MICROSOFT-CDO-BUSYSTATUS:FREE      + TRANSP:TRANSPARENT => Available / Free
@@ -1156,12 +1156,12 @@ if (count($listofextcals))
 $parameters = array(); $object = null;
 $reshook = $hookmanager->executeHooks('getCalendarEvents', $parameters, $object, $action);
 if (!empty($hookmanager->resArray['eventarray'])) {
-    foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
-        if (!isset($eventarray[$keyDate])) {
-            $eventarray[$keyDate] = array();
-        }
-        $eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
-    }
+	foreach ($hookmanager->resArray['eventarray'] as $keyDate => $events) {
+		if (!isset($eventarray[$keyDate])) {
+			$eventarray[$keyDate] = array();
+		}
+		$eventarray[$keyDate] = array_merge($eventarray[$keyDate], $events);
+	}
 }
 
 // Sort events
@@ -1180,7 +1180,7 @@ $cacheusers = array();
 $color_file = DOL_DOCUMENT_ROOT."/theme/".$conf->theme."/theme_vars.inc.php";
 if (is_readable($color_file))
 {
-    include_once $color_file;
+	include_once $color_file;
 }
 if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
 
@@ -1384,39 +1384,39 @@ if (empty($action) || $action == 'show_month')      // View by month
     echo " </div>\n";
 	*/
 
-    echo '</table>';
+	echo '</table>';
 	print '</div>';
 
-    /* WIP View per hour */
-    $useviewhour = 0;
-    if ($useviewhour)
-    {
-    	print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+	/* WIP View per hour */
+	$useviewhour = 0;
+	if ($useviewhour)
+	{
+		print '<div class="div-table-responsive-no-min borderbottom">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 
-    	$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
+		$maxheightwin = (isset($_SESSION["dol_screenheight"]) && $_SESSION["dol_screenheight"] > 500) ? ($_SESSION["dol_screenheight"] - 200) : 660; // Also into index.php file
 
-	    echo '<div style="max-height: '.$maxheightwin.'px;">';
+		echo '<div style="max-height: '.$maxheightwin.'px;">';
 		echo '<div class="tagtable centpercent calendarviewcontainer">';
 
-	    $maxnbofchar = 80;
+		$maxnbofchar = 80;
 
-	    $tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
-	    $minhour = round($tmp[0], 0);
-	    $maxhour = round($tmp[1], 0);
-	    if ($minhour > 23) $minhour = 23;
-	    if ($maxhour < 1)  $maxhour = 1;
-	    if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
+		$tmp = explode('-', $conf->global->MAIN_DEFAULT_WORKING_HOURS);
+		$minhour = round($tmp[0], 0);
+		$maxhour = round($tmp[1], 0);
+		if ($minhour > 23) $minhour = 23;
+		if ($maxhour < 1)  $maxhour = 1;
+		if ($maxhour <= $minhour) { $maxhour = $minhour + 1; }
 
-	    $i = 0;
-	    $j = 0;
+		$i = 0;
+		$j = 0;
 		while ($i < 24)
 		{
-		    echo ' <div class="tagtr calendarviewcontainertr">'."\n";
-		    echo '  <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
-		    echo '  <div class="tagtd '.$style.' tdtop"></div>'."\n";
-		    echo ' </div>'."\n";
-		    $i++;
-		    $j++;
+			echo ' <div class="tagtr calendarviewcontainertr">'."\n";
+			echo '  <div class="tagtd width100 tdtop">'.dol_print_date($i * 3600, 'hour', 'gmt').'</div>';
+			echo '  <div class="tagtd '.$style.' tdtop"></div>'."\n";
+			echo ' </div>'."\n";
+			$i++;
+			$j++;
 		}
 
 		echo '</div></div>';
@@ -1424,13 +1424,13 @@ if (empty($action) || $action == 'show_month')      // View by month
 		show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1);
 
 		print '</div>';
-    } else {
-    	print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
+	} else {
+		print '<div class="div-table-responsive-no-min">'; // You can use div-table-responsive-no-min if you dont need reserved height for your table
 
-    	show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
+		show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0);
 
-    	print '</div>';
-    }
+		print '</div>';
+	}
 }
 
 print "\n".'</form>';
@@ -1871,11 +1871,11 @@ function dol_color_minus($color, $minus, $minusunit = 16)
 	$newcolor = $color;
 	if ($minusunit == 16)
 	{
-    	$newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
-    	$newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
-    	$newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
+		$newcolor[0] = dechex(max(min(hexdec($newcolor[0]) - $minus, 15), 0));
+		$newcolor[2] = dechex(max(min(hexdec($newcolor[2]) - $minus, 15), 0));
+		$newcolor[4] = dechex(max(min(hexdec($newcolor[4]) - $minus, 15), 0));
 	} else {
-	    // Not yet implemented
+		// Not yet implemented
 	}
 	return $newcolor;
 }
@@ -1890,39 +1890,39 @@ function dol_color_minus($color, $minus, $minusunit = 16)
 function sort_events_by_date($a, $b)
 {
 	// Sort holidays at first
-    if ($a->type_code === 'HOLIDAY')
-    {
-        return -1;
-    }
+	if ($a->type_code === 'HOLIDAY')
+	{
+		return -1;
+	}
 
-    if ($b->type_code === 'HOLIDAY')
-    {
-        return 1;
-    }
+	if ($b->type_code === 'HOLIDAY')
+	{
+		return 1;
+	}
 
-    // datep => Event start time
-    // datef => Event end time
+	// datep => Event start time
+	// datef => Event end time
 
-    // Events have different start time
-    if ($a->datep !== $b->datep)
-    {
-        return $a->datep - $b->datep;
-    }
+	// Events have different start time
+	if ($a->datep !== $b->datep)
+	{
+		return $a->datep - $b->datep;
+	}
 
-    // Events have same start time and no end time
-    if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
-    {
-        return sort_events_by_percentage($a, $b);
-    }
+	// Events have same start time and no end time
+	if ((!is_numeric($b->datef)) || (!is_numeric($a->datef)))
+	{
+		return sort_events_by_percentage($a, $b);
+	}
 
-    // Events have the same start time and same end time
-    if ($b->datef === $a->datef)
-    {
-        return sort_events_by_percentage($a, $b);
-    }
+	// Events have the same start time and same end time
+	if ($b->datef === $a->datef)
+	{
+		return sort_events_by_percentage($a, $b);
+	}
 
-    // Events have the same start time, but have different end time -> longest event first
-    return $b->datef - $a->datef;
+	// Events have the same start time, but have different end time -> longest event first
+	return $b->datef - $a->datef;
 }
 
 /**
@@ -1934,18 +1934,18 @@ function sort_events_by_date($a, $b)
  */
 function sort_events_by_percentage($a, $b)
 {
-    // Sort events with no percentage before each other
-    // (usefull to sort holidays, sick days or similar on the top)
+	// Sort events with no percentage before each other
+	// (usefull to sort holidays, sick days or similar on the top)
 
-    if ($a->percentage < 0)
-    {
-        return -1;
-    }
+	if ($a->percentage < 0)
+	{
+		return -1;
+	}
 
-    if ($b->percentage < 0)
-    {
-        return 1;
-    }
+	if ($b->percentage < 0)
+	{
+		return 1;
+	}
 
-    return $b->percentage - $a->percentage;
+	return $b->percentage - $a->percentage;
 }

+ 2 - 2
htdocs/comm/action/list.php

@@ -160,7 +160,7 @@ $arrayfields = dol_sort_array($arrayfields, 'position');
 
 if (GETPOST('cancel', 'alpha'))
 {
-	$action='list'; $massaction='';
+	$action = 'list'; $massaction = '';
 }
 
 if (GETPOST("viewcal") || GETPOST("viewweek") || GETPOST("viewday"))
@@ -708,7 +708,7 @@ if ($resql)
 				$labeltype = $langs->trans("Message");
 			} else {
 				if (!empty($arraylist[$labeltype])) $labeltype = $arraylist[$labeltype];
-				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code];		// Use code in priority on type_code
+				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) $labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
 			}
 			print dol_trunc($labeltype, 28);
 			print '</td>';

+ 2 - 2
htdocs/compta/index.php

@@ -159,8 +159,8 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	$reshook = $hookmanager->executeHooks('printFieldListWhereCustomerDraft', $parameters);
 	$sql .= $hookmanager->resPrint;
 
-	$sql.= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
-	$sql.= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
+	$sql .= " GROUP BY f.rowid, f.ref, f.datef, f.total, f.tva, f.total_ttc, f.ref_client, f.type, ";
+	$sql .= "s.email, s.nom, s.rowid, s.code_client, s.code_compta, s.code_fournisseur, s.code_compta_fournisseur";
 
 	// Add Group from hooks
 	$parameters = array();

+ 39 - 39
htdocs/compta/prelevement/card.php

@@ -81,38 +81,38 @@ if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'e
 
 if (empty($reshook))
 {
-    if ($action == 'confirm_delete')
-    {
-        $res = $object->delete($user);
-        if ($res > 0)
-        {
-        	if ($object->type == 'bank-transfer') {
-        		header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
-        	} else {
-        		header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
-        	}
-            exit;
-        }
-    }
+	if ($action == 'confirm_delete')
+	{
+		$res = $object->delete($user);
+		if ($res > 0)
+		{
+			if ($object->type == 'bank-transfer') {
+				header("Location: ".DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php');
+			} else {
+				header("Location: ".DOL_URL_ROOT.'/compta/prelevement/index.php');
+			}
+			exit;
+		}
+	}
 
-    // Seems to no be used and replaced with $action == 'infocredit'
-    if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
-    {
-        $res = $object->set_credite();
-        if ($res >= 0)
-        {
-            header("Location: card.php?id=".$id);
-            exit;
-        }
-    }
+	// Seems to no be used and replaced with $action == 'infocredit'
+	if ($action == 'confirm_credite' && GETPOST('confirm', 'alpha') == 'yes')
+	{
+		$res = $object->set_credite();
+		if ($res >= 0)
+		{
+			header("Location: card.php?id=".$id);
+			exit;
+		}
+	}
 
-    if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
-    {
-        require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	if ($action == 'infotrans' && $user->rights->prelevement->bons->send)
+	{
+		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 		$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
-        /*
+		/*
         if ($_FILES['userfile']['name'] && basename($_FILES['userfile']['name'],".ps") == $object->ref)
         {
             $dir = $conf->prelevement->dir_output.'/receipts';
@@ -133,24 +133,24 @@ if (empty($reshook))
 
 		$error = $object->set_infotrans($user, $dt, GETPOST('methode', 'alpha'));
 
-        if ($error)
-        {
-            header("Location: card.php?id=".$id."&error=$error");
-            exit;
-        }
-    }
+		if ($error)
+		{
+			header("Location: card.php?id=".$id."&error=$error");
+			exit;
+		}
+	}
 
 	// Set direct debit order to credited, create payment and close invoices
 	if ($action == 'infocredit' && $user->rights->prelevement->bons->credit)
 	{
 		$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
-        $error = $object->set_infocredit($user, $dt);
-        if ($error)
-        {
-        	setEventMessages($object->error, $object->errors, 'errors');
-        }
-    }
+		$error = $object->set_infocredit($user, $dt);
+		if ($error)
+		{
+			setEventMessages($object->error, $object->errors, 'errors');
+		}
+	}
 }
 
 

+ 9 - 9
htdocs/compta/prelevement/class/bonprelevement.class.php

@@ -318,7 +318,7 @@ class BonPrelevement extends CommonObject
 				$this->type           = $obj->type;
 
 				$this->status         = $obj->status;
-				$this->statut         = $obj->status;	// For backward compatibility
+				$this->statut         = $obj->status; // For backward compatibility
 
 				$this->fetched = 1;
 
@@ -510,7 +510,7 @@ class BonPrelevement extends CommonObject
 					$paiement->num_paiement = $this->ref; // For backward compatibility
 					$paiement->id_prelevement = $this->id;
 
-					$paiement_id = $paiement->create($user);		// This use ->paiementid, that is ID of payment mode
+					$paiement_id = $paiement->create($user); // This use ->paiementid, that is ID of payment mode
 					if ($paiement_id < 0)
 					{
 						$error++;
@@ -540,7 +540,7 @@ class BonPrelevement extends CommonObject
 
 				// Update withdrawal line
 				// TODO: Translate to ligneprelevement.class.php
-				if (! $error) {
+				if (!$error) {
 					$sql = " UPDATE ".MAIN_DB_PREFIX."prelevement_lignes";
 					$sql .= " SET statut = 2";
 					$sql .= " WHERE fk_prelevement_bons = ".$this->id;
@@ -884,7 +884,7 @@ class BonPrelevement extends CommonObject
 				$sql .= " AND f.rowid = pfd.fk_facture_fourn";
 			}
 			$sql .= " AND s.rowid = f.fk_soc";
-			$sql .= " AND f.fk_statut = 1";			// Invoice validated
+			$sql .= " AND f.fk_statut = 1"; // Invoice validated
 			$sql .= " AND f.paye = 0";
 			$sql .= " AND pfd.traite = 0";
 			$sql .= " AND f.total_ttc > 0";
@@ -1179,7 +1179,7 @@ class BonPrelevement extends CommonObject
 			/*
 			 * Update total defined after generation of file
 			 */
-			if (! $error) {
+			if (!$error) {
 				$sql = "UPDATE ".MAIN_DB_PREFIX."prelevement_bons";
 				$sql .= " SET amount = ".price2num($this->total);
 				$sql .= " WHERE rowid = ".$this->id;
@@ -1542,7 +1542,7 @@ class BonPrelevement extends CommonObject
 					{
 						$obj = $this->db->fetch_object($resql);
 
-						if (! empty($cachearraytotestduplicate[$obj->idfac])) {
+						if (!empty($cachearraytotestduplicate[$obj->idfac])) {
 							$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
 							$this->invoice_in_error[$obj->idfac] = $this->error;
 							$result = -2;
@@ -1657,7 +1657,7 @@ class BonPrelevement extends CommonObject
 					{
 						$obj = $this->db->fetch_object($resql);
 
-						if (! empty($cachearraytotestduplicate[$obj->idfac])) {
+						if (!empty($cachearraytotestduplicate[$obj->idfac])) {
 							$this->error = $langs->trans('ErrorCompanyHasDuplicateDefaultBAN', $obj->socid);
 							$this->invoice_in_error[$obj->idfac] = $this->error;
 							$result = -2;
@@ -2192,7 +2192,7 @@ class BonPrelevement extends CommonObject
 				 $XML_SEPA_INFO .= '					<AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
 				 $XML_SEPA_INFO .= '				</PstlAdr>'.$CrLf;
 				 $XML_SEPA_INFO .= '			</UltmtCdtr>'.$CrLf;*/
-				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf;		// Field "Responsible of fees". Must be SLEV
+				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
 				$XML_SEPA_INFO .= '			<CdtrSchmeId>'.$CrLf;
 				$XML_SEPA_INFO .= '				<Id>'.$CrLf;
 				$XML_SEPA_INFO .= '					<PrvtId>'.$CrLf;
@@ -2254,7 +2254,7 @@ class BonPrelevement extends CommonObject
 				 $XML_SEPA_INFO .= '					<AdrLine>'.$conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN.'</AdrLine>'.$CrLf;
 				 $XML_SEPA_INFO .= '				</PstlAdr>'.$CrLf;
 				 $XML_SEPA_INFO .= '			</UltmtCdtr>'.$CrLf;*/
-				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf;		// Field "Responsible of fees". Must be SLEV
+				$XML_SEPA_INFO .= '			<ChrgBr>SLEV</ChrgBr>'.$CrLf; // Field "Responsible of fees". Must be SLEV
 				/*$XML_SEPA_INFO .= '			<CdtrSchmeId>'.$CrLf;
 				$XML_SEPA_INFO .= '				<Id>'.$CrLf;
 				$XML_SEPA_INFO .= '					<PrvtId>'.$CrLf;

+ 35 - 35
htdocs/compta/prelevement/create.php

@@ -84,10 +84,10 @@ if (empty($reshook))
 			$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS;
 		}
 		$bprev = new BonPrelevement($db);
-	    $executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
+		$executiondate = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), (GETPOST('reday', 'int') + $delayindays), GETPOST('reyear', 'int'));
 
-	    // $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
-	    $result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
+		// $conf->global->PRELEVEMENT_CODE_BANQUE and $conf->global->PRELEVEMENT_CODE_GUICHET should be empty (we don't use them anymore)
+		$result = $bprev->create($conf->global->PRELEVEMENT_CODE_BANQUE, $conf->global->PRELEVEMENT_CODE_GUICHET, $mode, $format, $executiondate, 0, $type);
 		if ($result < 0) {
 			setEventMessages($bprev->error, $bprev->errors, 'errors');
 		} elseif ($result == 0) {
@@ -188,30 +188,30 @@ print '<form action="'.$_SERVER['PHP_SELF'].'?action=create" method="POST">';
 print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 print '<input type="hidden" name="type" value="'.$type.'">';
 if ($nb) {
-    if ($pricetowithdraw) {
-        print $langs->trans('ExecutionDate').' ';
-        $datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
-        print $form->selectDate($datere, 're');
-
-        if ($mysoc->isInEEC()) {
-        	$title = $langs->trans("CreateForSepa");
-        	if ($type == 'bank-transfer') {
-        		$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
-        	}
-
-        	if ($type != 'bank-transfer') {
-            	print '<select name="format">';
-            	print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
-            	print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
-            	print '</select>';
-        	}
-            print '<input class="butAction" type="submit" value="'.$title.'"/>';
-        } else {
-        	$title = $langs->trans("CreateAll");
-        	if ($type == 'bank-transfer') {
-        		$title = $langs->trans("CreateFileForPaymentByBankTransfer");
-        	}
-        	print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
+	if ($pricetowithdraw) {
+		print $langs->trans('ExecutionDate').' ';
+		$datere = dol_mktime(0, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
+		print $form->selectDate($datere, 're');
+
+		if ($mysoc->isInEEC()) {
+			$title = $langs->trans("CreateForSepa");
+			if ($type == 'bank-transfer') {
+				$title = $langs->trans("CreateSepaFileForPaymentByBankTransfer");
+			}
+
+			if ($type != 'bank-transfer') {
+				print '<select name="format">';
+				print '<option value="FRST"'.(GETPOST('format', 'aZ09') == 'FRST' ? ' selected="selected"' : '').'>'.$langs->trans('SEPAFRST').'</option>';
+				print '<option value="RCUR"'.(GETPOST('format', 'aZ09') == 'RCUR' ? ' selected="selected"' : '').'>'.$langs->trans('SEPARCUR').'</option>';
+				print '</select>';
+			}
+			print '<input class="butAction" type="submit" value="'.$title.'"/>';
+		} else {
+			$title = $langs->trans("CreateAll");
+			if ($type == 'bank-transfer') {
+				$title = $langs->trans("CreateFileForPaymentByBankTransfer");
+			}
+			print '<a class="butAction" type="submit" href="create.php?action=create&format=ALL&type='.$type.'">'.$title."</a>\n";
 		}
 	} else {
 		if ($mysoc->isInEEC())
@@ -301,12 +301,12 @@ if ($resql)
 	$num = $db->num_rows($resql);
 	$i = 0;
 
-    $param = '';
+	$param = '';
 	if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
 	if ($socid) $param .= '&socid='.urlencode($socid);
-    if ($option) $param .= "&option=".urlencode($option);
+	if ($option) $param .= "&option=".urlencode($option);
 
-    print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
+	print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="page" value="'.$page.'">';
 	if (!empty($limit)) {
@@ -317,12 +317,12 @@ if ($resql)
 	if ($type == 'bank-transfer') {
 		$title = $langs->trans("InvoiceWaitingPaymentByBankTransfer");
 	}
-    print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
+	print_barre_liste($title, $page, $_SERVER['PHP_SELF'], $param, '', '', '', $num, $nbtotalofrecords, 'bill', 0, '', '', $limit);
 
-    $tradinvoice = "Invoice";
-    if ($type == 'bank-transfer') {
-    	$tradinvoice = "SupplierInvoice";
-    }
+	$tradinvoice = "Invoice";
+	if ($type == 'bank-transfer') {
+		$tradinvoice = "SupplierInvoice";
+	}
 
 	print '<table class="noborder centpercent">';
 	print '<tr class="liste_titre">';

+ 56 - 56
htdocs/compta/prelevement/factures.php

@@ -82,8 +82,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
 if ($id > 0 || $ref)
 {
   	if ($object->fetch($id, $ref) >= 0)
-    {
-    	$head = prelevement_prepare_head($object);
+	{
+		$head = prelevement_prepare_head($object);
 		dol_fiche_head($head, 'invoices', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@@ -151,9 +151,9 @@ if ($id > 0 || $ref)
 		print '</div>';
 
 		dol_fiche_end();
-    } else {
-      	dol_print_error($db);
-    }
+	} else {
+	  	dol_print_error($db);
+	}
 }
 
 
@@ -191,13 +191,13 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $resql = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($resql);
-    if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
-    {
-    	$page = 0;
-    	$offset = 0;
-    }
+	$resql = $db->query($sql);
+	$nbtotalofrecords = $db->num_rows($resql);
+	if (($page * $limit) > $nbtotalofrecords)	// if total resultset is smaller then paging size (filtering), goto and load page 0
+	{
+		$page = 0;
+		$offset = 0;
+	}
 }
 
 $sql .= $db->plimit($limit + 1, $offset);
@@ -212,13 +212,13 @@ if ($resql)
 
 	// Lines of title fields
 	print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
-    if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
+	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 	print '<input type="hidden" name="action" value="list">';
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
-    print '<input type="hidden" name="page" value="'.$page.'">';
+	print '<input type="hidden" name="page" value="'.$page.'">';
 	print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
 	print '<input type="hidden" name="id" value="'.$id.'">';
 
@@ -245,38 +245,38 @@ if ($resql)
 	$invoicetmpsupplier = new FactureFournisseur($db);
 
   	while ($i < min($num, $limit))
-    {
-     	$obj = $db->fetch_object($resql);
+	{
+	 	$obj = $db->fetch_object($resql);
 
-     	if ($obj->type == 'bank-transfer') {
-     		$invoicetmp = $invoicetmpsupplier;
-     	} else {
-     		$invoicetmp = $invoicetmpcustomer;
-     	}
-     	$invoicetmp->fetch($obj->facid);
+	 	if ($obj->type == 'bank-transfer') {
+	 		$invoicetmp = $invoicetmpsupplier;
+	 	} else {
+	 		$invoicetmp = $invoicetmpcustomer;
+	 	}
+	 	$invoicetmp->fetch($obj->facid);
 
-     	$thirdpartytmp->fetch($obj->socid);
+	 	$thirdpartytmp->fetch($obj->socid);
 
-      	print '<tr class="oddeven">';
+	  	print '<tr class="oddeven">';
 
-      	print "<td>";
-      	print $invoicetmp->getNomUrl(1);
-        print "</td>\n";
+	  	print "<td>";
+	  	print $invoicetmp->getNomUrl(1);
+		print "</td>\n";
 
-      	print '<td>';
-      	print $thirdpartytmp->getNomUrl(1);
-      	print "</td>\n";
+	  	print '<td>';
+	  	print $thirdpartytmp->getNomUrl(1);
+	  	print "</td>\n";
 
-      	// Amount of invoice
-      	print '<td class="right">'.price($obj->total_ttc)."</td>\n";
+	  	// Amount of invoice
+	  	print '<td class="right">'.price($obj->total_ttc)."</td>\n";
 
-      	// Amount requested
-      	print '<td class="right">'.price($obj->amount_requested)."</td>\n";
+	  	// Amount requested
+	  	print '<td class="right">'.price($obj->amount_requested)."</td>\n";
 
-      	// Status of requests
-      	print '<td class="center">';
+	  	// Status of requests
+	  	print '<td class="center">';
 
-      	if ($obj->statut == 0) {
+	  	if ($obj->statut == 0) {
 	  		print '-';
 		} elseif ($obj->statut == 2) {
 			if ($obj->type == 'bank-transfer') {
@@ -288,34 +288,34 @@ if ($resql)
 	  		print '<b>'.$langs->trans("StatusRefused").'</b>';
 		}
 
-      	print "</td>";
+	  	print "</td>";
 
-      	print "<td></td>";
+	  	print "<td></td>";
 
-      	print "</tr>\n";
+	  	print "</tr>\n";
 
-      	$totalinvoices += $obj->total_ttc;
-      	$totalamount_requested += $obj->amount_requested;
+	  	$totalinvoices += $obj->total_ttc;
+	  	$totalamount_requested += $obj->amount_requested;
 
-      	$i++;
-    }
+	  	$i++;
+	}
 
   	if ($num > 0)
-    {
-      	print '<tr class="liste_total">';
-     	print '<td>'.$langs->trans("Total").'</td>';
-      	print '<td>&nbsp;</td>';
-      	print '<td class="right">';
+	{
+	  	print '<tr class="liste_total">';
+	 	print '<td>'.$langs->trans("Total").'</td>';
+	  	print '<td>&nbsp;</td>';
+	  	print '<td class="right">';
 		//if ($totalinvoices != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");		// It is normal to have total that differs. For an amount of invoice of 100, request to pay may be 50 only.
-      	if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
+	  	if ($totalamount_requested != $object->amount) print img_warning("AmountOfFileDiffersFromSumOfInvoices");
 		print "</td>\n";
-      	print '<td class="right">';
+	  	print '<td class="right">';
 		print price($totalamount_requested);
-      	print "</td>\n";
-      	print '<td>&nbsp;</td>';
-      	print '<td>&nbsp;</td>';
-      	print "</tr>\n";
-    }
+	  	print "</td>\n";
+	  	print '<td>&nbsp;</td>';
+	  	print '<td>&nbsp;</td>';
+	  	print "</tr>\n";
+	}
 
   	print "</table>";
   	print '</div>';

+ 33 - 33
htdocs/compta/prelevement/fiche-rejet.php

@@ -76,8 +76,8 @@ llxHeader('', $langs->trans("WithdrawalsReceipts"));
 if ($prev_id > 0 || $ref)
 {
   	if ($object->fetch($prev_id, $ref) >= 0)
-    {
-    	$head = prelevement_prepare_head($object);
+	{
+		$head = prelevement_prepare_head($object);
 		dol_fiche_head($head, 'rejects', $langs->trans("WithdrawalsReceipts"), -1, 'payment');
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
@@ -145,9 +145,9 @@ if ($prev_id > 0 || $ref)
 		print '</div>';
 
 		dol_fiche_end();
-    } else {
-      	dol_print_error($db);
-    }
+	} else {
+	  	dol_print_error($db);
+	}
 }
 
 
@@ -205,44 +205,44 @@ if ($resql)
 
 	if ($num > 0)
 	{
-      	$i = 0;
-	    while ($i < $num)
-        {
-    		$obj = $db->fetch_object($resql);
+	  	$i = 0;
+		while ($i < $num)
+		{
+			$obj = $db->fetch_object($resql);
 
-    		print '<tr class="oddeven"><td>';
+			print '<tr class="oddeven"><td>';
 
-    		print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
-    		print img_picto('', 'statut'.$obj->statut).' ';
-    		print substr('000000'.$obj->rowid, -6);
-    		print '</a></td>';
-    		print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
+			print '<a href="'.DOL_URL_ROOT.'/compta/prelevement/line.php?id='.$obj->rowid.'">';
+			print img_picto('', 'statut'.$obj->statut).' ';
+			print substr('000000'.$obj->rowid, -6);
+			print '</a></td>';
+			print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.$obj->name."</a></td>\n";
 
-    		print '<td class="right">'.price($obj->amount)."</td>\n";
-    		print '<td>'.$rej->motifs[$obj->motif].'</td>';
+			print '<td class="right">'.price($obj->amount)."</td>\n";
+			print '<td>'.$rej->motifs[$obj->motif].'</td>';
 
-    		print '<td class="center">'.yn($obj->afacturer).'</td>';
-    		print '<td class="center">'.$obj->fk_facture.'</td>';
-    		print "</tr>\n";
+			print '<td class="center">'.yn($obj->afacturer).'</td>';
+			print '<td class="center">'.$obj->fk_facture.'</td>';
+			print "</tr>\n";
 
-    		$total += $obj->amount;
+			$total += $obj->amount;
 
-    		$i++;
-    	}
+			$i++;
+		}
 	} else {
-	    print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+		print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
 	}
 
   	if ($num > 0)
-    {
-    	print '<tr class="liste_total"><td>&nbsp;</td>';
-    	print '<td class="liste_total">'.$langs->trans("Total").'</td>';
-    	print '<td class="right">'.price($total)."</td>\n";
-    	print '<td colspan="3">&nbsp;</td>';
-    	print "</tr>\n";
-    }
-    print "</table>\n";
-    print '</div>';
+	{
+		print '<tr class="liste_total"><td>&nbsp;</td>';
+		print '<td class="liste_total">'.$langs->trans("Total").'</td>';
+		print '<td class="right">'.price($total)."</td>\n";
+		print '<td colspan="3">&nbsp;</td>';
+		print "</tr>\n";
+	}
+	print "</table>\n";
+	print '</div>';
 
 	$db->free($resql);
 } else {

File diff suppressed because it is too large
+ 544 - 544
htdocs/contact/card.php


+ 23 - 23
htdocs/contact/list.php

@@ -184,7 +184,7 @@ $arrayfields = array(
 	'p.statut'=>array('label'=>"Status", 'checked'=>1, 'position'=>1000),
 	'p.import_key'=>array('label'=>"ImportId", 'checked'=>0, 'position'=>1100),
 );
-if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
+if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
 	$arrayfields['p.fk_prospectcontactlevel'] = array('label'=>"ProspectLevelShort", 'checked'=>1, 'position'=>210);
 	$arrayfields['p.fk_stcommcontact'] = array('label'=>"StatusProsp", 'checked'=>1, 'position'=>215);
 }
@@ -270,8 +270,8 @@ if (empty($reshook))
 			}
 		}
 		$search_priv = "";
-		$search_stcomm='';
-		$search_level='';
+		$search_stcomm = '';
+		$search_level = '';
 		$search_status = -1;
 		$search_categ = '';
 		$search_categ_thirdparty = '';
@@ -314,7 +314,7 @@ $formother = new FormOther($db);
 $formcompany = new FormCompany($db);
 $contactstatic = new Contact($db);
 
-if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
+if (!empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
 	$contactstatic->loadCacheOfProspStatus();
 }
 
@@ -323,17 +323,17 @@ $title = (!empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) ? $langs->trans("C
 // Select every potentiels, and note each potentiels which fit in search parameters
 $tab_level = array();
 $sql = "SELECT code, label, sortorder";
-$sql.= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
-$sql.= " WHERE active > 0";
-$sql.= " ORDER BY sortorder";
+$sql .= " FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
+$sql .= " WHERE active > 0";
+$sql .= " ORDER BY sortorder";
 $resql = $db->query($sql);
 if ($resql)
 {
 	while ($obj = $db->fetch_object($resql))
 	{
 		// Compute level text
-		$level=$langs->trans($obj->code);
-		if ($level == $obj->code) $level=$langs->trans($obj->label);
+		$level = $langs->trans($obj->code);
+		if ($level == $obj->code) $level = $langs->trans($obj->label);
 		$tab_level[$obj->code] = $level;
 	}
 }
@@ -343,7 +343,7 @@ $sql = "SELECT s.rowid as socid, s.nom as name,";
 $sql .= " p.rowid, p.lastname as lastname, p.statut, p.firstname, p.zip, p.town, p.poste, p.email, p.no_email,";
 $sql .= " p.socialnetworks, p.photo,";
 $sql .= " p.phone as phone_pro, p.phone_mobile, p.phone_perso, p.fax, p.fk_pays, p.priv, p.datec as date_creation, p.tms as date_update,";
-$sql.= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
+$sql .= " st.libelle as stcomm, st.picto as stcomm_picto, p.fk_stcommcontact as stcomm_id, p.fk_prospectcontactlevel,";
 $sql .= " co.label as country, co.code as country_code";
 // Add fields from extrafields
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
@@ -357,7 +357,7 @@ $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p";
 if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (p.rowid = ef.fk_object)";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as co ON co.rowid = p.fk_pays";
 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = p.fk_soc";
-$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
+$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_stcommcontact as st ON st.id = p.fk_stcommcontact";
 if (!empty($search_categ)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_contact as cc ON p.rowid = cc.fk_socpeople"; // We need this table joined to the select in order to filter by categ
 if (!empty($search_categ_thirdparty)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_societe as cs ON s.rowid = cs.fk_soc"; // We need this table joined to the select in order to filter by categ
 if (!empty($search_categ_supplier)) $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX."categorie_fournisseur as cs2 ON s.rowid = cs2.fk_soc"; // We need this table joined to the select in order to filter by categ
@@ -469,7 +469,7 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 $sql .= $db->plimit($limit + 1, $offset);
 
 $resql = $db->query($sql);
-if (! $resql)
+if (!$resql)
 {
 	dol_print_error($db);
 	exit;
@@ -515,10 +515,10 @@ if ($search_email != '') $param .= '&amp;search_email='.urlencode($search_email)
 if ($search_no_email != '') $param .= '&amp;search_no_email='.urlencode($search_no_email);
 if ($search_status != '') $param .= '&amp;search_status='.urlencode($search_status);
 if ($search_priv == '0' || $search_priv == '1') $param .= "&amp;search_priv=".urlencode($search_priv);
-if ($search_stcomm != '') $param.='&search_stcomm='.urlencode($search_stcomm);
+if ($search_stcomm != '') $param .= '&search_stcomm='.urlencode($search_stcomm);
 if (is_array($search_level) && count($search_level)) {
 	foreach ($search_level as $slevel) {
-		$param.='&search_level[]='.urlencode($slevel);
+		$param .= '&search_level[]='.urlencode($slevel);
 	}
 }
 if ($search_import_key != '') $param .= '&amp;search_import_key='.urlencode($search_import_key);
@@ -739,20 +739,20 @@ if (!empty($arrayfields['p.priv']['checked']))
     print '</td>';
 }
 // Prospect level
-if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
+if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
 {
 	print '<td class="liste_titre center">';
 	print $form->multiselectarray('search_level', $tab_level, $search_level, 0, 0, 'width75', 0, 0, '', '', '', 2);
 	print '</td>';
 }
 // Prospect status
-if (! empty($arrayfields['p.fk_stcommcontact']['checked']))
+if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
 {
 	print '<td class="liste_titre maxwidthonsmartphone center">';
-	$arraystcomm=array();
+	$arraystcomm = array();
 	foreach ($contactstatic->cacheprospectstatus as $key => $val)
 	{
-		$arraystcomm[$val['id']]=($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
+		$arraystcomm[$val['id']] = ($langs->trans("StatusProspect".$val['id']) != "StatusProspect".$val['id'] ? $langs->trans("StatusProspect".$val['id']) : $val['label']);
 	}
 	print $form->selectarray('search_stcomm', $arraystcomm, $search_stcomm, -2, 0, 0, '', 0, 0, 0, '', 'nowrap ');
 	print '</td>';
@@ -877,7 +877,7 @@ while ($i < min($num, $limit))
 	$contactstatic->country_code = $obj->country_code;
 	$contactstatic->photo = $obj->photo;
 
-	$contactstatic->fk_prospectlevel=$obj->fk_prospectcontactlevel;
+	$contactstatic->fk_prospectlevel = $obj->fk_prospectcontactlevel;
 
 	print '<tr class="oddeven">';
 
@@ -1007,7 +1007,7 @@ while ($i < min($num, $limit))
 		if (!$i) $totalarray['nbfield']++;
 	}
 
-	if (! empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
+	if (!empty($arrayfields['p.fk_prospectcontactlevel']['checked']))
 	{
 		// Prospect level
 		print '<td class="center">';
@@ -1016,16 +1016,16 @@ while ($i < min($num, $limit))
 		if (!$i) $totalarray['nbfield']++;
 	}
 
-	if (! empty($arrayfields['p.fk_stcommcontact']['checked']))
+	if (!empty($arrayfields['p.fk_stcommcontact']['checked']))
 	{
 		// Prospect status
 		print '<td class="center nowrap"><div class="nowrap">';
-		print '<div class="inline-block">' . $contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
+		print '<div class="inline-block">'.$contactstatic->libProspCommStatut($obj->stcomm_id, 2, $contactstatic->cacheprospectstatus[$obj->stcomm_id]['label'], $obj->stcomm_picto);
 		print '</div> - <div class="inline-block">';
 		foreach ($contactstatic->cacheprospectstatus as $key => $val) {
 			$titlealt = 'default';
 			if (!empty($val['code']) && !in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt = $val['label'];
-			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="' . $_SERVER["PHP_SELF"] . '?stcommcontactid=' . $obj->rowid . '&stcomm=' . $val['code'] . '&action=setstcomm' . $param . ($page ? '&page=' . urlencode($page) : '') . '">' . img_action($titlealt, $val['code'], $val['picto']) . '</a>';
+			if ($obj->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?stcommcontactid='.$obj->rowid.'&stcomm='.$val['code'].'&action=setstcomm'.$param.($page ? '&page='.urlencode($page) : '').'">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
 		}
 		print '</div></div></td>';
 		if (!$i) $totalarray['nbfield']++;

+ 14 - 14
htdocs/core/actions_addupdatedelete.inc.php

@@ -85,7 +85,7 @@ if ($action == 'add' && !empty($permissiontoadd))
 		$object->$key = $value;
 		if ($val['notnull'] > 0 && $object->$key == '' && !is_null($val['default']) && $val['default'] == '(PROV)')
 		{
-		    $object->$key = '(PROV)';
+			$object->$key = '(PROV)';
 		}
 		if ($val['notnull'] > 0 && $object->$key == '' && is_null($val['default']))
 		{
@@ -105,7 +105,7 @@ if ($action == 'add' && !empty($permissiontoadd))
 		$result = $object->create($user);
 		if ($result > 0)
 		{
-		    // Creation OK
+			// Creation OK
 			$urltogo = $backtopage ? str_replace('__ID__', $result, $backtopage) : $backurlforlist;
 			$urltogo = preg_replace('/--IDFORBACKTOPAGE--/', $object->id, $urltogo); // New method to autoselect project after a New on another form object creation
 			header("Location: ".$urltogo);
@@ -154,7 +154,7 @@ if ($action == 'update' && !empty($permissiontoadd))
 				$value = '';
 			}
 		} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
-            $value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
+			$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
 		} elseif ($object->fields[$key]['type'] == 'boolean') {
 			$value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
 		} else {
@@ -223,11 +223,11 @@ if ($action == "update_extras" && !empty($permissiontoadd))
 // Action to delete
 if ($action == 'confirm_delete' && !empty($permissiontodelete))
 {
-    if (!($object->id > 0))
-    {
-        dol_print_error('', 'Error, object must be fetched before being deleted');
-        exit;
-    }
+	if (!($object->id > 0))
+	{
+		dol_print_error('', 'Error, object must be fetched before being deleted');
+		exit;
+	}
 
 	$result = $object->delete($user);
 	if ($result > 0)
@@ -246,7 +246,7 @@ if ($action == 'confirm_delete' && !empty($permissiontodelete))
 if ($action == 'confirm_deleteline' && $confirm == 'yes' && !empty($permissiontoadd))
 {
 	if (method_exists('deleteline', $object)) {
-		$result = $object->deleteline($user, $lineid);		// For backward compatibility
+		$result = $object->deleteline($user, $lineid); // For backward compatibility
 	} else {
 		$result = $object->deleteLine($user, $lineid);
 	}
@@ -385,11 +385,11 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
 	{
 		setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors');
 	} else {
-	    $objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
+		$objectutil = dol_clone($object, 1); // To avoid to denaturate loaded object when setting some properties for clone or if createFromClone modifies the object. We use native clone to keep this->db valid.
 		//$objectutil->date = dol_mktime(12, 0, 0, GETPOST('newdatemonth', 'int'), GETPOST('newdateday', 'int'), GETPOST('newdateyear', 'int'));
-        // ...
-	    $result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
-	    if (is_object($result) || $result > 0)
+		// ...
+		$result = $objectutil->createFromClone($user, (($object->id > 0) ? $object->id : $id));
+		if (is_object($result) || $result > 0)
 		{
 			$newid = 0;
 			if (is_object($result)) $newid = $result->id;
@@ -397,7 +397,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && !empty($permissiontoadd))
 			header("Location: ".$_SERVER['PHP_SELF'].'?id='.$newid); // Open record of new object
 			exit;
 		} else {
-		    setEventMessages($objectutil->error, $objectutil->errors, 'errors');
+			setEventMessages($objectutil->error, $objectutil->errors, 'errors');
 			$action = '';
 		}
 	}

+ 7 - 7
htdocs/core/actions_sendmails.inc.php

@@ -263,12 +263,12 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 
 		if (dol_strlen($sendto))
 		{
-            // Define $urlwithroot
-            $urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
-            $urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
-            //$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
+			// Define $urlwithroot
+			$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
+			$urlwithroot = $urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+			//$urlwithroot=DOL_MAIN_URL_ROOT;					// This is to use same domain name than current
 
-		    require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
+			require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php';
 
 			$langs->load("commercial");
 
@@ -419,7 +419,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 					// Initialisation of datas of object to call trigger
 					if (is_object($object))
 					{
-					    if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
+						if (empty($actiontypecode)) $actiontypecode = 'AC_OTH_AUTO'; // Event insert into agenda automatically
 
 						$object->socid = $sendtosocid; // To link to a company
 						$object->sendtoid = $sendtoid; // To link to contact-addresses. This is an array.
@@ -456,7 +456,7 @@ if (($action == 'send' || $action == 'relance') && !$_POST['addfile'] && !$_POST
 
 							if ($error) {
 								setEventMessages($object->error, $object->errors, 'errors');
-    						}
+							}
 						}
 						// End call of triggers
 					}

+ 194 - 194
htdocs/core/ajax/ajaxdirpreview.php

@@ -34,28 +34,28 @@ if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
 
 if (!isset($mode) || $mode != 'noajax')    // For ajax call
 {
-    require_once '../../main.inc.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-    require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
-
-    $action = GETPOST('action', 'aZ09');
-    $file = urldecode(GETPOST('file', 'alpha'));
-    $section = GETPOST("section", 'alpha');
-    $module = GETPOST("module", 'alpha');
-    $urlsource = GETPOST("urlsource", 'alpha');
-    $search_doc_ref = GETPOST('search_doc_ref', 'alpha');
-
-    $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
-    $sortfield = GETPOST("sortfield", 'alpha');
-    $sortorder = GETPOST("sortorder", 'alpha');
-    $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-    if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
-    $offset = $limit * $page;
-    $pageprev = $page - 1;
-    $pagenext = $page + 1;
-    if (!$sortorder) $sortorder = "ASC";
-    if (!$sortfield) $sortfield = "name";
+	require_once '../../main.inc.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+	require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
+
+	$action = GETPOST('action', 'aZ09');
+	$file = urldecode(GETPOST('file', 'alpha'));
+	$section = GETPOST("section", 'alpha');
+	$module = GETPOST("module", 'alpha');
+	$urlsource = GETPOST("urlsource", 'alpha');
+	$search_doc_ref = GETPOST('search_doc_ref', 'alpha');
+
+	$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit;
+	$sortfield = GETPOST("sortfield", 'alpha');
+	$sortorder = GETPOST("sortorder", 'alpha');
+	$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
+	if (empty($page) || $page == -1) { $page = 0; }     // If $page is not defined, or '' or -1
+	$offset = $limit * $page;
+	$pageprev = $page - 1;
+	$pagenext = $page + 1;
+	if (!$sortorder) $sortorder = "ASC";
+	if (!$sortfield) $sortfield = "name";
 
 	$rootdirfordoc = $conf->ecm->dir_output;
 
@@ -63,30 +63,30 @@ if (!isset($mode) || $mode != 'noajax')    // For ajax call
 
 	$ecmdir = new EcmDirectory($db);
 	if ($section > 0) {
-	    $result = $ecmdir->fetch($section);
-	    if (!$result > 0)
-	    {
-	        //dol_print_error($db,$ecmdir->error);
-	        //exit;
-	    }
+		$result = $ecmdir->fetch($section);
+		if (!$result > 0)
+		{
+			//dol_print_error($db,$ecmdir->error);
+			//exit;
+		}
 	}
 } else // For no ajax call
 {
 	$rootdirfordoc = $conf->ecm->dir_output;
 
 	$ecmdir = new EcmDirectory($db);
-    $relativepath = '';
-    if ($section > 0)
-    {
-        $result = $ecmdir->fetch($section);
-        if (!$result > 0)
-        {
-            dol_print_error($db, $ecmdir->error);
-            exit;
-        }
-
-        $relativepath = $ecmdir->getRelativePath(); // Example   'mydir/'
-    } elseif (GETPOST('section_dir'))
+	$relativepath = '';
+	if ($section > 0)
+	{
+		$result = $ecmdir->fetch($section);
+		if (!$result > 0)
+		{
+			dol_print_error($db, $ecmdir->error);
+			exit;
+		}
+
+		$relativepath = $ecmdir->getRelativePath(); // Example   'mydir/'
+	} elseif (GETPOST('section_dir'))
 	{
 		$relativepath = GETPOST('section_dir');
 	}
@@ -113,10 +113,10 @@ if ($user->socid > 0) $socid = $user->socid;
 // On interdit les remontees de repertoire ainsi que les pipe dans les noms de fichiers.
 if (preg_match('/\.\./', $upload_dir) || preg_match('/[<>|]/', $upload_dir))
 {
-    dol_syslog("Refused to deliver file ".$upload_dir);
-    // Do no show plain path in shown error message
-    dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
-    exit;
+	dol_syslog("Refused to deliver file ".$upload_dir);
+	// Do no show plain path in shown error message
+	dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $upload_dir));
+	exit;
 }
 
 // Check permissions
@@ -145,10 +145,10 @@ if ($modulepart == 'medias')
 if (!isset($mode) || $mode != 'noajax')
 {
 	// Ajout directives pour resoudre bug IE
-    header('Cache-Control: Public, must-revalidate');
-    header('Pragma: public');
+	header('Cache-Control: Public, must-revalidate');
+	header('Pragma: public');
 
-    top_httphead();
+	top_httphead();
 }
 
 $type = 'directory';
@@ -156,8 +156,8 @@ $type = 'directory';
 // This test if file exists should be useless. We keep it to find bug more easily
 if (!dol_is_dir($upload_dir))
 {
-    //dol_mkdir($upload_dir);
-    /*$langs->load("install");
+	//dol_mkdir($upload_dir);
+	/*$langs->load("install");
     dol_print_error(0,$langs->trans("ErrorDirDoesNotExists",$upload_dir));
     exit;*/
 }
@@ -173,76 +173,76 @@ if (!empty($pageid))     $param .= '&pageid='.urlencode($pageid);
 // Dir scan
 if ($type == 'directory')
 {
-    $formfile = new FormFile($db);
-
-    $maxlengthname = 40;
-    $excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
-    $sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
-
-    // Right area. If module is defined here, we are in automatic ecm.
-    $automodules = array(
-    	'company',
-    	'invoice',
-    	'invoice_supplier',
-    	'propal',
-    	'supplier_proposal',
-    	'order',
-    	'order_supplier',
-    	'contract',
-    	'product',
-    	'tax',
-    	'project',
-    	'fichinter',
-    	'user',
-    	'expensereport',
-    	'holiday',
-    	'recruitment-recruitmentcandidature',
-	    'banque',
-    	'mrp-mo'
-    );
-
-    // TODO change for multicompany sharing
-    if ($module == 'company') $upload_dir = $conf->societe->dir_output;
-    elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
-    elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
-    elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
-    elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
-    elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
-    elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
-    elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
-    elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
-    elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
-    elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
-    elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
-    elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
-    elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
-    elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
-    elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
-    elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
-    elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
-
-    // Automatic list
-    if (in_array($module, $automodules))
-    {
-        $param .= '&module='.$module;
-        if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
-
-        $textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
-
-        if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
-
-        $filter = preg_quote($search_doc_ref, '/');
-        $filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
-
-        $perm = $user->rights->ecm->upload;
-
-        $formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
-    }
-    // Manual list
-    else {
-    	if ($module == 'medias')
-    	{
-    		/*
+	$formfile = new FormFile($db);
+
+	$maxlengthname = 40;
+	$excludefiles = array('^SPECIMEN\.pdf$', '^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^payments$', '^CVS$', '^thumbs$');
+	$sorting = (strtolower($sortorder) == 'desc' ?SORT_DESC:SORT_ASC);
+
+	// Right area. If module is defined here, we are in automatic ecm.
+	$automodules = array(
+		'company',
+		'invoice',
+		'invoice_supplier',
+		'propal',
+		'supplier_proposal',
+		'order',
+		'order_supplier',
+		'contract',
+		'product',
+		'tax',
+		'project',
+		'fichinter',
+		'user',
+		'expensereport',
+		'holiday',
+		'recruitment-recruitmentcandidature',
+		'banque',
+		'mrp-mo'
+	);
+
+	// TODO change for multicompany sharing
+	if ($module == 'company') $upload_dir = $conf->societe->dir_output;
+	elseif ($module == 'invoice') $upload_dir = $conf->facture->dir_output;
+	elseif ($module == 'invoice_supplier') $upload_dir = $conf->fournisseur->facture->dir_output;
+	elseif ($module == 'propal') $upload_dir = $conf->propal->dir_output;
+	elseif ($module == 'supplier_proposal') $upload_dir = $conf->supplier_proposal->dir_output;
+	elseif ($module == 'order') $upload_dir = $conf->commande->dir_output;
+	elseif ($module == 'order_supplier') $upload_dir = $conf->fournisseur->commande->dir_output;
+	elseif ($module == 'contract') $upload_dir = $conf->contrat->dir_output;
+	elseif ($module == 'product') $upload_dir = $conf->product->dir_output;
+	elseif ($module == 'tax') $upload_dir = $conf->tax->dir_output;
+	elseif ($module == 'project') $upload_dir = $conf->projet->dir_output;
+	elseif ($module == 'fichinter') $upload_dir = $conf->ficheinter->dir_output;
+	elseif ($module == 'user') $upload_dir = $conf->user->dir_output;
+	elseif ($module == 'expensereport') $upload_dir = $conf->expensereport->dir_output;
+	elseif ($module == 'holiday') $upload_dir = $conf->holiday->dir_output;
+	elseif ($module == 'recruitment-recruitmentcandidature') $upload_dir = $conf->recruitment->dir_output.'/recruitmentcandidature';
+	elseif ($module == 'banque') $upload_dir = $conf->bank->dir_output;
+	elseif ($module == 'mrp-mo') $upload_dir = $conf->mrp->dir_output.'/mo';
+
+	// Automatic list
+	if (in_array($module, $automodules))
+	{
+		$param .= '&module='.$module;
+		if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.urlencode($search_doc_ref);
+
+		$textifempty = ($section ? $langs->trans("NoFileFound") : ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("NoFileFound")));
+
+		if ($module == 'company') $excludefiles[] = '^contact$'; // The subdir 'contact' contains files of contacts with no id of thirdparty.
+
+		$filter = preg_quote($search_doc_ref, '/');
+		$filearray = dol_dir_list($upload_dir, "files", 1, $filter, $excludefiles, $sortfield, $sorting, 1);
+
+		$perm = $user->rights->ecm->upload;
+
+		$formfile->list_of_autoecmfiles($upload_dir, $filearray, $module, $param, 1, '', $perm, 1, $textifempty, $maxlengthname, $url, 1);
+	}
+	// Manual list
+	else {
+		if ($module == 'medias')
+		{
+			/*
     		   $_POST is array like
     		  'token' => string '062380e11b7dcd009d07318b57b71750' (length=32)
 			  'action' => string 'file_manager' (length=12)
@@ -253,82 +253,82 @@ if ($type == 'directory')
 			  'max_file_size' => string '2097152' (length=7)
 			  'sendit' => string 'Envoyer fichier' (length=15)
     		 */
-    		$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
-    		if ($relativepath && $relativepath != '/') $relativepath .= '/';
-    		$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
-    		if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
-	    	{
-	    		$param .= '&file_manager=1';
-	    		if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
-	    		if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
-	    		//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
-	    	}
-    	} else {
-        	$relativepath = $ecmdir->getRelativePath();
-        	$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
-    	}
-
-        // If $section defined with value 0
+			$relativepath = GETPOST('file', 'alpha') ?GETPOST('file', 'alpha') : GETPOST('section_dir', 'alpha');
+			if ($relativepath && $relativepath != '/') $relativepath .= '/';
+			$upload_dir = $dolibarr_main_data_root.'/'.$module.'/'.$relativepath;
+			if (GETPOSTISSET('website') || GETPOSTISSET('file_manager'))
+			{
+				$param .= '&file_manager=1';
+				if (!preg_match('/website=/', $param)) $param .= '&website='.urlencode(GETPOST('website', 'alpha'));
+				if (!preg_match('/pageid=/', $param)) $param .= '&pageid='.urlencode(GETPOST('pageid', 'int'));
+				//if (!preg_match('/backtopage=/',$param)) $param.='&backtopage='.urlencode($_SERVER["PHP_SELF"].'?file_manager=1&website='.$websitekey.'&pageid='.$pageid);
+			}
+		} else {
+			$relativepath = $ecmdir->getRelativePath();
+			$upload_dir = $conf->ecm->dir_output.'/'.$relativepath;
+		}
+
+		// If $section defined with value 0
 		if (($section === '0' || empty($section)) && ($module != 'medias'))
-        {
-            $filearray = array();
-        } else {
-        	$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
-        }
-
-        if ($section)
-        {
-            $param .= '&section='.$section;
-        	if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
-
-            $textifempty = $langs->trans('NoFileFound');
-        } elseif ($section === '0')
-        {
-        	if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
-        	else $textifempty = $langs->trans('NoFileFound');
-        } else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
-
-        if ($module == 'medias')
-        {
-            $useinecm = 6;
-            $modulepart = 'medias';
-            $perm = ($user->rights->website->write || $user->rights->emailing->creer);
-            $title = 'none';
-        } elseif ($module == 'ecm') // DMS/ECM -> manual structure
-        {
-            if ($user->rights->ecm->read)
-            {
-                // Buttons: Preview
-                $useinecm = 2;
-            }
-
-            if ($user->rights->ecm->upload)
-            {
-                // Buttons: Preview + Delete
-                $useinecm = 4;
-            }
-
-            if ($user->rights->ecm->setup)
-            {
-                // Buttons: Preview + Delete + Edit
-                $useinecm = 5;
-            }
-
-            $perm = $user->rights->ecm->upload;
-            $modulepart = 'ecm';
-            $title = ''; // Use default
-        } else {
-            $useinecm = 5;
-            $modulepart = 'ecm';
-            $perm = $user->rights->ecm->upload;
-            $title = ''; // Use default
-        }
-
-        // When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
-        // When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
-        //var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
-        $formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
-    }
+		{
+			$filearray = array();
+		} else {
+			$filearray = dol_dir_list($upload_dir, "files", 0, '', array('^\.', '(\.meta|_preview.*\.png)$', '^temp$', '^CVS$'), $sortfield, $sorting, 1);
+		}
+
+		if ($section)
+		{
+			$param .= '&section='.$section;
+			if (isset($search_doc_ref) && $search_doc_ref != '') $param .= '&search_doc_ref='.$search_doc_ref;
+
+			$textifempty = $langs->trans('NoFileFound');
+		} elseif ($section === '0')
+		{
+			if ($module == 'ecm') $textifempty = '<br><div class="center"><font class="warning">'.$langs->trans("DirNotSynchronizedSyncFirst").'</font></div><br>';
+			else $textifempty = $langs->trans('NoFileFound');
+		} else $textifempty = ($showonrightsize == 'featurenotyetavailable' ? $langs->trans("FeatureNotYetAvailable") : $langs->trans("ECMSelectASection"));
+
+		if ($module == 'medias')
+		{
+			$useinecm = 6;
+			$modulepart = 'medias';
+			$perm = ($user->rights->website->write || $user->rights->emailing->creer);
+			$title = 'none';
+		} elseif ($module == 'ecm') // DMS/ECM -> manual structure
+		{
+			if ($user->rights->ecm->read)
+			{
+				// Buttons: Preview
+				$useinecm = 2;
+			}
+
+			if ($user->rights->ecm->upload)
+			{
+				// Buttons: Preview + Delete
+				$useinecm = 4;
+			}
+
+			if ($user->rights->ecm->setup)
+			{
+				// Buttons: Preview + Delete + Edit
+				$useinecm = 5;
+			}
+
+			$perm = $user->rights->ecm->upload;
+			$modulepart = 'ecm';
+			$title = ''; // Use default
+		} else {
+			$useinecm = 5;
+			$modulepart = 'ecm';
+			$perm = $user->rights->ecm->upload;
+			$title = ''; // Use default
+		}
+
+		// When we show list of files for ECM files, $filearray contains file list, and directory is defined with modulepart + section into $param
+		// When we show list of files for a directory, $filearray ciontains file list, and directory is defined with modulepart + $relativepath
+		//var_dump("section=".$section." title=".$title." modulepart=".$modulepart." useinecm=".$useinecm." perm=".$perm." relativepath=".$relativepath." param=".$param." url=".$url);
+		$formfile->list_of_documents($filearray, '', $modulepart, $param, 1, $relativepath, $perm, $useinecm, $textifempty, $maxlengthname, $title, $url, 0, $perm);
+	}
 }
 
 

+ 157 - 157
htdocs/core/class/CMailFile.class.php

@@ -41,47 +41,47 @@ class CMailFile
 	public $sendmode;
 	public $sendsetup;
 
-    public $subject; // Topic:       Subject of email
-    public $addr_from; // From:		Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
+	public $subject; // Topic:       Subject of email
+	public $addr_from; // From:		Label and EMail of sender (must include '<>'). For example '<myemail@example.com>' or 'John Doe <myemail@example.com>' or '<myemail+trackingid@example.com>'). Note that with gmail smtps, value here is forced by google to account (but not the reply-to).
 	// Sender:      Who send the email ("Sender" has sent emails on behalf of "From").
 	//              Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, add Sender field with an email of the protected domain.
 	// Return-Path: Email where to send bounds.
-    public $reply_to; // Reply-To:	Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
-    public $errors_to; // Errors-To:	Email where to send errors.
-    public $addr_to;
-    public $addr_cc;
-    public $addr_bcc;
-    public $trackid;
+	public $reply_to; // Reply-To:	Email where to send replies from mailer software (mailer use From if reply-to not defined, Gmail use gmail account if reply-to not defined)
+	public $errors_to; // Errors-To:	Email where to send errors.
+	public $addr_to;
+	public $addr_cc;
+	public $addr_bcc;
+	public $trackid;
 
-    public $mixed_boundary;
-    public $related_boundary;
-    public $alternative_boundary;
-    public $deliveryreceipt;
+	public $mixed_boundary;
+	public $related_boundary;
+	public $alternative_boundary;
+	public $deliveryreceipt;
 
-    public $eol;
-    public $eol2;
+	public $eol;
+	public $eol2;
 
 	/**
 	 * @var string Error code (or message)
 	 */
 	public $error = '';
 
-    public $smtps; // Contains SMTPs object (if this method is used)
-    public $phpmailer; // Contains PHPMailer object (if this method is used)
+	public $smtps; // Contains SMTPs object (if this method is used)
+	public $phpmailer; // Contains PHPMailer object (if this method is used)
 
 	/**
 	 * @var string CSS
 	 */
 	public $css;
 	//! Defined css style for body background
-    public $styleCSS;
+	public $styleCSS;
 	//! Defined background directly in body tag
-    public $bodyCSS;
+	public $bodyCSS;
 
-    public $msgid;
-    public $headers;
-    public $message;
-    /**
+	public $msgid;
+	public $headers;
+	public $message;
+	/**
 	 * @var array fullfilenames list (full path of filename on file system)
 	 */
 	public $filename_list = array();
@@ -95,21 +95,21 @@ class CMailFile
 	public $mimefilename_list = array();
 
 	// Image
-    public $html;
-    public $image_boundary;
-    public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
-    public $html_images = array();
-    public $images_encoded = array();
-    public $image_types = array(
-        'gif'  => 'image/gif',
+	public $html;
+	public $image_boundary;
+	public $atleastoneimage = 0; // at least one image file with file=xxx.ext into content (TODO Debug this. How can this case be tested. Remove if not used).
+	public $html_images = array();
+	public $images_encoded = array();
+	public $image_types = array(
+		'gif'  => 'image/gif',
 		'jpg'  => 'image/jpeg',
 		'jpeg' => 'image/jpeg',
 		'jpe'  => 'image/jpeg',
 		'bmp'  => 'image/bmp',
 		'png'  => 'image/png',
 		'tif'  => 'image/tiff',
-        'tiff' => 'image/tiff',
-    );
+		'tiff' => 'image/tiff',
+	);
 
 
 	/**
@@ -147,7 +147,7 @@ class CMailFile
 		// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
 		if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
 
-        $this->subject = $subject;
+		$this->subject = $subject;
 		$this->addr_to = $to;
 		$this->addr_from = $from;
 		$this->msg = $msg;
@@ -210,8 +210,8 @@ class CMailFile
 		}
 		if (empty($msg))
 		{
-		    dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
-		    $msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure)
+			dol_syslog("CMailFile::CMailfile: Try to send an email with empty body");
+			$msg = '.'; // Avoid empty message (with empty message content, you will see a multipart structure)
 		}
 
 		// Detect if message is HTML (use fast method)
@@ -291,7 +291,7 @@ class CMailFile
 
 		// Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
 		if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) {
-			$addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
+			$addr_bcc .= ($addr_bcc ? ', ' : '').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
 		}
 
 		// We set all data according to choosed sending method.
@@ -411,40 +411,40 @@ class CMailFile
 			$this->smtps = $smtps;
 		} elseif ($this->sendmode == 'swiftmailer') {
 			// Use Swift Mailer library
-            $host = dol_getprefix('email');
-
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php';
-
-            // egulias autoloader lib
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php';
-
-            require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
-
-            // Create the message
-            //$this->message = Swift_Message::newInstance();
-            $this->message = new Swift_Message();
-            //$this->message = new Swift_SignedMessage();
-            // Adding a trackid header to a message
-            $headers = $this->message->getHeaders();
-            $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
-            $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
-            $headerID = $this->msgid;
-            $msgid = $headers->get('Message-ID');
-            $msgid->setId($headerID);
-            $headers->addIdHeader('References', $headerID);
-            // TODO if (! empty($moreinheader)) ...
-
-            // Give the message a subject
-            try {
-                $result = $this->message->setSubject($this->subject);
-            } catch (Exception $e) {
-                $this->errors[] = $e->getMessage();
-            }
-
-            // Set the From address with an associative array
-            //$this->message->setFrom(array('john@doe.com' => 'John Doe'));
-            if (! empty($this->addr_from)) {
-                try {
+			$host = dol_getprefix('email');
+
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lexer/lib/Doctrine/Common/Lexer/AbstractLexer.php';
+
+			// egulias autoloader lib
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/autoload.php';
+
+			require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
+
+			// Create the message
+			//$this->message = Swift_Message::newInstance();
+			$this->message = new Swift_Message();
+			//$this->message = new Swift_SignedMessage();
+			// Adding a trackid header to a message
+			$headers = $this->message->getHeaders();
+			$headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
+			$this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
+			$headerID = $this->msgid;
+			$msgid = $headers->get('Message-ID');
+			$msgid->setId($headerID);
+			$headers->addIdHeader('References', $headerID);
+			// TODO if (! empty($moreinheader)) ...
+
+			// Give the message a subject
+			try {
+				$result = $this->message->setSubject($this->subject);
+			} catch (Exception $e) {
+				$this->errors[] = $e->getMessage();
+			}
+
+			// Set the From address with an associative array
+			//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
+			if (! empty($this->addr_from)) {
+				try {
 					if (! empty($conf->global->MAIN_FORCE_DISABLE_MAIL_SPOOFING)) {
 						// Prevent email spoofing for smtp server with a strict configuration
 						$regexp = '/([a-z0-9_\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,4})+/i'; // This regular expression extracts all emails from a string
@@ -459,35 +459,35 @@ class CMailFile
 					} else {
 						$result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
 					}
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            // Set the To addresses with an associative array
-            if (! empty($this->addr_to)) {
-                try {
-                    $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            if (! empty($this->reply_to)) {
-                try {
-                	$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
-                } catch (Exception $e) {
-                    $this->errors[] = $e->getMessage();
-                }
-            }
-
-            try {
-                $result = $this->message->setCharSet($conf->file->character_set_client);
-            } catch (Exception $e) {
-                $this->errors[] = $e->getMessage();
-            }
-
-            if (!empty($this->html)) {
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			// Set the To addresses with an associative array
+			if (! empty($this->addr_to)) {
+				try {
+					$result = $this->message->setTo($this->getArrayAddress($this->addr_to));
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			if (! empty($this->reply_to)) {
+				try {
+					$result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
+				} catch (Exception $e) {
+					$this->errors[] = $e->getMessage();
+				}
+			}
+
+			try {
+				$result = $this->message->setCharSet($conf->file->character_set_client);
+			} catch (Exception $e) {
+				$this->errors[] = $e->getMessage();
+			}
+
+			if (!empty($this->html)) {
 				if (!empty($css)) {
 					$this->css = $css;
 					$this->buildCSS();
@@ -578,26 +578,26 @@ class CMailFile
 			$sendingmode = $this->sendmode;
 			if ($this->context == 'emailing' && !empty($conf->global->MAILING_NO_USING_PHPMAIL) && $sendingmode == 'mail')
 			{
-			    // List of sending methods
-			    $listofmethods = array();
-			    $listofmethods['mail'] = 'PHP mail function';
-			    //$listofmethods['simplemail']='Simplemail class';
-			    $listofmethods['smtps'] = 'SMTP/SMTPS socket library';
-
-			    // EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
-			    // You ensure that every user is using its own SMTP server when using the mass emailing module.
-			    $linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
-			    $linktoadminemailend = '</a>';
-			    $this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
-			    $this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
-			    $this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
-			    $this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
-			    if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
-			    {
-			        $this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
-			        $this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
-			    }
-                return false;
+				// List of sending methods
+				$listofmethods = array();
+				$listofmethods['mail'] = 'PHP mail function';
+				//$listofmethods['simplemail']='Simplemail class';
+				$listofmethods['smtps'] = 'SMTP/SMTPS socket library';
+
+				// EMailing feature may be a spam problem, so when you host several users/instance, having this option may force each user to use their own SMTP agent.
+				// You ensure that every user is using its own SMTP server when using the mass emailing module.
+				$linktoadminemailbefore = '<a href="'.DOL_URL_ROOT.'/admin/mails.php">';
+				$linktoadminemailend = '</a>';
+				$this->error = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
+				$this->errors[] = $langs->trans("MailSendSetupIs", $listofmethods[$sendingmode]);
+				$this->error .= '<br>'.$langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
+				$this->errors[] = $langs->trans("MailSendSetupIs2", $linktoadminemailbefore, $linktoadminemailend, $langs->transnoentitiesnoconv("MAIN_MAIL_SENDMODE"), $listofmethods['smtps']);
+				if (!empty($conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS))
+				{
+					$this->error .= '<br>'.$langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
+					$this->errors[] = $langs->trans("MailSendSetupIs3", $conf->global->MAILING_SMTP_SETUP_EMAILS_FOR_QUESTIONS);
+				}
+				return false;
 			}
 
 			// Check number of recipient is lower or equal than MAIL_MAX_NB_OF_RECIPIENTS_IN_SAME_EMAIL
@@ -828,9 +828,9 @@ class CMailFile
 				}
 			} elseif ($this->sendmode == 'swiftmailer')
 			{
-                // Use Swift Mailer library
-                // ------------------------------------------
-                require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
+				// Use Swift Mailer library
+				// ------------------------------------------
+				require_once DOL_DOCUMENT_ROOT.'/includes/swiftmailer/lib/swift_required.php';
 
 				// Clean parameters
 				if (empty($conf->global->$keyforsmtpserver)) $conf->global->$keyforsmtpserver = ini_get('SMTP');
@@ -849,22 +849,22 @@ class CMailFile
 				//$smtps->_msgReplyTo  = 'reply@web.com';
 
 				// Switch content encoding to base64 - avoid the doubledot issue with quoted-printable
-                $contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
-                $this->message->setEncoder($contentEncoderBase64);
+				$contentEncoderBase64 = new Swift_Mime_ContentEncoder_Base64ContentEncoder();
+				$this->message->setEncoder($contentEncoderBase64);
 
 				// Create the Mailer using your created Transport
 				$this->mailer = new Swift_Mailer($this->transport);
 
-                // DKIM SIGN
-                if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) {
-                    $privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
-                    $domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
-                    $selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
-                    $signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
-                    $this->message->attachSigner($signer->ignoreHeader('Return-Path'));
-                }
+				// DKIM SIGN
+				if ($conf->global->MAIN_MAIL_EMAIL_DKIM_ENABLED) {
+					$privateKey = $conf->global->MAIN_MAIL_EMAIL_DKIM_PRIVATE_KEY;
+					$domainName = $conf->global->MAIN_MAIL_EMAIL_DKIM_DOMAIN;
+					$selector = $conf->global->MAIN_MAIL_EMAIL_DKIM_SELECTOR;
+					$signer = new Swift_Signers_DKIMSigner($privateKey, $domainName, $selector);
+					$this->message->attachSigner($signer->ignoreHeader('Return-Path'));
+				}
 
-                if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
+				if (!empty($conf->global->MAIN_MAIL_DEBUG)) {
 					// To use the ArrayLogger
 					$this->logger = new Swift_Plugins_Loggers_ArrayLogger();
 					// Or to use the Echo Logger
@@ -924,7 +924,7 @@ class CMailFile
 		return '=?'.$conf->file->character_set_client.'?B?'.base64_encode($stringtoencode).'?=';
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Read a file on disk and return encoded content for emails (mode = 'mail')
 	 *
@@ -933,7 +933,7 @@ class CMailFile
 	 */
 	private function _encode_file($sourcefile)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$newsourcefile = dol_osencode($sourcefile);
 
 		if (is_readable($newsourcefile))
@@ -949,7 +949,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Write content of a SMTP request into a dump file (mode = all)
 	 *  Used for debugging.
@@ -959,7 +959,7 @@ class CMailFile
 	 */
 	public function dump_mail()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $dolibarr_main_data_root;
 
 		if (@is_writeable($dolibarr_main_data_root))	// Avoid fatal error on fopen with open_basedir
@@ -1040,7 +1040,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Create SMTP headers (mode = 'mail')
 	 *
@@ -1048,7 +1048,7 @@ class CMailFile
 	 */
 	public function write_smtpheaders()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$out = "";
 
@@ -1104,7 +1104,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Create header MIME (mode = 'mail')
 	 *
@@ -1114,7 +1114,7 @@ class CMailFile
 	 */
 	public function write_mimeheaders($filename_list, $mimefilename_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$mimedone = 0;
 		$out = "";
 
@@ -1135,7 +1135,7 @@ class CMailFile
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Return email content (mode = 'mail')
 	 *
@@ -1144,7 +1144,7 @@ class CMailFile
 	 */
 	public function write_body($msgtext)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$out = '';
@@ -1235,7 +1235,7 @@ class CMailFile
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Attach file to email (mode = 'mail')
 	 *
@@ -1246,7 +1246,7 @@ class CMailFile
 	 */
 	public function write_files($filename_list, $mimetype_list, $mimefilename_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$out = '';
 
 		$filename_list_size = count($filename_list);
@@ -1282,7 +1282,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Attach an image to email (mode = 'mail')
 	 *
@@ -1291,7 +1291,7 @@ class CMailFile
 	 */
 	public function write_images($images_list)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$out = '';
 
 		if (is_array($images_list))
@@ -1315,7 +1315,7 @@ class CMailFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Try to create a socket connection
 	 *
@@ -1325,7 +1325,7 @@ class CMailFile
 	 */
 	public function check_server_port($host, $port)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$_retVal = 0;
@@ -1356,7 +1356,7 @@ class CMailFile
 
 			dol_syslog("Try socket connection to host=".$host." port=".$port);
 			//See if we can connect to the SMTP server
-            if ($socket = @fsockopen(
+			if ($socket = @fsockopen(
 					$host, // Host to test, IP or domain. Add ssl:// for SSL/TLS.
 					$port, // which Port number to use
 					$errno, // actual system level error
@@ -1377,7 +1377,7 @@ class CMailFile
 		return $_retVal;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * This function has been modified as provided by SirSir to allow multiline responses when
 	 * using SMTP Extensions.
@@ -1388,7 +1388,7 @@ class CMailFile
 	 */
 	public function server_parse($socket, $response)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$_retVal = true; // Indicates if Object was created or not
 		$server_response = '';
 
@@ -1512,8 +1512,8 @@ class CMailFile
 	 *										     If format 2: 'john@doe.com'
 	 *										     If format 3: '<john@doe.com>' or '"John Doe" <john@doe.com>' or '"=?UTF-8?B?Sm9obiBEb2U=?=" <john@doe.com>'
 	 *                                           If format 4: 'John Doe' or 'john@doe.com' if no label exists
-     *                                           If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists
-     * @see getArrayAddress()
+	 *                                           If format 5: <a href="mailto:john@doe.com">John Doe</a> or <a href="mailto:john@doe.com">john@doe.com</a> if no label exists
+	 * @see getArrayAddress()
 	 */
 	public static function getValidAddress($address, $format, $encode = 0, $maxnumberofemail = 0)
 	{
@@ -1541,10 +1541,10 @@ class CMailFile
 				$i++;
 
 				$newemail = '';
-                if ($format == 5) {
-                    $newemail = $name ? $name : $email;
-                    $newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>';
-                }
+				if ($format == 5) {
+					$newemail = $name ? $name : $email;
+					$newemail = '<a href="mailto:'.$email.'">'.$newemail.'</a>';
+				}
 				if ($format == 4)
 				{
 					$newemail = $name ? $name : $email;

File diff suppressed because it is too large
+ 208 - 208
htdocs/core/class/commonobject.class.php


File diff suppressed because it is too large
+ 248 - 248
htdocs/core/class/html.form.class.php


+ 251 - 251
htdocs/core/class/html.formactions.class.php

@@ -29,58 +29,58 @@
  */
 class FormActions
 {
-    /**
-     * @var DoliDB Database handler.
-     */
-    public $db;
+	/**
+	 * @var DoliDB Database handler.
+	 */
+	public $db;
 
-    /**
+	/**
 	 * @var string Error code (or message)
 	 */
 	public $error = '';
 
 
-    /**
+	/**
 	 *	Constructor
 	 *
-     *  @param      DoliDB		$db      Database handler
-     */
-    public function __construct($db)
-    {
-        $this->db = $db;
-    }
-
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Show list of action status
-     *
-     * 	@param	string	$formname		Name of form where select is included
-     * 	@param	string	$selected		Preselected value (-1..100)
-     * 	@param	int		$canedit		1=can edit, 0=read only
-     *  @param  string	$htmlname   	Name of html prefix for html fields (selectX and valX)
-     *  @param	integer	$showempty		Show an empty line if select is used
-     *  @param	integer	$onlyselect		0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
-     *  @param  string  $morecss        More css on select field
-     * 	@return	void
-     */
-    public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
-    {
-        // phpcs:enable
-        global $langs, $conf;
-
-        $listofstatus = array(
-            '-1' => $langs->trans("ActionNotApplicable"),
-            '0' => $langs->trans("ActionsToDoShort"),
-            '50' => $langs->trans("ActionRunningShort"),
-            '100' => $langs->trans("ActionDoneShort")
-        );
+	 *  @param      DoliDB		$db      Database handler
+	 */
+	public function __construct($db)
+	{
+		$this->db = $db;
+	}
+
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Show list of action status
+	 *
+	 * 	@param	string	$formname		Name of form where select is included
+	 * 	@param	string	$selected		Preselected value (-1..100)
+	 * 	@param	int		$canedit		1=can edit, 0=read only
+	 *  @param  string	$htmlname   	Name of html prefix for html fields (selectX and valX)
+	 *  @param	integer	$showempty		Show an empty line if select is used
+	 *  @param	integer	$onlyselect		0=Standard, 1=Hide percent of completion and force usage of a select list, 2=Same than 1 and add "Incomplete (Todo+Running)
+	 *  @param  string  $morecss        More css on select field
+	 * 	@return	void
+	 */
+	public function form_select_status_action($formname, $selected, $canedit = 1, $htmlname = 'complete', $showempty = 0, $onlyselect = 0, $morecss = 'maxwidth100')
+	{
+		// phpcs:enable
+		global $langs, $conf;
+
+		$listofstatus = array(
+			'-1' => $langs->trans("ActionNotApplicable"),
+			'0' => $langs->trans("ActionsToDoShort"),
+			'50' => $langs->trans("ActionRunningShort"),
+			'100' => $langs->trans("ActionDoneShort")
+		);
 		// +ActionUncomplete
 
-        if (!empty($conf->use_javascript_ajax))
-        {
-            print "\n";
-            print "<script type=\"text/javascript\">
+		if (!empty($conf->use_javascript_ajax))
+		{
+			print "\n";
+			print "<script type=\"text/javascript\">
                 var htmlname = '".$htmlname."';
 
                 $(document).ready(function () {
@@ -124,142 +124,142 @@ class FormActions
                     }
                 }
                 </script>\n";
-        }
-        if (!empty($conf->use_javascript_ajax) || $onlyselect)
-        {
-        	//var_dump($selected);
-        	if ($selected == 'done') $selected = '100';
-            print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
-            if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>';
-            foreach ($listofstatus as $key => $val)
-            {
-                print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
-                if ($key == '50' && $onlyselect == 2)
-                {
-                	print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
-                }
-            }
-            print '</select>';
-            if ($selected == 0 || $selected == 100) $canedit = 0;
-
-            if (empty($onlyselect))
-            {
-	            print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
-    	        print '<span class="hideonsmartphone hideifna">%</span>';
-            }
-        } else {
-            print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
-        }
-    }
-
-
-    /**
-     *  Show list of actions for element
-     *
-     *  @param	Object	$object					Object
-     *  @param  string	$typeelement			'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
-     *	@param	int		$socid					Socid of user
-     *  @param	int		$forceshowtitle			Show title even if there is no actions to show
-     *  @param  string  $morecss        		More css on table
-     *  @param	int		$max					Max number of record
-     *  @param	string	$moreparambacktopage	More param for the backtopage
-     *  @param	string	$morehtmlcenter			More html text on center of title line
-     *	@return	int								<0 if KO, >=0 if OK
-     */
-    public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
-    {
-        global $langs, $conf, $user;
-
-        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
-
-        $sortfield = 'a.datep,a.id';
-        $sortorder = 'DESC,DESC';
-
-        $listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
-        if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
-
-        $num = count($listofactions);
-        if ($num || $forceshowtitle)
-        {
-        	if ($typeelement == 'invoice')               $title = $langs->trans('ActionsOnBill');
-        	elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
-        	elseif ($typeelement == 'propal')            $title = $langs->trans('ActionsOnPropal');
-        	elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
-        	elseif ($typeelement == 'order')             $title = $langs->trans('ActionsOnOrder');
-        	elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order')   $title = $langs->trans('ActionsOnOrder');
-        	elseif ($typeelement == 'shipping')          $title = $langs->trans('ActionsOnShipping');
-            elseif ($typeelement == 'fichinter')         $title = $langs->trans('ActionsOnFicheInter');
-            elseif ($typeelement == 'project')           $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            elseif ($typeelement == 'task')              $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            elseif ($typeelement == 'member')            $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
-            else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
-
-            $urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
-
-            $projectid = $object->fk_project;
-            if ($typeelement == 'project') $projectid = $object->id;
-
-            $newcardbutton = '';
-            if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
+		}
+		if (!empty($conf->use_javascript_ajax) || $onlyselect)
+		{
+			//var_dump($selected);
+			if ($selected == 'done') $selected = '100';
+			print '<select '.($canedit ? '' : 'disabled ').'name="'.$htmlname.'" id="select'.$htmlname.'" class="flat'.($morecss ? ' '.$morecss : '').'">';
+			if ($showempty) print '<option value=""'.($selected == '' ? ' selected' : '').'></option>';
+			foreach ($listofstatus as $key => $val)
+			{
+				print '<option value="'.$key.'"'.(($selected == $key && strlen($selected) == strlen($key)) || (($selected > 0 && $selected < 100) && $key == '50') ? ' selected' : '').'>'.$val.'</option>';
+				if ($key == '50' && $onlyselect == 2)
+				{
+					print '<option value="todo"'.($selected == 'todo' ? ' selected' : '').'>'.$langs->trans("ActionUncomplete").' ('.$langs->trans("ActionsToDoShort")."+".$langs->trans("ActionRunningShort").')</option>';
+				}
+			}
+			print '</select>';
+			if ($selected == 0 || $selected == 100) $canedit = 0;
+
+			if (empty($onlyselect))
 			{
-                $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage));
+				print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat hideifna" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit && ($selected >= 0) ? '' : ' disabled').'>';
+				print '<span class="hideonsmartphone hideifna">%</span>';
 			}
+		} else {
+			print ' <input type="text" id="val'.$htmlname.'" name="percentage" class="flat" value="'.($selected >= 0 ? $selected : '').'" size="2"'.($canedit ? '' : ' disabled').'>%';
+		}
+	}
 
 
-        	print '<!-- formactions->showactions -->'."\n";
-        	print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter);
+	/**
+	 *  Show list of actions for element
+	 *
+	 *  @param	Object	$object					Object
+	 *  @param  string	$typeelement			'invoice', 'propal', 'order', 'invoice_supplier', 'order_supplier', 'fichinter'
+	 *	@param	int		$socid					Socid of user
+	 *  @param	int		$forceshowtitle			Show title even if there is no actions to show
+	 *  @param  string  $morecss        		More css on table
+	 *  @param	int		$max					Max number of record
+	 *  @param	string	$moreparambacktopage	More param for the backtopage
+	 *  @param	string	$morehtmlcenter			More html text on center of title line
+	 *	@return	int								<0 if KO, >=0 if OK
+	 */
+	public function showactions($object, $typeelement, $socid = 0, $forceshowtitle = 0, $morecss = 'listactions', $max = 0, $moreparambacktopage = '', $morehtmlcenter = '')
+	{
+		global $langs, $conf, $user;
 
-        	$page = 0; $param = '';
+		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 
-        	print '<div class="div-table-responsive-no-min">';
-        	print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
-        	print '<tr class="liste_titre">';
-        	print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
-        	print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
-        	print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
-        	print '</tr>';
-        	print "\n";
+		$sortfield = 'a.datep,a.id';
+		$sortorder = 'DESC,DESC';
 
-        	if (is_array($listofactions) && count($listofactions))
-        	{
-        		$cacheusers = array();
+		$listofactions = ActionComm::getActions($this->db, $socid, $object->id, $typeelement, '', $sortfield, $sortorder, ($max ? ($max + 1) : 0));
+		if (!is_array($listofactions)) dol_print_error($this->db, 'FailedToGetActions');
 
-	        	$cursorevent = 0;
-	        	foreach ($listofactions as $actioncomm)
-	        	{
-	        		if ($max && $cursorevent >= $max) break;
+		$num = count($listofactions);
+		if ($num || $forceshowtitle)
+		{
+			if ($typeelement == 'invoice')               $title = $langs->trans('ActionsOnBill');
+			elseif ($typeelement == 'invoice_supplier' || $typeelement == 'supplier_invoice') $title = $langs->trans('ActionsOnBill');
+			elseif ($typeelement == 'propal')            $title = $langs->trans('ActionsOnPropal');
+			elseif ($typeelement == 'supplier_proposal') $title = $langs->trans('ActionsOnSupplierProposal');
+			elseif ($typeelement == 'order')             $title = $langs->trans('ActionsOnOrder');
+			elseif ($typeelement == 'order_supplier' || $typeelement == 'supplier_order')   $title = $langs->trans('ActionsOnOrder');
+			elseif ($typeelement == 'shipping')          $title = $langs->trans('ActionsOnShipping');
+			elseif ($typeelement == 'fichinter')         $title = $langs->trans('ActionsOnFicheInter');
+			elseif ($typeelement == 'project')           $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			elseif ($typeelement == 'task')              $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			elseif ($typeelement == 'member')            $title = $langs->trans('LatestLinkedEvents', $max ? $max : '');
+			else $title = $langs->trans("LatestLinkedEvents", $max ? $max : '');
+
+			$urlbacktopage = $_SERVER['PHP_SELF'].'?id='.$object->id.($moreparambacktopage ? '&'.$moreparambacktopage : '');
+
+			$projectid = $object->fk_project;
+			if ($typeelement == 'project') $projectid = $object->id;
+
+			$newcardbutton = '';
+			if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create))
+			{
+				$newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage));
+			}
+
+
+			print '<!-- formactions->showactions -->'."\n";
+			print load_fiche_titre($title, $newcardbutton, '', 0, 0, '', $morehtmlcenter);
+
+			$page = 0; $param = '';
+
+			print '<div class="div-table-responsive-no-min">';
+			print '<table class="centpercent noborder'.($morecss ? ' '.$morecss : '').'">';
+			print '<tr class="liste_titre">';
+			print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Title', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
+			print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, '', $sortfield, $sortorder, 'center ', 1);
+			print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, 'right ', 1);
+			print '</tr>';
+			print "\n";
+
+			if (is_array($listofactions) && count($listofactions))
+			{
+				$cacheusers = array();
 
-	        		$ref = $actioncomm->getNomUrl(1, -1);
-	        		$label = $actioncomm->getNomUrl(0, 38);
+				$cursorevent = 0;
+				foreach ($listofactions as $actioncomm)
+				{
+					if ($max && $cursorevent >= $max) break;
 
-	        		print '<tr class="oddeven">';
-	        		// Ref
+					$ref = $actioncomm->getNomUrl(1, -1);
+					$label = $actioncomm->getNomUrl(0, 38);
+
+					print '<tr class="oddeven">';
+					// Ref
 					print '<td class="nowraponall">'.$ref.'</td>';
 					// Onwer
-	        		print '<td class="tdoverflowmax150">';
-	        		if (!empty($actioncomm->userownerid))
-	        		{
-	        			if (is_object($cacheusers[$actioncomm->userownerid]))
-	        			{
-	        				$tmpuser = $cacheusers[$actioncomm->userownerid];
-	        			} else {
-	        				$tmpuser = new User($this->db);
-	        				$tmpuser->fetch($actioncomm->userownerid);
-	        				$cacheusers[$actioncomm->userownerid] = $tmpuser;
-	        			}
-	        			if ($tmpuser->id > 0)
-	        			{
-	        				print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
-	        			}
-	        		}
-	        		print '</td>';
+					print '<td class="tdoverflowmax150">';
+					if (!empty($actioncomm->userownerid))
+					{
+						if (is_object($cacheusers[$actioncomm->userownerid]))
+						{
+							$tmpuser = $cacheusers[$actioncomm->userownerid];
+						} else {
+							$tmpuser = new User($this->db);
+							$tmpuser->fetch($actioncomm->userownerid);
+							$cacheusers[$actioncomm->userownerid] = $tmpuser;
+						}
+						if ($tmpuser->id > 0)
+						{
+							print $tmpuser->getNomUrl(-1, '', 0, 0, 16, 0, 'firstelselast', '');
+						}
+					}
+					print '</td>';
 
 					// Type
-	        		print '<td>';
-	        		// TODO Code common with code into comm/action/list.php
+					print '<td>';
+					// TODO Code common with code into comm/action/list.php
 					$imgpicto = '';
 					if (!empty($conf->global->AGENDA_USE_EVENT_TYPE))
 					{
@@ -281,100 +281,100 @@ class FormActions
 					} else {
 						print $actioncomm->type_short ? $actioncomm->type_short : $actioncomm->type;
 					}
-	        		print '</td>';
-	        		// Label
-	        		print '<td>'.$label.'</td>';
-	        		// Date
-	        		print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel');
-	        		if ($actioncomm->datef)
-	        		{
-		        		$tmpa = dol_getdate($actioncomm->datep);
-		        		$tmpb = dol_getdate($actioncomm->datef);
-		        		if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
-		        		{
-		        			if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel');
-		        		} else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel');
-	        		}
-	        		print '</td>';
-	        		print '<td class="right">';
-        			print $actioncomm->getLibStatut(3);
-	        		print '</td>';
-	        		print '</tr>';
-
-	        		$cursorevent++;
-	        	}
-        	} else {
-        		print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
-        	}
-
-        	if ($max && $num > $max)
-        	{
-        		print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
-        	}
-
-        	print '</table>';
-        	print '</div>';
-        }
-
-        return $num;
-    }
-
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Output html select list of type of event
-     *
-     *  @param	array|string	$selected       Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too.
-     *  @param  string		    $htmlname       Name of select field
-     *  @param	string		    $excludetype	A type to exclude ('systemauto', 'system', '')
-     *  @param	integer		    $onlyautoornot	1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual"
-     *  @param	int		        $hideinfohelp	1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value
-     *  @param  int		        $multiselect    1=Allow multiselect of action type
-     *  @param  int             $nooutput       1=No output
-     *  @param	string			$morecss		More css to add to SELECT component.
-     * 	@return	string
-     */
-    public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '')
-    {
-        // phpcs:enable
-        global $langs, $user, $form, $conf;
-
-        if (!is_object($form)) $form = new Form($this->db);
-
-        require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
-        require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
-        $caction = new CActionComm($this->db);
-
-        // Suggest a list with manual events or all auto events
-        $arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
-        if (empty($multiselect)) {
-            // Add empty line at start only if no multiselect
-            array_unshift($arraylist, '&nbsp;');
-        }
-        //asort($arraylist);
-
-       	if ($selected == 'manual') $selected = 'AC_OTH';
-       	if ($selected == 'auto')   $selected = 'AC_OTH_AUTO';
-
-       	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
-
-       	$out = '';
+					print '</td>';
+					// Label
+					print '<td>'.$label.'</td>';
+					// Date
+					print '<td class="center">'.dol_print_date($actioncomm->datep, 'dayhour', 'tzuserrel');
+					if ($actioncomm->datef)
+					{
+						$tmpa = dol_getdate($actioncomm->datep);
+						$tmpb = dol_getdate($actioncomm->datef);
+						if ($tmpa['mday'] == $tmpb['mday'] && $tmpa['mon'] == $tmpb['mon'] && $tmpa['year'] == $tmpb['year'])
+						{
+							if ($tmpa['hours'] != $tmpb['hours'] || $tmpa['minutes'] != $tmpb['minutes'] && $tmpa['seconds'] != $tmpb['seconds']) print '-'.dol_print_date($actioncomm->datef, 'hour', 'tzuserrel');
+						} else print '-'.dol_print_date($actioncomm->datef, 'dayhour', 'tzuserrel');
+					}
+					print '</td>';
+					print '<td class="right">';
+					print $actioncomm->getLibStatut(3);
+					print '</td>';
+					print '</tr>';
+
+					$cursorevent++;
+				}
+			} else {
+				print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+			}
+
+			if ($max && $num > $max)
+			{
+				print '<tr class="oddeven"><td colspan="6" class="opacitymedium">'.$langs->trans("More").'...</td></tr>';
+			}
+
+			print '</table>';
+			print '</div>';
+		}
+
+		return $num;
+	}
+
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Output html select list of type of event
+	 *
+	 *  @param	array|string	$selected       Type pre-selected (can be 'manual', 'auto' or 'AC_xxx'). Can be an array too.
+	 *  @param  string		    $htmlname       Name of select field
+	 *  @param	string		    $excludetype	A type to exclude ('systemauto', 'system', '')
+	 *  @param	integer		    $onlyautoornot	1=Group all type AC_XXX into 1 line AC_MANUAL. 0=Keep details of type, -1=Keep details and add a combined line "All manual"
+	 *  @param	int		        $hideinfohelp	1=Do not show info help, 0=Show, -1=Show+Add info to tell how to set default value
+	 *  @param  int		        $multiselect    1=Allow multiselect of action type
+	 *  @param  int             $nooutput       1=No output
+	 *  @param	string			$morecss		More css to add to SELECT component.
+	 * 	@return	string
+	 */
+	public function select_type_actions($selected = '', $htmlname = 'actioncode', $excludetype = '', $onlyautoornot = 0, $hideinfohelp = 0, $multiselect = 0, $nooutput = 0, $morecss = '')
+	{
+		// phpcs:enable
+		global $langs, $user, $form, $conf;
+
+		if (!is_object($form)) $form = new Form($this->db);
+
+		require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
+		require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
+		$caction = new CActionComm($this->db);
+
+		// Suggest a list with manual events or all auto events
+		$arraylist = $caction->liste_array(1, 'code', $excludetype, $onlyautoornot);
+		if (empty($multiselect)) {
+			// Add empty line at start only if no multiselect
+			array_unshift($arraylist, '&nbsp;');
+		}
+		//asort($arraylist);
+
+	   	if ($selected == 'manual') $selected = 'AC_OTH';
+	   	if ($selected == 'auto')   $selected = 'AC_OTH_AUTO';
+
+	   	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO)) unset($arraylist['AC_OTH_AUTO']);
+
+	   	$out = '';
 
 		if (!empty($multiselect))
 		{
-	        if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
+			if (!is_array($selected) && !empty($selected)) $selected = explode(',', $selected);
 			$out .= $form->multiselectarray($htmlname, $arraylist, $selected, 0, 0, 'centpercent', 0, 0);
 		} else {
 			$out .= $form->selectarray($htmlname, $arraylist, $selected, 0, 0, 0, '', 0, 0, 0, '', 'minwidth200'.($morecss ? ' '.$morecss : ''), 1);
 		}
 
-        if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
-        {
-            $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1);
-        }
+		if ($user->admin && empty($onlyautoornot) && $hideinfohelp <= 0)
+		{
+			$out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup").($hideinfohelp == -1 ? ". ".$langs->trans("YouCanSetDefaultValueInModuleSetup") : ''), 1);
+		}
 
-        if ($nooutput) return $out;
-        else print $out;
-        return '';
-    }
+		if ($nooutput) return $out;
+		else print $out;
+		return '';
+	}
 }

+ 200 - 200
htdocs/core/class/html.formcompany.class.php

@@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
 class FormCompany extends Form
 {
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    	Return list of labels (translated) of third parties type
 	 *
@@ -50,7 +50,7 @@ class FormCompany extends Form
 	 */
 	public function typent_array($mode = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs, $mysoc;
 
 		$effs = array();
@@ -83,7 +83,7 @@ class FormCompany extends Form
 		return $effs;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Renvoie la liste des types d'effectifs possibles (pas de traduction car nombre)
 	 *
@@ -93,7 +93,7 @@ class FormCompany extends Form
 	 */
 	public function effectif_array($mode = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$effs = array();
 
 		$sql = "SELECT id, code, libelle";
@@ -123,7 +123,7 @@ class FormCompany extends Form
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Affiche formulaire de selection des modes de reglement
 	 *
@@ -135,7 +135,7 @@ class FormCompany extends Form
 	 */
 	public function form_prospect_level($page, $selected = '', $htmlname = 'prospect_level_id', $empty = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs;
 
 		print '<form method="post" action="'.$page.'">';
@@ -225,12 +225,12 @@ class FormCompany extends Form
 		print '</form>';
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
-     *   In the case of an all-country list, the display breaks on the country.
-     *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
-     *   Thus the links with the departments are done on a department independently of its name.
+	 *   In the case of an all-country list, the display breaks on the country.
+	 *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
+	 *   Thus the links with the departments are done on a department independently of its name.
 	 *
 	 *   @param     string	$selected        	Code state preselected
 	 *   @param     int		$country_codeid     0=list for all countries, otherwise country code or country rowid to show
@@ -239,16 +239,16 @@ class FormCompany extends Form
 	 */
 	public function select_departement($selected = '', $country_codeid = 0, $htmlname = 'state_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->select_state($selected, $country_codeid, $htmlname);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Returns the drop-down list of departments/provinces/cantons for all countries or for a given country.
-     *   In the case of an all-country list, the display breaks on the country.
-     *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
-     *   Thus the links with the departments are done on a department independently of its name.
+	 *   In the case of an all-country list, the display breaks on the country.
+	 *   The key of the list is the code (there can be several entries for a given code but in this case, the country field differs).
+	 *   Thus the links with the departments are done on a department independently of its name.
 	 *
 	 *    @param	int		$selected        	Code state preselected (mus be state id)
 	 *    @param    integer	$country_codeid    	Country code or id: 0=list for all countries, otherwise country code or country rowid to show
@@ -258,7 +258,7 @@ class FormCompany extends Form
 	 */
 	public function select_state($selected = 0, $country_codeid = 0, $htmlname = 'state_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 
 		dol_syslog(get_class($this)."::select_departement selected=".$selected.", country_codeid=".$country_codeid, LOG_DEBUG);
@@ -349,7 +349,7 @@ class FormCompany extends Form
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Retourne la liste deroulante des regions actives dont le pays est actif
 	 *   La cle de la liste est le code (il peut y avoir plusieurs entree pour
@@ -362,7 +362,7 @@ class FormCompany extends Form
 	 */
 	public function select_region($selected = '', $htmlname = 'region_id')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs;
 		$langs->load("dict");
 
@@ -412,7 +412,7 @@ class FormCompany extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Return combo list with people title
 	 *
@@ -424,7 +424,7 @@ class FormCompany extends Form
 	 */
 	public function select_civility($selected = '', $htmlname = 'civility_id', $morecss = 'maxwidth150', $addjscombo = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 		$langs->load("dict");
 
@@ -473,7 +473,7 @@ class FormCompany extends Form
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
 	 *    Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays.
@@ -487,25 +487,25 @@ class FormCompany extends Form
 	 */
 	public function select_forme_juridique($selected = '', $country_codeid = 0, $filter = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->select_juridicalstatus($selected, $country_codeid, $filter);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Retourne la liste deroulante des formes juridiques tous pays confondus ou pour un pays donne.
 	 *    Dans le cas d'une liste tous pays confondu, on affiche une rupture sur le pays
 	 *
 	 *    @param	string		$selected        	Preselected code of juridical type
 	 *    @param    int			$country_codeid     0=list for all countries, otherwise list only country requested
-     *    @param    string		$filter          	Add a SQL filter on list
-     *    @param	string		$htmlname			HTML name of select
-     *    @param	string		$morecss			More CSS
-     *    @return	string							String with HTML select
+	 *    @param    string		$filter          	Add a SQL filter on list
+	 *    @param	string		$htmlname			HTML name of select
+	 *    @param	string		$morecss			More CSS
+	 *    @return	string							String with HTML select
 	 */
 	public function select_juridicalstatus($selected = '', $country_codeid = 0, $filter = '', $htmlname = 'forme_juridique_code', $morecss = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user;
 		$langs->load("dict");
 
@@ -578,9 +578,9 @@ class FormCompany extends Form
 			$out .= '</select>';
 			if ($user->admin) $out .= ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
 
-		    // Make select dynamic
-        	include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
-	        $out .= ajax_combobox($htmlname);
+			// Make select dynamic
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
+			$out .= ajax_combobox($htmlname);
 
 			$out .= '</div>';
 		} else {
@@ -600,8 +600,8 @@ class FormCompany extends Form
 	 *  @param  string		$htmlname       Name of HTML form
 	 * 	@param	array		$limitto		Disable answers that are not id in this array list
 	 *  @param	int			$forceid		This is to force another object id than object->id
-     *  @param	string		$moreparam		String with more param to add into url when noajax search is used.
-     *  @param	string		$morecss		More CSS on select component
+	 *  @param	string		$moreparam		String with more param to add into url when noajax search is used.
+	 *  @param	string		$morecss		More CSS on select component
 	 * 	@return int 						The selected third party ID
 	 */
 	public function selectCompaniesForNewContact($object, $var_id, $selected = '', $htmlname = 'newcompany', $limitto = '', $forceid = 0, $moreparam = '', $morecss = '')
@@ -746,21 +746,21 @@ class FormCompany extends Form
 		}
 	}
 
-    /**
-     *  Return a select list with types of contacts
-     *
-     *  @param	object		$object         Object to use to find type of contact
-     *  @param  string		$selected       Default selected value
-     *  @param  string		$htmlname		HTML select name
-     *  @param  string		$source			Source ('internal' or 'external')
-     *  @param  string		$sortorder		Sort criteria ('position', 'code', ...)
-     *  @param  int			$showempty      1=Add en empty line
-     *  @param  string      $morecss        Add more css to select component
-     *  @return	void
-     */
-    public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '')
+	/**
+	 *  Return a select list with types of contacts
+	 *
+	 *  @param	object		$object         Object to use to find type of contact
+	 *  @param  string		$selected       Default selected value
+	 *  @param  string		$htmlname		HTML select name
+	 *  @param  string		$source			Source ('internal' or 'external')
+	 *  @param  string		$sortorder		Sort criteria ('position', 'code', ...)
+	 *  @param  int			$showempty      1=Add en empty line
+	 *  @param  string      $morecss        Add more css to select component
+	 *  @return	void
+	 */
+	public function selectTypeContact($object, $selected, $htmlname = 'type', $source = 'internal', $sortorder = 'position', $showempty = 0, $morecss = '')
 	{
-	    global $user, $langs;
+		global $user, $langs;
 
 		if (is_object($object) && method_exists($object, 'liste_type_contact'))
 		{
@@ -822,7 +822,7 @@ class FormCompany extends Form
 		return 'ErrorBadValueForParameterRenderMode'; // Should not happened
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *    Return a select list with zip codes and their town
 	 *
@@ -837,7 +837,7 @@ class FormCompany extends Form
 	 */
 	public function select_ziptown($selected = '', $htmlname = 'zipcode', $fields = '', $fieldsize = 0, $disableautocomplete = 0, $moreattrib = '', $morecss = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$out = '';
@@ -855,155 +855,155 @@ class FormCompany extends Form
 		return $out;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
-     *
-     *  @param	int		$idprof         1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
-     *  @param  string	$htmlname       Name of HTML select
-     *  @param  string	$preselected    Default value to show
-     *  @param  string	$country_code   FR, IT, ...
-     *  @param  string  $morecss        More css
-     *  @return	string					HTML string with prof id
-     */
-    public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent')
-    {
-        // phpcs:enable
-        global $conf, $langs, $hookmanager;
-
-        $formlength = 0;
-        if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
-        	if ($country_code == 'FR')
-        	{
-        		if (isset($idprof)) {
-        			if ($idprof == 1) $formlength = 9;
-        			elseif ($idprof == 2) $formlength = 14;
-        			elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
-        			elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id
-        		}
-        	} elseif ($country_code == 'ES')
-        	{
-        		if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits
-        		if ($idprof == 2) $formlength = 12; //NASS 12 digits without /
-        		if ($idprof == 3) $formlength = 5; //CNAE 5 digits
-        		if ($idprof == 4) $formlength = 32; //depend of college
-        	}
-        }
-
-        $selected = $preselected;
-        if (!$selected && isset($idprof)) {
-        	if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1;
-        	elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2;
-        	elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3;
-        	elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4;
-        }
-
-        $maxlength = $formlength;
-        if (empty($formlength)) { $formlength = 24; $maxlength = 128; }
-
-        $out = '';
-
-        // Execute hook getInputIdProf to complete or replace $out
-        $parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code);
-        $reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
-        if (empty($reshook))
-        {
-        	$out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
-        }
-        $out .= $hookmanager->resPrint;
-
-        return $out;
-    }
-
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     * Return a HTML select with localtax values for thirdparties
-     *
-     * @param 	int 		$local			LocalTax
-     * @param 	int 		$selected		Preselected value
-     * @param 	string      $htmlname		HTML select name
-     * @return	void
-     */
-    public function select_localtax($local, $selected, $htmlname)
-    {
-        // phpcs:enable
-        $tax = get_localtax_by_third($local);
-
-        $num = $this->db->num_rows($tax);
-        $i = 0;
-    	if ($num)
-    	{
-    		$valors = explode(":", $tax);
-
-    		if (count($valors) > 1)
-    		{
-    			//montar select
-    			print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
-    			while ($i <= (count($valors)) - 1)
-    			{
-    				if ($selected == $valors[$i])
-    				{
-    					print '<option value="'.$valors[$i].'" selected>';
-    				} else {
-    					print '<option value="'.$valors[$i].'">';
-    				}
-    				print $valors[$i];
-    				print '</option>';
-    				$i++;
-    			}
-    			print'</select>';
-    		}
-    	}
-    }
-
-    /**
-     * Return a HTML select for thirdparty type
-     *
-     * @param int $selected selected value
-     * @param string $htmlname HTML select name
-     * @param string $htmlidname HTML select id
-     * @param string $typeinput HTML output
-     * @param string $morecss More css
-     * @return string HTML string
-     */
-    public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
-    {
-
-    	global $conf, $langs;
-
-    	$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
-    	if ($typeinput == 'form') {
-    		if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>';
-	    	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
-	    		$out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
-	    	}
-	    	if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
-	    		$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
-	    	}
-	    	if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-	    		$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-	    	}
-	    	$out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
-    	} elseif ($typeinput == 'list') {
-    		$out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>';
-    		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
-    			$out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
-    		}
-    		if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-    			$out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-    		}
-    		$out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
-    		$out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>';
-    	} elseif ($typeinput == 'admin') {
-    		if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
-    			$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
-    		}
-    		if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
-    			$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
-    		}
-    	}
-    	$out .= '</select>';
-
-    	return $out;
-    }
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Return HTML string to use as input of professional id into a HTML page (siren, siret, etc...)
+	 *
+	 *  @param	int		$idprof         1,2,3,4 (Example: 1=siren,2=siret,3=naf,4=rcs/rm)
+	 *  @param  string	$htmlname       Name of HTML select
+	 *  @param  string	$preselected    Default value to show
+	 *  @param  string	$country_code   FR, IT, ...
+	 *  @param  string  $morecss        More css
+	 *  @return	string					HTML string with prof id
+	 */
+	public function get_input_id_prof($idprof, $htmlname, $preselected, $country_code, $morecss = 'maxwidth100onsmartphone quatrevingtpercent')
+	{
+		// phpcs:enable
+		global $conf, $langs, $hookmanager;
+
+		$formlength = 0;
+		if (empty($conf->global->MAIN_DISABLEPROFIDRULES)) {
+			if ($country_code == 'FR')
+			{
+				if (isset($idprof)) {
+					if ($idprof == 1) $formlength = 9;
+					elseif ($idprof == 2) $formlength = 14;
+					elseif ($idprof == 3) $formlength = 5; // 4 chiffres et 1 lettre depuis janvier
+					elseif ($idprof == 4) $formlength = 32; // No maximum as we need to include a town name in this id
+				}
+			} elseif ($country_code == 'ES')
+			{
+				if ($idprof == 1) $formlength = 9; //CIF/NIF/NIE 9 digits
+				if ($idprof == 2) $formlength = 12; //NASS 12 digits without /
+				if ($idprof == 3) $formlength = 5; //CNAE 5 digits
+				if ($idprof == 4) $formlength = 32; //depend of college
+			}
+		}
+
+		$selected = $preselected;
+		if (!$selected && isset($idprof)) {
+			if ($idprof == 1 && !empty($this->idprof1)) $selected = $this->idprof1;
+			elseif ($idprof == 2 && !empty($this->idprof2)) $selected = $this->idprof2;
+			elseif ($idprof == 3 && !empty($this->idprof3)) $selected = $this->idprof3;
+			elseif ($idprof == 4 && !empty($this->idprof4)) $selected = $this->idprof4;
+		}
+
+		$maxlength = $formlength;
+		if (empty($formlength)) { $formlength = 24; $maxlength = 128; }
+
+		$out = '';
+
+		// Execute hook getInputIdProf to complete or replace $out
+		$parameters = array('formlength'=>$formlength, 'selected'=>$preselected, 'idprof'=>$idprof, 'htmlname'=>$htmlname, 'country_code'=>$country_code);
+		$reshook = $hookmanager->executeHooks('getInputIdProf', $parameters);
+		if (empty($reshook))
+		{
+			$out .= '<input type="text" '.($morecss ? 'class="'.$morecss.'" ' : '').'name="'.$htmlname.'" id="'.$htmlname.'" maxlength="'.$maxlength.'" value="'.$selected.'">';
+		}
+		$out .= $hookmanager->resPrint;
+
+		return $out;
+	}
+
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 * Return a HTML select with localtax values for thirdparties
+	 *
+	 * @param 	int 		$local			LocalTax
+	 * @param 	int 		$selected		Preselected value
+	 * @param 	string      $htmlname		HTML select name
+	 * @return	void
+	 */
+	public function select_localtax($local, $selected, $htmlname)
+	{
+		// phpcs:enable
+		$tax = get_localtax_by_third($local);
+
+		$num = $this->db->num_rows($tax);
+		$i = 0;
+		if ($num)
+		{
+			$valors = explode(":", $tax);
+
+			if (count($valors) > 1)
+			{
+				//montar select
+				print '<select class="flat" name="'.$htmlname.'" id="'.$htmlname.'">';
+				while ($i <= (count($valors)) - 1)
+				{
+					if ($selected == $valors[$i])
+					{
+						print '<option value="'.$valors[$i].'" selected>';
+					} else {
+						print '<option value="'.$valors[$i].'">';
+					}
+					print $valors[$i];
+					print '</option>';
+					$i++;
+				}
+				print'</select>';
+			}
+		}
+	}
+
+	/**
+	 * Return a HTML select for thirdparty type
+	 *
+	 * @param int $selected selected value
+	 * @param string $htmlname HTML select name
+	 * @param string $htmlidname HTML select id
+	 * @param string $typeinput HTML output
+	 * @param string $morecss More css
+	 * @return string HTML string
+	 */
+	public function selectProspectCustomerType($selected, $htmlname = 'client', $htmlidname = 'customerprospect', $typeinput = 'form', $morecss = '')
+	{
+
+		global $conf, $langs;
+
+		$out = '<select class="flat '.$morecss.'" name="'.$htmlname.'" id="'.$htmlidname.'">';
+		if ($typeinput == 'form') {
+			if ($selected == '' || $selected == '-1') $out .= '<option value="-1">&nbsp;</option>';
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
+				$out .= '<option value="2"'.($selected == 2 ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+				$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+			$out .= '<option value="0"'.((string) $selected == '0' ? ' selected' : '').'>'.$langs->trans('NorProspectNorCustomer').'</option>';
+		} elseif ($typeinput == 'list') {
+			$out .= '<option value="-1"'.(($selected == '' || $selected == '-1') ? ' selected' : '').'>&nbsp;</option>';
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS)) {
+				$out .= '<option value="2,3"'.($selected == '2,3' ? ' selected' : '').'>'.$langs->trans('Prospect').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1,3"'.($selected == '1,3' ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+			$out .= '<option value="4"'.($selected == '4' ? ' selected' : '').'>'.$langs->trans('Supplier').'</option>';
+			$out .= '<option value="0"'.($selected == '0' ? ' selected' : '').'>'.$langs->trans('Other').'</option>';
+		} elseif ($typeinput == 'admin') {
+			if (empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && empty($conf->global->SOCIETE_DISABLE_CUSTOMERS) && empty($conf->global->SOCIETE_DISABLE_PROSPECTSCUSTOMERS)) {
+				$out .= '<option value="3"'.($selected == 3 ? ' selected' : '').'>'.$langs->trans('ProspectCustomer').'</option>';
+			}
+			if (empty($conf->global->SOCIETE_DISABLE_CUSTOMERS)) {
+				$out .= '<option value="1"'.($selected == 1 ? ' selected' : '').'>'.$langs->trans('Customer').'</option>';
+			}
+		}
+		$out .= '</select>';
+
+		return $out;
+	}
 }

+ 75 - 75
htdocs/core/class/html.formfile.class.php

@@ -58,7 +58,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show form to upload a new file.
 	 *
@@ -70,8 +70,8 @@ class FormFile
 	 *  @param  int			$size          	Length of input file area. Deprecated.
 	 *  @param	Object		$object			Object to use (when attachment is done on an element)
 	 *  @param	string		$options		Add an option column
-     *  @param  integer     $useajax        Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option).
-     *                                      Deprecated 2 should never be used and if 1 is used, option should no be enabled.
+	 *  @param  integer     $useajax        Use fileupload ajax (0=never, 1=if enabled, 2=always whatever is option).
+	 *                                      Deprecated 2 should never be used and if 1 is used, option should no be enabled.
 	 *  @param	string		$savingdocmask	Mask to use to define output filename. For example 'XXXXX-__YYYYMMDD__-__file__'
 	 *  @param	integer		$linkfiles		1=Also add form to link files, 0=Do not show form to link files
 	 *  @param	string		$htmlname		Name and id of HTML form ('formuserfile' by default, 'formuserfileecm' when used to upload a file in ECM)
@@ -83,14 +83,14 @@ class FormFile
 	 */
 	public function form_attach_new_file($url, $title = '', $addcancel = 0, $sectionid = 0, $perm = 1, $size = 50, $object = '', $options = '', $useajax = 1, $savingdocmask = '', $linkfiles = 1, $htmlname = 'formuserfile', $accept = '', $sectiondir = '', $usewithoutform = 0, $capture = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $hookmanager;
 		$hookmanager->initHooks(array('formfile'));
 
-        // Deprecation warning
-        if ($useajax == 2) {
-            dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
-        }
+		// Deprecation warning
+		if ($useajax == 2) {
+			dol_syslog(__METHOD__.": using 2 for useajax is deprecated and should be not used", LOG_WARNING);
+		}
 
 		if (!empty($conf->browser->layout) && $conf->browser->layout != 'classic') $useajax = 0;
 
@@ -114,12 +114,12 @@ class FormFile
 
 			if (empty($usewithoutform))		// Try to avoid this and set instead the form by the caller.
 			{
-    			$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
-    			$out .= '<input type="hidden" name="token" value="'.newToken().'">';
-    			$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
-    			$out .= '<input type="hidden" id="'.$htmlname.'_section_id"  name="section_id" value="'.$sectionid.'">';
-    			$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">';
-    			$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
+				$out .= '<form name="'.$htmlname.'" id="'.$htmlname.'" action="'.$url.'" enctype="multipart/form-data" method="POST">';
+				$out .= '<input type="hidden" name="token" value="'.newToken().'">';
+				$out .= '<input type="hidden" id="'.$htmlname.'_section_dir" name="section_dir" value="'.$sectiondir.'">';
+				$out .= '<input type="hidden" id="'.$htmlname.'_section_id"  name="section_id" value="'.$sectionid.'">';
+				$out .= '<input type="hidden" name="sortfield" value="'.GETPOST('sortfield', 'alpha').'">';
+				$out .= '<input type="hidden" name="sortorder" value="'.GETPOST('sortorder', 'aZ09').'">';
 			}
 
 			$out .= '<table class="nobordernopadding centpercent">';
@@ -201,24 +201,24 @@ class FormFile
 			$out .= "</td></tr>";
 
 			if ($savingdocmask)
-            {
-            	//add a global variable for disable the auto renaming on upload
-                $rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : '');
+			{
+				//add a global variable for disable the auto renaming on upload
+				$rename = (empty($conf->global->MAIN_DOC_UPLOAD_NOT_RENAME_BY_DEFAULT) ? 'checked' : '');
 
-                $out .= '<tr>';
-   	            if (!empty($options)) $out .= '<td>'.$options.'</td>';
-	            $out .= '<td valign="middle" class="nowrap">';
+				$out .= '<tr>';
+   				if (!empty($options)) $out .= '<td>'.$options.'</td>';
+				$out .= '<td valign="middle" class="nowrap">';
 				$out .= '<input type="checkbox" '.$rename.' class="savingdocmask" name="savingdocmask" value="'.dol_escape_js($savingdocmask).'"> '.$langs->trans("SaveUploadedFileWithMask", preg_replace('/__file__/', $langs->transnoentitiesnoconv("OriginFileName"), $savingdocmask), $langs->transnoentitiesnoconv("OriginFileName"));
-            	$out .= '</td>';
-            	$out .= '</tr>';
-            }
+				$out .= '</td>';
+				$out .= '</tr>';
+			}
 
 			$out .= "</table>";
 
 			if (empty($usewithoutform))
 			{
-    			$out .= '</form>';
-	       		if (empty($sectionid)) $out .= '<br>';
+				$out .= '</form>';
+		   		if (empty($sectionid)) $out .= '<br>';
 			}
 
 			$out .= "\n</div><!-- End form attach new file -->\n";
@@ -232,10 +232,10 @@ class FormFile
 
 				if (empty($usewithoutform))
 				{
-    				$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n";
-    				$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
-    				$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n";
-    				$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id"  name="link_section_id" value="'.$sectionid.'">'."\n";
+					$out .= '<form name="'.$htmlname.'_link" id="'.$htmlname.'_link" action="'.$url.'" method="POST">'."\n";
+					$out .= '<input type="hidden" name="token" value="'.newToken().'">'."\n";
+					$out .= '<input type="hidden" id="'.$htmlname.'_link_section_dir" name="link_section_dir" value="">'."\n";
+					$out .= '<input type="hidden" id="'.$htmlname.'_link_section_id"  name="link_section_id" value="'.$sectionid.'">'."\n";
 				}
 
 				$out .= '<div class="valignmiddle">';
@@ -257,8 +257,8 @@ class FormFile
 				$out .= '</div>';
 				if (empty($usewithoutform))
 				{
-    				$out .= '<div class="clearboth"></div>';
-                    $out .= '</form><br>';
+					$out .= '<div class="clearboth"></div>';
+					$out .= '</form><br>';
 				}
 
 				$out .= "\n</div><!-- End form link new url -->\n";
@@ -268,7 +268,7 @@ class FormFile
 			$res = $hookmanager->executeHooks('formattachOptions', $parameters, $object);
 			if (empty($res))
 			{
-			    print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
+				print '<div class="'.($usewithoutform ? 'inline-block valignmiddle' : 'attacharea attacharea'.$htmlname).'">';
 				print $out;
 				print '</div>';
 			}
@@ -278,7 +278,7 @@ class FormFile
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *      Show the box with list of available documents for object
 	 *
@@ -303,7 +303,7 @@ class FormFile
 	 */
 	public function show_documents($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed = 0, $modelselected = '', $allowgenifempty = 1, $forcenomultilang = 0, $iconPDF = 0, $notused = 0, $noform = 0, $param = '', $title = '', $buttonlabel = '', $codelang = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$this->numoffiles = 0;
 		print $this->showdocuments($modulepart, $modulesubdir, $filedir, $urlsource, $genallowed, $delallowed, $modelselected, $allowgenifempty, $forcenomultilang, $iconPDF, $notused, $noform, $param, $title, $buttonlabel, $codelang);
 		return $this->numoffiles;
@@ -454,13 +454,13 @@ class FormFile
 					$modellist = ModelePDFExpedition::liste_modeles($this->db);
 				}
 			} elseif ($modulepart == 'reception')
-            {
-                if (is_array($genallowed)) $modellist = $genallowed;
-                else {
+			{
+				if (is_array($genallowed)) $modellist = $genallowed;
+				else {
 					include_once DOL_DOCUMENT_ROOT.'/core/modules/reception/modules_reception.php';
 					$modellist = ModelePdfReception::liste_modeles($this->db);
 				}
-            } elseif ($modulepart == 'livraison')
+			} elseif ($modulepart == 'livraison')
 			{
 				if (is_array($genallowed)) $modellist = $genallowed;
 				else {
@@ -611,16 +611,16 @@ class FormFile
 					$modellist = ModelePDFUserGroup::liste_modeles($this->db);
 				}
 			} else {
-			    $submodulepart = $modulepart;
+				$submodulepart = $modulepart;
 
-			    // modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
-			    $tmp = explode(':', $modulepart);
-			    if (!empty($tmp[1])) {
-			    	$modulepart = $tmp[0];
-			    	$submodulepart = $tmp[1];
-			    }
+				// modulepart = 'nameofmodule' or 'nameofmodule:NameOfObject'
+				$tmp = explode(':', $modulepart);
+				if (!empty($tmp[1])) {
+					$modulepart = $tmp[0];
+					$submodulepart = $tmp[1];
+				}
 
-			    // For normalized standard modules
+				// For normalized standard modules
 				$file = dol_buildpath('/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
 				if (file_exists($file))
 				{
@@ -628,7 +628,7 @@ class FormFile
 				}
 				// For normalized external modules.
 				else {
-				    $file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
+					$file = dol_buildpath('/'.$modulepart.'/core/modules/'.$modulepart.'/modules_'.strtolower($submodulepart).'.php', 0);
 					$res = include_once $file;
 				}
 
@@ -992,7 +992,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show list of documents in $filearray (may be they are all in same directory but may not)
 	 *  This also sync database if $upload_dir is defined.
@@ -1027,7 +1027,7 @@ class FormFile
 	 */
 	public function list_of_documents($filearray, $object, $modulepart, $param = '', $forcedownload = 0, $relativepath = '', $permonobject = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $title = '', $url = '', $showrelpart = 0, $permtoeditline = -1, $upload_dir = '', $sortfield = '', $sortorder = 'ASC', $disablemove = 1, $addfilterfields = 0, $disablecrop = -1)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $hookmanager;
 		global $sortfield, $sortorder, $maxheightmini;
 		global $dolibarr_main_url_root;
@@ -1049,7 +1049,7 @@ class FormFile
 		// For backward compatiblity, we detect file stored into an old path
 		if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos')
 		{
-		    $relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/';
+			$relativepath = preg_replace('/^.*\/produit\//', '', $filearray[0]['path']).'/';
 		}
 		// Defined relative dir to DOL_DATA_ROOT
 		$relativedir = '';
@@ -1233,13 +1233,13 @@ class FormFile
 						print '<td class="center">';
 						if (image_format_supported($file['name']) >= 0)
 						{
-						    if ($useinecm == 5 || $useinecm == 6)
-						    {
-						    	$smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir.
-						    } else {
-						        $smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original
-						    }
-						    if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
+							if ($useinecm == 5 || $useinecm == 6)
+							{
+								$smallfile = getImageFileNameForSize($file['name'], ''); // There is no thumb for ECM module and Media filemanager, so we use true image. TODO Change this it is slow on image dir.
+							} else {
+								$smallfile = getImageFileNameForSize($file['name'], '_small'); // For new thumbs using same ext (in lower case however) than original
+							}
+							if (!dol_is_file($file['path'].'/'.$smallfile)) $smallfile = getImageFileNameForSize($file['name'], '_small', '.png'); // For backward compatibility of old thumbs that were created with filename in lower case and with .png extension
 							//print $file['path'].'/'.$smallfile.'<br>';
 
 							$urlforhref = getAdvancedPreviewUrl($modulepart, $relativepath.$fileinfo['filename'].'.'.strtolower($fileinfo['extension']), 1, '&entity='.(!empty($object->entity) ? $object->entity : $conf->entity));
@@ -1353,7 +1353,7 @@ class FormFile
 							   	print '<td'.(($conf->browser->layout != 'phone' && empty($disablemove)) ? ' class="linecolmove tdlineupdown center"' : ' class="linecolmove center"').'>';
 							   	print '</td>';
 							}
-					    }
+						}
 					} else {
 						print '<td class="right">';
 						print '<input type="hidden" name="ecmfileid" value="'.$filearray[$key]['rowid'].'">';
@@ -1398,7 +1398,7 @@ class FormFile
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show list of documents in a directory
 	 *
@@ -1419,7 +1419,7 @@ class FormFile
 	 */
 	public function list_of_autoecmfiles($upload_dir, $filearray, $modulepart, $param, $forcedownload = 0, $relativepath = '', $permissiontodelete = 1, $useinecm = 0, $textifempty = '', $maxlength = 0, $url = '', $addfilterfields = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $form;
 		global $sortfield, $sortorder;
 		global $search_doc_ref;
@@ -1532,8 +1532,8 @@ class FormFile
 			$object_instance = new RecruitmentCandidature($this->db);
 		} elseif ($modulepart == 'banque')
 		{
-		    include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-		    $object_instance = new Account($this->db);
+			include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+			$object_instance = new Account($this->db);
 		} elseif ($modulepart == 'mrp-mo')
 		{
 			include_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
@@ -1574,7 +1574,7 @@ class FormFile
 					'banque'))) {
 					preg_match('/(.*)\/[^\/]+$/', $relativefile, $reg); $ref = (isset($reg[1]) ? $reg[1] : '');
 				} else {
-				    //print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
+					//print 'Error: Value for modulepart = '.$modulepart.' is not yet implemented in function list_of_autoecmfiles'."\n";
 				}
 
 				if (!$id && !$ref) continue;
@@ -1733,7 +1733,7 @@ class FormFile
 
 		print '<table width="100%" class="liste noborder nobottom">';
 		print '<tr class="liste_titre">';
-        print_liste_field_titre(
+		print_liste_field_titre(
 			$langs->trans("Links"),
 			$_SERVER['PHP_SELF'],
 			"name",
@@ -1742,20 +1742,20 @@ class FormFile
 			'',
 			$sortfield,
 			$sortorder,
-            ''
+			''
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			"",
 			"",
 			"",
 			"",
 			"",
 			'',
-            '',
-            '',
-            'right '
+			'',
+			'',
+			'right '
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			$langs->trans("Date"),
 			$_SERVER['PHP_SELF'],
 			"date",
@@ -1764,18 +1764,18 @@ class FormFile
 			'',
 			$sortfield,
 			$sortorder,
-            'center '
+			'center '
 		);
-        print_liste_field_titre(
+		print_liste_field_titre(
 			'',
 			$_SERVER['PHP_SELF'],
 			"",
 			"",
 			$param,
 			'',
-            '',
-            '',
-            'center '
+			'',
+			'',
+			'center '
 		);
 		print_liste_field_titre('', '', '');
 		print '</tr>';

+ 83 - 83
htdocs/core/class/html.formmail.class.php

@@ -37,75 +37,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
 class FormMail extends Form
 {
 	/**
-     * @var DoliDB Database handler.
-     */
-    public $db;
-
-    /**
-     * @var int 1 = Include HTML form tag and show submit button
-     *          0 = Do not include form tag and submit button
-     *          -1 = Do not include form tag but include submit button
-     */
+	 * @var DoliDB Database handler.
+	 */
+	public $db;
+
+	/**
+	 * @var int 1 = Include HTML form tag and show submit button
+	 *          0 = Do not include form tag and submit button
+	 *          -1 = Do not include form tag but include submit button
+	 */
 	public $withform;
 
-    /**
-     * @var string name from
-     */
+	/**
+	 * @var string name from
+	 */
 	public $fromname;
 
-    /**
-     * @var string email from
-     */
+	/**
+	 * @var string email from
+	 */
 	public $frommail;
 
-    /**
-     * @var string user, company, robot
-     */
-    public $fromtype;
-
-    /**
-     * @var int from ID
-     */
-    public $fromid;
-
-    /**
-     * @var int also from robot
-     */
-    public $fromalsorobot;
-
-    /**
-     * @var string thirdparty etc
-     */
-    public $totype;
-
-    /**
-     * @var int ID
-     */
-    public $toid;
-
-    /**
-     * @var string replyto name
-     */
-    public $replytoname;
-
-    /**
-     * @var string replyto email
-     */
+	/**
+	 * @var string user, company, robot
+	 */
+	public $fromtype;
+
+	/**
+	 * @var int from ID
+	 */
+	public $fromid;
+
+	/**
+	 * @var int also from robot
+	 */
+	public $fromalsorobot;
+
+	/**
+	 * @var string thirdparty etc
+	 */
+	public $totype;
+
+	/**
+	 * @var int ID
+	 */
+	public $toid;
+
+	/**
+	 * @var string replyto name
+	 */
+	public $replytoname;
+
+	/**
+	 * @var string replyto email
+	 */
 	public $replytomail;
 
-    /**
-     * @var string to name
-     */
+	/**
+	 * @var string to name
+	 */
 	public $toname;
 
-    /**
-     * @var string to email
-     */
+	/**
+	 * @var string to email
+	 */
 	public $tomail;
 
-    /**
-     * @var string trackid
-     */
+	/**
+	 * @var string trackid
+	 */
 	public $trackid;
 
 	public $withsubstit; // Show substitution array
@@ -180,7 +180,7 @@ class FormMail extends Form
 		$this->withfckeditor = -1; // -1 = Auto
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Clear list of attached files in send mail form (also stored in session)
 	 *
@@ -188,7 +188,7 @@ class FormMail extends Form
 	 */
 	public function clear_attached_files()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $user;
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
@@ -203,7 +203,7 @@ class FormMail extends Form
 		unset($_SESSION["listofmimes".$keytoavoidconflict]);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Add a file into the list of attached files (stored in SECTION array)
 	 *
@@ -214,7 +214,7 @@ class FormMail extends Form
 	 */
 	public function add_attached_files($path, $file = '', $type = '')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -237,7 +237,7 @@ class FormMail extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Remove a file from the list of attached files (stored in SECTION array)
 	 *
@@ -246,7 +246,7 @@ class FormMail extends Form
 	 */
 	public function remove_attached_files($keytodelete)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -267,7 +267,7 @@ class FormMail extends Form
 		}
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 * Return list of attached files (stored in SECTION array)
 	 *
@@ -275,7 +275,7 @@ class FormMail extends Form
 	 */
 	public function get_attached_files()
 	{
-        // phpcs:enable
+		// phpcs:enable
 		$listofpaths = array();
 		$listofnames = array();
 		$listofmimes = array();
@@ -287,7 +287,7 @@ class FormMail extends Form
 		return array('paths'=>$listofpaths, 'names'=>$listofnames, 'mimes'=>$listofmimes);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show the form to input an email
 	 *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@@ -299,11 +299,11 @@ class FormMail extends Form
 	 */
 	public function show_form($addfileaction = 'addfile', $removefileaction = 'removefile')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		print $this->get_form($addfileaction, $removefileaction);
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Get the form to input an email
 	 *  this->withfile: 0=No attaches files, 1=Show attached files, 2=Can add new attached files
@@ -316,17 +316,17 @@ class FormMail extends Form
 	 */
 	public function get_form($addfileaction = 'addfile', $removefileaction = 'removefile')
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $langs, $user, $hookmanager, $form;
 
-        // Required to show preview of mail attachments
-        require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
-        $formfile = new Formfile($this->db);
+		// Required to show preview of mail attachments
+		require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
+		$formfile = new Formfile($this->db);
 
 		if (!is_object($form)) $form = new Form($this->db);
 
 		// Load translation files required by the page
-        $langs->loadLangs(array('other', 'mails'));
+		$langs->loadLangs(array('other', 'mails'));
 
 		// Clear temp files. Must be done at beginning, before call of triggers
 		if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1'))
@@ -464,7 +464,7 @@ class FormMail extends Form
 					'propal_send', 'order_send', 'facture_send',
 					'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send',
 					'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all'
-                )))
+				)))
 			{
 				// If list of template is empty
 				$out .= '<div class="center" style="padding: 0px 0 12px 0">'."\n";
@@ -733,7 +733,7 @@ class FormMail extends Form
 				{
 					$out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : "";
 				} else {
-				    $out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
+					$out .= '<input class="minwidth200" id="sendtocc" name="sendtocc" value="'.(GETPOST("sendtocc", "alpha") ? GETPOST("sendtocc", "alpha") : ((!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
 					if (!empty($this->withtocc) && is_array($this->withtocc))
 					{
 						$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
@@ -854,10 +854,10 @@ class FormMail extends Form
 						foreach ($listofpaths as $key => $val)
 						{
 							$out .= '<div id="attachfile_'.$key.'">';
-                            // Preview of attachment
-                            preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params);
+							// Preview of attachment
+							preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT)-strlen($val))), $formfile_params);
 							$out .= img_mime($listofnames[$key]).' '.$listofnames[$key];
-                            $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
+							$out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]);
 							if (!$this->withfilereadonly)
 							{
 								$out .= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key + 1).'" class="removedfile" id="removedfile_'.$key.'" name="removedfile_'.$key.'" />';
@@ -1060,7 +1060,7 @@ class FormMail extends Form
 		if (!empty($this->withtocccreadonly)) {
 			$out .= (!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : "";
 		} else {
-		    $out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
+			$out .= '<input class="minwidth200" id="sendtoccc" name="sendtoccc" value="'.(GETPOST("sendtoccc", "alpha") ? GETPOST("sendtoccc", "alpha") : ((!is_array($this->withtoccc) && !is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
 			if (!empty($this->withtoccc) && is_array($this->withtoccc)) {
 				$out .= " ".$langs->trans("and")."/".$langs->trans("or")." ";
 				// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
@@ -1185,7 +1185,7 @@ class FormMail extends Form
 	 */
 	public function getEMailTemplate($db, $type_template, $user, $outputlangs, $id = 0, $active = 1, $label = '')
 	{
-        $ret = new ModelMail();
+		$ret = new ModelMail();
 
 		if ($id == -2 && empty($label)) {
 			$this->error = 'LabelIsMandatoryWhenIdIs-2';
@@ -1513,9 +1513,9 @@ class ModelMail
 	public $id;
 
 	/**
-     * @var string Model mail label
-     */
-    public $label;
+	 * @var string Model mail label
+	 */
+	public $label;
 
 	public $topic;
 	public $content;

+ 21 - 21
htdocs/core/lib/ajax.lib.php

@@ -46,16 +46,16 @@
  */
 function ajax_autocompleter($selected, $htmlname, $url, $urloption = '', $minLength = 2, $autoselect = 0, $ajaxoptions = array(), $moreparams = '')
 {
-    if (empty($minLength)) $minLength = 1;
+	if (empty($minLength)) $minLength = 1;
 
-    $dataforrenderITem = 'ui-autocomplete';
-    $dataforitem = 'ui-autocomplete-item';
-    // Allow two constant to use other values for backward compatibility
-    if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
-    if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
+	$dataforrenderITem = 'ui-autocomplete';
+	$dataforitem = 'ui-autocomplete-item';
+	// Allow two constant to use other values for backward compatibility
+	if (defined('JS_QUERY_AUTOCOMPLETE_RENDERITEM')) $dataforrenderITem = constant('JS_QUERY_AUTOCOMPLETE_RENDERITEM');
+	if (defined('JS_QUERY_AUTOCOMPLETE_ITEM'))       $dataforitem = constant('JS_QUERY_AUTOCOMPLETE_ITEM');
 
-    // Input search_htmlname is original field
-    // Input htmlname is a second input field used when using ajax autocomplete.
+	// Input search_htmlname is original field
+	// Input htmlname is a second input field used when using ajax autocomplete.
 	$script = '<input type="hidden" name="'.$htmlname.'" id="'.$htmlname.'" value="'.$selected.'" '.($moreparams ? $moreparams : '').' />';
 
 	$script .= '<!-- Javascript code for autocomplete of field '.$htmlname.' -->'."\n";
@@ -348,7 +348,7 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
 	$msg = '<div id="dialog-info" title="'.dol_escape_htmltag($newtitle).'">';
 	$msg .= $message;
 	$msg .= '</div>'."\n";
-    $msg .= '<script>
+	$msg .= '<script>
     jQuery(function() {
         jQuery("#dialog-info").dialog({
 	        resizable: false,
@@ -364,9 +364,9 @@ function ajax_dialog($title, $message, $w = 350, $h = 150)
 	});
 	</script>';
 
-    $msg .= "\n";
+	$msg .= "\n";
 
-    return $msg;
+	return $msg;
 }
 
 
@@ -397,8 +397,8 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
 
 	if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete = 0;
 
-    $tmpplugin = 'select2';
-    $msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
+	$tmpplugin = 'select2';
+	$msg = "\n".'<!-- JS CODE TO ENABLE '.$tmpplugin.' for id = '.$htmlname.' -->
           <script>
         	$(document).ready(function () {
         		$(\''.(preg_match('/^\./', $htmlname) ? $htmlname : '#'.$htmlname).'\').'.$tmpplugin.'({
@@ -477,9 +477,9 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
 	}
 
 	$msg .= '});'."\n";
-    $msg .= "</script>\n";
+	$msg .= "</script>\n";
 
-    return $msg;
+	return $msg;
 }
 
 /**
@@ -500,7 +500,7 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
 	global $conf, $langs, $user;
 
 	$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
-	if (! isset($input)) $input = array();
+	if (!isset($input)) $input = array();
 
 	if (empty($conf->use_javascript_ajax) || $forcenoajax)
 	{
@@ -566,9 +566,9 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof
  */
 function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array())
 {
-    global $langs;
+	global $langs;
 
-    $out = '<script>
+	$out = '<script>
         $(function() {
             var input = '.json_encode($input).';
 
@@ -633,8 +633,8 @@ function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input =
             });
         });
     </script>';
-    $out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
-    $out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
+	$out .= '<span id="set_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? 'hideobject' : '').'">'.img_picto($langs->trans($text_off), 'switch_off').'</span>';
+	$out .= '<span id="del_'.$code.'_'.$object->id.'" class="linkobject '.($object->$code == 1 ? '' : 'hideobject').'">'.img_picto($langs->trans($text_on), 'switch_on').'</span>';
 
-    return $out;
+	return $out;
 }

File diff suppressed because it is too large
+ 512 - 512
htdocs/core/lib/company.lib.php


+ 10 - 10
htdocs/core/lib/expedition.lib.php

@@ -60,9 +60,9 @@ function expedition_prepare_head(Expedition $object)
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'order');
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'order', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -95,18 +95,18 @@ function expedition_admin_prepare_head()
 
 	if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFields");
-	    $head[$h][2] = 'attributes_shipment';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/expedition_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFields");
+		$head[$h][2] = 'attributes_shipment';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_EXPEDITION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFieldsLines");
-	    $head[$h][2] = 'attributeslines_shipment';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/expeditiondet_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFieldsLines");
+		$head[$h][2] = 'attributeslines_shipment';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_LIVRAISON))

+ 4 - 4
htdocs/core/lib/files.lib.php

@@ -958,11 +958,11 @@ function dolCheckVirus($src_file)
 		if (!class_exists('AntiVir')) {
 			require_once DOL_DOCUMENT_ROOT.'/core/class/antivir.class.php';
 		}
-		$antivir=new AntiVir($db);
+		$antivir = new AntiVir($db);
 		$result = $antivir->dol_avscan_file($src_file);
 		if ($result < 0)	// If virus or error, we stop here
 		{
-			$reterrors=$antivir->errors;
+			$reterrors = $antivir->errors;
 			return $reterrors;
 		}
 	}
@@ -1049,7 +1049,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
 		{
 			// $upload_dir ends with a slash, so be must be sure the medias dir to compare to ends with slash too.
 			$publicmediasdirwithslash = $conf->medias->multidir_output[$conf->entity];
-			if (! preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash.='/';
+			if (!preg_match('/\/$/', $publicmediasdirwithslash)) $publicmediasdirwithslash .= '/';
 
 			if (strpos($upload_dir, $publicmediasdirwithslash) !== 0) {	// We never add .noexe on files into media directory
 				$file_name .= '.noexe';
@@ -2771,7 +2771,7 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
 		if (preg_match('/^specimen/i', $original_file))	$accessallowed = 1; // If link to a file called specimen. Test must be done before changing $original_file int full path.
 		if ($fuser->admin) $accessallowed = 1; // If user is admin
 		$tmpmodulepart = explode('-', $modulepart);
-		if (! empty($tmpmodulepart[1])) {
+		if (!empty($tmpmodulepart[1])) {
 				$modulepart = $tmpmodulepart[0];
 				$original_file = $tmpmodulepart[1].'/'.$original_file;
 		}

File diff suppressed because it is too large
+ 353 - 353
htdocs/core/lib/functions.lib.php


File diff suppressed because it is too large
+ 463 - 463
htdocs/core/lib/functions2.lib.php


+ 1 - 1
htdocs/core/lib/functionsnumtoword.lib.php

@@ -259,7 +259,7 @@ function hundreds2text($hundreds, $tens, $units)
 	$decenas = array("", "", "TREINTA ", "CUARENTA ", "CINCUENTA ", "SESENTA ", "SETENTA ", "OCHENTA ", "NOVENTA ");
 	$veintis = array("VEINTE", "VEINTIUN", "VEINTID&OacuteS", "VEINTITR&EacuteS", "VEINTICUATRO", "VEINTICINCO", "VEINTIS&EacuteIS", "VEINTISIETE", "VEINTIOCHO", "VEINTINUEVE");
 	$diecis = array("DIEZ", "ONCE", "DOCE", "TRECE", "CATORCE", "QUINCE", "DIECIS&EacuteIS", "DIECISIETE", "DIECIOCHO", "DIECINUEVE");
-    $unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
+	$unidades = array("UN", "DOS", "TRES", "CUATRO", "CINCO", "SEIS", "SIETE", "OCHO", "NUEVE");
 	$entexto = "";
 	if ($hundreds != 0) {
 		$entexto .= $centenas[$hundreds - 1];

+ 19 - 19
htdocs/core/lib/hrm.lib.php

@@ -43,8 +43,8 @@ function establishment_prepare_head($object)
 
 	// Show more tabs from modules
 	// Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'establishment');
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/establishment/info.php?id='.$object->id;
@@ -64,30 +64,30 @@ function establishment_prepare_head($object)
  */
 function hrm_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $langs->load('hrm');
+	$langs->load('hrm');
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_hrm.php';
-    $head[$h][1] = $langs->trans("Parameters");
-    $head[$h][2] = 'parameters';
-    $h++;
+	$head[$h][1] = $langs->trans("Parameters");
+	$head[$h][2] = 'parameters';
+	$h++;
 
 	$head[$h][0] = DOL_URL_ROOT.'/hrm/admin/admin_establishment.php';
-    $head[$h][1] = $langs->trans("Establishments");
-    $head[$h][2] = 'establishments';
-    $h++;
+	$head[$h][1] = $langs->trans("Establishments");
+	$head[$h][2] = 'establishments';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin');
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'hrm_admin', 'remove');
 
-    return $head;
+	return $head;
 }

+ 84 - 84
htdocs/core/lib/images.lib.php

@@ -40,39 +40,39 @@ function image_format_supported($file, $acceptsvg = 0)
 {
 	global $conf;
 
-    $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
-    if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
-    	$regeximgext .= '|\.svg';		// Not allowed by default. SVG can contains javascript
-    }
-
-    // Case filename is not a format image
-    $reg = array();
-    if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
-
-    // Case filename is a format image but not supported by this PHP
-    $imgfonction = '';
-    if (strtolower($reg[1]) == '.gif')  $imgfonction = 'imagecreatefromgif';
-    if (strtolower($reg[1]) == '.jpg')  $imgfonction = 'imagecreatefromjpeg';
-    if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
-    if (strtolower($reg[1]) == '.png')  $imgfonction = 'imagecreatefrompng';
-    if (strtolower($reg[1]) == '.bmp')  $imgfonction = 'imagecreatefromwbmp';
-    if (strtolower($reg[1]) == '.webp')  $imgfonction = 'imagecreatefromwebp';
-    if (strtolower($reg[1]) == '.xpm')  $imgfonction = 'imagecreatefromxpm';
-    if (strtolower($reg[1]) == '.xbm')  $imgfonction = 'imagecreatefromxbm';
-    if (strtolower($reg[1]) == '.svg')  $imgfonction = 'imagecreatefromsvg'; // Never available
-    if ($imgfonction)
-    {
-        if (!function_exists($imgfonction))
-        {
-            // Fonctions of conversion not available in this PHP
-            return 0;
-        }
-
-        // Filename is a format image and supported for conversion by this PHP
-        return 1;
-    }
-
-    return 0;
+	$regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
+	if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
+		$regeximgext .= '|\.svg';		// Not allowed by default. SVG can contains javascript
+	}
+
+	// Case filename is not a format image
+	$reg = array();
+	if (!preg_match('/('.$regeximgext.')$/i', $file, $reg)) return -1;
+
+	// Case filename is a format image but not supported by this PHP
+	$imgfonction = '';
+	if (strtolower($reg[1]) == '.gif')  $imgfonction = 'imagecreatefromgif';
+	if (strtolower($reg[1]) == '.jpg')  $imgfonction = 'imagecreatefromjpeg';
+	if (strtolower($reg[1]) == '.jpeg') $imgfonction = 'imagecreatefromjpeg';
+	if (strtolower($reg[1]) == '.png')  $imgfonction = 'imagecreatefrompng';
+	if (strtolower($reg[1]) == '.bmp')  $imgfonction = 'imagecreatefromwbmp';
+	if (strtolower($reg[1]) == '.webp')  $imgfonction = 'imagecreatefromwebp';
+	if (strtolower($reg[1]) == '.xpm')  $imgfonction = 'imagecreatefromxpm';
+	if (strtolower($reg[1]) == '.xbm')  $imgfonction = 'imagecreatefromxbm';
+	if (strtolower($reg[1]) == '.svg')  $imgfonction = 'imagecreatefromsvg'; // Never available
+	if ($imgfonction)
+	{
+		if (!function_exists($imgfonction))
+		{
+			// Fonctions of conversion not available in this PHP
+			return 0;
+		}
+
+		// Filename is a format image and supported for conversion by this PHP
+		return 1;
+	}
+
+	return 0;
 }
 
 
@@ -97,9 +97,9 @@ function dol_getImageSize($file, $url = false)
 
 	if ($filetoread)
 	{
-    	$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
-    	$ret['width'] = $infoImg[0]; // Largeur de l'image
-    	$ret['height'] = $infoImg[1]; // Hauteur de l'image
+		$infoImg = getimagesize($filetoread); // Recuperation des infos de l'image
+		$ret['width'] = $infoImg[0]; // Largeur de l'image
+		$ret['height'] = $infoImg[1]; // Hauteur de l'image
 	}
 
 	return $ret;
@@ -305,7 +305,7 @@ function dol_imageResizeOrCrop($file, $mode, $newWidth, $newHeight, $src_x = 0,
 	if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
 
 	// Free memory. This does not delete image.
-    imagedestroy($img);
+	imagedestroy($img);
 	imagedestroy($imgThumb);
 
 	clearstatcache(); // File was replaced by a modified one, so we clear file caches.
@@ -441,20 +441,20 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	} elseif (!file_exists($file))
 	{
 		// Si le fichier passe en parametre n'existe pas
-        dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
-	    return $langs->trans("ErrorFileNotFound", $file);
+		dol_syslog($langs->trans("ErrorFileNotFound", $file), LOG_ERR);
+		return $langs->trans("ErrorFileNotFound", $file);
 	} elseif (image_format_supported($file) < 0)
 	{
-        dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
-	    return 'ErrorBadImageFormat';
+		dol_syslog('This file '.$file.' does not seem to be an image format file name.', LOG_WARNING);
+		return 'ErrorBadImageFormat';
 	} elseif (!is_numeric($maxWidth) || empty($maxWidth) || $maxWidth < -1) {
 		// Si la largeur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
-        dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
-	    return 'Error: Wrong value for parameter maxWidth';
+		dol_syslog('Wrong value for parameter maxWidth', LOG_ERR);
+		return 'Error: Wrong value for parameter maxWidth';
 	} elseif (!is_numeric($maxHeight) || empty($maxHeight) || $maxHeight < -1) {
 		// Si la hauteur max est incorrecte (n'est pas numerique, est vide, ou est inferieure a 0)
-        dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
-	    return 'Error: Wrong value for parameter maxHeight';
+		dol_syslog('Wrong value for parameter maxHeight', LOG_ERR);
+		return 'Error: Wrong value for parameter maxHeight';
 	}
 
 	$filetoread = realpath(dol_osencode($file)); // Chemin canonique absolu de l'image
@@ -495,7 +495,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$imgfonction = 'imagecreatefrompng';
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			break;
 		case IMAGETYPE_WBMP:	// 15
 			$imgfonction = 'imagecreatefromwbmp';
@@ -531,7 +531,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$extImg = '.png';
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			$extImg = '.bmp';
 			break;
 		case IMAGETYPE_WBMP:	// 15
@@ -540,14 +540,14 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			break;
 	}
 
-    if (!is_resource($img))
-    {
-        dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
-        return 0;
-    }
+	if (!is_resource($img))
+	{
+		dol_syslog('Failed to detect type of image. We found infoImg[2]='.$infoImg[2], LOG_WARNING);
+		return 0;
+	}
 
 	$exifAngle = false;
-    if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
+	if ($ort && !empty($conf->global->MAIN_USE_EXIF_ROTATION)) {
 		switch ($ort)
 		{
 			case 3: // 180 rotate left
@@ -568,12 +568,12 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 		}
 	}
 
-    if ($exifAngle)
-    {
+	if ($exifAngle)
+	{
 		$rotated = false;
 
-    	if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
-    	{
+		if ($infoImg[2] === 'IMAGETYPE_PNG') // In fact there is no exif on PNG but just in case
+		{
 			imagealphablending($img, false);
 			imagesavealpha($img, true);
 			$rotated = imagerotate($img, $exifAngle, imageColorAllocateAlpha($img, 0, 0, 0, 127));
@@ -583,9 +583,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			$rotated = imagerotate($img, $exifAngle, 0);
 		}
 
-    	// replace image with good orientation
-    	if (!empty($rotated)) {
-    		$img = $rotated;
+		// replace image with good orientation
+		if (!empty($rotated)) {
+			$img = $rotated;
 			$imgWidth = $trueImgWidth;
 			$imgHeight = $trueImgHeight;
 		}
@@ -612,8 +612,8 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	$thumbHeight = round($thumbHeight);
 	$thumbWidth = round($thumbWidth);
 
-    // Define target format
-    if (empty($targetformat)) $targetformat = $infoImg[2];
+	// Define target format
+	if (empty($targetformat)) $targetformat = $infoImg[2];
 
 	// Create empty image
 	if ($targetformat == IMAGETYPE_GIF)
@@ -643,31 +643,31 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 		case IMAGETYPE_GIF:	    // 1
 			$trans_colour = imagecolorallocate($imgThumb, 255, 255, 255); // On procede autrement pour le format GIF
 			imagecolortransparent($imgThumb, $trans_colour);
-            $extImgTarget = '.gif';
-            $newquality = 'NU';
-            break;
+			$extImgTarget = '.gif';
+			$newquality = 'NU';
+			break;
 		case IMAGETYPE_JPEG:    // 2
-            $trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
-            $extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
-            $newquality = $quality;
-            break;
+			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
+			$extImgTarget = (preg_match('/\.jpeg$/i', $file) ? '.jpeg' : '.jpg');
+			$newquality = $quality;
+			break;
 		case IMAGETYPE_PNG:	    // 3
 			imagealphablending($imgThumb, false); // Pour compatibilite sur certain systeme
 			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 127); // Keep transparent channel
-            $extImgTarget = '.png';
-            $newquality = $quality - 100;
-            $newquality = round(abs($quality - 100) * 9 / 100);
-            break;
+			$extImgTarget = '.png';
+			$newquality = $quality - 100;
+			$newquality = round(abs($quality - 100) * 9 / 100);
+			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
-            $extImgTarget = '.bmp';
-            $newquality = 'NU';
-            break;
+			// Not supported by PHP GD
+			$extImgTarget = '.bmp';
+			$newquality = 'NU';
+			break;
 		case IMAGETYPE_WBMP:	// 15
 			$trans_colour = imagecolorallocatealpha($imgThumb, 255, 255, 255, 0);
-            $extImgTarget = '.bmp';
-            $newquality = 'NU';
-            break;
+			$extImgTarget = '.bmp';
+			$newquality = 'NU';
+			break;
 	}
 	if (function_exists("imagefill")) imagefill($imgThumb, 0, 0, $trans_colour);
 
@@ -698,7 +698,7 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 			imagepng($imgThumb, $imgThumbName, $newquality);
 			break;
 		case IMAGETYPE_BMP:	    // 6
-            // Not supported by PHP GD
+			// Not supported by PHP GD
 			break;
 		case IMAGETYPE_WBMP:    // 15
 			imagewbmp($imgThumb, $imgThumbName);
@@ -708,9 +708,9 @@ function vignette($file, $maxWidth = 160, $maxHeight = 120, $extName = '_small',
 	// Set permissions on file
 	if (!empty($conf->global->MAIN_UMASK)) @chmod($imgThumbName, octdec($conf->global->MAIN_UMASK));
 
-    // Free memory. This does not delete image.
-    imagedestroy($img);
-    imagedestroy($imgThumb);
+	// Free memory. This does not delete image.
+	imagedestroy($img);
+	imagedestroy($imgThumb);
 
 	return $imgThumbName;
 }

+ 111 - 111
htdocs/core/lib/member.lib.php

@@ -63,46 +63,46 @@ function member_prepare_head(Adherent $object)
 		$h++;
 	}
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
-
-    $nbNote = 0;
-    if (!empty($object->note)) $nbNote++;
-    if (!empty($object->note_private)) $nbNote++;
-    if (!empty($object->note_public)) $nbNote++;
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member');
+
+	$nbNote = 0;
+	if (!empty($object->note)) $nbNote++;
+	if (!empty($object->note_private)) $nbNote++;
+	if (!empty($object->note_public)) $nbNote++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/note.php?id='.$object->id;
 	$head[$h][1] = $langs->trans("Note");
 	$head[$h][2] = 'note';
-    if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
+	if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
 	$h++;
 
-    // Attachments
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-    $upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
-    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-    $nbLinks = Link::count($db, $object->element, $object->id);
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
-    $head[$h][1] = $langs->trans('Documents');
-    if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
-    $head[$h][2] = 'document';
-    $h++;
+	// Attachments
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+	$upload_dir = $conf->adherent->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'member');
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+	$nbLinks = Link::count($db, $object->element, $object->id);
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/document.php?id='.$object->id;
+	$head[$h][1] = $langs->trans('Documents');
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.($nbFiles + $nbLinks).'</span>';
+	$head[$h][2] = 'document';
+	$h++;
 
 	// Show agenda tab
 	if (!empty($conf->agenda->enabled))
 	{
-	    $head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
-	    $head[$h][1] = $langs->trans("Events");
-	    if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
-	    {
-	        $head[$h][1] .= '/';
-	        $head[$h][1] .= $langs->trans("Agenda");
-	    }
-	    $head[$h][2] = 'agenda';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT."/adherents/agenda.php?id=".$object->id;
+		$head[$h][1] = $langs->trans("Events");
+		if (!empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read)))
+		{
+			$head[$h][1] .= '/';
+			$head[$h][1] .= $langs->trans("Agenda");
+		}
+		$head[$h][2] = 'agenda';
+		$h++;
 	}
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member', 'remove');
@@ -148,11 +148,11 @@ function member_type_prepare_head(AdherentType $object)
 		$h++;
 	}
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype');
 
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'membertype', 'remove');
 
@@ -166,45 +166,45 @@ function member_type_prepare_head(AdherentType $object)
  */
 function member_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
-    $head[$h][1] = $langs->trans("Miscellaneous");
-    $head[$h][2] = 'general';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent.php';
+	$head[$h][1] = $langs->trans("Miscellaneous");
+	$head[$h][2] = 'general';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
-    $head[$h][1] = $langs->trans("EMails");
-    $head[$h][2] = 'emails';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_emails.php';
+	$head[$h][1] = $langs->trans("EMails");
+	$head[$h][2] = 'emails';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin');
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsMember");
-    $head[$h][2] = 'attributes';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsMember");
+	$head[$h][2] = 'attributes';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsMemberType");
-    $head[$h][2] = 'attributes_type';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/adherent_type_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsMemberType");
+	$head[$h][2] = 'attributes_type';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
-    $head[$h][1] = $langs->trans("BlankSubscriptionForm");
-    $head[$h][2] = 'website';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/admin/website.php';
+	$head[$h][1] = $langs->trans("BlankSubscriptionForm");
+	$head[$h][2] = 'website';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'member_admin', 'remove');
 
-    return $head;
+	return $head;
 }
 
 
@@ -216,50 +216,50 @@ function member_admin_prepare_head()
  */
 function member_stats_prepare_head($object)
 {
-    global $langs, $conf, $user;
-
-    $h = 0;
-    $head = array();
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
-    $head[$h][1] = $langs->trans("Subscriptions");
-    $head[$h][2] = 'statssubscription';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
-    $head[$h][1] = $langs->trans("Country");
-    $head[$h][2] = 'statscountry';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
-    $head[$h][1] = $langs->trans("Region");
-    $head[$h][2] = 'statsregion';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
-    $head[$h][1] = $langs->trans("State");
-    $head[$h][2] = 'statsstate';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
-    $head[$h][1] = $langs->trans('Town');
-    $head[$h][2] = 'statstown';
-    $h++;
-
-    $head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
-    $head[$h][1] = $langs->trans('ByProperties');
-    $head[$h][2] = 'statsbyproperties';
-    $h++;
-
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
-
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
-
-    return $head;
+	global $langs, $conf, $user;
+
+	$h = 0;
+	$head = array();
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/index.php';
+	$head[$h][1] = $langs->trans("Subscriptions");
+	$head[$h][2] = 'statssubscription';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbycountry';
+	$head[$h][1] = $langs->trans("Country");
+	$head[$h][2] = 'statscountry';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbyregion';
+	$head[$h][1] = $langs->trans("Region");
+	$head[$h][2] = 'statsregion';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbystate';
+	$head[$h][1] = $langs->trans("State");
+	$head[$h][2] = 'statsstate';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/geo.php?mode=memberbytown';
+	$head[$h][1] = $langs->trans('Town');
+	$head[$h][2] = 'statstown';
+	$h++;
+
+	$head[$h][0] = DOL_URL_ROOT.'/adherents/stats/byproperties.php';
+	$head[$h][1] = $langs->trans('ByProperties');
+	$head[$h][2] = 'statsbyproperties';
+	$h++;
+
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats');
+
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'member_stats', 'remove');
+
+	return $head;
 }
 
 /**

+ 9 - 9
htdocs/core/lib/multicurrency.lib.php

@@ -30,21 +30,21 @@
  */
 function multicurrencyAdminPrepareHead()
 {
-    global $langs, $conf;
+	global $langs, $conf;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
-    $head[$h][1] = $langs->trans("Parameters");
-    $head[$h][2] = 'settings';
-    $h++;
+	$head[$h][0] = dol_buildpath("/admin/multicurrency.php", 1);
+	$head[$h][1] = $langs->trans("Parameters");
+	$head[$h][2] = 'settings';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency');
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'multicurrency', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**

+ 24 - 24
htdocs/core/lib/reception.lib.php

@@ -49,18 +49,18 @@ function reception_prepare_head(Reception $object)
 
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB))
 	{
-	    $objectsrc = $object;
-	    if ($object->origin == 'commande' && $object->origin_id > 0)
-	    {
-	        $objectsrc = new Commande($db);
-	        $objectsrc->fetch($object->origin_id);
-	    }
-	    $nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
-	    $head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
-    	$head[$h][1] = $langs->trans("ContactsAddresses");
+		$objectsrc = $object;
+		if ($object->origin == 'commande' && $object->origin_id > 0)
+		{
+			$objectsrc = new Commande($db);
+			$objectsrc->fetch($object->origin_id);
+		}
+		$nbContact = count($objectsrc->liste_contact(-1, 'internal')) + count($objectsrc->liste_contact(-1, 'external'));
+		$head[$h][0] = DOL_URL_ROOT."/reception/contact.php?id=".$object->id;
+		$head[$h][1] = $langs->trans("ContactsAddresses");
 		if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
-    	$head[$h][2] = 'contact';
-    	$h++;
+		$head[$h][2] = 'contact';
+		$h++;
 	}
 
 	// Show more tabs from modules
@@ -69,18 +69,18 @@ function reception_prepare_head(Reception $object)
 	// $this->tabs = array('entity:-tabname);   												to remove a tab
 	complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception');
 
-    $nbNote = 0;
-    if (!empty($object->note_private)) $nbNote++;
-    if (!empty($object->note_public)) $nbNote++;
+	$nbNote = 0;
+	if (!empty($object->note_private)) $nbNote++;
+	if (!empty($object->note_public)) $nbNote++;
 	$head[$h][0] = DOL_URL_ROOT."/reception/note.php?id=".$object->id;
 	$head[$h][1] = $langs->trans("Notes");
 	if ($nbNote > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbNote.'</span>';
 	$head[$h][2] = 'note';
 	$h++;
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'reception', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -105,18 +105,18 @@ function reception_admin_prepare_head()
 
 	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFields");
-	    $head[$h][2] = 'attributes_reception';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/reception_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFields");
+		$head[$h][2] = 'attributes_reception';
+		$h++;
 	}
 
 	if (!empty($conf->global->MAIN_SUBMODULE_RECEPTION))
 	{
-	    $head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
-	    $head[$h][1] = $langs->trans("ExtraFieldsLines");
-	    $head[$h][2] = 'attributeslines_reception';
-	    $h++;
+		$head[$h][0] = DOL_URL_ROOT.'/admin/commande_fournisseur_dispatch_extrafields.php';
+		$head[$h][1] = $langs->trans("ExtraFieldsLines");
+		$head[$h][2] = 'attributeslines_reception';
+		$h++;
 	}
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'reception_admin', 'remove');

+ 3 - 3
htdocs/core/lib/resource.lib.php

@@ -37,13 +37,13 @@ function resource_prepare_head($object)
 
 	$head[$h][0] = dol_buildpath('/resource/card.php', 1).'?id='.$object->id;
 	$head[$h][1] = $langs->trans("ResourceCard");
-    $head[$h][2] = 'resource';
+	$head[$h][2] = 'resource';
 	$h++;
 
 	if (empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && (empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_USER) || empty($conf->global->RESOURCE_HIDE_ADD_CONTACT_THIPARTY)))
 	{
-	    $nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
-	    $head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
+		$nbContact = count($object->liste_contact(-1, 'internal')) + count($object->liste_contact(-1, 'external'));
+		$head[$h][0] = DOL_URL_ROOT.'/resource/contact.php?id='.$object->id;
 		$head[$h][1] = $langs->trans('ContactsAddresses');
 		if ($nbContact > 0) $head[$h][1] .= '<span class="badge marginleftonlyshort">'.$nbContact.'</span>';
 		$head[$h][2] = 'contact';

+ 46 - 46
htdocs/core/lib/salaries.lib.php

@@ -27,41 +27,41 @@
  */
 function salaries_prepare_head($object)
 {
-    global $db, $langs, $conf;
+	global $db, $langs, $conf;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
-    $head[$h][1] = $langs->trans("SalaryPayment");
-    $head[$h][2] = 'card';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/card.php?id='.$object->id;
+	$head[$h][1] = $langs->trans("SalaryPayment");
+	$head[$h][2] = 'card';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname);   												to remove a tab
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname);   												to remove a tab
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries');
 
-    require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
-    require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
-    $upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
-    $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
-    $nbLinks = Link::count($db, $object->element, $object->id);
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
-    $head[$h][1] = $langs->trans('Documents');
-    if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
-    $head[$h][2] = 'documents';
-    $h++;
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
+	require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php';
+	$upload_dir = $conf->salaries->dir_output."/".dol_sanitizeFileName($object->ref);
+	$nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$'));
+	$nbLinks = Link::count($db, $object->element, $object->id);
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/document.php?id='.$object->id;
+	$head[$h][1] = $langs->trans('Documents');
+	if (($nbFiles + $nbLinks) > 0) $head[$h][1] .= '<span class="badge ">'.($nbFiles + $nbLinks).'</span>';
+	$head[$h][2] = 'documents';
+	$h++;
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
-    $head[$h][1] = $langs->trans("Info");
-    $head[$h][2] = 'info';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/info.php?id='.$object->id;
+	$head[$h][1] = $langs->trans("Info");
+	$head[$h][2] = 'info';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'salaries', 'remove');
 
-    return $head;
+	return $head;
 }
 
 /**
@@ -71,28 +71,28 @@ function salaries_prepare_head($object)
  */
 function salaries_admin_prepare_head()
 {
-    global $langs, $conf, $user;
+	global $langs, $conf, $user;
 
-    $h = 0;
-    $head = array();
+	$h = 0;
+	$head = array();
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
-    $head[$h][1] = $langs->trans("Miscellaneous");
-    $head[$h][2] = 'general';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries.php';
+	$head[$h][1] = $langs->trans("Miscellaneous");
+	$head[$h][2] = 'general';
+	$h++;
 
-    // Show more tabs from modules
-    // Entries must be declared in modules descriptor with line
-    // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
-    // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
+	// Show more tabs from modules
+	// Entries must be declared in modules descriptor with line
+	// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to add new tab
+	// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__');   to remove a tab
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin');
 
-    $head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
-    $head[$h][1] = $langs->trans("ExtraFieldsSalaries");
-    $head[$h][2] = 'attributes';
-    $h++;
+	$head[$h][0] = DOL_URL_ROOT.'/salaries/admin/salaries_extrafields.php';
+	$head[$h][1] = $langs->trans("ExtraFieldsSalaries");
+	$head[$h][2] = 'attributes';
+	$h++;
 
-    complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
+	complete_head_from_modules($conf, $langs, null, $head, $h, 'salaries_admin', 'remove');
 
-    return $head;
+	return $head;
 }

+ 2 - 2
htdocs/core/lib/security.lib.php

@@ -309,7 +309,7 @@ function restrictedArea($user, $features, $objectid = 0, $tableandshare = '', $f
 						break;
 					}
 				}
-			} elseif (!empty($feature))	{												// This is for permissions on 2 levels ('creer' or 'write')
+			} elseif (!empty($feature)) {												// This is for permissions on 2 levels ('creer' or 'write')
 				//print '<br>feature='.$feature.' creer='.$user->rights->$feature->creer.' write='.$user->rights->$feature->write; exit;
 				if (empty($user->rights->$feature->creer)
 				&& empty($user->rights->$feature->write)
@@ -541,7 +541,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
 			if ($feature == 'agenda')// Also check owner or attendee for users without allactions->read
 			{
 				if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
-					require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
+					require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 					$action = new ActionComm($db);
 					$action->fetch($objectid);
 					if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {

+ 1 - 1
htdocs/core/lib/takepos.lib.php

@@ -71,5 +71,5 @@ function takepos_admin_prepare_head()
 
 	complete_head_from_modules($conf, $langs, null, $head, $h, 'takepos_admin', 'remove');
 
-    return $head;
+	return $head;
 }

File diff suppressed because it is too large
+ 526 - 526
htdocs/core/lib/ticket.lib.php


File diff suppressed because it is too large
+ 293 - 293
htdocs/core/menus/standard/eldy.lib.php


+ 40 - 40
htdocs/core/modules/bank/doc/pdf_ban.modules.php

@@ -41,8 +41,8 @@ class pdf_ban extends ModeleBankAccountDoc
 	public $emetteur;
 
 	/**
-     * @var string Dolibarr version of the loaded document
-     */
+	 * @var string Dolibarr version of the loaded document
+	 */
 	public $version = 'development';
 
 	/**
@@ -50,12 +50,12 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-    public function __construct($db)
+	public function __construct($db)
 	{
 		global $conf, $langs, $mysoc;
 
 		// Load translation files required by the page
-        $langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
+		$langs->loadLangs(array("main", "bank", "withdrawals", "companies"));
 
 		$this->db = $db;
 		$this->name = "ban";
@@ -89,7 +89,7 @@ class pdf_ban extends ModeleBankAccountDoc
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction generant le projet sur le disque
 	 *
@@ -97,9 +97,9 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *	@param	Translate	$outputlangs	Lang output object
 	 *	@return	int         				1 if OK, <=0 if KO
 	 */
-    public function write_file($object, $outputlangs)
+	public function write_file($object, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -113,16 +113,16 @@ class pdf_ban extends ModeleBankAccountDoc
 		{
 			//$nblines = count($object->lines);  // This is set later with array of tasks
 
-		    // Definition of $dir and $file
-		    if ($object->specimen)
-		    {
-		        $dir = $conf->bank->dir_output;
-		        $file = $dir."/SPECIMEN.pdf";
-		    } else {
-		        $objectref = dol_sanitizeFileName($object->ref);
-		        $dir = $conf->bank->dir_output."/".$objectref;
-		        $file = $dir."/".$objectref.".pdf";
-		    }
+			// Definition of $dir and $file
+			if ($object->specimen)
+			{
+				$dir = $conf->bank->dir_output;
+				$file = $dir."/SPECIMEN.pdf";
+			} else {
+				$objectref = dol_sanitizeFileName($object->ref);
+				$dir = $conf->bank->dir_output."/".$objectref;
+				$file = $dir."/".$objectref.".pdf";
+			}
 
 			if (!file_exists($dir))
 			{
@@ -146,20 +146,20 @@ class pdf_ban extends ModeleBankAccountDoc
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -185,7 +185,7 @@ class pdf_ban extends ModeleBankAccountDoc
 				$tab_top = 50;
 				$tab_height = 200;
 				$tab_top_newpage = 40;
-                $tab_height_newpage = 210;
+				$tab_height_newpage = 210;
 
 				// Affiche notes
 				if (!empty($object->note_public))
@@ -246,8 +246,8 @@ class pdf_ban extends ModeleBankAccountDoc
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -280,12 +280,12 @@ class pdf_ban extends ModeleBankAccountDoc
 	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-    protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 	{
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -310,7 +310,7 @@ class pdf_ban extends ModeleBankAccountDoc
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -321,8 +321,8 @@ class pdf_ban extends ModeleBankAccountDoc
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -376,7 +376,7 @@ class pdf_ban extends ModeleBankAccountDoc
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Project		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 92 - 92
htdocs/core/modules/bank/doc/pdf_sepamandate.modules.php

@@ -43,9 +43,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	public $emetteur;
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
@@ -53,7 +53,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 *
 	 *  @param		DoliDB		$db      Database handler
 	 */
-    public function __construct($db)
+	public function __construct($db)
 	{
 		global $conf, $langs, $mysoc;
 
@@ -88,22 +88,22 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
 	 *  Fonction generant le projet sur le disque
 	 *
 	 *	@param	    Project		$object   		    Object project a generer
 	 *	@param	    Translate	$outputlangs	    Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details (not used for this template)
-     *  @param		int			$hidedesc			Do not show desc (not used for this template)
-     *  @param		int			$hideref			Do not show ref (not used for this template)
-     *  @param      null|array  $moreparams         More parameters
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details (not used for this template)
+	 *  @param		int			$hidedesc			Do not show desc (not used for this template)
+	 *  @param		int			$hideref			Do not show ref (not used for this template)
+	 *  @param      null|array  $moreparams         More parameters
 	 *	@return	    int         				    1 if OK, <=0 if KO
 	 */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0, $moreparams = null)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user, $mysoc;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -117,18 +117,18 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		{
 			//$nblines = count($object->lines);  // This is set later with array of tasks
 
-		    // Definition of $dir and $file
-		    if ($object->specimen)
-		    {
-		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
-		        else $dir = $conf->bank->dir_output;
-		        $file = $dir."/SPECIMEN.pdf";
-		    } else {
-		        $objectref = dol_sanitizeFileName($object->ref);
-		        if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
-		        else $dir = $conf->bank->dir_output."/".$objectref;
-		        $file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
-		    }
+			// Definition of $dir and $file
+			if ($object->specimen)
+			{
+				if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
+				else $dir = $conf->bank->dir_output;
+				$file = $dir."/SPECIMEN.pdf";
+			} else {
+				$objectref = dol_sanitizeFileName($object->ref);
+				if (!empty($moreparams['force_dir_output'])) $dir = $moreparams['force_dir_output'];
+				else $dir = $conf->bank->dir_output."/".$objectref;
+				$file = $dir."/".$langs->transnoentitiesnoconv("SepaMandateShort").' '.$objectref."-".dol_sanitizeFileName($object->rum).".pdf";
+			}
 
 			if (!file_exists($dir))
 			{
@@ -152,20 +152,20 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -191,7 +191,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$tab_top = 50;
 				$tab_height = 200;
 				$tab_top_newpage = 40;
-                $tab_height_newpage = 210;
+				$tab_height_newpage = 210;
 
 				// Show notes
 				if (!empty($object->note_public))
@@ -271,7 +271,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$sepaname = '______________________________________________';
 				if ($thirdparty->id > 0)
 				{
-				    $sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
+					$sepaname = $thirdparty->name.($object->account_owner ? ' ('.$object->account_owner.')' : '');
 				}
 				$posY = $pdf->GetY();
 				$posY += 3;
@@ -292,7 +292,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$address = '______________________________________________';
 				if ($thirdparty->id > 0)
 				{
-				    $address = $thirdparty->getFullAddress();
+					$address = $thirdparty->getFullAddress();
 				}
 				$posY = $pdf->GetY();
 				$posY += 1;
@@ -302,9 +302,9 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
 				if (preg_match('/_____/', $address))
 				{
-    				$posY += 6;
-    				$pdf->SetXY(80, $posY);
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
+					$posY += 6;
+					$pdf->SetXY(80, $posY);
+					$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $address, 0, 'L');
 				}
 
 				$ban = '__________________________________________________';
@@ -346,10 +346,10 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
 				if (empty($object->frstrecur))
 				{
-    				$posY += 6;
-    				$pdf->SetXY(80, $posY);
-				    $txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
-    				$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
+					$posY += 6;
+					$pdf->SetXY(80, $posY);
+					$txt = '('.$langs->transnoentitiesnoconv("PleaseCheckOne").')';
+					$pdf->MultiCell($this->page_largeur - $this->marge_gauche - $this->marge_droite, 3, $txt, 0, 'L');
 				}
 
 				$posY = $pdf->GetY();
@@ -399,8 +399,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -433,12 +433,12 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 *   @param		int			$hidebottom		Hide bottom bar of array
 	 *   @return	void
 	 */
-    protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
+	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
 	{
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 	}
 
 
@@ -455,27 +455,27 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
-        global $conf, $mysoc;
+		// phpcs:enable
+		global $conf, $mysoc;
 
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-	    $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
+		$diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 1 : $conf->global->PDF_DIFFSIZE_TITLE);
 
-	    $posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
+		$posy += $this->_signature_area($pdf, $object, $posy, $outputlangs);
 
-	    $pdf->SetXY($this->marge_gauche, $posy);
-	    $pdf->SetFont('', '', $default_font_size);
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
-	    $posy = $pdf->GetY() + 2;
+		$pdf->SetXY($this->marge_gauche, $posy);
+		$pdf->SetFont('', '', $default_font_size);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("PleaseReturnMandate", $mysoc->email).':', 0, 'L', 0);
+		$posy = $pdf->GetY() + 2;
 
-	    $pdf->SetXY($this->marge_gauche, $posy);
-	    $pdf->SetFont('', '', $default_font_size - $diffsizetitle);
-	    $pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
+		$pdf->SetXY($this->marge_gauche, $posy);
+		$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
+		$pdf->MultiCell(100, 6, $mysoc->name, 0, 'L', 0);
 		$pdf->MultiCell(100, 6, $outputlangs->convToOutputCharset($mysoc->getFullAddress()), 0, 'L', 0);
 		$posy = $pdf->GetY() + 2;
 
-	    return $posy;
+		return $posy;
 	}
 
 
@@ -493,33 +493,33 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	 */
 	protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
-	    $tab_top = $posy + 4;
-	    $tab_hl = 4;
+		// phpcs:enable
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
+		$tab_top = $posy + 4;
+		$tab_hl = 4;
 
-	    $posx = $this->marge_gauche;
-	    $pdf->SetXY($posx, $tab_top + 0);
+		$posx = $this->marge_gauche;
+		$pdf->SetXY($posx, $tab_top + 0);
 
-	    $pdf->SetFont('', '', $default_font_size - 2);
+		$pdf->SetFont('', '', $default_font_size - 2);
 
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
-	    $pdf->MultiCell(100, 3, ' ');
-	    $pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentitiesnoconv("DateOfSignature"), 0, 'L', 0);
+		$pdf->MultiCell(100, 3, ' ');
+		$pdf->MultiCell(100, 3, '______________________', 0, 'L', 0);
 
-	    $posx = 120;
-	    $largcol = ($this->page_largeur - $this->marge_droite - $posx);
-	    $useborder = 0;
-	    $index = 0;
-	    // Total HT
-	    $pdf->SetFillColor(255, 255, 255);
-	    $pdf->SetXY($posx, $tab_top + 0);
-	    $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
+		$posx = 120;
+		$largcol = ($this->page_largeur - $this->marge_droite - $posx);
+		$useborder = 0;
+		$index = 0;
+		// Total HT
+		$pdf->SetFillColor(255, 255, 255);
+		$pdf->SetXY($posx, $tab_top + 0);
+		$pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentitiesnoconv("Signature"), 0, 'L', 1);
 
-	    $pdf->SetXY($posx, $tab_top + $tab_hl);
-	    $pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
+		$pdf->SetXY($posx, $tab_top + $tab_hl);
+		$pdf->MultiCell($largcol, $tab_hl * 3, '', 1, 'R');
 
-	    return ($tab_hl * 7);
+		return ($tab_hl * 7);
 	}
 
 
@@ -545,7 +545,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -556,8 +556,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -578,7 +578,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 		$daterum = '__________________';
 		if (!empty($object->date_rum))
 		{
-            $daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
+			$daterum = dol_print_date($object->date_rum, 'day', false, $outputlangs, true);
 		} else $daterum = dol_print_date($object->datec, 'day', false, $outputlangs, true); // For old record, the date_rum was not saved.
 		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : ".$daterum, '', 'R');
 		/*$posy+=6;
@@ -616,7 +616,7 @@ class pdf_sepamandate extends ModeleBankAccountDoc
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Project		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 89 - 89
htdocs/core/modules/cheque/doc/pdf_blochet.class.php

@@ -68,17 +68,17 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
 		$this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
 
-        // Retrieves transmitter
-        $this->emetteur = $mysoc;
-        if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
+		// Retrieves transmitter
+		$this->emetteur = $mysoc;
+		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
 
-        // Define column position
-        $this->line_height = 5;
+		// Define column position
+		$this->line_height = 5;
 		$this->line_per_page = 40;
 		$this->tab_height = 200; //$this->line_height * $this->line_per_page;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction to generate document on disk
 	 *
@@ -86,19 +86,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 *	@param	string			$_dir			Directory
 	 *	@param	string			$number			Number
 	 *	@param	Translate		$outputlangs	Lang output object
-     *	@return	int     						1=ok, 0=ko
+	 *	@return	int     						1=ok, 0=ko
 	 */
 	public function write_file($object, $_dir, $number, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $hookmanager;
 
-        if (!is_object($outputlangs)) $outputlangs = $langs;
-        // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
-        $sav_charset_output = $outputlangs->charset_output;
-        if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
+		if (!is_object($outputlangs)) $outputlangs = $langs;
+		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
+		$sav_charset_output = $outputlangs->charset_output;
+		if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
 
-        // Load traductions files required by page
+		// Load traductions files required by page
 		$outputlangs->loadLangs(array("main", "companies", "bills", "products", "compta"));
 
 		$dir = $_dir."/".get_exdir($number, 0, 1, 0, $object, 'cheque').$number;
@@ -128,19 +128,19 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
 		// Create PDF instance
-        $pdf = pdf_getInstance($this->format);
-        $heightforinfotot = 50; // Height reserved to output the info and total part
-        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-        $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-        if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-        $pdf->SetAutoPageBreak(1, 0);
-
-        if (class_exists('TCPDF'))
-        {
-            $pdf->setPrintHeader(false);
-            $pdf->setPrintFooter(false);
-        }
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
+		$pdf = pdf_getInstance($this->format);
+		$heightforinfotot = 50; // Height reserved to output the info and total part
+		$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+		$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+		if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+		$pdf->SetAutoPageBreak(1, 0);
+
+		if (class_exists('TCPDF'))
+		{
+			$pdf->setPrintHeader(false);
+			$pdf->setPrintFooter(false);
+		}
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
 
 		$pdf->Open();
 		$pagenb = 0;
@@ -170,7 +170,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		}
 
 		$pdf->AddPage();
-        $pagenb++;
+		$pagenb++;
 		$this->Header($pdf, $pagenb, $pages, $outputlangs);
 
 		$this->Body($pdf, $pagenb, $pages, $outputlangs);
@@ -195,8 +195,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 		if ($reshook < 0)
 		{
-		    $this->error = $hookmanager->error;
-		    $this->errors = $hookmanager->errors;
+			$this->error = $hookmanager->error;
+			$this->errors = $hookmanager->errors;
 		}
 
 		if (!empty($conf->global->MAIN_UMASK))
@@ -204,12 +204,12 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 
 		$this->result = array('fullpath'=>$file);
 
-        $outputlangs->charset_output = $sav_charset_output;
-	    return 1; // No error
+		$outputlangs->charset_output = $sav_charset_output;
+		return 1; // No error
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Generate Header
 	 *
@@ -221,7 +221,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 */
 	public function Header(&$pdf, $page, $pages, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $langs;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -230,47 +230,47 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 
 		$title = $outputlangs->transnoentities("CheckReceipt");
 		$pdf->SetFont('', 'B', $default_font_size);
-        $pdf->SetXY(10, 8);
-        $pdf->MultiCell(0, 2, $title, 0, 'L');
+		$pdf->SetXY(10, 8);
+		$pdf->MultiCell(0, 2, $title, 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 15);
+		$pdf->SetXY(10, 15);
 		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Ref"), 0, 'L');
-        $pdf->SetXY(32, 15);
+		$pdf->SetXY(32, 15);
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L');
+		$pdf->MultiCell(60, 2, $outputlangs->convToOutputCharset($this->ref.($this->ref_ext ? " - ".$this->ref_ext : '')), 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 20);
-        $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L');
-        $pdf->SetXY(32, 20);
-        $pdf->SetFont('', '', $default_font_size);
-        $pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs));
+		$pdf->SetXY(10, 20);
+		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Date"), 0, 'L');
+		$pdf->SetXY(32, 20);
+		$pdf->SetFont('', '', $default_font_size);
+		$pdf->MultiCell(60, 2, dol_print_date($this->date, "day", false, $outputlangs));
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 26);
-        $pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
+		$pdf->SetXY(10, 26);
+		$pdf->MultiCell(22, 2, $outputlangs->transnoentities("Owner"), 0, 'L');
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(32, 26);
-        $pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
+		$pdf->SetXY(32, 26);
+		$pdf->MultiCell(80, 2, $outputlangs->convToOutputCharset($this->account->proprio), 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(10, 32);
-        $pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L');
-        pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
+		$pdf->SetXY(10, 32);
+		$pdf->MultiCell(0, 2, $outputlangs->transnoentities("Account"), 0, 'L');
+		pdf_bank($pdf, $outputlangs, 32, 32, $this->account, 1);
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(114, 15);
+		$pdf->SetXY(114, 15);
 		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Signature"), 0, 'L');
 
-        $pdf->Rect(9, 14, 192, 35);
-        $pdf->line(9, 19, 112, 19);
-        $pdf->line(9, 25, 112, 25);
-        //$pdf->line(9, 31, 201, 31);
-        $pdf->line(9, 31, 112, 31);
+		$pdf->Rect(9, 14, 192, 35);
+		$pdf->line(9, 19, 112, 19);
+		$pdf->line(9, 25, 112, 25);
+		//$pdf->line(9, 31, 201, 31);
+		$pdf->line(9, 31, 112, 31);
 
-        $pdf->line(30, 14, 30, 49);
-        $pdf->line(112, 14, 112, 49);
+		$pdf->line(30, 14, 30, 49);
+		$pdf->line(112, 14, 112, 49);
 
 		// Number of cheques
 		$posy = 51;
@@ -284,11 +284,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("NumberOfCheques"), 0, 'L');
 
 		$pdf->SetFont('', 'B', $default_font_size);
-        $pdf->SetXY(57, $posy + 1);
-        $pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L');
+		$pdf->SetXY(57, $posy + 1);
+		$pdf->MultiCell(40, 2, $this->nbcheque, 0, 'L');
 
 		$pdf->SetFont('', '', $default_font_size);
-        $pdf->SetXY(148, $posy + 1);
+		$pdf->SetXY(148, $posy + 1);
 		$pdf->MultiCell(40, 2, $langs->trans("Total"));
 
 		$pdf->SetFont('', 'B', $default_font_size);
@@ -302,11 +302,11 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10);
 
 		$pdf->SetXY(41, $this->tab_top + 2);
-        $pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L');
+		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("Bank"), 0, 'L');
 		$pdf->line(100, $this->tab_top, 100, $this->tab_top + $this->tab_height + 10);
 
-        $pdf->SetXY(101, $this->tab_top + 2);
-        $pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L');
+		$pdf->SetXY(101, $this->tab_top + 2);
+		$pdf->MultiCell(40, 2, $outputlangs->transnoentities("CheckTransmitter"), 0, 'L');
 		$pdf->line(180, $this->tab_top, 180, $this->tab_top + $this->tab_height + 10);
 
 		$pdf->SetXY(180, $this->tab_top + 2);
@@ -317,7 +317,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Output array
 	 *
@@ -329,7 +329,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 	 */
 	public function Body(&$pdf, $pagenb, $pages, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		// x=10 - Num
 		// x=30 - Banque
 		// x=100 - Emetteur
@@ -342,30 +342,30 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$num = count($this->lines);
 		for ($j = 0; $j < $num; $j++)
 		{
-            // Dynamic max line heigh calculation
-            $dynamic_line_height = array();
-            $dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
-            $dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
-            $max_line_height = max($dynamic_line_height);
-            // Calculate number of line used function of estimated line size
-            if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1;
-            else $nb_lines = 1;
-
-            // Add page break if we do not have space to add current line
+			// Dynamic max line heigh calculation
+			$dynamic_line_height = array();
+			$dynamic_line_height[] = $pdf->getStringHeight(60, $outputlangs->convToOutputCharset($this->lines[$j]->bank_chq));
+			$dynamic_line_height[] = $pdf->getStringHeight(80, $outputlangs->convToOutputCharset($this->lines[$j]->emetteur_chq));
+			$max_line_height = max($dynamic_line_height);
+			// Calculate number of line used function of estimated line size
+			if ($max_line_height > $this->line_height) $nb_lines = floor($max_line_height / $this->line_height) + 1;
+			else $nb_lines = 1;
+
+			// Add page break if we do not have space to add current line
 			if ($lineinpage >= ($this->line_per_page - 1))
 			{
-			    $lineinpage = 0; $yp = 0;
-
-                // New page
-                $pdf->AddPage();
-                $pagenb++;
-                $this->Header($pdf, $pagenb, $pages, $outputlangs);
-                $pdf->SetFont('', '', $default_font_size - 1);
-                $pdf->MultiCell(0, 3, ''); // Set interline to 3
-                $pdf->SetTextColor(0, 0, 0);
+				$lineinpage = 0; $yp = 0;
+
+				// New page
+				$pdf->AddPage();
+				$pagenb++;
+				$this->Header($pdf, $pagenb, $pages, $outputlangs);
+				$pdf->SetFont('', '', $default_font_size - 1);
+				$pdf->MultiCell(0, 3, ''); // Set interline to 3
+				$pdf->SetTextColor(0, 0, 0);
 			}
 
-            $lineinpage += $nb_lines;
+			$lineinpage += $nb_lines;
 
 			$pdf->SetXY(1, $this->tab_top + 10 + $yp);
 			$pdf->MultiCell(8, $this->line_height, $j + 1, 0, 'R', 0);
@@ -382,14 +382,14 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 			$pdf->SetXY(180, $this->tab_top + 10 + $yp);
 			$pdf->MultiCell(20, $this->line_height, price($this->lines[$j]->amount_chq), 0, 'R', 0);
 
-            $yp = $yp + ($this->line_height * $nb_lines);
+			$yp = $yp + ($this->line_height * $nb_lines);
 		}
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Object		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output
@@ -410,7 +410,7 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
 		$paramfreetext = 'BANK_CHEQUERECEIPT_FREE_TEXT';
 		if (!empty($conf->global->$paramfreetext))
 		{
-		    $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
+			$newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray);
 		}
 
 		return pdf_pagefoot($pdf, $outputlangs, $newfreetext, $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);

+ 104 - 104
htdocs/core/modules/contract/doc/pdf_strato.modules.php

@@ -41,70 +41,70 @@ require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
 class pdf_strato extends ModelePDFContract
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -160,21 +160,21 @@ class pdf_strato extends ModelePDFContract
 		$this->posxdesc = $this->marge_gauche + 1;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param		CommonObject	$object				Id of object to generate
-     *  @param		object			$outputlangs		Lang output object
-     *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int				$hidedetails		Do not show line details
-     *  @param		int				$hidedesc			Do not show desc
-     *  @param		int				$hideref			Do not show ref
-     *  @return		int									1=OK, 0=KO
-     */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
-    {
-        // phpcs:enable
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		CommonObject	$object				Id of object to generate
+	 *  @param		object			$outputlangs		Lang output object
+	 *  @param		string			$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int				$hidedetails		Do not show line details
+	 *  @param		int				$hidedesc			Do not show desc
+	 *  @param		int				$hideref			Do not show ref
+	 *  @return		int									1=OK, 0=KO
+	 */
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	{
+		// phpcs:enable
 		global $user, $langs, $conf, $hookmanager, $mysoc;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -186,7 +186,7 @@ class pdf_strato extends ModelePDFContract
 
 		if ($conf->contrat->dir_output)
 		{
-            $object->fetch_thirdparty();
+			$object->fetch_thirdparty();
 
 			// Definition of $dir and $file
 			if ($object->specimen)
@@ -221,26 +221,26 @@ class pdf_strato extends ModelePDFContract
 				global $action;
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -341,12 +341,12 @@ class pdf_strato extends ModelePDFContract
 						}
 
 						$txtpredefinedservice = '';
-                        $txtpredefinedservice = $objectligne->product_label;
-                        if ($objectligne->product_label)
-                        {
-                        	$txtpredefinedservice .= ' - ';
-                        	$txtpredefinedservice .= $objectligne->product_label;
-                        }
+						$txtpredefinedservice = $objectligne->product_label;
+						if ($objectligne->product_label)
+						{
+							$txtpredefinedservice .= ' - ';
+							$txtpredefinedservice .= $objectligne->product_label;
+						}
 
 						$desc = dol_htmlentitiesbr($objectligne->desc, 1); // Desc (not empty for free lines)
 						$txt = '';
@@ -359,7 +359,7 @@ class pdf_strato extends ModelePDFContract
 						if (empty($conf->global->CONTRACT_HIDE_REAL_DATE_ON_PDF))
 						{
 							$txt .= '<br>';
-	                        $txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
+							$txt .= $outputlangs->transnoentities("DateStartRealShort")." : <strong>".$daters.'</strong>';
 							if ($objectligne->date_cloture) $txt .= " - ".$outputlangs->transnoentities("DateEndRealShort")." : '<strong>'".$datere.'</strong>';
 						}
 
@@ -476,8 +476,8 @@ class pdf_strato extends ModelePDFContract
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -518,7 +518,7 @@ class pdf_strato extends ModelePDFContract
 		if ($hidetop) $hidetop = -1;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
-        /*
+		/*
 		$pdf->SetXY($this->marge_gauche, $tab_top);
 		$pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0);
 		$pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8);
@@ -548,16 +548,16 @@ class pdf_strato extends ModelePDFContract
 		$this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height + 3); // Rect takes a length in 3rd parameter and 4th parameter
 	}
 
-    /**
-     * Show footer signature of page
-     * @param   TCPDF       $pdf            Object PDF
-     * @param   int         $tab_top        tab height position
-     * @param   int         $tab_height     tab height
-     * @param   Translate   $outputlangs    Object language for output
-     * @return void
-     */
+	/**
+	 * Show footer signature of page
+	 * @param   TCPDF       $pdf            Object PDF
+	 * @param   int         $tab_top        tab height position
+	 * @param   int         $tab_height     tab height
+	 * @param   Translate   $outputlangs    Object language for output
+	 * @return void
+	 */
 	protected function tabSignature(&$pdf, $tab_top, $tab_height, $outputlangs)
-    {
+	{
 		$pdf->SetDrawColor(128, 128, 128);
 		$posmiddle = $this->marge_gauche + round(($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2);
 		$posy = $tab_top + $tab_height + 3 + 3;
@@ -573,20 +573,20 @@ class pdf_strato extends ModelePDFContract
 
 		$pdf->SetXY($posmiddle + 5, $posy + 5);
 		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $posmiddle - 5, 20, '', 1);
-    }
+	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
-     *  Show top header of page.
-     *
-     *  @param	TCPDF		$pdf     		Object PDF
-     *  @param  CommonObject	$object     	Object to show
-     *  @param  int	    	$showaddress    0=no, 1=yes
-     *  @param  Translate	$outputlangs	Object lang for output
-     *  @return	void
-     */
+	/**
+	 *  Show top header of page.
+	 *
+	 *  @param	TCPDF		$pdf     		Object PDF
+	 *  @param  CommonObject	$object     	Object to show
+	 *  @param  int	    	$showaddress    0=no, 1=yes
+	 *  @param  Translate	$outputlangs	Object lang for output
+	 *  @return	void
+	 */
 	protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
-    {
+	{
 		global $conf, $langs;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -617,8 +617,8 @@ class pdf_strato extends ModelePDFContract
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -754,7 +754,7 @@ class pdf_strato extends ModelePDFContract
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	PDF			$pdf     			PDF
 	 * 		@param	CommonObject		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 334 - 334
htdocs/core/modules/expedition/doc/pdf_espadon.modules.php

@@ -36,71 +36,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_espadon extends ModelePdfExpedition
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
-    /**
-     * @var string model name
-     */
-    public $name;
+	/**
+	 * @var string model name
+	 */
+	public $name;
 
-    /**
-     * @var string model description (short text)
-     */
-    public $description;
+	/**
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -148,11 +148,11 @@ class pdf_espadon extends ModelePdfExpedition
 	 *
 	 *	@param		Object		$object			    Object expedition to generate (or id if old method)
 	 *	@param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int         	    			1=OK, 0=KO
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int         	    			1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
@@ -177,16 +177,16 @@ class pdf_espadon extends ModelePdfExpedition
 
 		$nblines = count($object->lines);
 
-        // Loop on each lines to detect if there is at least one image to show
-        $realpatharray = array();
-        $this->atleastonephoto = false;
-        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
-        {
-            $objphoto = new Product($this->db);
+		// Loop on each lines to detect if there is at least one image to show
+		$realpatharray = array();
+		$this->atleastonephoto = false;
+		if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
+		{
+			$objphoto = new Product($this->db);
 
-            for ($i = 0; $i < $nblines; $i++)
-            {
-                if (empty($object->lines[$i]->fk_product)) continue;
+			for ($i = 0; $i < $nblines; $i++)
+			{
+				if (empty($object->lines[$i]->fk_product)) continue;
 
 				$objphoto = new Product($this->db);
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -202,34 +202,34 @@ class pdf_espadon extends ModelePdfExpedition
 
 				$realpath = '';
 
-                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
-                {
-                    if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
-                    {
-                        if ($obj['photo_vignette'])
-                        {
-                            $filename = $obj['photo_vignette'];
-                        } else {
-                            $filename = $obj['photo'];
-                        }
-                    } else {
-                        $filename = $obj['photo'];
-                    }
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
+				{
+					if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))		// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+					{
+						if ($obj['photo_vignette'])
+						{
+							$filename = $obj['photo_vignette'];
+						} else {
+							$filename = $obj['photo'];
+						}
+					} else {
+						$filename = $obj['photo'];
+					}
 
 					$realpath = $dir.$filename;
 					$this->atleastonephoto = true;
-                    break;
-                }
+					break;
+				}
 
-                if ($realpath) $realpatharray[$i] = $realpath;
-            }
-        }
+				if ($realpath) $realpatharray[$i] = $realpath;
+			}
+		}
 
-        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
 
 		if ($conf->expedition->dir_output)
 		{
-		    // Definition of $dir and $file
+			// Definition of $dir and $file
 			if ($object->specimen)
 			{
 				$dir = $conf->expedition->dir_output."/sending";
@@ -268,23 +268,23 @@ class pdf_espadon extends ModelePdfExpedition
 				$pdf = pdf_getInstance($this->format);
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
 				$heightforinfotot = 8; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -315,7 +315,7 @@ class pdf_espadon extends ModelePdfExpedition
 				$tab_height = 130;
 				$tab_height_newpage = 150;
 
-                $this->posxdesc = $this->marge_gauche + 1;
+				$this->posxdesc = $this->marge_gauche + 1;
 
 				// Incoterm
 				$height_incoterms = 0;
@@ -340,15 +340,15 @@ class pdf_espadon extends ModelePdfExpedition
 					}
 				}
 
-                // display note
-                $notetoshow = empty($object->note_public) ? '' : $object->note_public;
+				// display note
+				$notetoshow = empty($object->note_public) ? '' : $object->note_public;
 
-                // Extrafields in note
-                $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
-                if (!empty($extranote))
-                {
-                    $notetoshow = dol_concatdesc($notetoshow, $extranote);
-                }
+				// Extrafields in note
+				$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+				if (!empty($extranote))
+				{
+					$notetoshow = dol_concatdesc($notetoshow, $extranote);
+				}
 
 				if (!empty($notetoshow) || !empty($object->tracking_number))
 				{
@@ -391,7 +391,7 @@ class pdf_espadon extends ModelePdfExpedition
 					// Notes
 					if (!empty($notetoshow))
 					{
-					    $pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
+						$pdf->SetFont('', '', $default_font_size - 1); // In loop to manage multi-page
 						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt, dol_htmlentitiesbr($notetoshow), 0, 1);
 					}
 
@@ -441,69 +441,69 @@ class pdf_espadon extends ModelePdfExpedition
 
 					if ($this->getColumnStatus('photo'))
 					{
-					    // We start with Photo of product line
-					    if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
-					    {
-					        $pdf->AddPage('', '', true);
-					        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-					        //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-					        $pdf->setPage($pageposbefore + 1);
+						// We start with Photo of product line
+						if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
+						{
+							$pdf->AddPage('', '', true);
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+							//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+							$pdf->setPage($pageposbefore + 1);
 
-					        $curY = $tab_top_newpage;
+							$curY = $tab_top_newpage;
 
 							// Allows data in the first page if description is long enough to break in multiples pages
 							if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 								$showpricebeforepagebreak = 1;
 							else $showpricebeforepagebreak = 0;
-					    }
+						}
 
 
-					    if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
-					    {
-					        $pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
-					        // $pdf->Image does not increase value return by getY, so we save it manually
-					        $posYAfterImage = $curY + $imglinesize['height'];
-					    }
+						if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
+						{
+							$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+							// $pdf->Image does not increase value return by getY, so we save it manually
+							$posYAfterImage = $curY + $imglinesize['height'];
+						}
 					}
 
 					// Description of product line
 					if ($this->getColumnStatus('desc'))
 					{
-					    $pdf->startTransaction();
-
-                        $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
-                        $pageposafter = $pdf->getPage();
-					    if ($pageposafter > $pageposbefore)	// There is a pagebreak
-					    {
-					        $pdf->rollbackTransaction(true);
-
-                            $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
-					        $pageposafter = $pdf->getPage();
-					        $posyafter = $pdf->GetY();
-					        //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
-					        if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
-					        {
-					            if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
-					            {
-					                $pdf->AddPage('', '', true);
-					                if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-					                //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-					                $pdf->setPage($pageposafter + 1);
-					            }
-					        } else {
-					            // We found a page break
+						$pdf->startTransaction();
+
+						$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+
+						$pageposafter = $pdf->getPage();
+						if ($pageposafter > $pageposbefore)	// There is a pagebreak
+						{
+							$pdf->rollbackTransaction(true);
+
+							$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+
+							$pageposafter = $pdf->getPage();
+							$posyafter = $pdf->GetY();
+							//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
+							{
+								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
+								{
+									$pdf->AddPage('', '', true);
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+									//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+									$pdf->setPage($pageposafter + 1);
+								}
+							} else {
+								// We found a page break
 								// Allows data in the first page if description is long enough to break in multiples pages
 								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 									$showpricebeforepagebreak = 1;
 								else $showpricebeforepagebreak = 0;
-					        }
-					    } else // No pagebreak
-					    {
-					        $pdf->commitTransaction();
-					    }
-					    $posYAfterDescription = $pdf->GetY();
+							}
+						} else // No pagebreak
+						{
+							$pdf->commitTransaction();
+						}
+						$posYAfterDescription = $pdf->GetY();
 					}
 
 					$nexY = $pdf->GetY();
@@ -541,39 +541,39 @@ class pdf_espadon extends ModelePdfExpedition
 
 					if ($this->getColumnStatus('weight'))
 					{
-					    $this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, array('html'=>1));
-					    $nexY = max($pdf->GetY(), $nexY);
+						$this->printStdColumnContent($pdf, $curY, 'weight', $weighttxt.(($weighttxt && $voltxt) ? '<br>' : '').$voltxt, array('html'=>1));
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					if ($this->getColumnStatus('qty_asked'))
 					{
-					    $this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$this->printStdColumnContent($pdf, $curY, 'qty_asked', $object->lines[$i]->qty_asked);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					if ($this->getColumnStatus('qty_shipped'))
 					{
-					    $this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$this->printStdColumnContent($pdf, $curY, 'qty_shipped', $object->lines[$i]->qty_shipped);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					if ($this->getColumnStatus('subprice'))
 					{
-					    $this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
-					    $nexY = max($pdf->GetY(), $nexY);
+						$this->printStdColumnContent($pdf, $curY, 'subprice', price($object->lines[$i]->subprice, 0, $outputlangs));
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
-                    // Extrafields
-                    if (!empty($object->lines[$i]->array_options)) {
-                        foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
-                            if ($this->getColumnStatus($extrafieldColKey))
-                            {
-                                $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
-                                $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
-                                $nexY = max($pdf->GetY(), $nexY);
-                            }
-                        }
-                    }
+					// Extrafields
+					if (!empty($object->lines[$i]->array_options)) {
+						foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
+							if ($this->getColumnStatus($extrafieldColKey))
+							{
+								$extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
+								$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
+								$nexY = max($pdf->GetY(), $nexY);
+							}
+						}
+					}
 
 					// Add line
 					if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
@@ -646,8 +646,8 @@ class pdf_espadon extends ModelePdfExpedition
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -683,9 +683,9 @@ class pdf_espadon extends ModelePdfExpedition
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $sign = 1;
+		$sign = 1;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$tab2_top = $posy;
 		$tab2_hl = 4;
@@ -715,8 +715,8 @@ class pdf_espadon extends ModelePdfExpedition
 		// Set trueVolume and volume_units not currently stored into database
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
 		{
-		    $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
-		    $object->volume_units = $object->size_units * 3;
+			$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
+			$object->volume_units = $object->size_units * 3;
 		}
 
 		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@@ -727,40 +727,40 @@ class pdf_espadon extends ModelePdfExpedition
 
 
 
-    	if ($this->getColumnStatus('desc'))
-    	{
-    	    $this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
-    	}
+		if ($this->getColumnStatus('desc'))
+		{
+			$this->printStdColumnContent($pdf, $tab2_top, 'desc', $outputlangs->transnoentities("Total"));
+		}
 
 
 		if ($this->getColumnStatus('weight'))
 		{
-		    if ($totalWeighttoshow)
-		    {
-		        $this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
-		        $index++;
-		    }
-
-		    if ($totalVolumetoshow)
-		    {
-		        $y = $tab2_top + ($tab2_hl * $index);
-		        $this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
-		    }
+			if ($totalWeighttoshow)
+			{
+				$this->printStdColumnContent($pdf, $tab2_top, 'weight', $totalWeighttoshow);
+				$index++;
+			}
+
+			if ($totalVolumetoshow)
+			{
+				$y = $tab2_top + ($tab2_hl * $index);
+				$this->printStdColumnContent($pdf, $y, 'weight', $totalVolumetoshow);
+			}
 		}
 
 		if ($this->getColumnStatus('qty_asked') && $totalOrdered)
 		{
-		    $this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered);
+			$this->printStdColumnContent($pdf, $tab2_top, 'qty_asked', $totalOrdered);
 		}
 
 		if ($this->getColumnStatus('qty_shipped') && $totalToShip)
 		{
-		    $this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip);
+			$this->printStdColumnContent($pdf, $tab2_top, 'qty_shipped', $totalToShip);
 		}
 
 		if ($this->getColumnStatus('subprice'))
 		{
-		    $this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs));
+			$this->printStdColumnContent($pdf, $tab2_top, 'subprice', price($object->total_ht, 0, $outputlangs));
 		}
 
 		$pdf->SetTextColor(0, 0, 0);
@@ -814,7 +814,7 @@ class pdf_espadon extends ModelePdfExpedition
 		$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
 
 		if (empty($hidetop)) {
-		    $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+			$pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
 		}
 	}
 
@@ -841,7 +841,7 @@ class pdf_espadon extends ModelePdfExpedition
 		// Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
 		{
-            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
+					pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
 		}
 
 		//Prepare next
@@ -861,8 +861,8 @@ class pdf_espadon extends ModelePdfExpedition
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -918,10 +918,10 @@ class pdf_espadon extends ModelePdfExpedition
 		// Date planned delivery
 		if (!empty($object->date_delivery))
 		{
-    			$posy += 4;
-    			$pdf->SetXY($posx, $posy);
-    			$pdf->SetTextColor(0, 0, 60);
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
 		}
 
 		if (!empty($object->thirdparty->code_client))
@@ -940,7 +940,7 @@ class pdf_espadon extends ModelePdfExpedition
 		$origin = $object->origin;
 		$origin_id = $object->origin_id;
 
-	    // TODO move to external function
+		// TODO move to external function
 		if (!empty($conf->$origin->enabled))     // commonly $origin='commande'
 		{
 			$outputlangs->load('orders');
@@ -950,7 +950,7 @@ class pdf_espadon extends ModelePdfExpedition
 			$result = $linkedobject->fetch($origin_id);
 			if ($result >= 0)
 			{
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+				//$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
 
 				$pdf->SetFont('', '', $default_font_size - 2);
 				$text = $linkedobject->ref;
@@ -1064,7 +1064,7 @@ class pdf_espadon extends ModelePdfExpedition
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
@@ -1090,21 +1090,21 @@ class pdf_espadon extends ModelePdfExpedition
 	 */
 	public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-	    global $conf, $hookmanager;
+		global $conf, $hookmanager;
 
-	    // Default field style for content
-	    $this->defaultContentsFieldsStyle = array(
-	        'align' => 'R', // R,C,L
-            'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	    );
+		// Default field style for content
+		$this->defaultContentsFieldsStyle = array(
+			'align' => 'R', // R,C,L
+			'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+		);
 
-	    // Default field style for content
-	    $this->defaultTitlesFieldsStyle = array(
-	        'align' => 'C', // R,C,L
-	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	    );
+		// Default field style for content
+		$this->defaultTitlesFieldsStyle = array(
+			'align' => 'C', // R,C,L
+			'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+		);
 
-	    /*
+		/*
 	     * For exemple
 	     $this->cols['theColKey'] = array(
 	     'rank' => $rank, // int : use for ordering columns
@@ -1122,128 +1122,128 @@ class pdf_espadon extends ModelePdfExpedition
 	     );
 	     */
 
-	    $rank = 0; // do not use negative rank
-	    $this->cols['desc'] = array(
-	        'rank' => $rank,
-	        'width' => false, // only for desc
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'Designation', // use lang key is usefull in somme case with module
-	            'align' => 'L',
-	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
-	            // 'label' => ' ', // the final label
-                'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	        'content' => array(
-                'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['photo'] = array(
-	        'rank' => $rank,
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
-	        'status' => false,
-	        'title' => array(
-	            'textkey' => 'Photo',
-	            'label' => ' '
-	        ),
-	        'content' => array(
-	            'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	        'border-left' => false, // remove left line separator
-	    );
-
-	    if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
-	    {
-	        $this->cols['photo']['status'] = true;
-	    }
-
-	    $rank = $rank + 10;
-	    $this->cols['weight'] = array(
-	        'rank' => $rank,
-	        'width' => 30, // in mm
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'WeightVolShort'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-
-	    $rank = $rank + 10;
-	    $this->cols['subprice'] = array(
-	        'rank' => $rank,
-	        'width' => 19, // in mm
-	        'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
-	        'title' => array(
-	            'textkey' => 'PriceUHT'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['totalexcltax'] = array(
-	        'rank' => $rank,
-	        'width' => 26, // in mm
-	        'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
-	        'title' => array(
-	            'textkey' => 'TotalHT'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['qty_asked'] = array(
-	        'rank' => $rank,
-	        'width' => 30, // in mm
-	        'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
-	        'title' => array(
-	            'textkey' => 'QtyOrdered'
-	        ),
-	        'border-left' => true, // add left line separator
-	        'content' => array(
-	            'align' => 'C',
-	        ),
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['qty_shipped'] = array(
-	        'rank' => $rank,
-	        'width' => 30, // in mm
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'QtyToShip'
-	        ),
-	        'border-left' => true, // add left line separator
-	        'content' => array(
-	            'align' => 'C',
-	        ),
-	    );
-
-        // Add extrafields cols
-        if (!empty($object->lines)) {
-            $line = reset($object->lines);
-            $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
-        }
-
-	    $parameters = array(
-	        'object' => $object,
-	        'outputlangs' => $outputlangs,
-	        'hidedetails' => $hidedetails,
-	        'hidedesc' => $hidedesc,
-	        'hideref' => $hideref
-	    );
-
-	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
-	    if ($reshook < 0)
-	    {
-	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-	    } elseif (empty($reshook))
-	    {
-	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
-	    } else {
-	        $this->cols = $hookmanager->resArray;
-	    }
+		$rank = 0; // do not use negative rank
+		$this->cols['desc'] = array(
+			'rank' => $rank,
+			'width' => false, // only for desc
+			'status' => true,
+			'title' => array(
+				'textkey' => 'Designation', // use lang key is usefull in somme case with module
+				'align' => 'L',
+				// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+				// 'label' => ' ', // the final label
+				'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+			'content' => array(
+				'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+		);
+
+		$rank = $rank + 10;
+		$this->cols['photo'] = array(
+			'rank' => $rank,
+			'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+			'status' => false,
+			'title' => array(
+				'textkey' => 'Photo',
+				'label' => ' '
+			),
+			'content' => array(
+				'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+			'border-left' => false, // remove left line separator
+		);
+
+		if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE) && !empty($this->atleastonephoto))
+		{
+			$this->cols['photo']['status'] = true;
+		}
+
+		$rank = $rank + 10;
+		$this->cols['weight'] = array(
+			'rank' => $rank,
+			'width' => 30, // in mm
+			'status' => true,
+			'title' => array(
+				'textkey' => 'WeightVolShort'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+
+		$rank = $rank + 10;
+		$this->cols['subprice'] = array(
+			'rank' => $rank,
+			'width' => 19, // in mm
+			'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
+			'title' => array(
+				'textkey' => 'PriceUHT'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		$rank = $rank + 10;
+		$this->cols['totalexcltax'] = array(
+			'rank' => $rank,
+			'width' => 26, // in mm
+			'status' => !empty($conf->global->MAIN_PDF_SHIPPING_DISPLAY_AMOUNT_HT) ? 1 : 0,
+			'title' => array(
+				'textkey' => 'TotalHT'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		$rank = $rank + 10;
+		$this->cols['qty_asked'] = array(
+			'rank' => $rank,
+			'width' => 30, // in mm
+			'status' => empty($conf->global->SHIPPING_PDF_HIDE_ORDERED) ? 1 : 0,
+			'title' => array(
+				'textkey' => 'QtyOrdered'
+			),
+			'border-left' => true, // add left line separator
+			'content' => array(
+				'align' => 'C',
+			),
+		);
+
+		$rank = $rank + 10;
+		$this->cols['qty_shipped'] = array(
+			'rank' => $rank,
+			'width' => 30, // in mm
+			'status' => true,
+			'title' => array(
+				'textkey' => 'QtyToShip'
+			),
+			'border-left' => true, // add left line separator
+			'content' => array(
+				'align' => 'C',
+			),
+		);
+
+		// Add extrafields cols
+		if (!empty($object->lines)) {
+			$line = reset($object->lines);
+			$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+		}
+
+		$parameters = array(
+			'object' => $object,
+			'outputlangs' => $outputlangs,
+			'hidedetails' => $hidedetails,
+			'hidedesc' => $hidedesc,
+			'hideref' => $hideref
+		);
+
+		$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+		if ($reshook < 0)
+		{
+			setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+		} elseif (empty($reshook))
+		{
+			$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+		} else {
+			$this->cols = $hookmanager->resArray;
+		}
 	}
 }

+ 76 - 76
htdocs/core/modules/expedition/doc/pdf_merou.modules.php

@@ -37,71 +37,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_merou extends ModelePdfExpedition
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -142,21 +142,21 @@ class pdf_merou extends ModelePdfExpedition
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Function to build pdf onto disk
 	 *
 	 *	@param		Object		$object			Object expedition to generate (or id if old method)
 	 *	@param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int         	    			1=OK, 0=KO
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int         	    			1=OK, 0=KO
 	 */
 	public function write_file(&$object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $conf, $langs, $mysoc, $hookmanager;
 
 		$object->fetch_thirdparty();
@@ -179,7 +179,7 @@ class pdf_merou extends ModelePdfExpedition
 
 			//Create recipient
 			$idcontact = $object->$origin->getIdContact('external', 'SHIPPING');
-            $this->destinataire = new Contact($this->db);
+			$this->destinataire = new Contact($this->db);
 			if (!empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
 
 			//Create deliverer
@@ -225,23 +225,23 @@ class pdf_merou extends ModelePdfExpedition
 				$pdf = pdf_getInstance($this->format, 'mm', 'l');
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
 				$heightforinfotot = 0; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-			    if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -414,12 +414,12 @@ class pdf_merou extends ModelePdfExpedition
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
-                if (!empty($conf->global->MAIN_UMASK))
-                    @chmod($file, octdec($conf->global->MAIN_UMASK));
+				if (!empty($conf->global->MAIN_UMASK))
+					@chmod($file, octdec($conf->global->MAIN_UMASK));
 
 				$this->result = array('fullpath'=>$file);
 
@@ -479,7 +479,7 @@ class pdf_merou extends ModelePdfExpedition
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
@@ -498,11 +498,11 @@ class pdf_merou extends ModelePdfExpedition
 		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("NameAndSignature"), 0, 'C');
 
 		// Show page nb only on iso languages (so default Helvetica font)
-        //if (pdf_getPDFFont($outputlangs) == 'Helvetica')
-        //{
-    	//    $pdf->SetXY(-10,-10);
-        //    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
-        //}
+		//if (pdf_getPDFFont($outputlangs) == 'Helvetica')
+		//{
+		//    $pdf->SetXY(-10,-10);
+		//    $pdf->MultiCell(11, 2, $pdf->PageNo().'/'.$pdf->getAliasNbPages(), 0, 'R', 0);
+		//}
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -526,11 +526,11 @@ class pdf_merou extends ModelePdfExpedition
 			//Affiche le filigrane brouillon - Print Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->SENDING_DRAFT_WATERMARK)))
 		{
-            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SENDING_DRAFT_WATERMARK);
 		}
 
-        $posy = $this->marge_haute;
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posy = $this->marge_haute;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 
 		$Xoff = 90;
 		$Yoff = 0;
@@ -547,8 +547,8 @@ class pdf_merou extends ModelePdfExpedition
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, 10, 5, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);

+ 154 - 154
htdocs/core/modules/expedition/doc/pdf_rouget.modules.php

@@ -37,71 +37,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
  */
 class pdf_rouget extends ModelePdfExpedition
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
-    /**
-     * @var string model name
-     */
-    public $name;
+	/**
+	 * @var string model name
+	 */
+	public $name;
 
-    /**
-     * @var string model description (short text)
-     */
-    public $description;
+	/**
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -159,18 +159,18 @@ class pdf_rouget extends ModelePdfExpedition
 
 		$this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
 
-        // To work with US executive format
-        if ($this->page_largeur < 210) {
-            $this->posxweightvol -= 20;
-            $this->posxpicture -= 20;
-            $this->posxqtyordered -= 20;
-            $this->posxqtytoship -= 20;
-        }
+		// To work with US executive format
+		if ($this->page_largeur < 210) {
+			$this->posxweightvol -= 20;
+			$this->posxpicture -= 20;
+			$this->posxqtyordered -= 20;
+			$this->posxqtytoship -= 20;
+		}
 
 		if (!empty($conf->global->SHIPPING_PDF_HIDE_ORDERED)) {
-		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
-		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
-		    $this->posxqtyordered = $this->posxqtytoship;
+			$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
+			$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
+			$this->posxqtyordered = $this->posxqtytoship;
 		}
 	}
 
@@ -180,11 +180,11 @@ class pdf_rouget extends ModelePdfExpedition
 	 *
 	 *	@param		Object		$object			Object expedition to generate (or id if old method)
 	 *	@param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int         	    			1=OK, 0=KO
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int         	    			1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
@@ -202,15 +202,15 @@ class pdf_rouget extends ModelePdfExpedition
 
 		$nblines = count($object->lines);
 
-        // Loop on each lines to detect if there is at least one image to show
-        $realpatharray = array();
-        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
-        {
-            $objphoto = new Product($this->db);
+		// Loop on each lines to detect if there is at least one image to show
+		$realpatharray = array();
+		if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
+		{
+			$objphoto = new Product($this->db);
 
-            for ($i = 0; $i < $nblines; $i++)
-            {
-                if (empty($object->lines[$i]->fk_product)) continue;
+			for ($i = 0; $i < $nblines; $i++)
+			{
+				if (empty($object->lines[$i]->fk_product)) continue;
 
 				$objphoto = new Product($this->db);
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -225,28 +225,28 @@ class pdf_rouget extends ModelePdfExpedition
 
 				$realpath = '';
 
-                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
-                    if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
-                        // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
-                        if ($obj['photo_vignette'])
-                        {
-                            $filename = $obj['photo_vignette'];
-                        } else {
-                            $filename = $obj['photo'];
-                        }
-                    } else {
-                        $filename = $obj['photo'];
-                    }
-
-                    $realpath = $dir.$filename;
-                    break;
-                }
-
-                if ($realpath) $realpatharray[$i] = $realpath;
-            }
-        }
-
-        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+					if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
+						// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+						if ($obj['photo_vignette'])
+						{
+							$filename = $obj['photo_vignette'];
+						} else {
+							$filename = $obj['photo'];
+						}
+					} else {
+						$filename = $obj['photo'];
+					}
+
+					$realpath = $dir.$filename;
+					break;
+				}
+
+				if ($realpath) $realpatharray[$i] = $realpath;
+			}
+		}
+
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
 
 		if ($conf->expedition->dir_output)
 		{
@@ -289,23 +289,23 @@ class pdf_rouget extends ModelePdfExpedition
 				$pdf = pdf_getInstance($this->format);
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
 				$heightforinfotot = 8; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -544,8 +544,8 @@ class pdf_rouget extends ModelePdfExpedition
 
 					if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
 					{
-					    $pdf->SetXY($this->posxqtyordered, $curY);
-					    $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
+						$pdf->SetXY($this->posxqtyordered, $curY);
+						$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
 					}
 
 					if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
@@ -637,8 +637,8 @@ class pdf_rouget extends ModelePdfExpedition
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -674,9 +674,9 @@ class pdf_rouget extends ModelePdfExpedition
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $sign = 1;
+		$sign = 1;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$tab2_top = $posy;
 		$tab2_hl = 4;
@@ -706,8 +706,8 @@ class pdf_rouget extends ModelePdfExpedition
 		// Set trueVolume and volume_units not currently stored into database
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
 		{
-		    $object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
-		    $object->volume_units = $object->size_units * 3;
+			$object->trueVolume = price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
+			$object->volume_units = $object->size_units * 3;
 		}
 
 		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@@ -715,29 +715,29 @@ class pdf_rouget extends ModelePdfExpedition
 		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
 		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
 
-    	$pdf->SetFillColor(255, 255, 255);
-    	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
+		$pdf->SetFillColor(255, 255, 255);
+		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
 
-        if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
-        {
-            $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
-        	$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
-        }
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
+		{
+			$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
+		}
 
-        if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
-        {
-        	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
-        	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
-        }
+		if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
+		{
+			$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
+		}
 
 		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT))
 		{
-	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
-	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
+			$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
 
-	    	$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
-	    	$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
+			$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
 		}
 
 		if (empty($conf->global->SHIPPING_PDF_HIDE_WEIGHT_AND_VOLUME))
@@ -745,17 +745,17 @@ class pdf_rouget extends ModelePdfExpedition
 			// Total Weight
 			if ($totalWeighttoshow)
 			{
-	    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
-	    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
+				$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+				$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
 
-	    		$index++;
+				$index++;
 			}
 			if ($totalVolumetoshow)
 			{
-	    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
-	    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
+				$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+				$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
 
-			    $index++;
+				$index++;
 			}
 			if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
 		}
@@ -816,25 +816,25 @@ class pdf_rouget extends ModelePdfExpedition
 			}
 		}
 
-        if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
-        {
-            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
-    		if (empty($hidetop))
-    		{
-    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
-    		}
-        }
-
-        if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
-        {
+		if (empty($conf->global->SHIPPING_PDF_HIDE_ORDERED))
+		{
+			$pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
+			if (empty($hidetop))
+			{
+				$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
+				$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
+			}
+		}
+
+		if (empty($conf->global->SHIPPING_PDF_HIDE_QTYTOSHIP))
+		{
 			$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
 			if (empty($hidetop))
 			{
 				$pdf->SetXY($this->posxqtytoship, $tab_top + 1);
 				$pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"), '', 'C');
 			}
-        }
+		}
 
 		if (!empty($conf->global->SHIPPING_PDF_DISPLAY_AMOUNT_HT)) {
 			$pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
@@ -876,7 +876,7 @@ class pdf_rouget extends ModelePdfExpedition
 		// Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK)))
 		{
-            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
+					pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
 		}
 
 		//Prepare la suite
@@ -896,8 +896,8 @@ class pdf_rouget extends ModelePdfExpedition
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -953,10 +953,10 @@ class pdf_rouget extends ModelePdfExpedition
 		// Date planned delivery
 		if (!empty($object->date_delivery))
 		{
-    			$posy += 4;
-    			$pdf->SetXY($posx, $posy);
-    			$pdf->SetTextColor(0, 0, 60);
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
 		}
 
 		if (!empty($object->thirdparty->code_client))
@@ -975,7 +975,7 @@ class pdf_rouget extends ModelePdfExpedition
 		$origin = $object->origin;
 		$origin_id = $object->origin_id;
 
-	    // TODO move to external function
+		// TODO move to external function
 		if (!empty($conf->$origin->enabled))     // commonly $origin='commande'
 		{
 			$outputlangs->load('orders');
@@ -985,7 +985,7 @@ class pdf_rouget extends ModelePdfExpedition
 			$result = $linkedobject->fetch($origin_id);
 			if ($result >= 0)
 			{
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+				//$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
 
 				$pdf->SetFont('', '', $default_font_size - 2);
 				$text = $linkedobject->ref;
@@ -1099,7 +1099,7 @@ class pdf_rouget extends ModelePdfExpedition
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Object		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output

+ 151 - 151
htdocs/core/modules/expensereport/doc/pdf_standard.modules.php

@@ -44,71 +44,71 @@ require_once DOL_DOCUMENT_ROOT.'/user/class/userbankaccount.class.php';
  */
 class pdf_standard extends ModeleExpenseReport
 {
-     /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 /**
+	  * @var DoliDb Database handler
+	  */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
-
-    /**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var string document type
+	 */
+	public $type;
+
+	/**
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -209,7 +209,7 @@ class pdf_standard extends ModeleExpenseReport
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -258,24 +258,24 @@ class pdf_standard extends ModeleExpenseReport
 				$pdf = pdf_getInstance($this->format);
 				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-		        $heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-
-	            $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-			    // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 12; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -417,15 +417,15 @@ class pdf_standard extends ModeleExpenseReport
 						$pdf->commitTransaction();
 					}
 					$i++;
-                    //nexY
-                    $nexY = $pdf->GetY();
-                    $pageposafter = $pdf->getPage();
-                    $pdf->setPage($pageposbefore);
-                    $pdf->setTopMargin($this->marge_haute);
-                    $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+					//nexY
+					$nexY = $pdf->GetY();
+					$pageposafter = $pdf->getPage();
+					$pdf->setPage($pageposbefore);
+					$pdf->setTopMargin($this->marge_haute);
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
 
-                    //$nblineFollowComment = 1;
-                    // Search number of lines coming to know if there is enough room
+					//$nblineFollowComment = 1;
+					// Search number of lines coming to know if there is enough room
 					// if ($i < ($nblines - 1))	// If it's not last line
 					// {
 					//     //Fetch current description to know on which line the next one should be placed
@@ -436,11 +436,11 @@ class pdf_standard extends ModeleExpenseReport
 					// 	$nbLineCommentNeed = dol_nboflines_bis($follow_comment,52,$outputlangs->charset_output);
 					// 	$nbLineTypeNeed = dol_nboflines_bis($follow_type,4,$outputlangs->charset_output);
 
-                    //     $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed);
+					//     $nblineFollowComment = max($nbLineCommentNeed, $nbLineTypeNeed);
 					// }
 
-                    //$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3);    // Add space between lines
-                    $nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
+					//$nexY+=$nblineFollowComment*($pdf->getFontSize()*1.3);    // Add space between lines
+					$nexY += ($pdf->getFontSize() * 1.3); // Add space between lines
 
 					// Detect if some page were added automatically and output _tableau for past pages
 					while ($pagenb < $pageposafter)
@@ -487,7 +487,7 @@ class pdf_standard extends ModeleExpenseReport
 
 				$pdf->SetFont('', '', 10);
 
-            	// Show total area box
+				// Show total area box
 				$posy = $bottomlasttab + 5;
 				$posy_start_of_totals = $posy;
 				$pdf->SetXY(130, $posy);
@@ -498,7 +498,7 @@ class pdf_standard extends ModeleExpenseReport
 
 				if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
 				{
-				    // TODO Show vat amout per tax level
+					// TODO Show vat amout per tax level
 					$posy += 5;
 					$pdf->SetXY(130, $posy);
 					$pdf->SetTextColor(0, 0, 60);
@@ -536,8 +536,8 @@ class pdf_standard extends ModeleExpenseReport
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -568,78 +568,78 @@ class pdf_standard extends ModeleExpenseReport
 	 */
 	protected function printLine(&$pdf, $object, $linenumber, $curY, $default_font_size, $outputlangs, $hidedetails = 0)
 	{
-        global $conf;
-        $pdf->SetFont('', '', $default_font_size - 1);
-
-        // Accountancy piece
-        $pdf->SetXY($this->posxpiece, $curY);
-        $pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
-
-        // Date
-        //$pdf->SetXY($this->posxdate -1, $curY);
-        //$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C');
-
-        // Type
-        $pdf->SetXY($this->posxtype - 1, $curY);
-        $nextColumnPosX = $this->posxup;
-        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
-            $nextColumnPosX = $this->posxtva;
-        }
-        if (!empty($conf->projet->enabled)) {
-            $nextColumnPosX = $this->posxprojet;
-        }
-
-        $expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
+		global $conf;
+		$pdf->SetFont('', '', $default_font_size - 1);
+
+		// Accountancy piece
+		$pdf->SetXY($this->posxpiece, $curY);
+		$pdf->writeHTMLCell($this->posxcomment - $this->posxpiece - 0.8, 4, $this->posxpiece - 1, $curY, $linenumber + 1, 0, 1);
+
+		// Date
+		//$pdf->SetXY($this->posxdate -1, $curY);
+		//$pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4, dol_print_date($object->lines[$linenumber]->date,"day",false,$outputlangs), 0, 'C');
+
+		// Type
+		$pdf->SetXY($this->posxtype - 1, $curY);
+		$nextColumnPosX = $this->posxup;
+		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+			$nextColumnPosX = $this->posxtva;
+		}
+		if (!empty($conf->projet->enabled)) {
+			$nextColumnPosX = $this->posxprojet;
+		}
+
+		$expensereporttypecode = $object->lines[$linenumber]->type_fees_code;
 		$expensereporttypecodetoshow = ($outputlangs->trans(($expensereporttypecode)) == $expensereporttypecode ? $object->lines[$linenumber]->type_fees_libelle : $outputlangs->trans($expensereporttypecode));
 
 
 		if ($expensereporttypecodetoshow == $expensereporttypecode) {
-            $expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow);
-        }
-        //$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9);
-
-        //$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C');
-
-        // Project
-        //if (! empty($conf->projet->enabled))
-        //{
-        //    $pdf->SetFont('','', $default_font_size - 1);
-        //    $pdf->SetXY($this->posxprojet, $curY);
-        //    $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C');
-        //}
-
-        // VAT Rate
-        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
-            $vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails);
-            $pdf->SetXY($this->posxtva, $curY);
-            $pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R');
-        }
-
-        // Unit price
-        $pdf->SetXY($this->posxup, $curY);
-        $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R');
-
-        // Quantity
-        $pdf->SetXY($this->posxqty, $curY);
-        $pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
-
-        // Total with all taxes
-        $pdf->SetXY($this->postotalttc - 1, $curY);
-        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
-
-        // Comments
-        $pdf->SetXY($this->posxcomment, $curY);
-        $comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' ';
-        $comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>';
-        if (!empty($object->lines[$linenumber]->projet_ref)) {
-            $comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>';
-        }
-        $comment .= $object->lines[$linenumber]->comments;
-        $pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
+			$expensereporttypecodetoshow = preg_replace('/^(EX_|TF_)/', '', $expensereporttypecodetoshow);
+		}
+		//$expensereporttypecodetoshow = dol_trunc($expensereporttypecodetoshow, 9);
+
+		//$pdf->MultiCell($nextColumnPosX-$this->posxtype-0.8, 4, $expensereporttypecodetoshow, 0, 'C');
+
+		// Project
+		//if (! empty($conf->projet->enabled))
+		//{
+		//    $pdf->SetFont('','', $default_font_size - 1);
+		//    $pdf->SetXY($this->posxprojet, $curY);
+		//    $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4, $object->lines[$linenumber]->projet_ref, 0, 'C');
+		//}
+
+		// VAT Rate
+		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
+			$vat_rate = pdf_getlinevatrate($object, $linenumber, $outputlangs, $hidedetails);
+			$pdf->SetXY($this->posxtva, $curY);
+			$pdf->MultiCell($this->posxup - $this->posxtva - 0.8, 4, $vat_rate, 0, 'R');
+		}
+
+		// Unit price
+		$pdf->SetXY($this->posxup, $curY);
+		$pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 4, price($object->lines[$linenumber]->value_unit), 0, 'R');
+
+		// Quantity
+		$pdf->SetXY($this->posxqty, $curY);
+		$pdf->MultiCell($this->postotalttc - $this->posxqty - 0.8, 4, $object->lines[$linenumber]->qty, 0, 'R');
+
+		// Total with all taxes
+		$pdf->SetXY($this->postotalttc - 1, $curY);
+		$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalttc, 4, price($object->lines[$linenumber]->total_ttc), 0, 'R');
+
+		// Comments
+		$pdf->SetXY($this->posxcomment, $curY);
+		$comment = $outputlangs->trans("Date").':'.dol_print_date($object->lines[$linenumber]->date, "day", false, $outputlangs).' ';
+		$comment .= $outputlangs->trans("Type").':'.$expensereporttypecodetoshow.'<br>';
+		if (!empty($object->lines[$linenumber]->projet_ref)) {
+			$comment .= $outputlangs->trans("Project").':'.$object->lines[$linenumber]->projet_ref.'<br>';
+		}
+		$comment .= $object->lines[$linenumber]->comments;
+		$pdf->writeHTMLCell($this->posxtva - $this->posxcomment - 0.8, 4, $this->posxcomment - 1, $curY, $comment, 0, 1);
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
+	/**
 	 *  Show top header of page.
 	 *
 	 *  @param	TCPDF		$pdf     		Object PDF
@@ -666,7 +666,7 @@ class pdf_standard extends ModeleExpenseReport
 		pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
 		*/
 
-	    // Draft watermark
+		// Draft watermark
 		if ($object->fk_statut == 0 && !empty($conf->global->EXPENSEREPORT_DRAFT_WATERMARK)) {
  			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->EXPENSEREPORT_DRAFT_WATERMARK);
 		}
@@ -683,8 +683,8 @@ class pdf_standard extends ModeleExpenseReport
 		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
 		if ($this->emetteur->logo) {
 			if (is_readable($logo)) {
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -933,15 +933,15 @@ class pdf_standard extends ModeleExpenseReport
 		//	$pdf->MultiCell($this->posxprojet-$this->posxtype - 1, 2, $outputlangs->transnoentities("Type"), '', 'C');
 		//}
 
-        //if (!empty($conf->projet->enabled))
-        //{
-        //    // Project
-        //    $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
-    	//	if (empty($hidetop)) {
-        //        $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
-        //        $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
-    	//	}
-        //}
+		//if (!empty($conf->projet->enabled))
+		//{
+		//    // Project
+		//    $pdf->line($this->posxprojet - 1, $tab_top, $this->posxprojet - 1, $tab_top + $tab_height);
+		//	if (empty($hidetop)) {
+		//        $pdf->SetXY($this->posxprojet - 1, $tab_top + 1);
+		//        $pdf->MultiCell($this->posxtva - $this->posxprojet - 1, 2, $outputlangs->transnoentities("Project"), '', 'C');
+		//	}
+		//}
 
 		// VAT
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
@@ -952,7 +952,7 @@ class pdf_standard extends ModeleExpenseReport
 			}
 		}
 
-        // Unit price
+		// Unit price
 		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
 		if (empty($hidetop)) {
 			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
@@ -1090,7 +1090,7 @@ class pdf_standard extends ModeleExpenseReport
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param  TCPDF		$pdf     			PDF
 	 *  @param  Object		$object				Object to show
 	 *  @param  Translate	$outputlangs		Object lang for output

+ 162 - 162
htdocs/core/modules/facture/doc/pdf_crabe.modules.php

@@ -43,76 +43,76 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_crabe extends ModelePDFFactures
 {
-     /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 /**
+	  * @var DoliDb Database handler
+	  */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var int 	Save the name of generated file as the main doc when generating a doc with this template
-     */
-    public $update_main_doc_field;
+	/**
+	 * @var int 	Save the name of generated file as the main doc when generating a doc with this template
+	 */
+	public $update_main_doc_field;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -197,14 +197,14 @@ class pdf_crabe extends ModelePDFFactures
 		$this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
-		    $this->posxpicture -= 20;
-		    $this->posxtva -= 20;
-		    $this->posxup -= 20;
-		    $this->posxqty -= 20;
-		    $this->posxunit -= 20;
-		    $this->posxdiscount -= 20;
-		    $this->posxprogress -= 20;
-		    $this->postotalht -= 20;
+			$this->posxpicture -= 20;
+			$this->posxtva -= 20;
+			$this->posxup -= 20;
+			$this->posxqty -= 20;
+			$this->posxunit -= 20;
+			$this->posxdiscount -= 20;
+			$this->posxprogress -= 20;
+			$this->postotalht -= 20;
 		}
 
 		$this->tva = array();
@@ -216,21 +216,21 @@ class pdf_crabe extends ModelePDFFactures
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
-     *  Function to build pdf onto disk
-     *
-     *  @param		Object		$object				Object to generate
-     *  @param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int         	    			1=OK, 0=KO
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		Object		$object				Object to generate
+	 *  @param		Translate	$outputlangs		Lang output object
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int         	    			1=OK, 0=KO
 	 */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
 
 		dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
@@ -318,27 +318,27 @@ class pdf_crabe extends ModelePDFFactures
 
 				// Create pdf instance
 				$pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $pdf->SetAutoPageBreak(1, 0);
-
-                $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                	$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-				    $tplidx = $pdf->importPage(1);
-                }
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$pdf->SetAutoPageBreak(1, 0);
+
+				$heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -380,14 +380,14 @@ class pdf_crabe extends ModelePDFFactures
 				}
 				if (empty($this->atleastonediscount))    // retreive space not used by discount
 				{
-				    $delta = ($this->posxprogress - $this->posxdiscount);
-				    $this->posxpicture += $delta;
-				    $this->posxtva += $delta;
-				    $this->posxup += $delta;
-				    $this->posxqty += $delta;
-				    $this->posxunit += $delta;
-				    $this->posxdiscount += $delta;
-				    // post of fields after are not modified, stay at same position
+					$delta = ($this->posxprogress - $this->posxdiscount);
+					$this->posxpicture += $delta;
+					$this->posxtva += $delta;
+					$this->posxup += $delta;
+					$this->posxqty += $delta;
+					$this->posxunit += $delta;
+					$this->posxdiscount += $delta;
+					// post of fields after are not modified, stay at same position
 				}
 
 				$progress_width = 0;
@@ -452,11 +452,11 @@ class pdf_crabe extends ModelePDFFactures
 						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
 					}
 				}
-                // Extrafields in note
-                $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
-                if (!empty($extranote)) {
-                    $notetoshow = dol_concatdesc($notetoshow, $extranote);
-                }
+				// Extrafields in note
+				$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+				if (!empty($extranote)) {
+					$notetoshow = dol_concatdesc($notetoshow, $extranote);
+				}
 				if ($notetoshow)
 				{
 					$tab_top -= 2;
@@ -606,17 +606,17 @@ class pdf_crabe extends ModelePDFFactures
 					// Discount on line
 					if ($object->lines[$i]->remise_percent)
 					{
-                        $pdf->SetXY($this->posxdiscount - 2, $curY);
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
-					    $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
+						$pdf->SetXY($this->posxdiscount - 2, $curY);
+						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+						$pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0, 'R');
 					}
 
 					// Situation progress
 					if ($this->situationinvoice)
 					{
-					    $progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
-					    $pdf->SetXY($this->posxprogress, $curY);
-				        $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
+						$progress = pdf_getlineprogress($object, $i, $outputlangs, $hidedetails);
+						$pdf->SetXY($this->posxprogress, $curY);
+						$pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0, 'R');
 					}
 
 					// Total HT line
@@ -660,7 +660,7 @@ class pdf_crabe extends ModelePDFFactures
 						$localtax2_type = $localtaxtmp_array[2];
 					}
 
-				    // retrieve global local tax
+					// retrieve global local tax
 					if ($localtax1_type && $localtax1ligne != 0)
 						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -754,8 +754,8 @@ class pdf_crabe extends ModelePDFFactures
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -780,23 +780,23 @@ class pdf_crabe extends ModelePDFFactures
 	/**
 	 *  Show payments table
 	 *
-     *  @param	TCPDF		$pdf            Object PDF
-     *  @param  Object		$object         Object invoice
-     *  @param  int			$posy           Position y in PDF
-     *  @param  Translate	$outputlangs    Object langs for output
-     *  @param  int			$heightforfooter height for footer
-     *  @return int             			<0 if KO, >0 if OK
+	 *  @param	TCPDF		$pdf            Object PDF
+	 *  @param  Object		$object         Object invoice
+	 *  @param  int			$posy           Position y in PDF
+	 *  @param  Translate	$outputlangs    Object langs for output
+	 *  @param  int			$heightforfooter height for footer
+	 *  @return int             			<0 if KO, >0 if OK
 	 */
 	protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs, $heightforfooter = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
-        $sign = 1;
-        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+		$sign = 1;
+		if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
 
 		$current_page = $pdf->getPage();
-        $tab3_posx = 120;
+		$tab3_posx = 120;
 		$tab3_top = $posy + 8;
 		$tab3_width = 80;
 		$tab3_height = 4;
@@ -937,8 +937,8 @@ class pdf_crabe extends ModelePDFFactures
 	 */
 	protected function _tableau_versements_header($pdf, $object, $outputlangs, $default_font_size, $tab3_posx, $tab3_top, $tab3_width, $tab3_height)
 	{
-	    // phpcs:enable
-	    $title = $outputlangs->transnoentities("PaymentsAlreadyDone");
+		// phpcs:enable
+		$title = $outputlangs->transnoentities("PaymentsAlreadyDone");
 		if ($object->type == 2) $title = $outputlangs->transnoentities("PaymentsBackAlreadyDone");
 
 		$pdf->SetFont('', '', $default_font_size - 3);
@@ -973,7 +973,7 @@ class pdf_crabe extends ModelePDFFactures
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1085,13 +1085,13 @@ class pdf_crabe extends ModelePDFFactures
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
 					{
@@ -1100,13 +1100,13 @@ class pdf_crabe extends ModelePDFFactures
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 				}
 			}
@@ -1148,13 +1148,13 @@ class pdf_crabe extends ModelePDFFactures
 	 */
 	protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 
-        $sign = 1;
-        if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
+		$sign = 1;
+		if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$tab2_top = $posy;
 		$tab2_hl = 4;
@@ -1193,7 +1193,7 @@ class pdf_crabe extends ModelePDFFactures
 			{
 				// Nothing to do
 			} else {
-			    // FIXME amount of vat not supported with multicurrency
+				// FIXME amount of vat not supported with multicurrency
 
 				//Local tax 1 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
@@ -1227,7 +1227,7 @@ class pdf_crabe extends ModelePDFFactures
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1262,7 +1262,7 @@ class pdf_crabe extends ModelePDFFactures
 					}
 				}
 
-                //}
+				//}
 
 				// VAT
 				foreach ($this->tva as $tvakey => $tvaval)
@@ -1319,7 +1319,7 @@ class pdf_crabe extends ModelePDFFactures
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1558,23 +1558,23 @@ class pdf_crabe extends ModelePDFFactures
 
 		if ($this->atleastonediscount)
 		{
-		    $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
-    		if (empty($hidetop))
-    		{
-   			    $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
+			$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
+			if (empty($hidetop))
+			{
+   				$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
    				$pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C');
-    		}
-        }
-
-        if ($this->situationinvoice) {
-            $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
-            if (empty($hidetop)) {
-                $pdf->SetXY($this->posxprogress, $tab_top + 1);
-                $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
-            }
-        }
-
-        $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+			}
+		}
+
+		if ($this->situationinvoice) {
+			$pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
+			if (empty($hidetop)) {
+				$pdf->SetXY($this->posxprogress, $tab_top + 1);
+				$pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities("ProgressShort"), '', 'C');
+			}
+		}
+
+		$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
 			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
@@ -1605,9 +1605,9 @@ class pdf_crabe extends ModelePDFFactures
 
 		// Show Draft Watermark
 		if ($object->statut == Facture::STATUS_DRAFT && (!empty($conf->global->FACTURE_DRAFT_WATERMARK)))
-        {
-		      pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
-        }
+		{
+			  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->FACTURE_DRAFT_WATERMARK);
+		}
 
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
@@ -1615,7 +1615,7 @@ class pdf_crabe extends ModelePDFFactures
 		$w = 110;
 
 		$posy = $this->marge_haute;
-        $posx = $this->page_largeur - $this->marge_droite - $w;
+		$posx = $this->page_largeur - $this->marge_droite - $w;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
 
@@ -1634,7 +1634,7 @@ class pdf_crabe extends ModelePDFFactures
 				}
 				if (is_readable($logo))
 				{
-				    $height = pdf_getHeightForLogo($logo);
+					$height = pdf_getHeightForLogo($logo);
 					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 				} else {
 					$pdf->SetTextColor(200, 0, 0);
@@ -1771,16 +1771,16 @@ class pdf_crabe extends ModelePDFFactures
 		// Get contact
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 		{
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $usertmp = new User($this->db);
-		        $usertmp->fetch($arrayidcontact[0]);
-                $posy += 4;
-                $pdf->SetXY($posx, $posy);
-		        $pdf->SetTextColor(0, 0, 60);
-		        $pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
-		    }
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$usertmp = new User($this->db);
+				$usertmp->fetch($arrayidcontact[0]);
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell($w, 3, $langs->transnoentities("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+			}
 		}
 
 		$posy += 1;
@@ -1888,7 +1888,7 @@ class pdf_crabe extends ModelePDFFactures
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

File diff suppressed because it is too large
+ 755 - 755
htdocs/core/modules/facture/doc/pdf_sponge.modules.php


+ 113 - 113
htdocs/core/modules/livraison/doc/pdf_typhon.modules.php

@@ -39,70 +39,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
 class pdf_typhon extends ModelePDFDeliveryOrder
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
-
-    /**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var string document type
+	 */
+	public $type;
+
+	/**
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -171,21 +171,21 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param      Object		$object				Object to generate
-     *  @param      Translate	$outputlangs		Lang output object
-     *  @param      string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param      int			$hidedetails		Do not show line details
-     *  @param      int			$hidedesc			Do not show desc
-     *  @param      int			$hideref			Do not show ref
-     *  @return     int             			1=OK, 0=KO
-     */
-    public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
-    {
-        // phpcs:enable
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param      Object		$object				Object to generate
+	 *  @param      Translate	$outputlangs		Lang output object
+	 *  @param      string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param      int			$hidedetails		Do not show line details
+	 *  @param      int			$hidedesc			Do not show desc
+	 *  @param      int			$hideref			Do not show ref
+	 *  @return     int             			1=OK, 0=KO
+	 */
+	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	{
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $hookmanager;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -236,25 +236,25 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 
 				// Create pdf instance
 				$pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 30; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 30; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				// We get the shipment that is the origin of delivery receipt
 				$expedition = new Expedition($this->db);
@@ -377,42 +377,42 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 					// Description of product line
 					$curX = $this->posxdesc - 1;
 
-                    $showpricebeforepagebreak = 1;
-
-                    $pdf->startTransaction();
-                    pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc);
-                    $pageposafter = $pdf->getPage();
-                    if ($pageposafter > $pageposbefore)	// There is a pagebreak
-                    {
-                    	$pdf->rollbackTransaction(true);
-                    	$pageposafter = $pageposbefore;
-                    	//print $pageposafter.'-'.$pageposbefore;exit;
-                    	$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-                    	pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc);
-                    	$posyafter = $pdf->GetY();
-                    	if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
-                    	{
-                    		if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
-                    		{
-                    			$pdf->AddPage('', '', true);
-                    			if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-                    			if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-                    			$pdf->setPage($pageposafter + 1);
-                    		}
-                    	} else {
-                    		// We found a page break
+					$showpricebeforepagebreak = 1;
+
+					$pdf->startTransaction();
+					pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 3, $curX, $curY, $hideref, $hidedesc);
+					$pageposafter = $pdf->getPage();
+					if ($pageposafter > $pageposbefore)	// There is a pagebreak
+					{
+						$pdf->rollbackTransaction(true);
+						$pageposafter = $pageposbefore;
+						//print $pageposafter.'-'.$pageposbefore;exit;
+						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+						pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxcomm - $curX, 4, $curX, $curY, $hideref, $hidedesc);
+						$posyafter = $pdf->GetY();
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
+						{
+							if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
+							{
+								$pdf->AddPage('', '', true);
+								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+								if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+								$pdf->setPage($pageposafter + 1);
+							}
+						} else {
+							// We found a page break
 							// Allows data in the first page if description is long enough to break in multiples pages
 							if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 								$showpricebeforepagebreak = 1;
 							else $showpricebeforepagebreak = 0;
-                    	}
-                    } else // No pagebreak
-                    {
-                    	$pdf->commitTransaction();
-                    }
+						}
+					} else // No pagebreak
+					{
+						$pdf->commitTransaction();
+					}
 
 					$nexY = $pdf->GetY();
-                    $pageposafter = $pdf->getPage();
+					$pageposafter = $pdf->getPage();
 					$pdf->setPage($pageposbefore);
 					$pdf->setTopMargin($this->marge_haute);
 					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -602,8 +602,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -623,7 +623,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Show miscellaneous information (payment mode, payment term, ...)
 	 *
@@ -635,7 +635,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -756,8 +756,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -895,7 +895,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Object		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output
@@ -903,9 +903,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
 	 *  @return	int								Return height of bottom margin including footer text
 	 */
 	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
-    {
-        global $conf;
-        $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
-        return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
-    }
+	{
+		global $conf;
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+		return pdf_pagefoot($pdf, $outputlangs, 'DELIVERY_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+	}
 }

+ 242 - 242
htdocs/core/modules/modProduct.class.php

@@ -132,26 +132,26 @@ class modProduct extends DolibarrModules
 		$this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour)
 		$this->rights[$r][3] = 0; // La permission est-elle une permission par defaut
 		$this->rights[$r][4] = 'supprimer';
-        $r++;
+		$r++;
 
 		$this->rights[$r][0] = 38; // Must be same permission than in service module
 		$this->rights[$r][1] = 'Export products';
 		$this->rights[$r][2] = 'r';
 		$this->rights[$r][3] = 0;
 		$this->rights[$r][4] = 'export';
-        $r++;
+		$r++;
 
 		$this->rights[$r][0] = 39;
 		$this->rights[$r][1] = 'Ignore minimum price';
 		$this->rights[$r][2] = 'r';
 		$this->rights[$r][3] = 0;
 		$this->rights[$r][4] = 'ignore_price_min_advance';
-        $r++;
+		$r++;
 
-        // Menus
-        //-------
+		// Menus
+		//-------
 
-        $this->menu = 1; // This module adds menu entries. They are coded into menu manager.
+		$this->menu = 1; // This module adds menu entries. They are coded into menu manager.
 		/* We can't enable this here because it must be enabled in both product and service module and this creates duplicate inserts
 		$r=0;
 		$this->menu[$r]=array(	'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=admintools',		    // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
@@ -278,90 +278,90 @@ class modProduct extends DolibarrModules
 
 		if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES))
 		{
-		    // Exports product multiprice
-		    $r++;
-		    $this->export_code[$r] = $this->rights_class.'_'.$r;
-		    $this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)
-		    $this->export_permission[$r] = array(array("produit", "export"));
-		    $this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",
-		        's.nom'=>'ThirdParty',
-		        'pr.price_base_type'=>"PriceBase",
-		        'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",
-		        'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",
-		        'pr.tva_tx'=>'PriceVATRate',
-		        'pr.default_vat_code'=>'PriceVATCode',
-		        'pr.datec'=>'DateCreation');
-		    if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
-		    $this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
-		        's.nom'=>'company',
-		        'pr.price_base_type'=>"product", 'pr.price'=>"product",
-		        'pr.price_ttc'=>"product",
-		        'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",
-		        'pr.tva_tx'=>'product',
-		        'pr.default_vat_code'=>'product',
-		        'pr.recuperableonly'=>'product',
-		        'pr.datec'=>"product");
-		    $this->export_sql_start[$r] = 'SELECT DISTINCT ';
-		    $this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
-		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
-		    $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';
-		    $this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
+			// Exports product multiprice
+			$r++;
+			$this->export_code[$r] = $this->rights_class.'_'.$r;
+			$this->export_label[$r] = "ProductsPricePerCustomer"; // Translation key (used only if key ExportDataset_xxx_z not found)
+			$this->export_permission[$r] = array(array("produit", "export"));
+			$this->export_fields_array[$r] = array('p.rowid'=>"Id", 'p.ref'=>"Ref",
+				's.nom'=>'ThirdParty',
+				'pr.price_base_type'=>"PriceBase",
+				'pr.price'=>"PriceUnitPriceHT", 'pr.price_ttc'=>"PriceUnitPriceTTC",
+				'pr.price_min'=>"MinPriceUnitPriceHT", 'pr.price_min_ttc'=>"MinPriceUnitPriceTTC",
+				'pr.tva_tx'=>'PriceVATRate',
+				'pr.default_vat_code'=>'PriceVATCode',
+				'pr.datec'=>'DateCreation');
+			if (is_object($mysoc) && $mysoc->useNPR()) $this->export_fields_array[$r]['pr.recuperableonly'] = 'NPR';
+			$this->export_entities_array[$r] = array('p.rowid'=>"product", 'p.ref'=>"product",
+				's.nom'=>'company',
+				'pr.price_base_type'=>"product", 'pr.price'=>"product",
+				'pr.price_ttc'=>"product",
+				'pr.price_min'=>"product", 'pr.price_min_ttc'=>"product",
+				'pr.tva_tx'=>'product',
+				'pr.default_vat_code'=>'product',
+				'pr.recuperableonly'=>'product',
+				'pr.datec'=>"product");
+			$this->export_sql_start[$r] = 'SELECT DISTINCT ';
+			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
+			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_customer_price as pr ON p.rowid = pr.fk_product AND pr.entity = '.$conf->entity; // export prices only for the current entity
+			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON pr.fk_soc = s.rowid';
+			$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
 		}
 
 		if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
 		{
 			// Exports virtual products
-        	$r++;
-    		$this->export_code[$r] = $this->rights_class.'_'.$r;
-    		$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
-    		$this->export_permission[$r] = array(array("produit", "export"));
-    		$this->export_fields_array[$r] = array(
+			$r++;
+			$this->export_code[$r] = $this->rights_class.'_'.$r;
+			$this->export_label[$r] = "AssociatedProducts"; // Translation key (used only if key ExportDataset_xxx_z not found)
+			$this->export_permission[$r] = array(array("produit", "export"));
+			$this->export_fields_array[$r] = array(
 				'p.rowid'=>"Id", 'p.ref'=>"Ref", 'p.label'=>"Label", 'p.description'=>"Description", 'p.url'=>"PublicUrl",
 				'p.accountancy_code_sell'=>"ProductAccountancySellCode", 'p.accountancy_code_sell_intra'=>"ProductAccountancySellIntraCode",
-                'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",
-                'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",
-    			'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',
-    			'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',
+				'p.accountancy_code_sell_export'=>"ProductAccountancySellExportCode", 'p.accountancy_code_buy'=>"ProductAccountancyBuyCode",
+				'p.accountancy_code_buy_intra'=>"ProductAccountancyBuyIntraCode", 'p.accountancy_code_buy_export'=>"ProductAccountancyBuyExportCode",
+				'p.note'=>"NotePrivate", 'p.note_public'=>'NotePublic',
+				'p.weight'=>"Weight", 'p.length'=>"Length", 'p.surface'=>"Surface", 'p.volume'=>"Volume", 'p.customcode'=>'CustomCode',
 				'p.price_base_type'=>"PriceBase", 'p.price'=>"UnitPriceHT", 'p.price_ttc'=>"UnitPriceTTC", 'p.tva_tx'=>'VATRate', 'p.tosell'=>"OnSell",
 				'p.tobuy'=>"OnBuy", 'p.datec'=>'DateCreation', 'p.tms'=>'DateModification'
 			);
-    		if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
-    		if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
-    		$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
-    		$this->export_TypeFields_array[$r] = array(
+			if (!empty($conf->stock->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.stock'=>'Stock', 'p.seuil_stock_alerte'=>'StockLimit', 'p.desiredstock'=>'DesiredStock', 'p.pmp'=>'PMPValue'));
+			if (!empty($conf->barcode->enabled)) $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p.barcode'=>'BarCode'));
+			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('pa.qty'=>'Qty', 'pa.incdec'=>'ComposedProductIncDecStock'));
+			$this->export_TypeFields_array[$r] = array(
 				'p.ref'=>"Text", 'p.label'=>"Text", 'p.description'=>"Text", 'p.url'=>"Text",
-    			'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",
-    			'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",
-    			'p.note'=>"Text", 'p.note_public'=>"Text",
-    			'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',
+				'p.accountancy_code_sell'=>"Text", 'p.accountancy_code_sell_intra'=>"Text", 'p.accountancy_code_sell_export'=>"Text",
+				'p.accountancy_code_buy'=>"Text", 'p.accountancy_code_buy_intra'=>"Text", 'p.accountancy_code_buy_export'=>"Text",
+				'p.note'=>"Text", 'p.note_public'=>"Text",
+				'p.weight'=>"Numeric", 'p.length'=>"Numeric", 'p.surface'=>"Numeric", 'p.volume'=>"Numeric", 'p.customcode'=>'Text',
 				'p.price_base_type'=>"Text", 'p.price'=>"Numeric", 'p.price_ttc'=>"Numeric", 'p.tva_tx'=>'Numeric', 'p.tosell'=>"Boolean", 'p.tobuy'=>"Boolean",
 				'p.datec'=>'Date', 'p.tms'=>'Date'
 			);
-    		if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
-    		if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
-    		$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
-    		$this->export_entities_array[$r] = array(
+			if (!empty($conf->stock->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.stock'=>'Numeric', 'p.seuil_stock_alerte'=>'Numeric', 'p.desiredstock'=>'Numeric', 'p.pmp'=>'Numeric', 'p.cost_price'=>'Numeric'));
+			if (!empty($conf->barcode->enabled)) $this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('p.barcode'=>'Text'));
+			$this->export_TypeFields_array[$r] = array_merge($this->export_TypeFields_array[$r], array('pa.qty'=>'Numeric'));
+			$this->export_entities_array[$r] = array(
 				'p.rowid'=>"virtualproduct", 'p.ref'=>"virtualproduct", 'p.label'=>"virtualproduct", 'p.description'=>"virtualproduct", 'p.url'=>"virtualproduct",
 				'p.accountancy_code_sell'=>'virtualproduct', 'p.accountancy_code_sell_intra'=>'virtualproduct', 'p.accountancy_code_sell_export'=>'virtualproduct',
-                'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct',
+				'p.accountancy_code_buy'=>'virtualproduct', 'p.accountancy_code_buy_intra'=>'virtualproduct', 'p.accountancy_code_buy_export'=>'virtualproduct',
 				'p.note'=>"virtualproduct", 'p.length'=>"virtualproduct",
 				'p.surface'=>"virtualproduct", 'p.volume'=>"virtualproduct", 'p.weight'=>"virtualproduct", 'p.customcode'=>'virtualproduct',
 				'p.price_base_type'=>"virtualproduct", 'p.price'=>"virtualproduct", 'p.price_ttc'=>"virtualproduct", 'p.tva_tx'=>"virtualproduct",
 				'p.tosell'=>"virtualproduct", 'p.tobuy'=>"virtualproduct", 'p.datec'=>"virtualproduct", 'p.tms'=>"virtualproduct"
 			);
-    		if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));
-    		if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
-            $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
-    		$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
-    		include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
-            $this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));
-    		$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));
-    		$this->export_sql_start[$r] = 'SELECT DISTINCT ';
-    		$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
-    		$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
-    		$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
-    		$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
-    		$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
+			if (!empty($conf->stock->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.stock'=>'virtualproduct', 'p.seuil_stock_alerte'=>'virtualproduct', 'p.desiredstock'=>'virtualproduct', 'p.pmp'=>'virtualproduct'));
+			if (!empty($conf->barcode->enabled)) $this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p.barcode'=>'virtualproduct'));
+			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('pa.qty'=>"subproduct", 'pa.incdec'=>'subproduct'));
+			$keyforselect = 'product'; $keyforelement = 'product'; $keyforaliasextra = 'extra';
+			include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
+			$this->export_fields_array[$r] = array_merge($this->export_fields_array[$r], array('p2.rowid'=>"Id", 'p2.ref'=>"Ref", 'p2.label'=>"Label", 'p2.description'=>"Description"));
+			$this->export_entities_array[$r] = array_merge($this->export_entities_array[$r], array('p2.rowid'=>"subproduct", 'p2.ref'=>"subproduct", 'p2.label'=>"subproduct", 'p2.description'=>"subproduct"));
+			$this->export_sql_start[$r] = 'SELECT DISTINCT ';
+			$this->export_sql_end[$r]  = ' FROM '.MAIN_DB_PREFIX.'product as p';
+			$this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_extrafields as extra ON p.rowid = extra.fk_object,';
+			$this->export_sql_end[$r] .= ' '.MAIN_DB_PREFIX.'product_association as pa, '.MAIN_DB_PREFIX.'product as p2';
+			$this->export_sql_end[$r] .= ' WHERE p.entity IN ('.getEntity('product').')'; // For product and service profile
+			$this->export_sql_end[$r] .= ' AND p.rowid = pa.fk_product_pere AND p2.rowid = pa.fk_product_fils';
 		}
 
 		// Imports
@@ -378,34 +378,34 @@ class modProduct extends DolibarrModules
 		$this->import_tables_array[$r] = array('p'=>MAIN_DB_PREFIX.'product', 'extra'=>MAIN_DB_PREFIX.'product_extrafields');
 		$this->import_tables_creator_array[$r] = array('p'=>'fk_user_author'); // Fields to store import user id
 		$this->import_fields_array[$r] = array(
-	        'p.ref' => "Ref*",
-            'p.label' => "Label*",
+			'p.ref' => "Ref*",
+			'p.label' => "Label*",
 			'p.fk_product_type' => "Type*",
 			'p.tosell' => "OnSell*",
 			'p.tobuy' => "OnBuy*",
 			'p.description' => "Description",
 			'p.url' => "PublicUrl",
 			'p.customcode' => 'CustomCode',
-            'p.fk_country' => 'CountryCode',
-            'p.accountancy_code_sell' => "ProductAccountancySellCode",
-            'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
-            'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
-            'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
+			'p.fk_country' => 'CountryCode',
+			'p.accountancy_code_sell' => "ProductAccountancySellCode",
+			'p.accountancy_code_sell_intra' => "ProductAccountancySellIntraCode",
+			'p.accountancy_code_sell_export' => "ProductAccountancySellExportCode",
+			'p.accountancy_code_buy' => "ProductAccountancyBuyCode",
 			'p.accountancy_code_buy_intra' => "ProductAccountancyBuyIntraCode",
 			'p.accountancy_code_buy_export' => "ProductAccountancyBuyExportCode",
 			'p.note_public' => "NotePublic",
 			'p.note' => "NotePrivate",
 			'p.weight' => "Weight",
-            'p.weight_units' => "WeightUnits",
-            'p.length' => "Length",
+			'p.weight_units' => "WeightUnits",
+			'p.length' => "Length",
 			'p.length_units' => "LengthUnits",
-            'p.width' => "Width",
+			'p.width' => "Width",
 			'p.width_units' => "WidthUnits",
-            'p.height' => "Height",
-            'p.height_units' => "HeightUnits",
-            'p.surface' => "Surface",
-            'p.surface_units' => "SurfaceUnits",
-            'p.volume' => "Volume",
+			'p.height' => "Height",
+			'p.height_units' => "HeightUnits",
+			'p.surface' => "Surface",
+			'p.surface_units' => "SurfaceUnits",
+			'p.volume' => "Volume",
 			'p.volume_units' => "VolumeUnits",
 			'p.duration' => "Duration", //duration of service
 			'p.finished' => 'Nature',
@@ -419,9 +419,9 @@ class modProduct extends DolibarrModules
 			'p.cost_price' => "CostPrice",
 		);
 
-        $this->import_convertvalue_array[$r] = array(
-        	    'p.weight_units' => array(
-	        	    	'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
+		$this->import_convertvalue_array[$r] = array(
+				'p.weight_units' => array(
+						'rule' => 'fetchscalefromcodeunits', // Switch this to fetchidfromcodeunits when we will store id instead of scale in product table
 						'classfile' => '/core/class/cunits.class.php',
 						'class' => 'CUnits',
 						'method' => 'fetch',
@@ -468,38 +468,38 @@ class modProduct extends DolibarrModules
 						'units' => 'volume',
 						'dict' => 'DictionaryMeasuringUnits'
 				),
-                'p.fk_country' => array(
-                    'rule' => 'fetchidfromcodeid',
-                    'classfile' => '/core/class/ccountry.class.php',
-                    'class' => 'Ccountry',
-                    'method' => 'fetch',
-                    'dict' => 'DictionaryCountry'
-                )
+				'p.fk_country' => array(
+					'rule' => 'fetchidfromcodeid',
+					'classfile' => '/core/class/ccountry.class.php',
+					'class' => 'Ccountry',
+					'method' => 'fetch',
+					'dict' => 'DictionaryCountry'
+				)
 		);
 
 		$this->import_regex_array[$r] = array(
-            'p.ref' => '[^ ]',
-            'p.price_base_type' => '\AHT\z|\ATTC\z',
-            'p.tosell' => '^[0|1]$',
-            'p.tobuy' => '^[0|1]$',
-            'p.fk_product_type' => '^[0|1]$',
-            'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
-            'p.recuperableonly' => '^[0|1]$',
-            'p.finished' => '^[0|1]$'
-        );
-
-        if (!empty($conf->stock->enabled)) {//if Stock module enabled
-            $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
+			'p.ref' => '[^ ]',
+			'p.price_base_type' => '\AHT\z|\ATTC\z',
+			'p.tosell' => '^[0|1]$',
+			'p.tobuy' => '^[0|1]$',
+			'p.fk_product_type' => '^[0|1]$',
+			'p.datec' => '^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$',
+			'p.recuperableonly' => '^[0|1]$',
+			'p.finished' => '^[0|1]$'
+		);
+
+		if (!empty($conf->stock->enabled)) {//if Stock module enabled
+			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
 				'p.fk_default_warehouse'=>'DefaultWarehouse',
 				'p.tobatch'=>'ManageLotSerial',
-                'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
-                'p.pmp' => 'PMPValue', //weighted average price
-                'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
-            ));
+				'p.seuil_stock_alerte' => 'StockLimit', //lower limit for warning
+				'p.pmp' => 'PMPValue', //weighted average price
+				'p.desiredstock' => 'DesiredStock'//desired stock for replenishment feature
+			));
 
-            $this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
+			$this->import_regex_array[$r] = array_merge($this->import_regex_array[$r], array(
 				'p.tobatch' => '^[0|1]$'
-            ));
+			));
 
 			$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
 					'p.fk_default_warehouse' => array(
@@ -510,7 +510,7 @@ class modProduct extends DolibarrModules
 					'element'=> 'Warehouse'
 				)
 			));
-        }
+		}
 
 		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.cost_price'=>'CostPrice'));
 		if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('p.recuperableonly'=>'NPR'));
@@ -525,77 +525,77 @@ class modProduct extends DolibarrModules
 		$resql = $this->db->query($sql);
 		if ($resql)    // This can fail when class is used on old database (during migration for example)
 		{
-		    while ($obj = $this->db->fetch_object($resql))
-		    {
-		        $fieldname = 'extra.'.$obj->name;
-		        $fieldlabel = ucfirst($obj->label);
-		        $this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
-		        $import_extrafield_sample[$fieldname] = $fieldlabel;
-		    }
+			while ($obj = $this->db->fetch_object($resql))
+			{
+				$fieldname = 'extra.'.$obj->name;
+				$fieldlabel = ucfirst($obj->label);
+				$this->import_fields_array[$r][$fieldname] = $fieldlabel.($obj->fieldrequired ? '*' : '');
+				$import_extrafield_sample[$fieldname] = $fieldlabel;
+			}
 		}
 		// End add extra fields
 		$this->import_fieldshidden_array[$r] = array('extra.fk_object'=>'lastrowid-'.MAIN_DB_PREFIX.'product'); // aliastable.field => ('user->id' or 'lastrowid-'.tableparent)
 
 		// field order as per structure of table llx_product
 		$import_sample = array(
-            'p.ref' => "PREF123456",
-            'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
-            'p.label' => "Product name in default language",
-            'p.description' => "Product description in default language",
-            'p.note_public' => "a public note (free text)",
-            'p.note' => "a private note (free text)",
-            'p.customcode' => 'customs code',
-            'p.fk_country' => 'FR',
-            'p.price' => "100",
+			'p.ref' => "PREF123456",
+			'p.datec' => dol_print_date(dol_now(), '%Y-%m-%d'),
+			'p.label' => "Product name in default language",
+			'p.description' => "Product description in default language",
+			'p.note_public' => "a public note (free text)",
+			'p.note' => "a private note (free text)",
+			'p.customcode' => 'customs code',
+			'p.fk_country' => 'FR',
+			'p.price' => "100",
 			'p.price_min' => "100",
-            'p.price_ttc' => "110",
+			'p.price_ttc' => "110",
 			'p.price_min_ttc' => "110",
-            'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
-            'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'
-            'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
-            'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
-            'p.fk_product_type' => "0 (product) / 1 (service)",
-            'p.duration' => "eg. 365d/12m/1y",
-            'p.url' => 'link to product (no https)',
-            'p.accountancy_code_sell' => "",
-            'p.accountancy_code_sell_intra' => "",
-            'p.accountancy_code_sell_export' => "",
-            'p.accountancy_code_buy' => "",
-            'p.accountancy_code_buy_intra' => "",
-            'p.accountancy_code_buy_export' => "",
-            'p.weight' => "",
+			'p.price_base_type' => "HT (show/use price excl. tax) / TTC (show/use price incl. tax)",
+			'p.tva_tx' => '10', // tax rate eg: 10. Must match numerically one of the tax rates defined for your country'
+			'p.tosell' => "0 (not for sale to customer, eg. raw material) / 1 (for sale)",
+			'p.tobuy' => "0 (not for purchase from supplier, eg. virtual product) / 1 (for purchase)",
+			'p.fk_product_type' => "0 (product) / 1 (service)",
+			'p.duration' => "eg. 365d/12m/1y",
+			'p.url' => 'link to product (no https)',
+			'p.accountancy_code_sell' => "",
+			'p.accountancy_code_sell_intra' => "",
+			'p.accountancy_code_sell_export' => "",
+			'p.accountancy_code_buy' => "",
+			'p.accountancy_code_buy_intra' => "",
+			'p.accountancy_code_buy_export' => "",
+			'p.weight' => "",
 			'p.weight_units' => 'kg', // Use a unit of measure from the dictionary. g/Kg/T etc....matches field "Short label" for unit type "weight" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.length' => "",
+			'p.length' => "",
 			'p.length_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.width' => "",
+			'p.width' => "",
 			'p.width_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.height' => "",
+			'p.height' => "",
 			'p.height_units' => 'm', // Use a unit of measure from the dictionary. m/cm/mm etc....matches field "Short label" for unit type "size" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.surface' => "",
+			'p.surface' => "",
 			'p.surface_units' => 'm2', // Use a unit of measure from the dictionary. m2/cm2/mm2 etc....matches field "Short label" for unit type "surface" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.volume' => "",
+			'p.volume' => "",
 			'p.volume_units' => 'm3', //Use a unit of measure from the dictionary. m3/cm3/mm3 etc....matches field "Short label" for unit type "volume" in table "' . MAIN_DB_PREFIX . 'c_units',
-            'p.finished' => '0 (raw material) / 1 (finished goods)'
-        );
-        //clauses copied from import_fields_array
-        if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(
+			'p.finished' => '0 (raw material) / 1 (finished goods)'
+		);
+		//clauses copied from import_fields_array
+		if (!empty($conf->stock->enabled)) $import_sample = array_merge($import_sample, array(
 				'p.tobatch'=>"0 (don't use) / 1 (use batch/serial number)",
-                'p.seuil_stock_alerte' => '',
-                'p.pmp' => '0',
-                'p.desiredstock' => ''
-            ));
-        if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));
-        if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));
-        if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));
-        if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
-        if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));
-        if (!empty($conf->global->PRODUCT_USE_UNITS)) {
-            $import_sample = array_merge(
-                $import_sample,
-                array(
-                    'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'
-                )
-            );
+				'p.seuil_stock_alerte' => '',
+				'p.pmp' => '0',
+				'p.desiredstock' => ''
+			));
+		if (!empty($conf->fournisseur->enabled) || !empty($conf->margin->enabled)) $import_sample = array_merge($import_sample, array('p.cost_price'=>'90'));
+		if (is_object($mysoc) && $mysoc->useNPR()) $import_sample = array_merge($import_sample, array('p.recuperableonly'=>'0'));
+		if (is_object($mysoc) && $mysoc->useLocalTax(1)) $import_sample = array_merge($import_sample, array('p.localtax1_tx'=>'', 'p.localtax1_type'=>''));
+		if (is_object($mysoc) && $mysoc->useLocalTax(2)) $import_sample = array_merge($import_sample, array('p.localtax2_tx'=>'', 'p.localtax2_type'=>''));
+		if (!empty($conf->barcode->enabled)) $import_sample = array_merge($import_sample, array('p.barcode'=>''));
+		if (!empty($conf->global->PRODUCT_USE_UNITS)) {
+			$import_sample = array_merge(
+				$import_sample,
+				array(
+					'p.fk_unit' => 'use a unit of measure from the dictionary. G/KG/M2/M3 etc....matches field "code" in table "'.MAIN_DB_PREFIX.'c_units"'
+				)
+			);
 
 			$this->import_convertvalue_array[$r] = array_merge($this->import_convertvalue_array[$r], array(
 				'p.fk_unit' => array(
@@ -608,8 +608,8 @@ class modProduct extends DolibarrModules
 			));
 		}
 		$this->import_examplevalues_array[$r] = array_merge($import_sample, $import_extrafield_sample);
-        $this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
-        if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
+		$this->import_updatekeys_array[$r] = array('p.ref'=>'Ref');
+		if (!empty($conf->barcode->enabled)) $this->import_updatekeys_array[$r] = array_merge($this->import_updatekeys_array[$r], array('p.barcode'=>'BarCode')); //only show/allow barcode as update key if Barcode module enabled
 
 		if (!empty($conf->fournisseur->enabled))
 		{
@@ -622,34 +622,34 @@ class modProduct extends DolibarrModules
 			$this->import_tables_array[$r] = array('sp'=>MAIN_DB_PREFIX.'product_fournisseur_price');
 			$this->import_tables_creator_array[$r] = array('sp'=>'fk_user');
 			$this->import_fields_array[$r] = array(//field order as per structure of table llx_product_fournisseur_price, without optional fields
-			    'sp.fk_product'=>"ProductOrService*",
-                'sp.fk_soc' => "Supplier*",
-                'sp.ref_fourn' => 'SupplierRef*',
-                'sp.quantity' => "QtyMin*",
-                'sp.tva_tx' => 'VATRate',
-                'sp.default_vat_code' => 'VATCode',
-                'sp.delivery_time_days' => 'DeliveryDelay',
-                'sp.supplier_reputation' => 'SupplierReputation'
+				'sp.fk_product'=>"ProductOrService*",
+				'sp.fk_soc' => "Supplier*",
+				'sp.ref_fourn' => 'SupplierRef*',
+				'sp.quantity' => "QtyMin*",
+				'sp.tva_tx' => 'VATRate',
+				'sp.default_vat_code' => 'VATCode',
+				'sp.delivery_time_days' => 'DeliveryDelay',
+				'sp.supplier_reputation' => 'SupplierReputation'
 			);
 			if (is_object($mysoc) && $mysoc->useNPR())       $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.recuperableonly'=>'VATNPR'));
 			if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
 			if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
-            $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
+			$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
 					'sp.price'=>"PriceQtyMinHT*",
 					'sp.unitprice'=>'UnitPriceHT*', // TODO Make this field not required and calculate it from price and qty
 					'sp.remise_percent'=>'DiscountQtyMin'
 			));
 
-            if ($conf->multicurrency->enabled)
-            {
-                $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
-                    'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line
-                    'sp.multicurrency_code'=>'CurrencyCode',
-                    'sp.multicurrency_tx'=>'CurrencyRate',
-                    'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',
-                    'sp.multicurrency_price'=>'CurrencyPrice',
-                ));
-            }
+			if ($conf->multicurrency->enabled)
+			{
+				$this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array(
+					'sp.fk_multicurrency'=>'CurrencyCodeId', //ideally this should be automatically obtained from the CurrencyCode on the next line
+					'sp.multicurrency_code'=>'CurrencyCode',
+					'sp.multicurrency_tx'=>'CurrencyRate',
+					'sp.multicurrency_unitprice'=>'CurrencyUnitPrice',
+					'sp.multicurrency_price'=>'CurrencyPrice',
+				));
+			}
 
 			$this->import_convertvalue_array[$r] = array(
 					'sp.fk_soc'=>array('rule'=>'fetchidfromref', 'classfile'=>'/societe/class/societe.class.php', 'class'=>'Societe', 'method'=>'fetch', 'element'=>'ThirdParty'),
@@ -657,38 +657,38 @@ class modProduct extends DolibarrModules
 			);
 
 			$this->import_examplevalues_array[$r] = array(
-                'sp.fk_product' => "PRODUCT_REF or id:123456",
-                'sp.fk_soc' => "My Supplier",
-                'sp.ref_fourn' => "XYZ-F123456",
-                'sp.quantity' => "5",
-                'sp.tva_tx' => '10',
-			    'sp.price'=>"50",
-			    'sp.unitprice'=>'50',
-			    'sp.remise_percent'=>'0',
-			    'sp.default_vat_code' => '',
-                'sp.delivery_time_days' => '5',
-                'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
+				'sp.fk_product' => "PRODUCT_REF or id:123456",
+				'sp.fk_soc' => "My Supplier",
+				'sp.ref_fourn' => "XYZ-F123456",
+				'sp.quantity' => "5",
+				'sp.tva_tx' => '10',
+				'sp.price'=>"50",
+				'sp.unitprice'=>'50',
+				'sp.remise_percent'=>'0',
+				'sp.default_vat_code' => '',
+				'sp.delivery_time_days' => '5',
+				'sp.supplier_reputation' => 'FAVORITE / NOTTHGOOD / DONOTORDER'
 			);
-            if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));
-            if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
-            if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
-            $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
-                'sp.price' => "50.00",
-                'sp.unitprice' => '10',
-                // TODO Make this field not required and calculate it from price and qty
-                'sp.remise_percent' => '20'
-            ));
-            if ($conf->multicurrency->enabled)
-            {
-                $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
-                    'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',
-                    'sp.multicurrency_code'=>'GBP',
-                    'sp.multicurrency_tx'=>'1.12345',
-                    'sp.multicurrency_unitprice'=>'',
-                    // TODO Make this field not required and calculate it from price and qty
-                    'sp.multicurrency_price'=>''
-                ));
-            }
+			if (is_object($mysoc) && $mysoc->useNPR()) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.recuperableonly'=>''));
+			if (is_object($mysoc) && $mysoc->useLocalTax(1)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax1_tx'=>'LT1', 'sp.localtax1_type'=>'LT1Type'));
+			if (is_object($mysoc) && $mysoc->useLocalTax(2)) $this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array('sp.localtax2_tx'=>'LT2', 'sp.localtax2_type'=>'LT2Type'));
+			$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
+				'sp.price' => "50.00",
+				'sp.unitprice' => '10',
+				// TODO Make this field not required and calculate it from price and qty
+				'sp.remise_percent' => '20'
+			));
+			if ($conf->multicurrency->enabled)
+			{
+				$this->import_examplevalues_array[$r] = array_merge($this->import_examplevalues_array[$r], array(
+					'sp.fk_multicurrency'=>'eg: 2, rowid for code of multicurrency currency',
+					'sp.multicurrency_code'=>'GBP',
+					'sp.multicurrency_tx'=>'1.12345',
+					'sp.multicurrency_unitprice'=>'',
+					// TODO Make this field not required and calculate it from price and qty
+					'sp.multicurrency_price'=>''
+				));
+			}
 
 			$this->import_updatekeys_array[$r] = array('sp.fk_product'=>'ProductOrService', 'sp.ref_fourn'=>'SupplierRef', 'sp.fk_soc'=>'Supplier');
 		}
@@ -712,26 +712,26 @@ class modProduct extends DolibarrModules
 			if (is_object($mysoc) && $mysoc->useNPR()) $this->import_fields_array[$r] = array_merge($this->import_fields_array[$r], array('pr.recuperableonly'=>'NPR'));
 			$this->import_regex_array[$r] = array('pr.datec'=>'^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]$', 'pr.recuperableonly'=>'^[0|1]$');
 			$this->import_convertvalue_array[$r] = array(
-			    'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
+				'pr.fk_product'=>array('rule'=>'fetchidfromref', 'classfile'=>'/product/class/product.class.php', 'class'=>'Product', 'method'=>'fetch', 'element'=>'Product')
 			);
 			$this->import_examplevalues_array[$r] = array('pr.fk_product'=>"PRODUCT_REF or id:123456",
 				'pr.price_base_type'=>"HT (for excl tax) or TTC (for inc tax)", 'pr.price_level'=>"1",
 				'pr.price'=>"100", 'pr.price_ttc'=>"110",
 				'pr.price_min'=>"100", 'pr.price_min_ttc'=>"110",
 				'pr.tva_tx'=>'20',
-			    'pr.recuperableonly'=>'0',
+				'pr.recuperableonly'=>'0',
 				'pr.date_price'=>'2013-04-10');
 		}
 
 		if (!empty($conf->global->MAIN_MULTILANGS))
 		{
-		    // Import translations of product names and descriptions
-		    $r++;
-		    $this->import_code[$r] = $this->rights_class.'_languages';
-		    $this->import_label[$r] = "ProductsOrServicesTranslations";
+			// Import translations of product names and descriptions
+			$r++;
+			$this->import_code[$r] = $this->rights_class.'_languages';
+			$this->import_label[$r] = "ProductsOrServicesTranslations";
 			$this->import_icon[$r] = $this->picto;
 			$this->import_entities_array[$r] = array(); // We define here only fields that use another icon that the one defined into import_icon
-		    $this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');
+			$this->import_tables_array[$r] = array('l'=>MAIN_DB_PREFIX.'product_lang');
 			// multiline translation, one line per translation
 			$this->import_fields_array[$r] = array('l.fk_product'=>'ProductOrService*', 'l.lang'=>'Language*', 'l.label'=>'TranslatedLabel', 'l.description'=>'TranslatedDescription');
 			//$this->import_fields_array[$r]['l.note']='TranslatedNote';
@@ -744,20 +744,20 @@ class modProduct extends DolibarrModules
 	}
 
 
-    /**
-     *  Function called when module is enabled.
-     *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
-     *  It also creates data directories
-     *
-     *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
-     *  @return     int             	1 if OK, 0 if KO
-     */
-    public function init($options = '')
-    {
-        $this->remove($options);
+	/**
+	 *  Function called when module is enabled.
+	 *  The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database.
+	 *  It also creates data directories
+	 *
+	 *  @param      string	$options    Options when enabling module ('', 'newboxdefonly', 'noboxes')
+	 *  @return     int             	1 if OK, 0 if KO
+	 */
+	public function init($options = '')
+	{
+		$this->remove($options);
 
-        $sql = array();
+		$sql = array();
 
-        return $this->_init($sql, $options);
-    }
+		return $this->_init($sql, $options);
+	}
 }

+ 47 - 47
htdocs/core/modules/modRecruitment.class.php

@@ -266,75 +266,75 @@ class modRecruitment extends DolibarrModules
 		/* BEGIN MODULEBUILDER TOPMENU */
 		/* END MODULEBUILDER TOPMENU */
 		/* BEGIN MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
-		$this->menu[$r++]=array(
-			'fk_menu'=>'fk_mainmenu=hrm',      // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
-			'type'=>'left',                          // This is a Top menu entry
+		$this->menu[$r++] = array(
+			'fk_menu'=>'fk_mainmenu=hrm', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+			'type'=>'left', // This is a Top menu entry
 			'titre'=>'Recruitment',
 			'mainmenu'=>'hrm',
 			'leftmenu'=>'recruitmentjobposition',
 			'url'=>'/recruitment/recruitmentindex.php',
-			'langs'=>'recruitment',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
-			'position'=>1000+$r,
-			'enabled'=>'$conf->recruitment->enabled',  // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.
-			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read',			                // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
+			'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+			'position'=>1000 + $r,
+			'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled.
+			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
 			'target'=>'',
-			'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both
+			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
 		);
-		$this->menu[$r++]=array(
-			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
-			'type'=>'left',			                // This is a Left menu entry
+		$this->menu[$r++] = array(
+			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+			'type'=>'left', // This is a Left menu entry
 			'titre'=>'NewPositionToBeFilled',
 			'mainmenu'=>'hrm',
 			'leftmenu'=>'recruitment_recruitmentjobposition_new',
 			'url'=>'/recruitment/recruitmentjobposition_card.php?action=create',
-			'langs'=>'recruitment',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
-			'position'=>1000+$r,
-			'enabled'=>'$conf->recruitment->enabled',  // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
-			'perms'=>'$user->rights->recruitment->recruitmentjobposition->write',			                // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
+			'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+			'position'=>1000 + $r,
+			'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+			'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
 			'target'=>'',
-			'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both
+			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
 		);
-		$this->menu[$r++]=array(
-			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
-			'type'=>'left',			                // This is a Left menu entry
+		$this->menu[$r++] = array(
+			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+			'type'=>'left', // This is a Left menu entry
 			'titre'=>'ListOfPositionsToBeFilled',
 			'mainmenu'=>'hrm',
 			'leftmenu'=>'recruitment_recruitmentjobposition_list',
 			'url'=>'/recruitment/recruitmentjobposition_list.php',
-			'langs'=>'recruitment',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
-			'position'=>1000+$r,
-			'enabled'=>'$conf->recruitment->enabled',  // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
-			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read',			                // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
+			'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+			'position'=>1000 + $r,
+			'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
 			'target'=>'',
-			'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both
+			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
 		);
-		$this->menu[$r++]=array(
-			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
-			'type'=>'left',			                // This is a Left menu entry
+		$this->menu[$r++] = array(
+			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+			'type'=>'left', // This is a Left menu entry
 			'titre'=>'NewCandidature',
 			'mainmenu'=>'hrm',
 			'leftmenu'=>'recruitment_recruitmentcandidature_new',
 			'url'=>'/recruitment/recruitmentcandidature_card.php?action=create',
-			'langs'=>'recruitment',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
-			'position'=>1000+$r,
-			'enabled'=>'$conf->recruitment->enabled',  // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
-			'perms'=>'$user->rights->recruitment->recruitmentjobposition->write',			                // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
+			'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+			'position'=>1000 + $r,
+			'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+			'perms'=>'$user->rights->recruitment->recruitmentjobposition->write', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
 			'target'=>'',
-			'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both
+			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
 		);
-		$this->menu[$r++]=array(
-			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition',	    // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
-			'type'=>'left',			                // This is a Left menu entry
+		$this->menu[$r++] = array(
+			'fk_menu'=>'fk_mainmenu=hrm,fk_leftmenu=recruitmentjobposition', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode
+			'type'=>'left', // This is a Left menu entry
 			'titre'=>'ListOfCandidatures',
 			'mainmenu'=>'hrm',
 			'leftmenu'=>'recruitment_recruitmentcandidature_list',
 			'url'=>'/recruitment/recruitmentcandidature_list.php',
-			'langs'=>'recruitment',	        // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
-			'position'=>1000+$r,
-			'enabled'=>'$conf->recruitment->enabled',  // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
-			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read',			                // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
+			'langs'=>'recruitment', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.
+			'position'=>1000 + $r,
+			'enabled'=>'$conf->recruitment->enabled', // Define condition to show or hide menu entry. Use '$conf->recruitment->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
+			'perms'=>'$user->rights->recruitment->recruitmentjobposition->read', // Use 'perms'=>'$user->rights->recruitment->level1->level2' if you want your menu with a permission rules
 			'target'=>'',
-			'user'=>2,				                // 0=Menu for internal users, 1=external users, 2=both
+			'user'=>2, // 0=Menu for internal users, 1=external users, 2=both
 		);
 		/* END MODULEBUILDER LEFTMENU RECRUITMENTJOBPOSITION */
 
@@ -422,24 +422,24 @@ class modRecruitment extends DolibarrModules
 		// Document template
 		$moduledir = 'mymodule';
 		$myTmpObjects = array();
-		$myTmpObjects['RecruitmentJobPosition']=array('includerefgeneration'=>1, 'includedocgeneration'=>1);
+		$myTmpObjects['RecruitmentJobPosition'] = array('includerefgeneration'=>1, 'includedocgeneration'=>1);
 
 		foreach ($myTmpObjects as $myTmpObjectKey => $myTmpObjectArray) {
 			if ($myTmpObjectKey == 'MyObject') continue;
 			if ($myTmpObjectArray['includerefgeneration']) {
-				$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
-				$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
-				$dest=$dirodt.'/template_myobjects.odt';
+				$src = DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
+				$dirodt = DOL_DATA_ROOT.'/doctemplates/mymodule';
+				$dest = $dirodt.'/template_myobjects.odt';
 
-				if (file_exists($src) && ! file_exists($dest))
+				if (file_exists($src) && !file_exists($dest))
 				{
 					require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 					dol_mkdir($dirodt);
-					$result=dol_copy($src, $dest, 0, 0);
+					$result = dol_copy($src, $dest, 0, 0);
 					if ($result < 0)
 					{
 						$langs->load("errors");
-						$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+						$this->error = $langs->trans('ErrorFailToCopyFile', $src, $dest);
 						return 0;
 					}
 				}

+ 32 - 32
htdocs/core/modules/modSocialNetworks.class.php

@@ -31,57 +31,57 @@ include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
 class modSocialNetworks extends DolibarrModules
 {
 
-    /**
+	/**
 	 *   Constructor. Define names, constants, directories, boxes, permissions
 	 *
 	 *   @param      DoliDB		$db      Database handler
-     */
-    public function __construct($db)
-    {
-    	global $langs, $conf;
+	 */
+	public function __construct($db)
+	{
+		global $langs, $conf;
 
-        $this->db = $db;
-        $this->numero = 3400;
+		$this->db = $db;
+		$this->numero = 3400;
 
 		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
 		// It is used to group modules in module setup page
-        $this->family = "interface";
-        // Module position in the family on 2 digits ('01', '10', '20', ...)
-        $this->module_position = '20';
-        // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
-        $this->name = preg_replace('/^mod/i', '', get_class($this));
-        $this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";
+		$this->family = "interface";
+		// Module position in the family on 2 digits ('01', '10', '20', ...)
+		$this->module_position = '20';
+		// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
+		$this->description = "Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...)";
 		// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
-        $this->version = 'dolibarr';
-        // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
-        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
-        // Name of image file used for this module.
-        $this->picto = 'share-alt';
+		$this->version = 'dolibarr';
+		// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
+		$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
+		// Name of image file used for this module.
+		$this->picto = 'share-alt';
 
-        // Data directories to create when module is enabled
-        $this->dirs = array();
+		// Data directories to create when module is enabled
+		$this->dirs = array();
 
-        // Config pages
+		// Config pages
 		$this->config_page_url = array(DOL_URL_ROOT.'/admin/dict.php?id=38');
 
-        // Dependencies
-        $this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module
+		// Dependencies
+		$this->hidden = !empty($conf->global->MODULE_SOCIALNETWORKS_DISABLED); // A condition to hide module
 		$this->depends = array('modSociete'); // List of module class names as string that must be enabled if this module is enabled
 		$this->requiredby = array(); // List of module ids to disable if this one is disabled
 		$this->conflictwith = array(); // List of module class names as string this module is in conflict with
 		$this->phpmin = array(5, 4); // Minimum version of PHP required by module
-        $this->langfiles = array();
+		$this->langfiles = array();
 
-        // Constants
+		// Constants
 
 
-        // New pages on tabs
-        $this->tabs = array();
+		// New pages on tabs
+		$this->tabs = array();
 
-        // Boxes
-        $this->boxes = array();
+		// Boxes
+		$this->boxes = array();
 
-        // Main menu entries
-        $this->menu = array();
-    }
+		// Main menu entries
+		$this->menu = array();
+	}
 }

+ 186 - 186
htdocs/core/modules/movement/doc/pdf_standard.modules.php

@@ -37,74 +37,74 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_stdandard extends ModelePDFMovement
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
-    /**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	/**
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
-    /**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	/**
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
-    /**
-     * @var array format
-     */
-    public $format;
+	/**
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
-    /**
+	/**
 	 * @var Societe Issuer
 	 */
 	public $emetteur;
@@ -179,7 +179,7 @@ class pdf_stdandard extends ModelePDFMovement
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Function to build a document on disk using the generic odt module.
 	 *
@@ -193,7 +193,7 @@ class pdf_stdandard extends ModelePDFMovement
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -203,9 +203,9 @@ class pdf_stdandard extends ModelePDFMovement
 		// Load traductions files required by page
 		$outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
 
-        /**
-         * TODO: get from object
-         */
+		/**
+		 * TODO: get from object
+		 */
 
 		$id = GETPOST('id', 'int');
 		$ref = GETPOST('ref', 'alpha');
@@ -328,7 +328,7 @@ class pdf_stdandard extends ModelePDFMovement
 		$resql = $db->query($sql);
 		$nbtotalofrecords = $db->num_rows($result);
 
-        /*
+		/*
          * END TODO
          **/
 
@@ -414,21 +414,21 @@ class pdf_stdandard extends ModelePDFMovement
 				$pdf->SetAutoPageBreak(1, 0);
 
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -773,8 +773,8 @@ class pdf_stdandard extends ModelePDFMovement
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -809,34 +809,34 @@ class pdf_stdandard extends ModelePDFMovement
 	 */
 	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
 	{
-	    global $conf;
+		global $conf;
 
-	    // Force to disable hidetop and hidebottom
-	    $hidebottom = 0;
-	    if ($hidetop) $hidetop = -1;
+		// Force to disable hidetop and hidebottom
+		$hidebottom = 0;
+		if ($hidetop) $hidetop = -1;
 
-	    $currency = !empty($currency) ? $currency : $conf->currency;
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$currency = !empty($currency) ? $currency : $conf->currency;
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-	    // Amount in (at tab_top - 1)
-	    $pdf->SetTextColor(0, 0, 0);
-	    $pdf->SetFont('', '', $default_font_size - 2);
+		// Amount in (at tab_top - 1)
+		$pdf->SetTextColor(0, 0, 0);
+		$pdf->SetFont('', '', $default_font_size - 2);
 
-	    if (empty($hidetop))
-	    {
-	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
-	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+		if (empty($hidetop))
+		{
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
+			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
 
-	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
-	        if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
-	    }
+			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+		}
 
-	    $pdf->SetDrawColor(128, 128, 128);
-	    $pdf->SetFont('', 'B', $default_font_size - 3);
+		$pdf->SetDrawColor(128, 128, 128);
+		$pdf->SetFont('', 'B', $default_font_size - 3);
 
-	    // Output Rect
-	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect takes a length in 3rd parameter and 4th parameter
+		// Output Rect
+		//$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect takes a length in 3rd parameter and 4th parameter
 
 		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
 		$pdf->SetDrawColor(220, 26, 26);
@@ -846,12 +846,12 @@ class pdf_stdandard extends ModelePDFMovement
 		$pdf->SetTextColor(0, 0, 120);
 
 		//Ref mouv
-	    if (empty($hidetop))
-	    {
-	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line takes a position y in 2nd parameter and 4th parameter
-	        $pdf->SetXY($this->posxidref, $tab_top + 1);
-	        $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
-	    }
+		if (empty($hidetop))
+		{
+			//$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line takes a position y in 2nd parameter and 4th parameter
+			$pdf->SetXY($this->posxidref, $tab_top + 1);
+			$pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
+		}
 
 		//Date mouv
 		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
@@ -862,20 +862,20 @@ class pdf_stdandard extends ModelePDFMovement
 		}
 
 		//Ref Product
-	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
-	        $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
-	    }
+		//$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
+			$pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
+		}
 
 		//Label Product
-	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
+		//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
 			$pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C');
-	    }
+		}
 
 		//Lot/serie Product
 		//$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
@@ -886,36 +886,36 @@ class pdf_stdandard extends ModelePDFMovement
 		}
 
 		//Code Inv
-	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
+		//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
 			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
 			$pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C');
-	    }
+		}
 
 		//Label mouvement
-	    //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxunit, $tab_top + 1);
-	        $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
-	    }
+		//$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxunit, $tab_top + 1);
+			$pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
+		}
 
 		//Origin
-	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
-	        $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
-	    }
+		//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
+			$pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
+		}
 
 		//Qty
-	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
-	        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
-	    }
+		//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->postotalht + 2, $tab_top + 1);
+			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+		}
 
 		$pdf->SetDrawColor(220, 26, 26);
 		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
@@ -936,70 +936,70 @@ class pdf_stdandard extends ModelePDFMovement
 	 */
 	protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
 	{
-	    global $conf, $langs, $db, $hookmanager;
+		global $conf, $langs, $db, $hookmanager;
 
-	    // Load traductions files required by page
+		// Load traductions files required by page
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
 
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-	    if ($object->type == 1) $titlekey = 'ServiceSheet';
-	    else $titlekey = 'StockSheet';
+		if ($object->type == 1) $titlekey = 'ServiceSheet';
+		else $titlekey = 'StockSheet';
 
-	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
 
-	    // Show Draft Watermark
-	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
-	    {
-	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
-	    }
+		// Show Draft Watermark
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
+		{
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
+		}
 
-	    $pdf->SetTextColor(0, 0, 60);
-	    $pdf->SetFont('', 'B', $default_font_size + 3);
+		$pdf->SetTextColor(0, 0, 60);
+		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-	    $posy = $this->marge_haute;
-	    $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posy = $this->marge_haute;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 
-	    $pdf->SetXY($this->marge_gauche, $posy);
+		$pdf->SetXY($this->marge_gauche, $posy);
 
-	    // Logo
-	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
-	    if ($this->emetteur->logo)
-	    {
-	        if (is_readable($logo))
-	        {
-	            $height = pdf_getHeightForLogo($logo);
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
-	        } else {
-	            $pdf->SetTextColor(200, 0, 0);
-	            $pdf->SetFont('', 'B', $default_font_size - 2);
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
-	        }
-	    } else {
-	        $text = $this->emetteur->name;
-	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
-	    }
+		// Logo
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+		if ($this->emetteur->logo)
+		{
+			if (is_readable($logo))
+			{
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+			} else {
+				$pdf->SetTextColor(200, 0, 0);
+				$pdf->SetFont('', 'B', $default_font_size - 2);
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+			}
+		} else {
+			$text = $this->emetteur->name;
+			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+		}
 
-	    $pdf->SetFont('', 'B', $default_font_size + 3);
-	    $pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
-	    $title = $outputlangs->transnoentities("Warehouse");
-	    $pdf->MultiCell(100, 3, $title, '', 'R');
+		$pdf->SetFont('', 'B', $default_font_size + 3);
+		$pdf->SetXY($posx, $posy);
+		$pdf->SetTextColor(0, 0, 60);
+		$title = $outputlangs->transnoentities("Warehouse");
+		$pdf->MultiCell(100, 3, $title, '', 'R');
 
-	    $pdf->SetFont('', 'B', $default_font_size);
+		$pdf->SetFont('', 'B', $default_font_size);
 
-	    $posy += 5;
-	    $pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
+		$posy += 5;
+		$pdf->SetXY($posx, $posy);
+		$pdf->SetTextColor(0, 0, 60);
 
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
 
-	    $posy += 5;
-	    $pdf->SetFont('', '', $default_font_size - 1);
+		$posy += 5;
+		$pdf->SetFont('', '', $default_font_size - 1);
 		$pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
+		$pdf->SetTextColor(0, 0, 60);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
 
 		$posy += 4;
 		$pdf->SetXY($posx - 50, $posy);
@@ -1070,7 +1070,7 @@ class pdf_stdandard extends ModelePDFMovement
 		$nexY = $pdf->GetY();
 
 
-	    /*if ($object->ref_client)
+		/*if ($object->ref_client)
 	    {
 	        $posy+=5;
 	        $pdf->SetXY($posx,$posy);
@@ -1078,14 +1078,14 @@ class pdf_stdandard extends ModelePDFMovement
 	        $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
 	    }*/
 
-	    /*$posy+=4;
+		/*$posy+=4;
 	    $pdf->SetXY($posx,$posy);
 	    $pdf->SetTextColor(0,0,60);
 	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
 	    */
 
-	    // Get contact
-	    /*
+		// Get contact
+		/*
 	    if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 	    {
 	        $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
@@ -1100,14 +1100,14 @@ class pdf_stdandard extends ModelePDFMovement
 	        }
 	    }*/
 
-	    $posy += 2;
+		$posy += 2;
 
-	    // Show list of linked objects
-	    //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+		// Show list of linked objects
+		//$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
 
-	    if ($showaddress)
-	    {
-	        /*
+		if ($showaddress)
+		{
+			/*
 	        // Sender properties
 	        $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
 
@@ -1138,9 +1138,9 @@ class pdf_stdandard extends ModelePDFMovement
 	        $pdf->SetFont('','', $default_font_size - 1);
 	        $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
 	        */
-	    }
+		}
 
-	    $pdf->SetTextColor(0, 0, 0);
+		$pdf->SetTextColor(0, 0, 0);
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -1155,8 +1155,8 @@ class pdf_stdandard extends ModelePDFMovement
 	 */
 	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
 	{
-	    global $conf;
-	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
-	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+		global $conf;
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+		return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
 	}
 }

+ 5 - 5
htdocs/core/modules/movement/modules_movement.php

@@ -36,17 +36,17 @@ abstract class ModelePDFMovement extends CommonDocGenerator
 	public $error = '';
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Return list of active generation modules
 	 *
-     *  @param	DoliDB	$db     			Database handler
-     *  @param  integer	$maxfilenamelength  Max length of value to show
-     *  @return	array						List of templates
+	 *  @param	DoliDB	$db     			Database handler
+	 *  @param  integer	$maxfilenamelength  Max length of value to show
+	 *  @return	array						List of templates
 	 */
 	public static function liste_modeles($db, $maxfilenamelength = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$type = 'movement';

+ 59 - 59
htdocs/core/modules/project/doc/pdf_baleine.modules.php

@@ -39,70 +39,70 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 class pdf_baleine extends ModelePDFProjects
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -165,7 +165,7 @@ class pdf_baleine extends ModelePDFProjects
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Function to build pdf project onto disk
 	 *
@@ -175,7 +175,7 @@ class pdf_baleine extends ModelePDFProjects
 	 */
 	public function write_file($object, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -222,22 +222,22 @@ class pdf_baleine extends ModelePDFProjects
 				$pdf->SetAutoPageBreak(1, 0);
 
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				// Complete object by loading several other informations
 				$task = new Task($this->db);
@@ -492,8 +492,8 @@ class pdf_baleine extends ModelePDFProjects
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -584,7 +584,7 @@ class pdf_baleine extends ModelePDFProjects
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -595,8 +595,8 @@ class pdf_baleine extends ModelePDFProjects
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -657,7 +657,7 @@ class pdf_baleine extends ModelePDFProjects
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Project		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output

+ 405 - 405
htdocs/core/modules/project/doc/pdf_beluga.modules.php

@@ -54,11 +54,11 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 
 class pdf_beluga extends ModelePDFProjects
 {
-    /**
-     * Page orientation
-     * @var string 'P' or 'Portait' (default), 'L' or 'Landscape'
-     */
-    private $orientation = '';
+	/**
+	 * Page orientation
+	 * @var string 'P' or 'Portait' (default), 'L' or 'Landscape'
+	 */
+	private $orientation = '';
 
 	/**
 	 * Issuer
@@ -85,14 +85,14 @@ class pdf_beluga extends ModelePDFProjects
 		// Page size for A4 format
 		$this->type = 'pdf';
 		$formatarray = pdf_getFormat();
-        $this->orientation = 'L';
-        if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
-            $this->page_largeur = $formatarray['height'];
-            $this->page_hauteur = $formatarray['width'];
-        } else {
-            $this->page_largeur = $formatarray['width'];
-            $this->page_hauteur = $formatarray['height'];
-        }
+		$this->orientation = 'L';
+		if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
+			$this->page_largeur = $formatarray['height'];
+			$this->page_hauteur = $formatarray['width'];
+		} else {
+			$this->page_largeur = $formatarray['width'];
+			$this->page_hauteur = $formatarray['height'];
+		}
 		$this->format = array($this->page_largeur, $this->page_hauteur);
 		$this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
 		$this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
@@ -107,22 +107,22 @@ class pdf_beluga extends ModelePDFProjects
 		$this->emetteur = $mysoc;
 		if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
 
-        // Define position of columns
-        if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
-            $this->posxref = $this->marge_gauche + 1;
-            $this->posxdate = $this->marge_gauche + 105;
-            $this->posxsociety = $this->marge_gauche + 125;
-            $this->posxamountht = $this->marge_gauche + 190;
-            $this->posxamountttc = $this->marge_gauche + 215;
-            $this->posxstatut = $this->marge_gauche + 245;
-        } else {
-            $this->posxref = $this->marge_gauche + 1;
-            $this->posxdate = $this->marge_gauche + 25;
-            $this->posxsociety = $this->marge_gauche + 45;
-            $this->posxamountht = $this->marge_gauche + 110;
-            $this->posxamountttc = $this->marge_gauche + 135;
-            $this->posxstatut = $this->marge_gauche + 165;
-        }
+		// Define position of columns
+		if ($this->orientation == 'L' || $this->orientation == 'Landscape') {
+			$this->posxref = $this->marge_gauche + 1;
+			$this->posxdate = $this->marge_gauche + 105;
+			$this->posxsociety = $this->marge_gauche + 125;
+			$this->posxamountht = $this->marge_gauche + 190;
+			$this->posxamountttc = $this->marge_gauche + 215;
+			$this->posxstatut = $this->marge_gauche + 245;
+		} else {
+			$this->posxref = $this->marge_gauche + 1;
+			$this->posxdate = $this->marge_gauche + 25;
+			$this->posxsociety = $this->marge_gauche + 45;
+			$this->posxamountht = $this->marge_gauche + 110;
+			$this->posxamountttc = $this->marge_gauche + 135;
+			$this->posxstatut = $this->marge_gauche + 165;
+		}
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
 			$this->posxref -= 20;
@@ -135,7 +135,7 @@ class pdf_beluga extends ModelePDFProjects
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction generant le projet sur le disque
 	 *
@@ -145,10 +145,10 @@ class pdf_beluga extends ModelePDFProjects
 	 */
 	public function write_file($object, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user;
 
-        $formproject = new FormProjets($this->db);
+		$formproject = new FormProjets($this->db);
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
 		// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
@@ -194,22 +194,22 @@ class pdf_beluga extends ModelePDFProjects
 				$pdf->SetAutoPageBreak(1, 0);
 
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				// Complete object by loading several other informations
 				$task = new Task($this->db);
@@ -282,363 +282,363 @@ class pdf_beluga extends ModelePDFProjects
 				$curY = $tab_top + $heightoftitleline + 1;
 				$nexY = $tab_top + $heightoftitleline + 1;
 
-                $listofreferent = array(
-                    'propal'=>array(
-                    	'name'=>"Proposals",
-                    	'title'=>"ListProposalsAssociatedProject",
-                    	'class'=>'Propal',
-                    	'table'=>'propal',
-                        'datefieldname'=>'datep',
-                    	'test'=>$conf->propal->enabled && $user->rights->propale->lire,
-                        'lang'=>'propal'),
-                    'order'=>array(
-                    	'name'=>"CustomersOrders",
-                    	'title'=>"ListOrdersAssociatedProject",
-                    	'class'=>'Commande',
-                    	'table'=>'commande',
-                    	'datefieldname'=>'date_commande',
-                    	'test'=>$conf->commande->enabled && $user->rights->commande->lire,
-                        'lang'=>'orders'),
-                    'invoice'=>array(
-                    	'name'=>"CustomersInvoices",
-                    	'title'=>"ListInvoicesAssociatedProject",
-                    	'class'=>'Facture',
-                    	'margin'=>'add',
-                    	'table'=>'facture',
-                    	'datefieldname'=>'datef',
-                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire,
-                        'lang'=>'bills'),
-                    'invoice_predefined'=>array(
-                    	'name'=>"PredefinedInvoices",
-                    	'title'=>"ListPredefinedInvoicesAssociatedProject",
-                    	'class'=>'FactureRec',
-                    	'table'=>'facture_rec',
-                    	'datefieldname'=>'datec',
-                    	'test'=>$conf->facture->enabled && $user->rights->facture->lire,
-                        'lang'=>'bills'),
-                    'order_supplier'=>array(
-                    	'name'=>"SuppliersOrders",
-                    	'title'=>"ListSupplierOrdersAssociatedProject",
-                    	'class'=>'CommandeFournisseur',
-                    	'table'=>'commande_fournisseur',
-                    	'datefieldname'=>'date_commande',
-                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
-                        'lang'=>'orders'),
-                    'invoice_supplier'=>array(
-                    	'name'=>"BillsSuppliers",
-                    	'title'=>"ListSupplierInvoicesAssociatedProject",
-                    	'class'=>'FactureFournisseur',
-                    	'margin'=>'minus',
-                    	'table'=>'facture_fourn',
-                    	'datefieldname'=>'datef',
-                    	'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
-                        'lang'=>'bills'),
-                    'contract'=>array(
-                    	'name'=>"Contracts",
-                    	'title'=>"ListContractAssociatedProject",
-                    	'class'=>'Contrat',
-                    	'table'=>'contrat',
-                    	'datefieldname'=>'date_contrat',
-                    	'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
-                        'lang'=>'contract'),
-                    'intervention'=>array(
-                    	'name'=>"Interventions",
-                    	'title'=>"ListFichinterAssociatedProject",
-                    	'class'=>'Fichinter',
-                    	'table'=>'fichinter',
-                    	'datefieldname'=>'date_valid',
-                    	'disableamount'=>1,
-                    	'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
-                        'lang'=>'interventions'),
-                    'trip'=>array(
-                    	'name'=>"TripsAndExpenses",
-                    	'title'=>"ListExpenseReportsAssociatedProject",
-                    	'class'=>'Deplacement',
-                    	'table'=>'deplacement',
-                    	'datefieldname'=>'dated',
-                    	'margin'=>'minus',
-                    	'disableamount'=>1,
-                    	'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
-                        'lang'=>'trip'),
-                    'expensereport'=>array(
-                    	'name'=>"ExpensesReports",
-                    	'title'=>"ListExpenseReportsAssociatedProject",
-                    	'class'=>'ExpenseReport',
-                    	'table'=>'expensereport',
-                    	'datefieldname'=>'dated',
-                    	'margin'=>'minus',
-                    	'disableamount'=>1,
-                    	'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
-                        'lang'=>'trip'),
-                    'agenda'=>array(
-                    	'name'=>"Agenda",
-                    	'title'=>"ListActionsAssociatedProject",
-                    	'class'=>'ActionComm',
-                    	'table'=>'actioncomm',
-                    	'datefieldname'=>'datep',
-                    	'disableamount'=>1,
-                    	'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
-                        'lang'=>'agenda')
-                );
-
-                $hookmanager->initHooks(array('completeListOfReferent'));
-                $hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action);
-                if (!empty($hookmanager->resArray)) {
-                    $listofreferent = array_merge($listofreferent, $hookmanager->resArray);
-                }
-
-                foreach ($listofreferent as $key => $value)
-                {
-                	$title = $value['title'];
-                	$classname = $value['class'];
-                	$tablename = $value['table'];
-                	$datefieldname = $value['datefieldname'];
-                	$qualified = $value['test'];
-                	$langstoload = $value['lang'];
-                    $projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet';
-                	$langs->load($langstoload);
-
-                    if (!$qualified) continue;
-
-                    //var_dump("$key, $tablename, $datefieldname, $dates, $datee");
-                    $elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField);
-
-                    $num = count($elementarray);
-                    if ($num >= 0)
-                    {
-                        $nexY = $pdf->GetY() + 5;
-
-                        $curY = $nexY;
-                        $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
-                        $pdf->SetTextColor(0, 0, 0);
-
-                        $pdf->SetXY($this->posxref, $curY);
-                        $pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
-
-                        $selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField);
-                        $nexY = $pdf->GetY() + 1;
-                        $curY = $nexY;
-                        $pdf->SetXY($this->posxref, $curY);
-                        $pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L');
-                        $pdf->SetXY($this->posxdate, $curY);
-                        $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
-                        $pdf->SetXY($this->posxsociety, $curY);
-                        $titlethirdparty = $outputlangs->transnoentities("ThirdParty");
-                        if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User");
-                        $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L');
-                        if (empty($value['disableamount'])) {
-                            $pdf->SetXY($this->posxamountht, $curY);
-                            $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R');
-                            $pdf->SetXY($this->posxamountttc, $curY);
-                            $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R');
-                        } else {
-                            $pdf->SetXY($this->posxamountht, $curY);
-                            $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
-                        }
-                        $pdf->SetXY($this->posxstatut, $curY);
-                        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R');
-
-                        if (is_array($elementarray) && count($elementarray) > 0)
-                        {
-                            $nexY = $pdf->GetY();
-
-                            $total_ht = 0;
-                            $total_ttc = 0;
-                            $num = count($elementarray);
-
-				            // Loop on each lines
-				            for ($i = 0; $i < $num; $i++)
-				            {
-					            $curY = $nexY;
-					            $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
-					            $pdf->SetTextColor(0, 0, 0);
-
-					            $pdf->setTopMargin($tab_top_newpage);
-					            $pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
-					            $pageposbefore = $pdf->getPage();
-
-					            // Description of line
-					            $idofelement = $elementarray[$i];
-                             	if ($classname == 'ExpenseReport')
-                               	{
-                               		// We get id of expense report
-                               		$expensereportline = new ExpenseReportLine($this->db);
-                               		$expensereportline->fetch($idofelement);
-                               		$idofelement = $expensereportline->fk_expensereport;
-                               	}
-
-                                $element = new $classname($this->db);
-                                $element->fetch($idofelement);
-                                $element->fetch_thirdparty();
-                                // print $classname;
-
-                                $qualifiedfortotal = true;
-                                if ($key == 'invoice') {
-                                    if ($element->close_code == 'replaced')
-                                        $qualifiedfortotal = false; // Replacement invoice
-                                }
-
-					            $showpricebeforepagebreak = 1;
-
-					            $pdf->startTransaction();
-					            // Label
-					            $pdf->SetXY($this->posxref, $curY);
-					            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-					            $pageposafter = $pdf->getPage();
-					            if ($pageposafter > $pageposbefore)	// There is a pagebreak
-					            {
-						            $pdf->rollbackTransaction(true);
-						            $pageposafter = $pageposbefore;
-						            //print $pageposafter.'-'.$pageposbefore;exit;
-						            $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-						            // Label
-						            $pdf->SetXY($this->posxref, $curY);
-						            $posybefore = $pdf->GetY();
-						            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-						            $pageposafter = $pdf->getPage();
-						            $posyafter = $pdf->GetY();
-						            if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
-						            {
-							            if ($i == ($num - 1))	// No more lines, and no space left to show total, so we create a new page
-							            {
-								            $pdf->AddPage($this->orientation, '', true);
-								            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-								            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								            $pdf->setPage($pageposafter + 1);
-							            }
-						            } else {
-							            // We found a page break
+				$listofreferent = array(
+					'propal'=>array(
+						'name'=>"Proposals",
+						'title'=>"ListProposalsAssociatedProject",
+						'class'=>'Propal',
+						'table'=>'propal',
+						'datefieldname'=>'datep',
+						'test'=>$conf->propal->enabled && $user->rights->propale->lire,
+						'lang'=>'propal'),
+					'order'=>array(
+						'name'=>"CustomersOrders",
+						'title'=>"ListOrdersAssociatedProject",
+						'class'=>'Commande',
+						'table'=>'commande',
+						'datefieldname'=>'date_commande',
+						'test'=>$conf->commande->enabled && $user->rights->commande->lire,
+						'lang'=>'orders'),
+					'invoice'=>array(
+						'name'=>"CustomersInvoices",
+						'title'=>"ListInvoicesAssociatedProject",
+						'class'=>'Facture',
+						'margin'=>'add',
+						'table'=>'facture',
+						'datefieldname'=>'datef',
+						'test'=>$conf->facture->enabled && $user->rights->facture->lire,
+						'lang'=>'bills'),
+					'invoice_predefined'=>array(
+						'name'=>"PredefinedInvoices",
+						'title'=>"ListPredefinedInvoicesAssociatedProject",
+						'class'=>'FactureRec',
+						'table'=>'facture_rec',
+						'datefieldname'=>'datec',
+						'test'=>$conf->facture->enabled && $user->rights->facture->lire,
+						'lang'=>'bills'),
+					'order_supplier'=>array(
+						'name'=>"SuppliersOrders",
+						'title'=>"ListSupplierOrdersAssociatedProject",
+						'class'=>'CommandeFournisseur',
+						'table'=>'commande_fournisseur',
+						'datefieldname'=>'date_commande',
+						'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire,
+						'lang'=>'orders'),
+					'invoice_supplier'=>array(
+						'name'=>"BillsSuppliers",
+						'title'=>"ListSupplierInvoicesAssociatedProject",
+						'class'=>'FactureFournisseur',
+						'margin'=>'minus',
+						'table'=>'facture_fourn',
+						'datefieldname'=>'datef',
+						'test'=>$conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire,
+						'lang'=>'bills'),
+					'contract'=>array(
+						'name'=>"Contracts",
+						'title'=>"ListContractAssociatedProject",
+						'class'=>'Contrat',
+						'table'=>'contrat',
+						'datefieldname'=>'date_contrat',
+						'test'=>$conf->contrat->enabled && $user->rights->contrat->lire,
+						'lang'=>'contract'),
+					'intervention'=>array(
+						'name'=>"Interventions",
+						'title'=>"ListFichinterAssociatedProject",
+						'class'=>'Fichinter',
+						'table'=>'fichinter',
+						'datefieldname'=>'date_valid',
+						'disableamount'=>1,
+						'test'=>$conf->ficheinter->enabled && $user->rights->ficheinter->lire,
+						'lang'=>'interventions'),
+					'trip'=>array(
+						'name'=>"TripsAndExpenses",
+						'title'=>"ListExpenseReportsAssociatedProject",
+						'class'=>'Deplacement',
+						'table'=>'deplacement',
+						'datefieldname'=>'dated',
+						'margin'=>'minus',
+						'disableamount'=>1,
+						'test'=>$conf->deplacement->enabled && $user->rights->deplacement->lire,
+						'lang'=>'trip'),
+					'expensereport'=>array(
+						'name'=>"ExpensesReports",
+						'title'=>"ListExpenseReportsAssociatedProject",
+						'class'=>'ExpenseReport',
+						'table'=>'expensereport',
+						'datefieldname'=>'dated',
+						'margin'=>'minus',
+						'disableamount'=>1,
+						'test'=>$conf->expensereport->enabled && $user->rights->expensereport->lire,
+						'lang'=>'trip'),
+					'agenda'=>array(
+						'name'=>"Agenda",
+						'title'=>"ListActionsAssociatedProject",
+						'class'=>'ActionComm',
+						'table'=>'actioncomm',
+						'datefieldname'=>'datep',
+						'disableamount'=>1,
+						'test'=>$conf->agenda->enabled && $user->rights->agenda->allactions->read,
+						'lang'=>'agenda')
+				);
+
+				$hookmanager->initHooks(array('completeListOfReferent'));
+				$hookmanager->executeHooks('completeListOfReferent', ['listofreferent'=>$listofreferent], $object, $action);
+				if (!empty($hookmanager->resArray)) {
+					$listofreferent = array_merge($listofreferent, $hookmanager->resArray);
+				}
+
+				foreach ($listofreferent as $key => $value)
+				{
+					$title = $value['title'];
+					$classname = $value['class'];
+					$tablename = $value['table'];
+					$datefieldname = $value['datefieldname'];
+					$qualified = $value['test'];
+					$langstoload = $value['lang'];
+					$projectField = isset($value['project_field']) ? $value['project_field'] : 'fk_projet';
+					$langs->load($langstoload);
+
+					if (!$qualified) continue;
+
+					//var_dump("$key, $tablename, $datefieldname, $dates, $datee");
+					$elementarray = $object->get_element_list($key, $tablename, $datefieldname, $dates, $datee, $projectField);
+
+					$num = count($elementarray);
+					if ($num >= 0)
+					{
+						$nexY = $pdf->GetY() + 5;
+
+						$curY = $nexY;
+						$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+						$pdf->SetTextColor(0, 0, 0);
+
+						$pdf->SetXY($this->posxref, $curY);
+						$pdf->MultiCell($this->posxstatut - $this->posxref, 3, $outputlangs->transnoentities($title), 0, 'L');
+
+						$selectList = $formproject->select_element($tablename, $project->thirdparty->id, '', -2, $projectField);
+						$nexY = $pdf->GetY() + 1;
+						$curY = $nexY;
+						$pdf->SetXY($this->posxref, $curY);
+						$pdf->MultiCell($this->posxdate - $this->posxref, 3, $outputlangs->transnoentities("Ref"), 1, 'L');
+						$pdf->SetXY($this->posxdate, $curY);
+						$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, $outputlangs->transnoentities("Date"), 1, 'C');
+						$pdf->SetXY($this->posxsociety, $curY);
+						$titlethirdparty = $outputlangs->transnoentities("ThirdParty");
+						if ($classname == 'ExpenseReport') $titlethirdparty = $langs->trans("User");
+						$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $titlethirdparty, 1, 'L');
+						if (empty($value['disableamount'])) {
+							$pdf->SetXY($this->posxamountht, $curY);
+							$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, $outputlangs->transnoentities("AmountHTShort"), 1, 'R');
+							$pdf->SetXY($this->posxamountttc, $curY);
+							$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, $outputlangs->transnoentities("AmountTTCShort"), 1, 'R');
+						} else {
+							$pdf->SetXY($this->posxamountht, $curY);
+							$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
+						}
+						$pdf->SetXY($this->posxstatut, $curY);
+						$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Status"), 1, 'R');
+
+						if (is_array($elementarray) && count($elementarray) > 0)
+						{
+							$nexY = $pdf->GetY();
+
+							$total_ht = 0;
+							$total_ttc = 0;
+							$num = count($elementarray);
+
+							// Loop on each lines
+							for ($i = 0; $i < $num; $i++)
+							{
+								$curY = $nexY;
+								$pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
+								$pdf->SetTextColor(0, 0, 0);
+
+								$pdf->setTopMargin($tab_top_newpage);
+								$pdf->setPageOrientation($this->orientation, 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
+								$pageposbefore = $pdf->getPage();
+
+								// Description of line
+								$idofelement = $elementarray[$i];
+							 	if ($classname == 'ExpenseReport')
+							   	{
+							   		// We get id of expense report
+							   		$expensereportline = new ExpenseReportLine($this->db);
+							   		$expensereportline->fetch($idofelement);
+							   		$idofelement = $expensereportline->fk_expensereport;
+							   	}
+
+								$element = new $classname($this->db);
+								$element->fetch($idofelement);
+								$element->fetch_thirdparty();
+								// print $classname;
+
+								$qualifiedfortotal = true;
+								if ($key == 'invoice') {
+									if ($element->close_code == 'replaced')
+										$qualifiedfortotal = false; // Replacement invoice
+								}
+
+								$showpricebeforepagebreak = 1;
+
+								$pdf->startTransaction();
+								// Label
+								$pdf->SetXY($this->posxref, $curY);
+								$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+								$pageposafter = $pdf->getPage();
+								if ($pageposafter > $pageposbefore)	// There is a pagebreak
+								{
+									$pdf->rollbackTransaction(true);
+									$pageposafter = $pageposbefore;
+									//print $pageposafter.'-'.$pageposbefore;exit;
+									$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+									// Label
+									$pdf->SetXY($this->posxref, $curY);
+									$posybefore = $pdf->GetY();
+									$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+									$pageposafter = $pdf->getPage();
+									$posyafter = $pdf->GetY();
+									if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))	// There is no space left for total+free text
+									{
+										if ($i == ($num - 1))	// No more lines, and no space left to show total, so we create a new page
+										{
+											$pdf->AddPage($this->orientation, '', true);
+											if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+											if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+											$pdf->setPage($pageposafter + 1);
+										}
+									} else {
+										// We found a page break
 
 										// Allows data in the first page if description is long enough to break in multiples pages
 										if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 											$showpricebeforepagebreak = 1;
 										else $showpricebeforepagebreak = 0;
 
-							            $forcedesconsamepage = 1;
-							            if ($forcedesconsamepage)
-							            {
-								            $pdf->rollbackTransaction(true);
-								            $pageposafter = $pageposbefore;
-								            $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-
-								            $pdf->AddPage($this->orientation, '', true);
-								            if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-								            if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-								            $pdf->setPage($pageposafter + 1);
-								            $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
-								            $pdf->MultiCell(0, 3, ''); // Set interline to 3
-								            $pdf->SetTextColor(0, 0, 0);
-
-								            $pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-								            $curY = $tab_top_newpage + $heightoftitleline + 1;
-
-								            // Label
-								            $pdf->SetXY($this->posxref, $curY);
-								            $posybefore = $pdf->GetY();
-								            $pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
-								            $pageposafter = $pdf->getPage();
-								            $posyafter = $pdf->GetY();
-							            }
-						            }
-						            //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
-					            } else // No pagebreak
-					            {
-						            $pdf->commitTransaction();
-					            }
-					            $posYAfterDescription = $pdf->GetY();
-
-					            $nexY = $pdf->GetY();
-					            $pageposafter = $pdf->getPage();
-					            $pdf->setPage($pageposbefore);
-					            $pdf->setTopMargin($this->marge_haute);
-					            $pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it.
-
-					            // We suppose that a too long description is moved completely on next page
-					            if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
-						            //var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
-						            $pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
-					            }
-
-					            $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
-
-					            // Date
-					            if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
-						            $date = $element->date_commande;
-					            else {
-						            $date = $element->date;
-						            if (empty($date))
-							            $date = $element->datep;
-						            if (empty($date))
-							            $date = $element->date_contrat;
-						            if (empty($date))
-							            $date = $element->datev; // Fiche inter
-					            }
-
-					            $pdf->SetXY($this->posxdate, $curY);
-					            $pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
-
-					            $pdf->SetXY($this->posxsociety, $curY);
-					            if ($classname == 'ExpenseReport')
-					            {
-						            $fuser = new User($this->db);
-						            $fuser->fetch($element->fk_user_author);
-						            $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
-					            } else {
-						            $pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L');
-					            }
-
-                                // Amount without tax
-                                if (empty($value['disableamount'])) {
-                                    $pdf->SetXY($this->posxamountht, $curY);
-                                    $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R');
-                                    $pdf->SetXY($this->posxamountttc, $curY);
-                                    $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R');
-                                } else {
-                                	$pdf->SetXY($this->posxamountht, $curY);
-                                	if ($key == 'agenda')
-                                	{
-                                		$textforamount = dol_trunc($element->label, 26);
-                                		$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
-                                	} else {
-	                                    $pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
-                                	}
-                                }
-
-                                // Status
-                                if ($element instanceof CommonInvoice) {
-                                    // This applies for Facture and FactureFournisseur
-                                    $outputstatut = $element->getLibStatut(1, $element->getSommePaiement());
-                                } else {
-                                    $outputstatut = $element->getLibStatut(1);
-                                }
-                                $pdf->SetXY($this->posxstatut, $curY);
-                                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true);
-
-                                if ($qualifiedfortotal) {
-                                    $total_ht = $total_ht + $element->total_ht;
-                                    $total_ttc = $total_ttc + $element->total_ttc;
-                                }
-                                $nexY = $pdf->GetY();
-                                $curY = $nexY;
-                            }
-
-                            if (empty($value['disableamount'])) {
-                                $curY = $nexY;
-                                $pdf->SetXY($this->posxref, $curY);
-                                $pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L');
-                                $pdf->SetXY($this->posxamountht, $curY);
-                                $pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R');
-                                $pdf->SetXY($this->posxamountttc, $curY);
-                                $pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R');
-                                $pdf->SetXY($this->posxstatut, $curY);
-                                $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L');
-                            }
-                            $nexY = $pdf->GetY() + 5;
-                            $curY = $nexY;
-                        }
-                    }
-
-                    $nexY += 2; // Add space between lines
+										$forcedesconsamepage = 1;
+										if ($forcedesconsamepage)
+										{
+											$pdf->rollbackTransaction(true);
+											$pageposafter = $pageposbefore;
+											$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+
+											$pdf->AddPage($this->orientation, '', true);
+											if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+											if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+											$pdf->setPage($pageposafter + 1);
+											$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+											$pdf->MultiCell(0, 3, ''); // Set interline to 3
+											$pdf->SetTextColor(0, 0, 0);
+
+											$pdf->setPageOrientation($this->orientation, 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+											$curY = $tab_top_newpage + $heightoftitleline + 1;
+
+											// Label
+											$pdf->SetXY($this->posxref, $curY);
+											$posybefore = $pdf->GetY();
+											$pdf->MultiCell($this->posxdate - $this->posxref, 3, $element->ref, 1, 'L');
+											$pageposafter = $pdf->getPage();
+											$posyafter = $pdf->GetY();
+										}
+									}
+									//var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur -  ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak);
+								} else // No pagebreak
+								{
+									$pdf->commitTransaction();
+								}
+								$posYAfterDescription = $pdf->GetY();
+
+								$nexY = $pdf->GetY();
+								$pageposafter = $pdf->getPage();
+								$pdf->setPage($pageposbefore);
+								$pdf->setTopMargin($this->marge_haute);
+								$pdf->setPageOrientation($this->orientation, 1, 0); // The only function to edit the bottom margin of current page to set it.
+
+								// We suppose that a too long description is moved completely on next page
+								if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
+									//var_dump($pageposbefore.'-'.$pageposafter.'-'.$showpricebeforepagebreak);
+									$pdf->setPage($pageposafter); $curY = $tab_top_newpage + $heightoftitleline + 1;
+								}
+
+								$pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
+
+								// Date
+								if ($tablename == 'commande_fournisseur' || $tablename == 'supplier_order')
+									$date = $element->date_commande;
+								else {
+									$date = $element->date;
+									if (empty($date))
+										$date = $element->datep;
+									if (empty($date))
+										$date = $element->date_contrat;
+									if (empty($date))
+										$date = $element->datev; // Fiche inter
+								}
+
+								$pdf->SetXY($this->posxdate, $curY);
+								$pdf->MultiCell($this->posxsociety - $this->posxdate, 3, dol_print_date($date, 'day'), 1, 'C');
+
+								$pdf->SetXY($this->posxsociety, $curY);
+								if ($classname == 'ExpenseReport')
+								{
+									$fuser = new User($this->db);
+									$fuser->fetch($element->fk_user_author);
+									$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, $fuser->getFullName($outputlangs), 1, 'L');
+								} else {
+									$pdf->MultiCell($this->posxamountht - $this->posxsociety, 3, (is_object($element->thirdparty) ? $element->thirdparty->name : ''), 1, 'L');
+								}
+
+								// Amount without tax
+								if (empty($value['disableamount'])) {
+									$pdf->SetXY($this->posxamountht, $curY);
+									$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($element->total_ht) : ''), 1, 'R');
+									$pdf->SetXY($this->posxamountttc, $curY);
+									$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($element->total_ttc) : ''), 1, 'R');
+								} else {
+									$pdf->SetXY($this->posxamountht, $curY);
+									if ($key == 'agenda')
+									{
+										$textforamount = dol_trunc($element->label, 26);
+										$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, $textforamount, 1, 'L');
+									} else {
+										$pdf->MultiCell($this->posxstatut - $this->posxamountht, 3, "", 1, 'R');
+									}
+								}
+
+								// Status
+								if ($element instanceof CommonInvoice) {
+									// This applies for Facture and FactureFournisseur
+									$outputstatut = $element->getLibStatut(1, $element->getSommePaiement());
+								} else {
+									$outputstatut = $element->getLibStatut(1);
+								}
+								$pdf->SetXY($this->posxstatut, $curY);
+								$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputstatut, 1, 'R', false, 1, '', '', true, 0, true);
+
+								if ($qualifiedfortotal) {
+									$total_ht = $total_ht + $element->total_ht;
+									$total_ttc = $total_ttc + $element->total_ttc;
+								}
+								$nexY = $pdf->GetY();
+								$curY = $nexY;
+							}
+
+							if (empty($value['disableamount'])) {
+								$curY = $nexY;
+								$pdf->SetXY($this->posxref, $curY);
+								$pdf->MultiCell($this->posxamountttc - $this->posxref, 3, "TOTAL", 1, 'L');
+								$pdf->SetXY($this->posxamountht, $curY);
+								$pdf->MultiCell($this->posxamountttc - $this->posxamountht, 3, (isset($element->total_ht) ? price($total_ht) : ''), 1, 'R');
+								$pdf->SetXY($this->posxamountttc, $curY);
+								$pdf->MultiCell($this->posxstatut - $this->posxamountttc, 3, (isset($element->total_ttc) ? price($total_ttc) : ''), 1, 'R');
+								$pdf->SetXY($this->posxstatut, $curY);
+								$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxstatut, 3, $outputlangs->transnoentities("Nb")." ".$num, 1, 'L');
+							}
+							$nexY = $pdf->GetY() + 5;
+							$curY = $nexY;
+						}
+					}
+
+					$nexY += 2; // Add space between lines
 
 					// Detect if some page were added automatically and output _tableau for past pages
 					while ($pagenb < $pageposafter)
@@ -667,8 +667,8 @@ class pdf_beluga extends ModelePDFProjects
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -759,7 +759,7 @@ class pdf_beluga extends ModelePDFProjects
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -770,8 +770,8 @@ class pdf_beluga extends ModelePDFProjects
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -808,7 +808,7 @@ class pdf_beluga extends ModelePDFProjects
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	Project		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output

+ 41 - 41
htdocs/core/modules/project/doc/pdf_timespent.modules.php

@@ -97,7 +97,7 @@ class pdf_timespent extends ModelePDFProjects
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Fonction generant le projet sur le disque
 	 *
@@ -107,7 +107,7 @@ class pdf_timespent extends ModelePDFProjects
 	 */
 	public function write_file($object, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $hookmanager, $langs, $user;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -154,30 +154,30 @@ class pdf_timespent extends ModelePDFProjects
 				$pdf->SetAutoPageBreak(1, 0);
 
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				// Complete object by loading several other informations
 				$task = new Task($this->db);
 				$tasksarray = $task->getTasksArray(0, 0, $object->id);
 
-                if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
-                {
-                    $tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
-                }
+				if (!$object->id > 0)  // Special case when used with object = specimen, we may return all lines
+				{
+					$tasksarray = array_slice($tasksarray, 0, min(5, count($tasksarray)));
+				}
 
 				$object->lines = $tasksarray;
 				$nblines = count($object->lines);
@@ -423,8 +423,8 @@ class pdf_timespent extends ModelePDFProjects
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -462,7 +462,7 @@ class pdf_timespent extends ModelePDFProjects
 
 		$heightoftitleline = 10;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$pdf->SetDrawColor(128, 128, 128);
 
@@ -515,7 +515,7 @@ class pdf_timespent extends ModelePDFProjects
 		$pdf->SetTextColor(0, 0, 60);
 		$pdf->SetFont('', 'B', $default_font_size + 3);
 
-        $posx = $this->page_largeur - $this->marge_droite - 100;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
 		$posy = $this->marge_haute;
 
 		$pdf->SetXY($this->marge_gauche, $posy);
@@ -526,8 +526,8 @@ class pdf_timespent extends ModelePDFProjects
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -586,19 +586,19 @@ class pdf_timespent extends ModelePDFProjects
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
-     *  Show footer of page. Need this->emetteur object
-     *
-     *  @param  TCPDF       $pdf                PDF
-     *  @param  Project     $object             Object to show
-     *  @param  Translate   $outputlangs        Object lang for output
-     *  @param  int         $hidefreetext       1=Hide free text
-     *  @return integer
-     */
+	/**
+	 *  Show footer of page. Need this->emetteur object
+	 *
+	 *  @param  TCPDF       $pdf                PDF
+	 *  @param  Project     $object             Object to show
+	 *  @param  Translate   $outputlangs        Object lang for output
+	 *  @param  int         $hidefreetext       1=Hide free text
+	 *  @return integer
+	 */
 	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
-    {
-        global $conf;
-        $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
-        return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
-    }
+	{
+		global $conf;
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+		return pdf_pagefoot($pdf, $outputlangs, 'PROJECT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+	}
 }

+ 136 - 136
htdocs/core/modules/propale/doc/pdf_azur.modules.php

@@ -43,75 +43,75 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
 class pdf_azur extends ModelePDFPropales
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var string	Save the name of generated file as the main doc when generating a doc with this template
-     */
+	/**
+	 * @var string	Save the name of generated file as the main doc when generating a doc with this template
+	 */
 	public $update_main_doc_field;
 
 	/**
-     * @var string document type
-     */
-    public $type;
-
-    /**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var string document type
+	 */
+	public $type;
+
+	/**
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -200,21 +200,21 @@ class pdf_azur extends ModelePDFPropales
 		$this->atleastonediscount = 0;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
-     *  Function to build pdf onto disk
-     *
-     *  @param		Object		$object				Object to generate
-     *  @param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int             				1=OK, 0=KO
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		Object		$object				Object to generate
+	 *  @param		Translate	$outputlangs		Lang output object
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int             				1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -237,7 +237,7 @@ class pdf_azur extends ModelePDFPropales
 				if (empty($object->lines[$i]->fk_product)) continue;
 
 				$objphoto->fetch($object->lines[$i]->fk_product);
-                //var_dump($objphoto->ref);exit;
+				//var_dump($objphoto->ref);exit;
 				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
 				{
 					$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
@@ -324,22 +324,22 @@ class pdf_azur extends ModelePDFPropales
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
 				// Create pdf instance
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-	            $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                	$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -364,14 +364,14 @@ class pdf_azur extends ModelePDFPropales
 				}
 				if (empty($this->atleastonediscount))
 				{
-				    $delta = ($this->postotalht - $this->posxdiscount);
-				    $this->posxpicture += $delta;
-				    $this->posxtva += $delta;
-				    $this->posxup += $delta;
-				    $this->posxqty += $delta;
-				    $this->posxunit += $delta;
-				    $this->posxdiscount += $delta;
-				    // post of fields after are not modified, stay at same position
+					$delta = ($this->postotalht - $this->posxdiscount);
+					$this->posxpicture += $delta;
+					$this->posxtva += $delta;
+					$this->posxup += $delta;
+					$this->posxqty += $delta;
+					$this->posxunit += $delta;
+					$this->posxdiscount += $delta;
+					// post of fields after are not modified, stay at same position
 				}
 
 				// New page
@@ -379,12 +379,12 @@ class pdf_azur extends ModelePDFPropales
 				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 				$pagenb++;
 
-                $heightforinfotot = 40; // Height reserved to output the info and total part
-                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
-                $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				$heightforinfotot = 40; // Height reserved to output the info and total part
+				$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
 				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+				//print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
 
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
 				$pdf->SetFont('', '', $default_font_size - 1);
@@ -392,7 +392,7 @@ class pdf_azur extends ModelePDFPropales
 				$pdf->SetTextColor(0, 0, 0);
 
 
-	            $tab_top = 90 + $top_shift;
+				$tab_top = 90 + $top_shift;
 				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
 
 				// Incoterm
@@ -429,18 +429,18 @@ class pdf_azur extends ModelePDFPropales
 						if (!empty($salerepobj->signature)) $notetoshow = dol_concatdesc($notetoshow, $salerepobj->signature);
 					}
 				}
-                // Extrafields in note
-                $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
-                if (!empty($extranote)) {
-                    $notetoshow = dol_concatdesc($notetoshow, $extranote);
-                }
+				// Extrafields in note
+				$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+				if (!empty($extranote)) {
+					$notetoshow = dol_concatdesc($notetoshow, $extranote);
+				}
 				if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
 				{
-				    $tmpuser = new User($this->db);
-				    $tmpuser->fetch($object->user_author_id);
-				    $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
-				    if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
-				    if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
+					$tmpuser = new User($this->db);
+					$tmpuser->fetch($object->user_author_id);
+					$notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+					if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
+					if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
 				}
 				if ($notetoshow)
 				{
@@ -630,7 +630,7 @@ class pdf_azur extends ModelePDFPropales
 						$localtax2_type = $localtaxtmp_array[2];
 					}
 
-				    // retrieve global local tax
+					// retrieve global local tax
 					if ($localtax1_type && $localtax1ligne != 0)
 						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -714,7 +714,7 @@ class pdf_azur extends ModelePDFPropales
 				// Customer signature area
 				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
 				{
-				    $posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
+					$posy = $this->_signature_area($pdf, $object, $posy, $outputlangs);
 				}
 
 				// Pied de page
@@ -802,8 +802,8 @@ class pdf_azur extends ModelePDFPropales
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -823,23 +823,23 @@ class pdf_azur extends ModelePDFPropales
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show payments table
 	 *
-     *  @param	TCPDF		$pdf           Object PDF
-     *  @param  Object		$object         Object proposal
-     *  @param  int			$posy           Position y in PDF
-     *  @param  Translate	$outputlangs    Object langs for output
-     *  @return int             			<0 if KO, >0 if OK
+	 *  @param	TCPDF		$pdf           Object PDF
+	 *  @param  Object		$object         Object proposal
+	 *  @param  int			$posy           Position y in PDF
+	 *  @param  Translate	$outputlangs    Object langs for output
+	 *  @return int             			<0 if KO, >0 if OK
 	 */
 	protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Show miscellaneous information (payment mode, payment term, ...)
 	 *
@@ -851,7 +851,7 @@ class pdf_azur extends ModelePDFPropales
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -869,10 +869,10 @@ class pdf_azur extends ModelePDFPropales
 
 		$posxval = 52;
 
-        // Show shipping date
-        if (!empty($object->date_livraison))
+		// Show shipping date
+		if (!empty($object->date_livraison))
 		{
-            $outputlangs->load("sendings");
+			$outputlangs->load("sendings");
 			$pdf->SetFont('', 'B', $default_font_size - 2);
 			$pdf->SetXY($this->marge_gauche, $posy);
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@@ -882,7 +882,7 @@ class pdf_azur extends ModelePDFPropales
 			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
 
-            $posy = $pdf->GetY() + 1;
+			$posy = $pdf->GetY() + 1;
 		} elseif ($object->availability_code || $object->availability)    // Show availability conditions
 		{
 			$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -969,13 +969,13 @@ class pdf_azur extends ModelePDFPropales
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
 					{
@@ -984,13 +984,13 @@ class pdf_azur extends ModelePDFPropales
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 				}
 			}
@@ -1019,7 +1019,7 @@ class pdf_azur extends ModelePDFPropales
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show total to pay
 	 *
@@ -1032,7 +1032,7 @@ class pdf_azur extends ModelePDFPropales
 	 */
 	protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -1104,7 +1104,7 @@ class pdf_azur extends ModelePDFPropales
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1195,7 +1195,7 @@ class pdf_azur extends ModelePDFPropales
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1205,7 +1205,7 @@ class pdf_azur extends ModelePDFPropales
 
 					foreach ($localtax_rate as $tvakey => $tvaval)
 					{
-					    // retrieve global local tax
+						// retrieve global local tax
 						if ($tvakey != 0)    // On affiche pas taux 0
 						{
 							//$this->atleastoneratenotnull++;
@@ -1434,7 +1434,7 @@ class pdf_azur extends ModelePDFPropales
 		//  Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
 		{
-            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
 		}
 
 		$pdf->SetTextColor(0, 0, 60);
@@ -1460,8 +1460,8 @@ class pdf_azur extends ModelePDFPropales
 				}
 				if (is_readable($logo))
 				{
-				    $height = pdf_getHeightForLogo($logo);
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+					$height = pdf_getHeightForLogo($logo);
+					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 				} else {
 					$pdf->SetTextColor(200, 0, 0);
 					$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1543,16 +1543,16 @@ class pdf_azur extends ModelePDFPropales
 		// Get contact
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 		{
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $usertmp = new User($this->db);
-		        $usertmp->fetch($arrayidcontact[0]);
-                $posy += 4;
-                $pdf->SetXY($posx, $posy);
-		        $pdf->SetTextColor(0, 0, 60);
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
-		    }
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$usertmp = new User($this->db);
+				$usertmp->fetch($arrayidcontact[0]);
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+			}
 		}
 
 		$posy += 2;
@@ -1664,7 +1664,7 @@ class pdf_azur extends ModelePDFPropales
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
@@ -1679,7 +1679,7 @@ class pdf_azur extends ModelePDFPropales
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show area for the customer to sign
 	 *
@@ -1691,7 +1691,7 @@ class pdf_azur extends ModelePDFPropales
 	 */
 	protected function _signature_area(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 		$tab_top = $posy + 4;

+ 461 - 461
htdocs/core/modules/propale/doc/pdf_cyan.modules.php

@@ -41,82 +41,82 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_cyan extends ModelePDFPropales
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var string     Save the name of generated file as the main doc when generating a doc with this template
-     */
-    public $update_main_doc_field;
+	/**
+	 * @var string     Save the name of generated file as the main doc when generating a doc with this template
+	 */
+	public $update_main_doc_field;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
-     /**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 /**
+	  * @var int page_largeur
+	  */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
-    /**
-	* Issuer
-	* @var Societe Object that emits
-	*/
+	/**
+	 * Issuer
+	 * @var Societe Object that emits
+	 */
 	public $emetteur;
 
 
@@ -176,17 +176,17 @@ class pdf_cyan extends ModelePDFPropales
 		$this->atleastonediscount = 0;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
-     *  Function to build pdf onto disk
-     *
-     *  @param		Object		$object				Object to generate
-     *  @param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int             				1=OK, 0=KO
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		Object		$object				Object to generate
+	 *  @param		Translate	$outputlangs		Lang output object
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int             				1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
@@ -211,7 +211,7 @@ class pdf_cyan extends ModelePDFPropales
 
 		$hidetop = 0;
 		if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
-		    $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
+			$hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
 		}
 
 		// Loop on each lines to detect if there is at least one image to show
@@ -226,7 +226,7 @@ class pdf_cyan extends ModelePDFPropales
 				if (empty($object->lines[$i]->fk_product)) continue;
 
 				$objphoto->fetch($object->lines[$i]->fk_product);
-                //var_dump($objphoto->ref);exit;
+				//var_dump($objphoto->ref);exit;
 				if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
 				{
 					$pdir[0] = get_exdir($objphoto->id, 2, 0, 0, $objphoto, 'product').$objphoto->id."/photos/";
@@ -314,22 +314,22 @@ class pdf_cyan extends ModelePDFPropales
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
 				// Create pdf instance
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-	            $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                	$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -346,10 +346,10 @@ class pdf_cyan extends ModelePDFPropales
 
 				// Does we have at least one line with discount $this->atleastonediscount
 				foreach ($object->lines as $line) {
-				    if ($line->remise_percent) {
-				        $this->atleastonediscount = true;
-				        break;
-				    }
+					if ($line->remise_percent) {
+						$this->atleastonediscount = true;
+						break;
+					}
 				}
 
 
@@ -359,11 +359,11 @@ class pdf_cyan extends ModelePDFPropales
 				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 				$pagenb++;
 
-                $heightforinfotot = 40; // Height reserved to output the info and total part
-                $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
-                $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-                $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
-                //print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
+				$heightforinfotot = 40; // Height reserved to output the info and total part
+				$heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities("ProposalCustomerSignature")) + 10) : 0;
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22); // Height reserved to output the footer (value include bottom margin)
+				//print $heightforinfotot + $heightforsignature + $heightforfreetext + $heightforfooter;exit;
 
 				$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
 				$pdf->SetFont('', '', $default_font_size - 1);
@@ -371,7 +371,7 @@ class pdf_cyan extends ModelePDFPropales
 				$pdf->SetTextColor(0, 0, 0);
 
 
-	            $tab_top = 90 + $top_shift;
+				$tab_top = 90 + $top_shift;
 				$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
 
 
@@ -411,20 +411,20 @@ class pdf_cyan extends ModelePDFPropales
 					}
 				}
 
-                // Extrafields in note
-                $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
-                if (!empty($extranote))
-                {
-                    $notetoshow = dol_concatdesc($notetoshow, $extranote);
-                }
+				// Extrafields in note
+				$extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
+				if (!empty($extranote))
+				{
+					$notetoshow = dol_concatdesc($notetoshow, $extranote);
+				}
 
 				if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
 				{
-				    $tmpuser = new User($this->db);
-				    $tmpuser->fetch($object->user_author_id);
-				    $notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
-				    if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
-				    if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
+					$tmpuser = new User($this->db);
+					$tmpuser->fetch($object->user_author_id);
+					$notetoshow .= $langs->trans("CaseFollowedBy").' '.$tmpuser->getFullName($langs);
+					if ($tmpuser->email) $notetoshow .= ',  Mail: '.$tmpuser->email;
+					if ($tmpuser->office_phone) $notetoshow .= ', Tel: '.$tmpuser->office_phone;
 				}
 
 				$tab_height = $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter;
@@ -434,8 +434,8 @@ class pdf_cyan extends ModelePDFPropales
 				{
 					$tab_top -= 2;
 
-				    $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
-				    $pageposbeforenote = $pagenb;
+					$tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
+					$pageposbeforenote = $pagenb;
 
 					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
@@ -452,91 +452,91 @@ class pdf_cyan extends ModelePDFPropales
 
 					if ($pageposafternote > $pageposbeforenote)
 					{
-					    $pdf->rollbackTransaction(true);
-
-					    // prepar pages to receive notes
-					    while ($pagenb < $pageposafternote) {
-					        $pdf->AddPage();
-					        $pagenb++;
-					        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-					        // $this->_pagefoot($pdf,$object,$outputlangs,1);
-					        $pdf->setTopMargin($tab_top_newpage);
-					        // The only function to edit the bottom margin of current page to set it.
-					        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
-					    }
-
-					    // back to start
-					    $pdf->setPage($pageposbeforenote);
-					    $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
-					    $pdf->SetFont('', '', $default_font_size - 1);
-					    $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
-					    $pageposafternote = $pdf->getPage();
-
-					    $posyafter = $pdf->GetY();
-
-					    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
-					    {
-					        $pdf->AddPage('', '', true);
-					        $pagenb++;
-					        $pageposafternote++;
-					        $pdf->setPage($pageposafternote);
-					        $pdf->setTopMargin($tab_top_newpage);
-					        // The only function to edit the bottom margin of current page to set it.
-					        $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
-					        //$posyafter = $tab_top_newpage;
-					    }
-
-
-					    // apply note frame to previus pages
-					    $i = $pageposbeforenote;
-					    while ($i < $pageposafternote) {
-					        $pdf->setPage($i);
-
-
-					        $pdf->SetDrawColor(128, 128, 128);
-					        // Draw note frame
-					        if ($i > $pageposbeforenote) {
-					            $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
-					            $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
-					        } else {
-					            $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
-					            $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
-					        }
-
-					        // Add footer
-					        $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
-					        $this->_pagefoot($pdf, $object, $outputlangs, 1);
-
-					        $i++;
-					    }
-
-					    // apply note frame to last page
-					    $pdf->setPage($pageposafternote);
-					    if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-					    if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-					    $height_note = $posyafter - $tab_top_newpage;
-					    $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+						$pdf->rollbackTransaction(true);
+
+						// prepar pages to receive notes
+						while ($pagenb < $pageposafternote) {
+							$pdf->AddPage();
+							$pagenb++;
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+							// $this->_pagefoot($pdf,$object,$outputlangs,1);
+							$pdf->setTopMargin($tab_top_newpage);
+							// The only function to edit the bottom margin of current page to set it.
+							$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+						}
+
+						// back to start
+						$pdf->setPage($pageposbeforenote);
+						$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+						$pdf->SetFont('', '', $default_font_size - 1);
+						$pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
+						$pageposafternote = $pdf->getPage();
+
+						$posyafter = $pdf->GetY();
+
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))	// There is no space left for total+free text
+						{
+							$pdf->AddPage('', '', true);
+							$pagenb++;
+							$pageposafternote++;
+							$pdf->setPage($pageposafternote);
+							$pdf->setTopMargin($tab_top_newpage);
+							// The only function to edit the bottom margin of current page to set it.
+							$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
+							//$posyafter = $tab_top_newpage;
+						}
+
+
+						// apply note frame to previus pages
+						$i = $pageposbeforenote;
+						while ($i < $pageposafternote) {
+							$pdf->setPage($i);
+
+
+							$pdf->SetDrawColor(128, 128, 128);
+							// Draw note frame
+							if ($i > $pageposbeforenote) {
+								$height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
+								$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
+							} else {
+								$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
+								$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+							}
+
+							// Add footer
+							$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
+							$this->_pagefoot($pdf, $object, $outputlangs, 1);
+
+							$i++;
+						}
+
+						// apply note frame to last page
+						$pdf->setPage($pageposafternote);
+						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+						if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+						$height_note = $posyafter - $tab_top_newpage;
+						$pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
 					} else // No pagebreak
 					{
-					    $pdf->commitTransaction();
-					    $posyafter = $pdf->GetY();
-					    $height_note = $posyafter - $tab_top;
-					    $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
-
-
-					    if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
-					    {
-					        // not enough space, need to add page
-					        $pdf->AddPage('', '', true);
-					        $pagenb++;
-					        $pageposafternote++;
-					        $pdf->setPage($pageposafternote);
-					        if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-					        if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-
-					        $posyafter = $tab_top_newpage;
-					    }
+						$pdf->commitTransaction();
+						$posyafter = $pdf->GetY();
+						$height_note = $posyafter - $tab_top;
+						$pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
+
+
+						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
+						{
+							// not enough space, need to add page
+							$pdf->AddPage('', '', true);
+							$pagenb++;
+							$pageposafternote++;
+							$pdf->setPage($pageposafternote);
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+
+							$posyafter = $tab_top_newpage;
+						}
 					}
 					$tab_height = $tab_height - $height_note;
 					$tab_top = $posyafter + 6;
@@ -577,71 +577,71 @@ class pdf_cyan extends ModelePDFPropales
 
 					if ($this->getColumnStatus('photo'))
 					{
-    					// We start with Photo of product line
-    					if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
-    					{
-    						$pdf->AddPage('', '', true);
-    						if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-    						//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-    						$pdf->setPage($pageposbefore + 1);
+						// We start with Photo of product line
+						if (isset($imglinesize['width']) && isset($imglinesize['height']) && ($curY + $imglinesize['height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// If photo too high, we moved completely on new page
+						{
+							$pdf->AddPage('', '', true);
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+							//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+							$pdf->setPage($pageposbefore + 1);
 
-    						$curY = $tab_top_newpage;
+							$curY = $tab_top_newpage;
 
 							// Allows data in the first page if description is long enough to break in multiples pages
 							if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 								$showpricebeforepagebreak = 1;
 							else $showpricebeforepagebreak = 0;
-    					}
+						}
 
 
-    					if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
-    					{
-    						$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
-    						// $pdf->Image does not increase value return by getY, so we save it manually
-    						$posYAfterImage = $curY + $imglinesize['height'];
-    					}
+						if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
+						{
+							$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
+							// $pdf->Image does not increase value return by getY, so we save it manually
+							$posYAfterImage = $curY + $imglinesize['height'];
+						}
 					}
 
 					// Description of product line
 					if ($this->getColumnStatus('desc'))
 					{
-    					$pdf->startTransaction();
-
-                        $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-    					$pageposafter = $pdf->getPage();
-
-    					if ($pageposafter > $pageposbefore)	// There is a pagebreak
-    					{
-    						$pdf->rollbackTransaction(true);
-
-    						$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
-
-                            $this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
-
-    						$pageposafter = $pdf->getPage();
-    						$posyafter = $pdf->GetY();
-    						//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
-    						if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
-    						{
-    							if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
-    							{
-    								$pdf->AddPage('', '', true);
-    								if (!empty($tplidx)) $pdf->useTemplate($tplidx);
-    								//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
-    								$pdf->setPage($pageposafter + 1);
-    							}
-    						} else {
-    							// We found a page break
+						$pdf->startTransaction();
+
+						$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+						$pageposafter = $pdf->getPage();
+
+						if ($pageposafter > $pageposbefore)	// There is a pagebreak
+						{
+							$pdf->rollbackTransaction(true);
+
+							$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
+
+							$this->printColDescContent($pdf, $curY, 'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
+
+							$pageposafter = $pdf->getPage();
+							$posyafter = $pdf->GetY();
+							//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
+							if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))	// There is no space left for total+free text
+							{
+								if ($i == ($nblines - 1))	// No more lines, and no space left to show total, so we create a new page
+								{
+									$pdf->AddPage('', '', true);
+									if (!empty($tplidx)) $pdf->useTemplate($tplidx);
+									//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
+									$pdf->setPage($pageposafter + 1);
+								}
+							} else {
+								// We found a page break
 								// Allows data in the first page if description is long enough to break in multiples pages
 								if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
 									$showpricebeforepagebreak = 1;
 								else $showpricebeforepagebreak = 0;
-    						}
-    					} else // No pagebreak
-    					{
-    						$pdf->commitTransaction();
-    					}
-    					$posYAfterDescription = $pdf->GetY();
+							}
+						} else // No pagebreak
+						{
+							$pdf->commitTransaction();
+						}
+						$posYAfterDescription = $pdf->GetY();
 					}
 
 					$nexY = $pdf->GetY();
@@ -661,73 +661,73 @@ class pdf_cyan extends ModelePDFPropales
 					// VAT Rate
 					if ($this->getColumnStatus('vat'))
 					{
-					    $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
-					    $this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+						$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					// Unit price before discount
 					if ($this->getColumnStatus('subprice'))
 					{
-					    $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
-					    $this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
+						$this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					// Quantity
 					// Enough for 6 chars
 					if ($this->getColumnStatus('qty'))
 					{
-					    $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
-					    $this->printStdColumnContent($pdf, $curY, 'qty', $qty);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails);
+						$this->printStdColumnContent($pdf, $curY, 'qty', $qty);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 
 					// Unit
 					if ($this->getColumnStatus('unit'))
 					{
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
-					    $this->printStdColumnContent($pdf, $curY, 'unit', $unit);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+						$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					// Discount on line
 					if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
 					{
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
-					    $this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+						$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
 					// Total HT line
 					if ($this->getColumnStatus('totalexcltax'))
 					{
-					    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
-					    $this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
-					    $nexY = max($pdf->GetY(), $nexY);
+						$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
+						$this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
+						$nexY = max($pdf->GetY(), $nexY);
 					}
 
-                    // Extrafields
-                    if (!empty($object->lines[$i]->array_options)) {
-                        foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
-                            if ($this->getColumnStatus($extrafieldColKey))
-                            {
-                                $extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
-                                $this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
-                                $nexY = max($pdf->GetY(), $nexY);
-                            }
-                        }
-                    }
+					// Extrafields
+					if (!empty($object->lines[$i]->array_options)) {
+						foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
+							if ($this->getColumnStatus($extrafieldColKey))
+							{
+								$extrafieldValue = $this->getExtrafieldContent($object->lines[$i], $extrafieldColKey);
+								$this->printStdColumnContent($pdf, $curY, $extrafieldColKey, $extrafieldValue);
+								$nexY = max($pdf->GetY(), $nexY);
+							}
+						}
+					}
 
 					$parameters = array(
-					    'object' => $object,
-					    'i' => $i,
-					    'pdf' =>& $pdf,
-					    'curY' =>& $curY,
-					    'nexY' =>& $nexY,
-					    'outputlangs' => $outputlangs,
-					    'hidedetails' => $hidedetails
+						'object' => $object,
+						'i' => $i,
+						'pdf' =>& $pdf,
+						'curY' =>& $curY,
+						'nexY' =>& $nexY,
+						'outputlangs' => $outputlangs,
+						'hidedetails' => $hidedetails
 					);
 					$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
 
@@ -759,7 +759,7 @@ class pdf_cyan extends ModelePDFPropales
 						$localtax2_type = $localtaxtmp_array[2];
 					}
 
-				    // retrieve global local tax
+					// retrieve global local tax
 					if ($localtax1_type && $localtax1ligne != 0)
 						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -789,7 +789,7 @@ class pdf_cyan extends ModelePDFPropales
 						$pdf->setPage($pagenb);
 						if ($pagenb == $pageposbeforeprintlines)
 						{
-						    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
 						} else {
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
 						}
@@ -801,9 +801,9 @@ class pdf_cyan extends ModelePDFPropales
 					}
 					if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
 					{
-					    if ($pagenb == $pageposafter)
+						if ($pagenb == $pageposafter)
 						{
-						    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
+							$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
 						} else {
 							$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
 						}
@@ -819,7 +819,7 @@ class pdf_cyan extends ModelePDFPropales
 				// Show square
 				if ($pagenb == $pageposbeforeprintlines)
 				{
-				    $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
+					$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
 					$bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
 				} else {
 					$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
@@ -843,7 +843,7 @@ class pdf_cyan extends ModelePDFPropales
 				// Customer signature area
 				if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
 				{
-				    $posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
+					$posy = $this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
 				}
 
 				// Pied de page
@@ -931,8 +931,8 @@ class pdf_cyan extends ModelePDFPropales
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -954,11 +954,11 @@ class pdf_cyan extends ModelePDFPropales
 	/**
 	 *  Show payments table
 	 *
-     *  @param	TCPDF		$pdf           Object PDF
-     *  @param  Object		$object         Object proposal
-     *  @param  int			$posy           Position y in PDF
-     *  @param  Translate	$outputlangs    Object langs for output
-     *  @return int             			<0 if KO, >0 if OK
+	 *  @param	TCPDF		$pdf           Object PDF
+	 *  @param  Object		$object         Object proposal
+	 *  @param  int			$posy           Position y in PDF
+	 *  @param  Translate	$outputlangs    Object langs for output
+	 *  @return int             			<0 if KO, >0 if OK
 	 */
 	protected function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
 	{
@@ -992,10 +992,10 @@ class pdf_cyan extends ModelePDFPropales
 
 		$posxval = 52;
 
-        // Show shipping date
-        if (!empty($object->date_livraison))
+		// Show shipping date
+		if (!empty($object->date_livraison))
 		{
-            $outputlangs->load("sendings");
+			$outputlangs->load("sendings");
 			$pdf->SetFont('', 'B', $default_font_size - 2);
 			$pdf->SetXY($this->marge_gauche, $posy);
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@@ -1005,7 +1005,7 @@ class pdf_cyan extends ModelePDFPropales
 			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
 
-            $posy = $pdf->GetY() + 1;
+			$posy = $pdf->GetY() + 1;
 		} elseif ($object->availability_code || $object->availability)    // Show availability conditions
 		{
 			$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1092,13 +1092,13 @@ class pdf_cyan extends ModelePDFPropales
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
 					{
@@ -1107,13 +1107,13 @@ class pdf_cyan extends ModelePDFPropales
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 				}
 			}
@@ -1234,7 +1234,7 @@ class pdf_cyan extends ModelePDFPropales
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1328,7 +1328,7 @@ class pdf_cyan extends ModelePDFPropales
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1338,7 +1338,7 @@ class pdf_cyan extends ModelePDFPropales
 
 					foreach ($localtax_rate as $tvakey => $tvaval)
 					{
-					    // retrieve global local tax
+						// retrieve global local tax
 						if ($tvakey != 0)    // On affiche pas taux 0
 						{
 							//$this->atleastoneratenotnull++;
@@ -1478,7 +1478,7 @@ class pdf_cyan extends ModelePDFPropales
 		$this->pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
 
 		if (empty($hidetop)) {
-		    $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
+			$pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight); // line takes a position y in 2nd parameter and 4th parameter
 		}
 	}
 
@@ -1506,7 +1506,7 @@ class pdf_cyan extends ModelePDFPropales
 		//  Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
 		{
-            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
 		}
 
 		$pdf->SetTextColor(0, 0, 60);
@@ -1532,8 +1532,8 @@ class pdf_cyan extends ModelePDFPropales
 				}
 				if (is_readable($logo))
 				{
-				    $height = pdf_getHeightForLogo($logo);
-				    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+					$height = pdf_getHeightForLogo($logo);
+					$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 				} else {
 					$pdf->SetTextColor(200, 0, 0);
 					$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1615,16 +1615,16 @@ class pdf_cyan extends ModelePDFPropales
 		// Get contact
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 		{
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $usertmp = new User($this->db);
-		        $usertmp->fetch($arrayidcontact[0]);
-                $posy += 4;
-                $pdf->SetXY($posx, $posy);
-		        $pdf->SetTextColor(0, 0, 60);
-		        $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
-		    }
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$usertmp = new User($this->db);
+				$usertmp->fetch($arrayidcontact[0]);
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
+			}
 		}
 
 		$posy += 2;
@@ -1736,7 +1736,7 @@ class pdf_cyan extends ModelePDFPropales
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output
@@ -1796,23 +1796,23 @@ class pdf_cyan extends ModelePDFPropales
 	 *      @param	int				$hideref		Do not show ref
 	 *      @return	null
 	 */
-    public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
-    {
-	    global $conf, $hookmanager;
-
-	    // Default field style for content
-	    $this->defaultContentsFieldsStyle = array(
-	        'align' => 'R', // R,C,L
-	        'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	    );
-
-	    // Default field style for content
-	    $this->defaultTitlesFieldsStyle = array(
-	        'align' => 'C', // R,C,L
-	        'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	    );
-
-	    /*
+	public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	{
+		global $conf, $hookmanager;
+
+		// Default field style for content
+		$this->defaultContentsFieldsStyle = array(
+			'align' => 'R', // R,C,L
+			'padding' => array(1, 0.5, 1, 0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+		);
+
+		// Default field style for content
+		$this->defaultTitlesFieldsStyle = array(
+			'align' => 'C', // R,C,L
+			'padding' => array(0.5, 0, 0.5, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+		);
+
+		/*
 	     * For exemple
 	     $this->cols['theColKey'] = array(
 	     'rank' => $rank, // int : use for ordering columns
@@ -1830,145 +1830,145 @@ class pdf_cyan extends ModelePDFPropales
 	     );
 	     */
 
-	    $rank = 0; // do not use negative rank
-	    $this->cols['desc'] = array(
-	        'rank' => $rank,
-	        'width' => false, // only for desc
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'Designation', // use lang key is usefull in somme case with module
-	            'align' => 'L',
-	            // 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
-	            // 'label' => ' ', // the final label
-	            'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	        'content' => array(
-	            'align' => 'L',
-                'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['photo'] = array(
-	        'rank' => $rank,
-	        'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
-	        'status' => false,
-	        'title' => array(
-	            'textkey' => 'Photo',
-	            'label' => ' '
-	        ),
-	        'content' => array(
-	            'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
-	        ),
-	        'border-left' => false, // remove left line separator
-	    );
-
-	    if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
-	    {
-	        $this->cols['photo']['status'] = true;
-	    }
-
-
-	    $rank = $rank + 10;
-	    $this->cols['vat'] = array(
-	        'rank' => $rank,
-	        'status' => false,
-	        'width' => 16, // in mm
-	        'title' => array(
-	            'textkey' => 'VAT'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-	    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
-	    {
-	        $this->cols['vat']['status'] = true;
-	    }
-
-	    $rank = $rank + 10;
-	    $this->cols['subprice'] = array(
-	        'rank' => $rank,
-	        'width' => 19, // in mm
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'PriceUHT'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['qty'] = array(
-	        'rank' => $rank,
-	        'width' => 16, // in mm
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'Qty'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-	    $rank = $rank + 10;
-	    $this->cols['unit'] = array(
-	        'rank' => $rank,
-	        'width' => 11, // in mm
-	        'status' => false,
-	        'title' => array(
-	            'textkey' => 'Unit'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-	    if ($conf->global->PRODUCT_USE_UNITS) {
-	        $this->cols['unit']['status'] = true;
-	    }
-
-	    $rank = $rank + 10;
-	    $this->cols['discount'] = array(
-	        'rank' => $rank,
-	        'width' => 13, // in mm
-	        'status' => false,
-	        'title' => array(
-	            'textkey' => 'ReductionShort'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-	    if ($this->atleastonediscount) {
-	        $this->cols['discount']['status'] = true;
-	    }
-
-	    $rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
-	    $this->cols['totalexcltax'] = array(
-	        'rank' => $rank,
-	        'width' => 26, // in mm
-	        'status' => true,
-	        'title' => array(
-	            'textkey' => 'TotalHT'
-	        ),
-	        'border-left' => true, // add left line separator
-	    );
-
-        // Add extrafields cols
-        if (!empty($object->lines)) {
-            $line = reset($object->lines);
-            $this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
-        }
-
-	    $parameters = array(
-	        'object' => $object,
-	        'outputlangs' => $outputlangs,
-	        'hidedetails' => $hidedetails,
-	        'hidedesc' => $hidedesc,
-	        'hideref' => $hideref
-	    );
-
-	    $reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
-	    if ($reshook < 0)
-	    {
-	        setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
-	    } elseif (empty($reshook))
-	    {
-	        $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
-	    } else {
-	        $this->cols = $hookmanager->resArray;
-	    }
+		$rank = 0; // do not use negative rank
+		$this->cols['desc'] = array(
+			'rank' => $rank,
+			'width' => false, // only for desc
+			'status' => true,
+			'title' => array(
+				'textkey' => 'Designation', // use lang key is usefull in somme case with module
+				'align' => 'L',
+				// 'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
+				// 'label' => ' ', // the final label
+				'padding' => array(0.5, 1, 0.5, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+			'content' => array(
+				'align' => 'L',
+				'padding' => array(1, 0.5, 1, 1.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+		);
+
+		$rank = $rank + 10;
+		$this->cols['photo'] = array(
+			'rank' => $rank,
+			'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH), // in mm
+			'status' => false,
+			'title' => array(
+				'textkey' => 'Photo',
+				'label' => ' '
+			),
+			'content' => array(
+				'padding' => array(0, 0, 0, 0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
+			),
+			'border-left' => false, // remove left line separator
+		);
+
+		if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
+		{
+			$this->cols['photo']['status'] = true;
+		}
+
+
+		$rank = $rank + 10;
+		$this->cols['vat'] = array(
+			'rank' => $rank,
+			'status' => false,
+			'width' => 16, // in mm
+			'title' => array(
+				'textkey' => 'VAT'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
+		{
+			$this->cols['vat']['status'] = true;
+		}
+
+		$rank = $rank + 10;
+		$this->cols['subprice'] = array(
+			'rank' => $rank,
+			'width' => 19, // in mm
+			'status' => true,
+			'title' => array(
+				'textkey' => 'PriceUHT'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		$rank = $rank + 10;
+		$this->cols['qty'] = array(
+			'rank' => $rank,
+			'width' => 16, // in mm
+			'status' => true,
+			'title' => array(
+				'textkey' => 'Qty'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		$rank = $rank + 10;
+		$this->cols['unit'] = array(
+			'rank' => $rank,
+			'width' => 11, // in mm
+			'status' => false,
+			'title' => array(
+				'textkey' => 'Unit'
+			),
+			'border-left' => true, // add left line separator
+		);
+		if ($conf->global->PRODUCT_USE_UNITS) {
+			$this->cols['unit']['status'] = true;
+		}
+
+		$rank = $rank + 10;
+		$this->cols['discount'] = array(
+			'rank' => $rank,
+			'width' => 13, // in mm
+			'status' => false,
+			'title' => array(
+				'textkey' => 'ReductionShort'
+			),
+			'border-left' => true, // add left line separator
+		);
+		if ($this->atleastonediscount) {
+			$this->cols['discount']['status'] = true;
+		}
+
+		$rank = $rank + 1000; // add a big offset to be sure is the last col because default extrafield rank is 100
+		$this->cols['totalexcltax'] = array(
+			'rank' => $rank,
+			'width' => 26, // in mm
+			'status' => true,
+			'title' => array(
+				'textkey' => 'TotalHT'
+			),
+			'border-left' => true, // add left line separator
+		);
+
+		// Add extrafields cols
+		if (!empty($object->lines)) {
+			$line = reset($object->lines);
+			$this->defineColumnExtrafield($line, $outputlangs, $hidedetails);
+		}
+
+		$parameters = array(
+			'object' => $object,
+			'outputlangs' => $outputlangs,
+			'hidedetails' => $hidedetails,
+			'hidedesc' => $hidedesc,
+			'hideref' => $hideref
+		);
+
+		$reshook = $hookmanager->executeHooks('defineColumnField', $parameters, $this); // Note that $object may have been modified by hook
+		if ($reshook < 0)
+		{
+			setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+		} elseif (empty($reshook))
+		{
+			$this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys
+		} else {
+			$this->cols = $hookmanager->resArray;
+		}
 	}
 }

+ 110 - 110
htdocs/core/modules/reception/doc/pdf_squille.modules.php

@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_squille extends ModelePdfReception
 {
-    public $emetteur; // Objet societe qui emet
+	public $emetteur; // Objet societe qui emet
 
 
 	/**
@@ -83,17 +83,17 @@ class pdf_squille extends ModelePdfReception
 
 		if ($this->page_largeur < 210) // To work with US executive format
 		{
-		    $this->posxweightvol -= 20;
-		    $this->posxpicture -= 20;
-		    $this->posxqtyordered -= 20;
-		    $this->posxqtytoship -= 20;
+			$this->posxweightvol -= 20;
+			$this->posxpicture -= 20;
+			$this->posxqtyordered -= 20;
+			$this->posxqtytoship -= 20;
 		}
 
 		if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
 		{
-		    $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
-		    $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
-		    $this->posxqtyordered = $this->posxqtytoship;
+			$this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
+			$this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
+			$this->posxqtyordered = $this->posxqtytoship;
 		}
 	}
 
@@ -103,11 +103,11 @@ class pdf_squille extends ModelePdfReception
 	 *
 	 *	@param		Object		$object			Object reception to generate (or id if old method)
 	 *	@param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int         	    			1=OK, 0=KO
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int         	    			1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
@@ -124,15 +124,15 @@ class pdf_squille extends ModelePdfReception
 
 		$nblines = count($object->lines);
 
-        // Loop on each lines to detect if there is at least one image to show
-        $realpatharray = array();
-        if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
-        {
-            $objphoto = new Product($this->db);
+		// Loop on each lines to detect if there is at least one image to show
+		$realpatharray = array();
+		if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE))
+		{
+			$objphoto = new Product($this->db);
 
-            for ($i = 0; $i < $nblines; $i++)
-            {
-                if (empty($object->lines[$i]->fk_product)) continue;
+			for ($i = 0; $i < $nblines; $i++)
+			{
+				if (empty($object->lines[$i]->fk_product)) continue;
 
 				$objphoto = new Product($this->db);
 				$objphoto->fetch($object->lines[$i]->fk_product);
@@ -142,28 +142,28 @@ class pdf_squille extends ModelePdfReception
 
 				$realpath = '';
 
-                foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
-                    if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
-                        // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
-                        if ($obj['photo_vignette'])
-                        {
-                            $filename = $obj['photo_vignette'];
-                        } else {
-                            $filename = $obj['photo'];
-                        }
-                    } else {
-                        $filename = $obj['photo'];
-                    }
-
-                    $realpath = $dir.$filename;
-                    break;
-                }
-
-                if ($realpath) $realpatharray[$i] = $realpath;
-            }
-        }
-
-        if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
+				foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
+					if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
+						// If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
+						if ($obj['photo_vignette'])
+						{
+							$filename = $obj['photo_vignette'];
+						} else {
+							$filename = $obj['photo'];
+						}
+					} else {
+						$filename = $obj['photo'];
+					}
+
+					$realpath = $dir.$filename;
+					break;
+				}
+
+				if ($realpath) $realpatharray[$i] = $realpath;
+			}
+		}
+
+		if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
 
 		if ($conf->reception->dir_output)
 		{
@@ -206,22 +206,22 @@ class pdf_squille extends ModelePdfReception
 				$pdf = pdf_getInstance($this->format);
 				$default_font_size = pdf_getPDFFontSize($outputlangs);
 				$heightforinfotot = 8; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -458,12 +458,12 @@ class pdf_squille extends ModelePdfReception
 					//$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 3, $weighttxt.(($weighttxt && $voltxt)?'<br>':'').$voltxt,'','C');
 
 					if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
-					    $pdf->SetXY($this->posxqtyordered, $curY);
-					    if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
-						    $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
-						    $totalOrdered += $object->lines[$i]->qty_asked;
-					    }
-					    $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
+						$pdf->SetXY($this->posxqtyordered, $curY);
+						if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
+							$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked, '', 'C');
+							$totalOrdered += $object->lines[$i]->qty_asked;
+						}
+						$fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
 					}
 
 					$pdf->SetXY($this->posxqtytoship, $curY);
@@ -550,8 +550,8 @@ class pdf_squille extends ModelePdfReception
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -586,9 +586,9 @@ class pdf_squille extends ModelePdfReception
 		// phpcs:enable
 		global $conf, $mysoc;
 
-        $sign = 1;
+		$sign = 1;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$tab2_top = $posy;
 		$tab2_hl = 4;
@@ -619,8 +619,8 @@ class pdf_squille extends ModelePdfReception
 		// Set trueVolume and volume_units not currently stored into database
 		if ($object->trueWidth && $object->trueHeight && $object->trueDepth)
 		{
-		    $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
-		    $object->volume_units = $object->size_units * 3;
+			$object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
+			$object->volume_units = $object->size_units * 3;
 		}
 
 		if ($totalWeight != '') $totalWeighttoshow = showDimensionInBestUnit($totalWeight, 0, "weight", $outputlangs);
@@ -628,41 +628,41 @@ class pdf_squille extends ModelePdfReception
 		if ($object->trueWeight) $totalWeighttoshow = showDimensionInBestUnit($object->trueWeight, $object->weight_units, "weight", $outputlangs);
 		if ($object->trueVolume) $totalVolumetoshow = showDimensionInBestUnit($object->trueVolume, $object->volume_units, "volume", $outputlangs);
 
-    	$pdf->SetFillColor(255, 255, 255);
-    	$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
-    	$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
+		$pdf->SetFillColor(255, 255, 255);
+		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("Total"), 0, 'L', 1);
 
-        if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
-        {
-            $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
-        	$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
-        }
+		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
+		{
+			$pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0, 'C', 1);
+		}
 
-    	$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
-    	$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
+		$pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
+		$pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0, 'C', 1);
 
 		if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
-	    	$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
-	    	$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
+			$pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl, '', 0, 'C', 1);
 
-	    	$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
-	    	$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
+			$pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl, price($object->total_ht, 0, $outputlangs), 0, 'C', 1);
 		}
 
 		// Total Weight
 		if ($totalWeighttoshow)
 		{
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
+			$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0, 'C', 1);
 
-    		$index++;
+			$index++;
 		}
 		if ($totalVolumetoshow)
 		{
-    		$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
-    		$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
+			$pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
+			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0, 'C', 1);
 
-		    $index++;
+			$index++;
 		}
 		if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
 
@@ -719,15 +719,15 @@ class pdf_squille extends ModelePdfReception
 			$pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities("WeightVolShort"), '', 'C');
 		}
 
-        if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
-        {
-            $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
-    		if (empty($hidetop))
-    		{
-    			$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
-    			$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
-    		}
-        }
+		if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED))
+		{
+			$pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
+			if (empty($hidetop))
+			{
+				$pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
+				$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"), '', 'C');
+			}
+		}
 
 		$pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
@@ -776,7 +776,7 @@ class pdf_squille extends ModelePdfReception
 		// Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK)))
 		{
-            		pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
+					pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->RECEPTION_DRAFT_WATERMARK);
 		}
 
 		//Prepare la suite
@@ -796,8 +796,8 @@ class pdf_squille extends ModelePdfReception
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -853,10 +853,10 @@ class pdf_squille extends ModelePdfReception
 		// Date planned delivery
 		if (!empty($object->date_delivery))
 		{
-    			$posy += 4;
-    			$pdf->SetXY($posx, $posy);
-    			$pdf->SetTextColor(0, 0, 60);
-    			$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell($w, 4, $outputlangs->transnoentities("DateDeliveryPlanned")." : ".dol_print_date($object->date_delivery, "day", false, $outputlangs, true), '', 'R');
 		}
 
 		if (!empty($object->thirdparty->code_fournisseur))
@@ -875,7 +875,7 @@ class pdf_squille extends ModelePdfReception
 		$origin = $object->origin;
 		$origin_id = $object->origin_id;
 
-	    // TODO move to external function
+		// TODO move to external function
 		if (!empty($conf->fournisseur->enabled))     // commonly $origin='commande'
 		{
 			$outputlangs->load('orders');
@@ -885,7 +885,7 @@ class pdf_squille extends ModelePdfReception
 			$result = $linkedobject->fetch($origin_id);
 			if ($result >= 0)
 			{
-			    //$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
+				//$linkedobject->fetchObjectLinked()   Get all linked object to the $linkedobject (commonly order) into $linkedobject->linkedObjects
 
 				$pdf->SetFont('', '', $default_font_size - 2);
 				$text = $linkedobject->ref;
@@ -1002,7 +1002,7 @@ class pdf_squille extends ModelePdfReception
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	Object		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 29 - 29
htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php

@@ -44,14 +44,14 @@ class doc_generic_stock_odt extends ModelePDFStock
 	public $emetteur;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * @var string Dolibarr version of the loaded document
-     */
+	 * @var string Dolibarr version of the loaded document
+	 */
 	public $version = 'dolibarr';
 
 
@@ -65,7 +65,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 		global $conf, $langs, $mysoc;
 
 		// Load translation files required by the page
-        $langs->loadLangs(array("main", "companies"));
+		$langs->loadLangs(array("main", "companies"));
 
 		$this->db = $db;
 		$this->name = "ODT templates";
@@ -110,7 +110,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 		global $conf, $langs;
 
 		// Load translation files required by the page
-        $langs->loadLangs(array("errors", "companies"));
+		$langs->loadLangs(array("errors", "companies"));
 
 		$form = new Form($this->db);
 
@@ -192,7 +192,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 		return $texte;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Function to build a document on disk using the generic odt module.
 	 *
@@ -206,7 +206,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $stock, $langs, $conf, $mysoc, $hookmanager, $user;
 
 		if (empty($srctemplatepath))
@@ -278,8 +278,8 @@ class doc_generic_stock_odt extends ModelePDFStock
 				$newfileformat = substr($newfile, strrpos($newfile, '.') + 1);
 				if (!empty($conf->global->MAIN_DOC_USE_TIMING))
 				{
-				    $format = $conf->global->MAIN_DOC_USE_TIMING;
-				    if ($format == '1') $format = '%Y%m%d%H%M%S';
+					$format = $conf->global->MAIN_DOC_USE_TIMING;
+					if ($format == '1') $format = '%Y%m%d%H%M%S';
 					$filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat;
 				} else {
 					$filename = $newfiletmp.'.'.$newfileformat;
@@ -308,12 +308,12 @@ class doc_generic_stock_odt extends ModelePDFStock
 				{
 					// On peut utiliser le nom de la societe du contact
 					if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) {
-                        $socobject = $object->contact;
-                    } else {
-                        $socobject = $object->thirdparty;
-                        // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
-                        $contactobject = $object->contact;
-                    }
+						$socobject = $object->contact;
+					} else {
+						$socobject = $object->thirdparty;
+						// if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use
+						$contactobject = $object->contact;
+					}
 				} else {
 					$socobject = $object->thirdparty;
 				}
@@ -341,13 +341,13 @@ class doc_generic_stock_odt extends ModelePDFStock
 				// Open and load template
 				require_once ODTPHP_PATH.'odf.php';
 				try {
-                    $odfHandler = new odf(
-                        $srctemplatepath,
-					    array(
-						    'PATH_TO_TMP'	  => $conf->product->dir_temp,
-						    'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
-						    'DELIMITER_LEFT'  => '{',
-						    'DELIMITER_RIGHT' => '}'
+					$odfHandler = new odf(
+						$srctemplatepath,
+						array(
+							'PATH_TO_TMP'	  => $conf->product->dir_temp,
+							'ZIP_PROXY'		  => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
+							'DELIMITER_LEFT'  => '{',
+							'DELIMITER_RIGHT' => '}'
 						)
 					);
 				} catch (Exception $e)
@@ -404,7 +404,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 						}
 					} catch (OdfException $e)
 					{
-                        dol_syslog($e->getMessage(), LOG_INFO);
+						dol_syslog($e->getMessage(), LOG_INFO);
 					}
 				}
 				// Replace tags of lines
@@ -449,7 +449,7 @@ class doc_generic_stock_odt extends ModelePDFStock
 						$odfHandler->setVars($key, $value, true, 'UTF-8');
 					} catch (OdfException $e)
 					{
-                        dol_syslog($e->getMessage(), LOG_INFO);
+						dol_syslog($e->getMessage(), LOG_INFO);
 					}
 				}
 
@@ -463,15 +463,15 @@ class doc_generic_stock_odt extends ModelePDFStock
 						$odfHandler->exportAsAttachedPDF($file);
 					} catch (Exception $e) {
 						$this->error = $e->getMessage();
-                        dol_syslog($e->getMessage(), LOG_INFO);
+						dol_syslog($e->getMessage(), LOG_INFO);
 						return -1;
 					}
 				} else {
 					try {
-					    $odfHandler->saveToDisk($file);
+						$odfHandler->saveToDisk($file);
 					} catch (Exception $e) {
 						$this->error = $e->getMessage();
-                        dol_syslog($e->getMessage(), LOG_INFO);
+						dol_syslog($e->getMessage(), LOG_INFO);
 						return -1;
 					}
 				}

+ 185 - 185
htdocs/core/modules/stock/doc/pdf_standard.modules.php

@@ -36,74 +36,74 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_standard extends ModelePDFStock
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var string document type
-     */
-    public $type;
+	/**
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
-    /**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	/**
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
-    /**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	/**
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
-    /**
-     * @var array format
-     */
-    public $format;
+	/**
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
-    /**
+	/**
 	 * Issuer
 	 * @var Societe
 	 */
@@ -177,7 +177,7 @@ class pdf_standard extends ModelePDFStock
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Function to build a document on disk using the generic odt module.
 	 *
@@ -191,7 +191,7 @@ class pdf_standard extends ModelePDFStock
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -205,7 +205,7 @@ class pdf_standard extends ModelePDFStock
 
 		if ($conf->stock->dir_output)
 		{
-		    // Definition of $dir and $file
+			// Definition of $dir and $file
 			if ($object->specimen)
 			{
 				$dir = $conf->stock->dir_output;
@@ -250,21 +250,21 @@ class pdf_standard extends ModelePDFStock
 				$pdf->SetAutoPageBreak(1, 0);
 
 				$heightforinfotot = 40; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -611,8 +611,8 @@ class pdf_standard extends ModelePDFStock
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -647,34 +647,34 @@ class pdf_standard extends ModelePDFStock
 	 */
 	protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
 	{
-	    global $conf;
+		global $conf;
 
-	    // Force to disable hidetop and hidebottom
-	    $hidebottom = 0;
-	    if ($hidetop) $hidetop = -1;
+		// Force to disable hidetop and hidebottom
+		$hidebottom = 0;
+		if ($hidetop) $hidetop = -1;
 
-	    $currency = !empty($currency) ? $currency : $conf->currency;
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$currency = !empty($currency) ? $currency : $conf->currency;
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-	    // Amount in (at tab_top - 1)
-	    $pdf->SetTextColor(0, 0, 0);
-	    $pdf->SetFont('', '', $default_font_size - 2);
+		// Amount in (at tab_top - 1)
+		$pdf->SetTextColor(0, 0, 0);
+		$pdf->SetFont('', '', $default_font_size - 2);
 
-	    if (empty($hidetop))
-	    {
-	        $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
-	        $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
-	        $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+		if (empty($hidetop))
+		{
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
+			$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
+			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
 
-	        //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
-	        if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
-	    }
+			//$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
+		}
 
-	    $pdf->SetDrawColor(128, 128, 128);
-	    $pdf->SetFont('', 'B', $default_font_size - 3);
+		$pdf->SetDrawColor(128, 128, 128);
+		$pdf->SetFont('', 'B', $default_font_size - 3);
 
-	    // Output Rect
-	    //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect takes a length in 3rd parameter and 4th parameter
+		// Output Rect
+		//$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom);	// Rect takes a length in 3rd parameter and 4th parameter
 
 		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200)));
 		$pdf->SetDrawColor(200, 200, 200);
@@ -683,12 +683,12 @@ class pdf_standard extends ModelePDFStock
 		$pdf->SetDrawColor(128, 128, 128);
 		$pdf->SetTextColor(0, 0, 120);
 
-	    if (empty($hidetop))
-	    {
-	        //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line takes a position y in 2nd parameter and 4th parameter
-	        $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
-	        $pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L');
-	    }
+		if (empty($hidetop))
+		{
+			//$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);	// line takes a position y in 2nd parameter and 4th parameter
+			$pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
+			$pdf->MultiCell($this->wref, 3, $outputlangs->transnoentities("Ref"), '', 'L');
+		}
 
 		//$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
 		if (empty($hidetop))
@@ -697,40 +697,40 @@ class pdf_standard extends ModelePDFStock
 			$pdf->MultiCell($this->posxqty - $this->posxlabel - 1, 2, $outputlangs->transnoentities("Label"), '', 'L');
 		}
 
-	    //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
-	        $pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities("Units"), '', 'R');
-	    }
-
-	    //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->posxup - 1, $tab_top + 1);
+		//$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+			$pdf->MultiCell($this->posxup - $this->posxqty - 1, 2, $outputlangs->transnoentities("Units"), '', 'R');
+		}
+
+		//$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->posxup - 1, $tab_top + 1);
 			$pdf->MultiCell($this->posxunit - $this->posxup - 1, 2, $outputlangs->transnoentities("AverageUnitPricePMPShort"), '', 'R');
-	    }
+		}
 
 		//$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
 			$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
-            $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'R');
+			$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("EstimatedStockValueShort"), '', 'R');
 		}
 
-	    //$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
+		//$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
 			$pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
 			$pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("SellPriceMin"), '', 'R');
-	    }
+		}
 
-	    //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
-	    if (empty($hidetop))
-	    {
-	        $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
-	        $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R');
-	    }
+		//$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
+		if (empty($hidetop))
+		{
+			$pdf->SetXY($this->postotalht - 1, $tab_top + 1);
+			$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("EstimatedStockValueSellShort"), '', 'R');
+		}
 
 		$pdf->SetDrawColor(200, 200, 200);
 		$pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(200, 200, 200)));
@@ -751,70 +751,70 @@ class pdf_standard extends ModelePDFStock
 	 */
 	protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
 	{
-	    global $conf, $langs, $db, $hookmanager;
+		global $conf, $langs, $db, $hookmanager;
 
-	    // Load traductions files required by page
+		// Load traductions files required by page
 		$outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
 
-	    $default_font_size = pdf_getPDFFontSize($outputlangs);
-
-	    if ($object->type == 1) $titlekey = 'ServiceSheet';
-	    else $titlekey = 'StockSheet';
-
-	    pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
-
-	    // Show Draft Watermark
-	    if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
-	    {
-	        pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
-	    }
-
-	    $pdf->SetTextColor(0, 0, 60);
-	    $pdf->SetFont('', 'B', $default_font_size + 3);
-
-	    $posy = $this->marge_haute;
-	    $posx = $this->page_largeur - $this->marge_droite - 100;
-
-	    $pdf->SetXY($this->marge_gauche, $posy);
-
-	    // Logo
-	    $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
-	    if ($this->emetteur->logo)
-	    {
-	        if (is_readable($logo))
-	        {
-	            $height = pdf_getHeightForLogo($logo);
-	            $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
-	        } else {
-	            $pdf->SetTextColor(200, 0, 0);
-	            $pdf->SetFont('', 'B', $default_font_size - 2);
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
-	            $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
-	        }
-	    } else {
-	        $text = $this->emetteur->name;
-	        $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
-	    }
-
-	    $pdf->SetFont('', 'B', $default_font_size + 3);
-	    $pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
-	    $title = $outputlangs->transnoentities("Warehouse");
-	    $pdf->MultiCell(100, 3, $title, '', 'R');
-
-	    $pdf->SetFont('', 'B', $default_font_size);
-
-	    $posy += 5;
-	    $pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
-
-	    $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
-
-	    $posy += 5;
-	    $pdf->SetFont('', '', $default_font_size - 1);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
+
+		if ($object->type == 1) $titlekey = 'ServiceSheet';
+		else $titlekey = 'StockSheet';
+
+		pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
+
+		// Show Draft Watermark
+		if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
+		{
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
+		}
+
+		$pdf->SetTextColor(0, 0, 60);
+		$pdf->SetFont('', 'B', $default_font_size + 3);
+
+		$posy = $this->marge_haute;
+		$posx = $this->page_largeur - $this->marge_droite - 100;
+
+		$pdf->SetXY($this->marge_gauche, $posy);
+
+		// Logo
+		$logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
+		if ($this->emetteur->logo)
+		{
+			if (is_readable($logo))
+			{
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+			} else {
+				$pdf->SetTextColor(200, 0, 0);
+				$pdf->SetFont('', 'B', $default_font_size - 2);
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
+			}
+		} else {
+			$text = $this->emetteur->name;
+			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
+		}
+
+		$pdf->SetFont('', 'B', $default_font_size + 3);
+		$pdf->SetXY($posx, $posy);
+		$pdf->SetTextColor(0, 0, 60);
+		$title = $outputlangs->transnoentities("Warehouse");
+		$pdf->MultiCell(100, 3, $title, '', 'R');
+
+		$pdf->SetFont('', 'B', $default_font_size);
+
+		$posy += 5;
 		$pdf->SetXY($posx, $posy);
-	    $pdf->SetTextColor(0, 0, 60);
-	    $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
+		$pdf->SetTextColor(0, 0, 60);
+
+		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
+
+		$posy += 5;
+		$pdf->SetFont('', '', $default_font_size - 1);
+		$pdf->SetXY($posx, $posy);
+		$pdf->SetTextColor(0, 0, 60);
+		$pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
 
 		$posy += 4;
 		$pdf->SetXY($posx - 50, $posy);
@@ -883,20 +883,20 @@ class pdf_standard extends ModelePDFStock
 		$pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
 		$nexY = $pdf->GetY();
 
-	    $posy += 2;
+		$posy += 2;
 
-	    $top_shift = 0;
-	    // Show list of linked objects
-	    $current_y = $pdf->getY();
-	    $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
-	    if ($current_y < $pdf->getY())
-	    {
-	    	$top_shift = $pdf->getY() - $current_y;
-	    }
+		$top_shift = 0;
+		// Show list of linked objects
+		$current_y = $pdf->getY();
+		$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
+		if ($current_y < $pdf->getY())
+		{
+			$top_shift = $pdf->getY() - $current_y;
+		}
 
-	    $pdf->SetTextColor(0, 0, 0);
+		$pdf->SetTextColor(0, 0, 0);
 
-	    return $top_shift;
+		return $top_shift;
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
@@ -911,8 +911,8 @@ class pdf_standard extends ModelePDFStock
 	 */
 	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
 	{
-	    global $conf;
-	    $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
-	    return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+		global $conf;
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+		return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
 	}
 }

+ 155 - 155
htdocs/core/modules/supplier_invoice/doc/pdf_canelle.modules.php

@@ -38,76 +38,76 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_canelle extends ModelePDFSuppliersInvoices
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var int 	Save the name of generated file as the main doc when generating a doc with this template
-     */
-    public $update_main_doc_field;
+	/**
+	 * @var int 	Save the name of generated file as the main doc when generating a doc with this template
+	 */
+	public $update_main_doc_field;
 
 	/**
-     * @var string document type
-     */
-    public $type;
-
-    /**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var string document type
+	 */
+	public $type;
+
+	/**
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -123,8 +123,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	 *
 	 *  @param	DoliDB		$db     	Database handler
 	 */
-    public function __construct($db)
-    {
+	public function __construct($db)
+	{
 		global $conf, $langs, $mysoc;
 
 		// Translations
@@ -152,7 +152,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$this->option_codeproduitservice = 1; // Affiche code produit-service
 		$this->option_multilang = 1; // Dispo en plusieurs langues
 
-        // Define column position
+		// Define column position
 		$this->posxdesc = $this->marge_gauche + 1;
 		$this->posxtva = 112;
 		$this->posxup = 126;
@@ -181,28 +181,28 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		}
 
 		$this->tva = array();
-        $this->localtax1 = array();
-        $this->localtax2 = array();
+		$this->localtax1 = array();
+		$this->localtax2 = array();
 		$this->atleastoneratenotnull = 0;
 		$this->atleastonediscount = 0;
-    }
+	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
-     *  Function to build pdf onto disk
-     *
-     *  @param		FactureFournisseur	$object				Object to generate
-     *  @param		Translate			$outputlangs		Lang output object
-     *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int					$hidedetails		Do not show line details
-     *  @param		int					$hidedesc			Do not show desc
-     *  @param		int					$hideref			Do not show ref
-     *  @return		int										1=OK, 0=KO
-     */
-    public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
-    {
-        // phpcs:enable
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		FactureFournisseur	$object				Object to generate
+	 *  @param		Translate			$outputlangs		Lang output object
+	 *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int					$hidedetails		Do not show line details
+	 *  @param		int					$hidedesc			Do not show desc
+	 *  @param		int					$hideref			Do not show ref
+	 *  @return		int										1=OK, 0=KO
+	 */
+	public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	{
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $hookmanager, $nblines;
 
 		// Get source company
@@ -236,7 +236,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			} else {
 				$objectref = dol_sanitizeFileName($object->ref);
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
-                $dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref;
+				$dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id, 2, 0, 0, $object, 'invoice_supplier').$objectref;
 				$file = $dir."/".$objectref.".pdf";
 				if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
 			}
@@ -268,27 +268,27 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$nbpayments = count($object->getListOfPayments());
 
 				// Create pdf instance
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $pdf->SetAutoPageBreak(1, 0);
-
-                $heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                	$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$pdf->SetAutoPageBreak(1, 0);
+
+				$heightforinfotot = 50 + (4 * $nbpayments); // Height reserved to output the info and total part and payment part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -304,26 +304,26 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
 
 				// Set $this->atleastonediscount if you have at least one discount
-                for ($i = 0; $i < $nblines; $i++)
-                {
-                    if ($object->lines[$i]->remise_percent)
-                    {
-                        $this->atleastonediscount++;
-                    }
-                }
+				for ($i = 0; $i < $nblines; $i++)
+				{
+					if ($object->lines[$i]->remise_percent)
+					{
+						$this->atleastonediscount++;
+					}
+				}
 				if (empty($this->atleastonediscount))
 				{
-				    $delta = ($this->postotalht - $this->posxdiscount);
-				    $this->posxpicture += $delta;
-				    $this->posxtva += $delta;
-				    $this->posxup += $delta;
-				    $this->posxqty += $delta;
-				    $this->posxunit += $delta;
-				    $this->posxdiscount += $delta;
-				    // post of fields after are not modified, stay at same position
+					$delta = ($this->postotalht - $this->posxdiscount);
+					$this->posxpicture += $delta;
+					$this->posxtva += $delta;
+					$this->posxup += $delta;
+					$this->posxqty += $delta;
+					$this->posxunit += $delta;
+					$this->posxdiscount += $delta;
+					// post of fields after are not modified, stay at same position
 				}
 
-                // New page
+				// New page
 				$pdf->AddPage();
 				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 				$pagenb++;
@@ -438,7 +438,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$posYAfterDescription = $pdf->GetY();
 
 					$nexY = $pdf->GetY();
-                    $pageposafter = $pdf->getPage();
+					$pageposafter = $pdf->getPage();
 					$pdf->setPage($pageposbefore);
 					$pdf->setTopMargin($this->marge_haute);
 					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -451,12 +451,12 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					$pdf->SetFont('', '', $default_font_size - 1); // We reposition the default font
 
 					// VAT Rate
-                    if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
-                    {
-    					$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
-                        $pdf->SetXY($this->posxtva, $curY);
-	       				$pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
-                    }
+					if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+					{
+						$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
+						$pdf->SetXY($this->posxtva, $curY);
+		   				$pdf->MultiCell($this->posxup - $this->posxtva - 1, 3, $vat_rate, 0, 'R');
+					}
 
 					// Unit price before discount
 					$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails);
@@ -480,14 +480,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 					if ($object->lines[$i]->remise_percent)
 					{
 						$pdf->SetXY($this->posxdiscount - 2, $curY);
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
 						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R');
 					}
 
 					// Total HT line
 					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails);
-                    $pdf->SetXY($this->postotalht, $curY);
-                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
+					$pdf->SetXY($this->postotalht, $curY);
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
 
 					// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
 					if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
@@ -594,8 +594,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -612,10 +612,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			$this->error = $langs->transnoentities("ErrorConstantNotDefined", "SUPPLIER_OUTPUTDIR");
 			return 0;
 		}
-    }
+	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show total to pay
 	 *
@@ -628,7 +628,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	 */
 	protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 
 		$sign = 1;
@@ -636,7 +636,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-        $tab2_top = $posy;
+		$tab2_top = $posy;
 		$tab2_hl = 4;
 		$pdf->SetFont('', '', $default_font_size - 1);
 
@@ -866,7 +866,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$currency = !empty($currency) ? $currency : $conf->currency;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-        // Amount in (at tab_top - 1)
+		// Amount in (at tab_top - 1)
 		$pdf->SetTextColor(0, 0, 0);
 		$pdf->SetFont('', '', $default_font_size - 2);
 
@@ -895,14 +895,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		}
 
 		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
-        {
-    		$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
+		{
+			$pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
 			if (empty($hidetop))
 			{
-    			$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
-    			$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
 			}
-        }
+		}
 
 		$pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
@@ -947,7 +947,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show payments table
 	 *
@@ -959,7 +959,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	 */
 	protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 
 		$sign = 1;
@@ -1011,10 +1011,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		$resql = $this->db->query($sql);
 		if ($resql)
 		{
-		    $num = $this->db->num_rows($resql);
+			$num = $this->db->num_rows($resql);
 			$i = 0;
 			while ($i < $num) {
-			    $y += 3;
+				$y += 3;
 				$row = $this->db->fetch_object($resql);
 
 				$pdf->SetXY($tab3_posx, $tab3_top + $y);
@@ -1100,11 +1100,11 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 
 		if ($object->ref_supplier)
 		{
-    		$posy += 4;
+			$posy += 4;
 			$pdf->SetFont('', 'B', $default_font_size);
-    		$pdf->SetXY($posx, $posy);
+			$pdf->SetXY($posx, $posy);
 			$pdf->SetTextColor(0, 0, 60);
-    		$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : ".$object->ref_supplier, '', 'R');
+			$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : ".$object->ref_supplier, '', 'R');
 			$posy += 1;
 		}
 
@@ -1115,9 +1115,9 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 			$object->fetch_projet();
 			if (!empty($object->project->ref))
 			{
-        		$posy += 4;
+				$posy += 4;
 				$pdf->SetXY($posx, $posy);
-        		$langs->load("projects");
+				$langs->load("projects");
 				$pdf->SetTextColor(0, 0, 60);
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : ".(empty($object->project->ref) ? '' : $object->projet->ref), '', 'R');
 			}
@@ -1159,16 +1159,16 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 		if ($showaddress)
 		{
 			// Sender properties
-		    $carac_emetteur = '';
-		    // Add internal contact of proposal if defined
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $object->fetch_user($arrayidcontact[0]);
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
-		    }
+			$carac_emetteur = '';
+			// Add internal contact of proposal if defined
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$object->fetch_user($arrayidcontact[0]);
+				$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+			}
 
-		    $carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
+			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
 
 			// Show sender
 			$posy = 42 + $top_shift;
@@ -1251,19 +1251,19 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
-     *  Show footer of page. Need this->emetteur object
-     *
-     *  @param  TCPDF               $pdf                PDF
-     *  @param  FactureFournisseur  $object             Object to show
-     *  @param  Translate           $outputlangs        Object lang for output
-     *  @param  int                 $hidefreetext       1=Hide free text
-     *  @return int                                     Return height of bottom margin including footer text
-     */
-    protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
-    {
-        global $conf;
-        $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
-        return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
-    }
+	/**
+	 *  Show footer of page. Need this->emetteur object
+	 *
+	 *  @param  TCPDF               $pdf                PDF
+	 *  @param  FactureFournisseur  $object             Object to show
+	 *  @param  Translate           $outputlangs        Object lang for output
+	 *  @param  int                 $hidefreetext       1=Hide free text
+	 *  @return int                                     Return height of bottom margin including footer text
+	 */
+	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+	{
+		global $conf;
+		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
+		return pdf_pagefoot($pdf, $outputlangs, 'SUPPLIER_INVOICE_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
+	}
 }

File diff suppressed because it is too large
+ 351 - 351
htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php


+ 136 - 136
htdocs/core/modules/supplier_order/doc/pdf_muscadet.modules.php

@@ -41,71 +41,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
  */
 class pdf_muscadet extends ModelePDFSuppliersOrders
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
-    /**
-     * @var string document type
-     */
-    public $type;
+	/**
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-	  * @var array Minimum version of PHP required by module.
-	  * e.g.: PHP ≥ 5.6 = array(5, 6)
-	  */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -153,7 +153,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		$this->option_freetext = 1; // Support add of a personalised text
 		$this->option_draft_watermark = 1; // Support add of a watermark on drafts
 
-        // Get source company
+		// Get source company
 		$this->emetteur = $mysoc;
 		if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default, if was not defined
 
@@ -189,28 +189,28 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		}
 
 		$this->tva = array();
-        $this->localtax1 = array();
-        $this->localtax2 = array();
-        $this->atleastoneratenotnull = 0;
+		$this->localtax1 = array();
+		$this->localtax2 = array();
+		$this->atleastoneratenotnull = 0;
 		$this->atleastonediscount = 0;
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param		CommandeFournisseur	$object				Id of object to generate
-     *  @param		Translate			$outputlangs		Lang output object
-     *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int					$hidedetails		Do not show line details
-     *  @param		int					$hidedesc			Do not show desc
-     *  @param		int					$hideref			Do not show ref
-     *  @return		int										1=OK, 0=KO
-     */
-    public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		CommandeFournisseur	$object				Id of object to generate
+	 *  @param		Translate			$outputlangs		Lang output object
+	 *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int					$hidedetails		Do not show line details
+	 *  @param		int					$hidedesc			Do not show desc
+	 *  @param		int					$hideref			Do not show ref
+	 *  @return		int										1=OK, 0=KO
+	 */
+	public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -264,7 +264,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 			$amount_credit_notes_included = 0;
 			$amount_deposits_included = 0;
 			//$amount_credit_notes_included = $object->getSumCreditNotesUsed();
-            //$amount_deposits_included = $object->getSumDepositsUsed();
+			//$amount_deposits_included = $object->getSumDepositsUsed();
 
 			// Definition of $dir and $file
 			if ($object->specimen)
@@ -303,26 +303,26 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
 				$nblines = count($object->lines);
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -347,14 +347,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 				}
 				if (empty($this->atleastonediscount))
 				{
-				    $delta = ($this->postotalht - $this->posxdiscount);
-				    $this->posxpicture += $delta;
-				    $this->posxtva += $delta;
-				    $this->posxup += $delta;
-				    $this->posxqty += $delta;
-				    $this->posxunit += $delta;
-				    $this->posxdiscount += $delta;
-				    // post of fields after are not modified, stay at same position
+					$delta = ($this->postotalht - $this->posxdiscount);
+					$this->posxpicture += $delta;
+					$this->posxtva += $delta;
+					$this->posxup += $delta;
+					$this->posxqty += $delta;
+					$this->posxunit += $delta;
+					$this->posxdiscount += $delta;
+					// post of fields after are not modified, stay at same position
 				}
 
 				// New page
@@ -497,7 +497,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 					}
 
 					$nexY = $pdf->GetY();
-                    $pageposafter = $pdf->getPage();
+					$pageposafter = $pdf->getPage();
 					$pdf->setPage($pageposbefore);
 					$pdf->setTopMargin($this->marge_haute);
 					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -539,12 +539,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 					$pdf->SetXY($this->posxdiscount, $curY);
 					if ($object->lines[$i]->remise_percent)
 					{
-					    $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
+						$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails);
 						$pdf->MultiCell($this->postotalht - $this->posxdiscount - 1, 3, $remise_percent, 0, 'R');
 					}
 
 					// Total HT line
-                    $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
+					$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs);
 					$pdf->SetXY($this->postotalht, $curY);
 					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
 
@@ -574,7 +574,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 						$localtax2_type = $localtaxtmp_array[2];
 					}
 
-				    // retrieve global local tax
+					// retrieve global local tax
 					if ($localtax1_type && $localtax1ligne != 0)
 						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -653,7 +653,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 					$posy = $this->_tableau_versements($pdf, $object, $posy, $outputlangs);
 				}
 
-                // Pied de page
+				// Pied de page
 				$this->_pagefoot($pdf, $object, $outputlangs);
 				if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
 
@@ -668,8 +668,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -689,7 +689,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show payments table
 	 *
@@ -701,11 +701,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	 */
 	protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Show miscellaneous information (payment mode, payment term, ...)
 	 *
@@ -736,12 +736,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		if (!empty($object->cond_reglement_code) || $object->cond_reglement_id) {
 			$pdf->SetFont('', 'B', $default_font_size - 2);
 			$pdf->SetXY($this->marge_gauche, $posy);
-			$titre = $outputlangs->transnoentities("PaymentConditions") . ':';
+			$titre = $outputlangs->transnoentities("PaymentConditions").':';
 			$pdf->MultiCell(80, 4, $titre, 0, 'L');
 
 			$pdf->SetFont('', '', $default_font_size - 2);
 			$pdf->SetXY($posxval, $posy);
-			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) != ('PaymentCondition' . $object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition" . $object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_id);
+			$lib_condition_paiement = $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) != ('PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_id);
 			$lib_condition_paiement = str_replace('\n', "\n", $lib_condition_paiement);
 			$pdf->MultiCell(80, 4, $lib_condition_paiement, 0, 'L');
 
@@ -752,12 +752,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		if (!empty($object->mode_reglement_code)) {
 			$pdf->SetFont('', 'B', $default_font_size - 2);
 			$pdf->SetXY($this->marge_gauche, $posy);
-			$titre = $outputlangs->transnoentities("PaymentMode") . ':';
+			$titre = $outputlangs->transnoentities("PaymentMode").':';
 			$pdf->MultiCell(80, 5, $titre, 0, 'L');
 
 			$pdf->SetFont('', '', $default_font_size - 2);
 			$pdf->SetXY($posxval, $posy);
-			$lib_mode_reg = $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) != ('PaymentType' . $object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType" . $object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
+			$lib_mode_reg = $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) != ('PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities("PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
 			$pdf->MultiCell(80, 5, $lib_mode_reg, 0, 'L');
 
 			$posy = $pdf->GetY() + 2;
@@ -767,7 +767,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show total to pay
 	 *
@@ -780,12 +780,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	 */
 	protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-        $tab2_top = $posy;
+		$tab2_top = $posy;
 		$tab2_hl = 4;
 		$pdf->SetFont('', '', $default_font_size - 1);
 
@@ -869,7 +869,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		} else {
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on')
 			//{
-    			//Local tax 1
+				//Local tax 1
 			foreach ($this->localtax1 as $localtax_type => $localtax_rate)
 			{
 				if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
@@ -901,7 +901,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
 			//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 			//{
-    			//Local tax 2
+				//Local tax 2
 			foreach ($this->localtax2 as $localtax_type => $localtax_rate)
 			{
 				if (in_array((string) $localtax_type, array('2', '4', '6'))) continue;
@@ -945,8 +945,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		$pdf->SetFont('', '', $default_font_size - 1);
 		$pdf->SetTextColor(0, 0, 0);
 
-        $creditnoteamount = 0;
-        $depositsamount = 0;
+		$creditnoteamount = 0;
+		$depositsamount = 0;
 		//$creditnoteamount=$object->getSumCreditNotesUsed();
 		//$depositsamount=$object->getSumDepositsUsed();
 		//print "x".$creditnoteamount."-".$depositsamount;exit;
@@ -956,7 +956,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		if ($deja_regle > 0)
 		{
 			// Already paid + Deposits
-		    $index++;
+			$index++;
 
 			$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
 			$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
@@ -981,7 +981,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
+	/**
 	 *   Show table for lines
 	 *
 	 *   @param		TCPDF		$pdf     		Object PDF
@@ -1005,7 +1005,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		$currency = !empty($currency) ? $currency : $conf->currency;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-        // Amount in (at tab_top - 1)
+		// Amount in (at tab_top - 1)
 		$pdf->SetTextColor(0, 0, 0);
 		$pdf->SetFont('', '', $default_font_size - 2);
 
@@ -1033,15 +1033,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 			$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L');
 		}
 
-        if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
-        {
-    		$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
+		if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
+		{
+			$pdf->line($this->posxtva, $tab_top, $this->posxtva, $tab_top + $tab_height);
 			if (empty($hidetop))
 			{
-    			$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
-    			$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
+				$pdf->SetXY($this->posxtva - 3, $tab_top + 1);
+				$pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C');
 			}
-        }
+		}
 
 		$pdf->line($this->posxup, $tab_top, $this->posxup, $tab_top + $tab_height);
 		if (empty($hidetop))
@@ -1129,8 +1129,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1208,16 +1208,16 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 		// Get contact
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 		{
-    		$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-    		if (count($arrayidcontact) > 0)
-    		{
-    		    $usertmp = new User($this->db);
-    		    $usertmp->fetch($arrayidcontact[0]);
-                $posy += 4;
-                $pdf->SetXY($posx, $posy);
-    		    $pdf->SetTextColor(0, 0, 60);
-    		    $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
-    		}
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$usertmp = new User($this->db);
+				$usertmp->fetch($arrayidcontact[0]);
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
+			}
 		}
 
 		$posy += 1;
@@ -1234,15 +1234,15 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 
 		if ($showaddress)
 		{
-		    // Sender properties
-		    $carac_emetteur = '';
-		    // Add internal contact of proposal if defined
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $object->fetch_user($arrayidcontact[0]);
-		        $carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
-		    }
+			// Sender properties
+			$carac_emetteur = '';
+			// Add internal contact of proposal if defined
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$object->fetch_user($arrayidcontact[0]);
+				$carac_emetteur .= ($carac_emetteur ? "\n" : '').$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs))."\n";
+			}
 
 			$carac_emetteur .= pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, '', 0, 'source', $object);
 
@@ -1328,7 +1328,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *  Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *  @param	TCPDF		$pdf     			PDF
 	 *  @param	CommandeFournisseur		$object				Object to show
 	 *  @param	Translate	$outputlangs		Object lang for output

+ 88 - 88
htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php

@@ -38,71 +38,71 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php';
  */
 class pdf_standard extends ModelePDFSuppliersPayments
 {
-    /**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	/**
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
+
+	/**
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var string document type
-     */
-    public $type;
-
-    /**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
@@ -142,7 +142,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 		$this->option_logo = 1; // Affiche logo
 		$this->option_multilang = 1; // Dispo en plusieurs langues
 
-        // Define column position
+		// Define column position
 		$this->posxdate = $this->marge_gauche + 1;
 		$this->posxreffacturefourn = 30;
 		$this->posxreffacture = 65;
@@ -163,8 +163,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
 		}
 
 		$this->tva = array();
-        $this->localtax1 = array();
-        $this->localtax2 = array();
+		$this->localtax1 = array();
+		$this->localtax2 = array();
 		$this->atleastoneratenotnull = 0;
 		$this->atleastonediscount = 0;
 
@@ -174,21 +174,21 @@ class pdf_standard extends ModelePDFSuppliersPayments
 	}
 
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param		PaiementFourn		$object				Id of object to generate
-     *  @param		Translate			$outputlangs		Lang output object
-     *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int					$hidedetails		Do not show line details
-     *  @param		int					$hidedesc			Do not show desc
-     *  @param		int					$hideref			Do not show ref
-     *  @return		int										1=OK, 0=KO
-     */
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		PaiementFourn		$object				Id of object to generate
+	 *  @param		Translate			$outputlangs		Lang output object
+	 *  @param		string				$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int					$hidedetails		Do not show line details
+	 *  @param		int					$hidedesc			Do not show desc
+	 *  @param		int					$hideref			Do not show ref
+	 *  @return		int										1=OK, 0=KO
+	 */
 	public function write_file($object, $outputlangs = '', $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $hookmanager;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -233,7 +233,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 			} else {
 				$objectref = dol_sanitizeFileName($object->ref);
 				$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier);
-                $dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
+				$dir = $conf->fournisseur->payment->dir_output.'/'.$objectref;
 				$file = $dir."/".$objectref.".pdf";
 				if (!empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir."/".$objectref.($objectrefsupplier ? "_".$objectrefsupplier : "").".pdf";
 			}
@@ -262,26 +262,26 @@ class pdf_standard extends ModelePDFSuppliersPayments
 
 				$nblines = count($object->lines);
 
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -297,7 +297,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 				$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
 
 
-                // New page
+				// New page
 				$pdf->AddPage();
 				if (!empty($tplidx)) $pdf->useTemplate($tplidx);
 				$pagenb++;
@@ -370,7 +370,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 					}
 
 					$nexY = $pdf->GetY();
-                    $pageposafter = $pdf->getPage();
+					$pageposafter = $pdf->getPage();
 					$pdf->setPage($pageposbefore);
 					$pdf->setTopMargin($this->marge_haute);
 					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
@@ -403,8 +403,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
 					$pdf->MultiCell($this->posxtva - $this->posxup - 0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0);
 
 					// Total TTC line
-                    $pdf->SetXY($this->posxtotalttc, $curY);
-                    $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
+					$pdf->SetXY($this->posxtotalttc, $curY);
+					$pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0);
 
 
 					// Add line
@@ -483,8 +483,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -516,10 +516,10 @@ class pdf_standard extends ModelePDFSuppliersPayments
 	 */
 	protected function _tableau_cheque(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 
-        $default_font_size = pdf_getPDFFontSize($outputlangs);
+		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
 		$pdf->SetFont('', '', $default_font_size - 1);
 		$pdf->SetFillColor(255, 255, 255);
@@ -587,7 +587,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 		$currency = !empty($currency) ? $currency : $conf->currency;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
-        // Amount in (at tab_top - 1)
+		// Amount in (at tab_top - 1)
 		$pdf->SetTextColor(0, 0, 0);
 		$pdf->SetFont('', '', $default_font_size - 2);
 
@@ -643,8 +643,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -655,7 +655,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 			$text = $this->emetteur->name;
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
 		}
-        /*
+		/*
 		$pdf->SetFont('','B', $default_font_size + 3);
 		$pdf->SetXY($posx,$posy);
 		$pdf->SetTextColor(0,0,60);
@@ -788,7 +788,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
 	/**
 	 *   	Show footer of page. Need this->emetteur object
-     *
+	 *
 	 *   	@param	TCPDF		$pdf     			PDF
 	 * 		@param	FactureFournisseur		$object				Object to show
 	 *      @param	Translate	$outputlangs		Object lang for output

+ 150 - 150
htdocs/core/modules/supplier_proposal/doc/pdf_aurore.modules.php

@@ -39,76 +39,76 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
 class pdf_aurore extends ModelePDFSupplierProposal
 {
 	/**
-     * @var DoliDb Database handler
-     */
-    public $db;
+	 * @var DoliDb Database handler
+	 */
+	public $db;
 
 	/**
-     * @var string model name
-     */
-    public $name;
+	 * @var string model name
+	 */
+	public $name;
 
 	/**
-     * @var string model description (short text)
-     */
-    public $description;
+	 * @var string model description (short text)
+	 */
+	public $description;
 
 	/**
-     * @var string document type
-     */
-    public $type;
+	 * @var string document type
+	 */
+	public $type;
 
 	/**
-     * @var array Minimum version of PHP required by module.
-     * e.g.: PHP ≥ 5.6 = array(5, 6)
-     */
+	 * @var array Minimum version of PHP required by module.
+	 * e.g.: PHP ≥ 5.6 = array(5, 6)
+	 */
 	public $phpmin = array(5, 6);
 
 	/**
-     * Dolibarr version of the loaded document
-     * @var string
-     */
+	 * Dolibarr version of the loaded document
+	 * @var string
+	 */
 	public $version = 'dolibarr';
 
 	/**
-     * @var int page_largeur
-     */
-    public $page_largeur;
+	 * @var int page_largeur
+	 */
+	public $page_largeur;
 
 	/**
-     * @var int page_hauteur
-     */
-    public $page_hauteur;
+	 * @var int page_hauteur
+	 */
+	public $page_hauteur;
 
 	/**
-     * @var array format
-     */
-    public $format;
+	 * @var array format
+	 */
+	public $format;
 
 	/**
-     * @var int marge_gauche
-     */
+	 * @var int marge_gauche
+	 */
 	public $marge_gauche;
 
 	/**
-     * @var int marge_droite
-     */
+	 * @var int marge_droite
+	 */
 	public $marge_droite;
 
 	/**
-     * @var int marge_haute
-     */
+	 * @var int marge_haute
+	 */
 	public $marge_haute;
 
 	/**
-     * @var int marge_basse
-     */
+	 * @var int marge_basse
+	 */
 	public $marge_basse;
 
 	/**
-	* Issuer
-	* @var Societe
-	*/
+	 * Issuer
+	 * @var Societe
+	 */
 	public $emetteur;
 
 
@@ -161,15 +161,15 @@ class pdf_aurore extends ModelePDFSupplierProposal
 
 		if ($conf->global->PRODUCT_USE_UNITS)
 		{
-		    $this->posxtva = 101;
-		    $this->posxup = 118;
-		    $this->posxqty = 135;
-		    $this->posxunit = 151;
+			$this->posxtva = 101;
+			$this->posxup = 118;
+			$this->posxqty = 135;
+			$this->posxunit = 151;
 		} else {
-		    $this->posxtva = 102;
-		    $this->posxup = 126;
-		    $this->posxqty = 145;
-		    $this->posxunit = 162;
+			$this->posxtva = 102;
+			$this->posxup = 126;
+			$this->posxqty = 145;
+			$this->posxunit = 162;
 		}
 
 		if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxup = $this->posxtva;
@@ -192,21 +192,21 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		$this->atleastonediscount = 0;
 	}
 
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
-    /**
-     *  Function to build pdf onto disk
-     *
-     *  @param		Object		$object				Object to generate
-     *  @param		Translate	$outputlangs		Lang output object
-     *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
-     *  @param		int			$hidedetails		Do not show line details
-     *  @param		int			$hidedesc			Do not show desc
-     *  @param		int			$hideref			Do not show ref
-     *  @return     int             				1=OK, 0=KO
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	/**
+	 *  Function to build pdf onto disk
+	 *
+	 *  @param		Object		$object				Object to generate
+	 *  @param		Translate	$outputlangs		Lang output object
+	 *  @param		string		$srctemplatepath	Full path of source filename for generator using a template file
+	 *  @param		int			$hidedetails		Do not show line details
+	 *  @param		int			$hidedesc			Do not show desc
+	 *  @param		int			$hideref			Do not show ref
+	 *  @return     int             				1=OK, 0=KO
 	 */
 	public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
 
 		if (!is_object($outputlangs)) $outputlangs = $langs;
@@ -292,26 +292,26 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				$reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 
 				// Create pdf instance
-                $pdf = pdf_getInstance($this->format);
-                $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
-                $heightforinfotot = 50; // Height reserved to output the info and total part
-		        $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
-	            $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
-	            if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
-                $pdf->SetAutoPageBreak(1, 0);
-
-                if (class_exists('TCPDF'))
-                {
-                    $pdf->setPrintHeader(false);
-                    $pdf->setPrintFooter(false);
-                }
-                $pdf->SetFont(pdf_getPDFFont($outputlangs));
-                // Set path to the background PDF File
-                if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
-                {
-                    $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
-                    $tplidx = $pdf->importPage(1);
-                }
+				$pdf = pdf_getInstance($this->format);
+				$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
+				$heightforinfotot = 50; // Height reserved to output the info and total part
+				$heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
+				$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
+				if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
+				$pdf->SetAutoPageBreak(1, 0);
+
+				if (class_exists('TCPDF'))
+				{
+					$pdf->setPrintHeader(false);
+					$pdf->setPrintFooter(false);
+				}
+				$pdf->SetFont(pdf_getPDFFont($outputlangs));
+				// Set path to the background PDF File
+				if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
+				{
+					$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
+					$tplidx = $pdf->importPage(1);
+				}
 
 				$pdf->Open();
 				$pagenb = 0;
@@ -336,14 +336,14 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				}
 				if (empty($this->atleastonediscount))
 				{
-				    $delta = ($this->postotalht - $this->posxdiscount);
-				    $this->posxpicture += $delta;
-				    $this->posxtva += $delta;
-				    $this->posxup += $delta;
-				    $this->posxqty += $delta;
-				    $this->posxunit += $delta;
-				    $this->posxdiscount += $delta;
-				    // post of fields after are not modified, stay at same position
+					$delta = ($this->postotalht - $this->posxdiscount);
+					$this->posxpicture += $delta;
+					$this->posxtva += $delta;
+					$this->posxup += $delta;
+					$this->posxqty += $delta;
+					$this->posxunit += $delta;
+					$this->posxdiscount += $delta;
+					// post of fields after are not modified, stay at same position
 				}
 
 				// New page
@@ -375,7 +375,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				{
 					$tab_top -= 2;
 
-                    $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
+					$substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
 					complete_substitutions_array($substitutionarray, $outputlangs, $object);
 					$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
 					$notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
@@ -523,9 +523,9 @@ class pdf_aurore extends ModelePDFSupplierProposal
 					// Unit
 					if ($conf->global->PRODUCT_USE_UNITS)
 					{
-					    $unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
-					    $pdf->SetXY($this->posxunit, $curY);
-					    $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
+						$unit = pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
+						$pdf->SetXY($this->posxunit, $curY);
+						$pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0, 'L');
 					}
 
 					// Discount on line
@@ -570,7 +570,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 						$localtax2_type = $localtaxtmp_array[2];
 					}
 
-				    // retrieve global local tax
+					// retrieve global local tax
 					if ($localtax1_type && $localtax1ligne != 0)
 						$this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
 					if ($localtax2_type && $localtax2ligne != 0)
@@ -666,8 +666,8 @@ class pdf_aurore extends ModelePDFSupplierProposal
 				$reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
 				if ($reshook < 0)
 				{
-				    $this->error = $hookmanager->error;
-				    $this->errors = $hookmanager->errors;
+					$this->error = $hookmanager->error;
+					$this->errors = $hookmanager->errors;
 				}
 
 				if (!empty($conf->global->MAIN_UMASK))
@@ -687,23 +687,23 @@ class pdf_aurore extends ModelePDFSupplierProposal
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *  Show payments table
 	 *
-     *  @param	TCPDF		$pdf            Object PDF
-     *  @param  Object		$object         Object proposal
-     *  @param  int			$posy           Position y in PDF
-     *  @param  Translate	$outputlangs    Object langs for output
-     *  @return int             			<0 if KO, >0 if OK
+	 *  @param	TCPDF		$pdf            Object PDF
+	 *  @param  Object		$object         Object proposal
+	 *  @param  int			$posy           Position y in PDF
+	 *  @param  Translate	$outputlangs    Object langs for output
+	 *  @return int             			<0 if KO, >0 if OK
 	 */
 	protected function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *   Show miscellaneous information (payment mode, payment term, ...)
 	 *
@@ -715,7 +715,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 	 */
 	protected function _tableau_info(&$pdf, $object, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -723,10 +723,10 @@ class pdf_aurore extends ModelePDFSupplierProposal
 
 		$posxval = 52;
 
-        // Show shipping date
-        if (!empty($object->date_livraison))
+		// Show shipping date
+		if (!empty($object->date_livraison))
 		{
-            $outputlangs->load("sendings");
+			$outputlangs->load("sendings");
 			$pdf->SetFont('', 'B', $default_font_size - 2);
 			$pdf->SetXY($this->marge_gauche, $posy);
 			$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
@@ -736,7 +736,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 			$dlp = dol_print_date($object->date_livraison, "daytext", false, $outputlangs, true);
 			$pdf->MultiCell(80, 4, $dlp, 0, 'L');
 
-            $posy = $pdf->GetY() + 1;
+			$posy = $pdf->GetY() + 1;
 		} else {
 			$outputlangs->load("sendings");
 			$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -748,9 +748,9 @@ class pdf_aurore extends ModelePDFSupplierProposal
 			//$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
 			$pdf->MultiCell(80, 4, '', 0, 'L');
 
-            $posy = $pdf->GetY() + 1;
+			$posy = $pdf->GetY() + 1;
 		}
-        /* PHFAVRE
+		/* PHFAVRE
 		elseif ($object->availability_code || $object->availability)    // Show availability conditions
 		{
 			$pdf->SetFont('','B', $default_font_size - 2);
@@ -821,13 +821,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $account->proprio), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 					if ($conf->global->FACTURE_CHQ_NUMBER == -1)
 					{
@@ -836,13 +836,13 @@ class pdf_aurore extends ModelePDFSupplierProposal
 						$pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo', $this->emetteur->name), 0, 'L', 0);
 						$posy = $pdf->GetY() + 1;
 
-			            if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
-			            {
+						if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
+						{
 							$pdf->SetXY($this->marge_gauche, $posy);
 							$pdf->SetFont('', '', $default_font_size - $diffsizetitle);
 							$pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0, 'L', 0);
 							$posy = $pdf->GetY() + 2;
-			            }
+						}
 					}
 				}
 			}
@@ -870,7 +870,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
+	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
 	 *	Show total to pay
 	 *
@@ -883,7 +883,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 	 */
 	protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
 	{
-        // phpcs:enable
+		// phpcs:enable
 		global $conf, $mysoc;
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
 
@@ -952,7 +952,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 before VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1043,7 +1043,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 						}
 					}
 				}
-	      		//}
+		  		//}
 				//Local tax 2 after VAT
 				//if (! empty($conf->global->FACTURE_LOCAL_TAX2_OPTION) && $conf->global->FACTURE_LOCAL_TAX2_OPTION=='localtax2on')
 				//{
@@ -1053,7 +1053,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 
 					foreach ($localtax_rate as $tvakey => $tvaval)
 					{
-					    // retrieve global local tax
+						// retrieve global local tax
 						if ($tvakey != 0)    // On affiche pas taux 0
 						{
 							//$this->atleastoneratenotnull++;
@@ -1212,16 +1212,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
 		if (empty($hidetop))
 		{
-		    $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
-		    $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
+			$pdf->SetXY($this->posxqty - 1, $tab_top + 1);
+			$pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C');
 		}
 
 		if ($conf->global->PRODUCT_USE_UNITS) {
-		    $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
-		    if (empty($hidetop)) {
-		        $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
-                $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
-		    }
+			$pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
+			if (empty($hidetop)) {
+				$pdf->SetXY($this->posxunit - 1, $tab_top + 1);
+				$pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C');
+			}
 		}
 
 		$pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
@@ -1268,7 +1268,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		//  Show Draft Watermark
 		if ($object->statut == 0 && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK)))
 		{
-            pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
+			pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK);
 		}
 
 		$pdf->SetTextColor(0, 0, 60);
@@ -1285,8 +1285,8 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		{
 			if (is_readable($logo))
 			{
-			    $height = pdf_getHeightForLogo($logo);
-			    $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
+				$height = pdf_getHeightForLogo($logo);
+				$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
 			} else {
 				$pdf->SetTextColor(200, 0, 0);
 				$pdf->SetFont('', 'B', $default_font_size - 2);
@@ -1321,7 +1321,7 @@ class pdf_aurore extends ModelePDFSupplierProposal
 			$pdf->SetTextColor(0, 0, 60);
 			$pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : ".$outputlangs->convToOutputCharset($object->ref_client), '', 'R');
 		}
-        /* PHFAVRE
+		/* PHFAVRE
 		$posy+=4;
 		$pdf->SetXY($posx,$posy);
 		$pdf->SetTextColor(0,0,60);
@@ -1339,16 +1339,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
 		// Get contact
 		if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
 		{
-		    $arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
-		    if (count($arrayidcontact) > 0)
-		    {
-		        $usertmp = new User($this->db);
-		        $usertmp->fetch($arrayidcontact[0]);
-                $posy += 4;
-                $pdf->SetXY($posx, $posy);
-		        $pdf->SetTextColor(0, 0, 60);
-		        $pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
-		    }
+			$arrayidcontact = $object->getIdContact('internal', 'SALESREPFOLL');
+			if (count($arrayidcontact) > 0)
+			{
+				$usertmp = new User($this->db);
+				$usertmp->fetch($arrayidcontact[0]);
+				$posy += 4;
+				$pdf->SetXY($posx, $posy);
+				$pdf->SetTextColor(0, 0, 60);
+				$pdf->MultiCell(100, 3, $langs->trans("BuyerName")." : ".$usertmp->getFullName($langs), '', 'R');
+			}
 		}
 
 		$posy += 2;
@@ -1457,16 +1457,16 @@ class pdf_aurore extends ModelePDFSupplierProposal
 	}
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
-    /**
-     *  Show footer of page. Need this->emetteur object
-     *
-     *  @param  TCPDF		$pdf     			PDF
-     *  @param  Object		$object				Object to show
-     *  @param  Translate	$outputlangs		Object lang for output
-     *  @param  int			$hidefreetext		1=Hide free text
-     *  @return int								Return height of bottom margin including footer text
-     */
-    protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
+	/**
+	 *  Show footer of page. Need this->emetteur object
+	 *
+	 *  @param  TCPDF		$pdf     			PDF
+	 *  @param  Object		$object				Object to show
+	 *  @param  Translate	$outputlangs		Object lang for output
+	 *  @param  int			$hidefreetext		1=Hide free text
+	 *  @return int								Return height of bottom margin including footer text
+	 */
+	protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
 	{
 		global $conf;
 		$showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;

+ 1 - 1
htdocs/core/tpl/extrafields_list_search_title.tpl.php

@@ -27,7 +27,7 @@ if (!empty($extrafieldsobjectkey))	// $extrafieldsobject is the $object->table_e
 				if ($extrafields->attributes[$extrafieldsobjectkey]['type'][$key] == 'separate') {
 					print '<th class="liste_titre thseparator"></th>';
 				} else {
-					if (! empty($extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key]) && is_object($langs)) {
+					if (!empty($extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key]) && is_object($langs)) {
 						$langs->load($extrafields->attributes[$extrafieldsobjectkey]['langfile'][$key]);
 					}
 

Some files were not shown because too many files changed in this diff