Browse Source

Merge remote-tracking branch 'upstream/develop' into 10.0_intracommreport

Alexandre SPANGARO 4 years ago
parent
commit
27c36713d3
100 changed files with 1746 additions and 781 deletions
  1. 1 0
      .travis.yml
  2. 6 0
      .tx/config
  3. 1 1
      COPYRIGHT
  4. 99 1
      ChangeLog
  5. 1 1
      build/debian/control
  6. 15 2
      dev/dolibarr_changes.txt
  7. 172 0
      dev/resources/sepa/sample-credit-transfer.xml
  8. 0 0
      dev/resources/sepa/sample-direct-debit.xml
  9. 6 0
      dev/resources/sepa/text.txt
  10. 3 1
      htdocs/accountancy/bookkeeping/listbyaccount.php
  11. 7 2
      htdocs/accountancy/journal/bankjournal.php
  12. 3 3
      htdocs/accountancy/journal/expensereportsjournal.php
  13. 2 2
      htdocs/accountancy/supplier/lines.php
  14. 1 17
      htdocs/adherents/admin/adherent_emails.php
  15. 8 2
      htdocs/adherents/subscription.php
  16. 1 1
      htdocs/admin/bom_extrafields.php
  17. 3 3
      htdocs/admin/boxes.php
  18. 9 1
      htdocs/admin/clicktodial.php
  19. 29 8
      htdocs/admin/company.php
  20. 1 1
      htdocs/admin/confexped.php
  21. 44 17
      htdocs/admin/dict.php
  22. 1 1
      htdocs/admin/emailcollector_list.php
  23. 1 1
      htdocs/admin/events.php
  24. 1 1
      htdocs/admin/expedition.php
  25. 1 1
      htdocs/admin/expedition_extrafields.php
  26. 1 1
      htdocs/admin/expeditiondet_extrafields.php
  27. 35 65
      htdocs/admin/limits.php
  28. 1 1
      htdocs/admin/livraison.php
  29. 1 1
      htdocs/admin/livraison_extrafields.php
  30. 1 1
      htdocs/admin/livraisondet_extrafields.php
  31. 24 18
      htdocs/admin/mails_templates.php
  32. 1 1
      htdocs/admin/menus.php
  33. 1 1
      htdocs/admin/menus/index.php
  34. 1 1
      htdocs/admin/menus/other.php
  35. 2 2
      htdocs/admin/modulehelp.php
  36. 16 14
      htdocs/admin/modules.php
  37. 1 1
      htdocs/admin/mrp_extrafields.php
  38. 41 57
      htdocs/admin/pdf.php
  39. 1 1
      htdocs/admin/perms.php
  40. 1 1
      htdocs/admin/proxy.php
  41. 81 57
      htdocs/admin/receiptprinter.php
  42. 1 1
      htdocs/admin/resource.php
  43. 1 1
      htdocs/admin/security.php
  44. 1 1
      htdocs/admin/security_file.php
  45. 1 1
      htdocs/admin/security_other.php
  46. 26 17
      htdocs/admin/system/database-tables.php
  47. 2 1
      htdocs/admin/tools/dolibarr_export.php
  48. 4 4
      htdocs/admin/translation.php
  49. 4 2
      htdocs/api/class/api_documents.class.php
  50. 7 5
      htdocs/api/index.php
  51. 5 3
      htdocs/barcode/printsheet.php
  52. 1 1
      htdocs/bom/bom_agenda.php
  53. 5 3
      htdocs/bom/bom_card.php
  54. 7 2
      htdocs/bom/class/bom.class.php
  55. 9 2
      htdocs/bom/tpl/linkedobjectblock.tpl.php
  56. 1 2
      htdocs/bom/tpl/objectline_create.tpl.php
  57. 1 1
      htdocs/bom/tpl/objectline_title.tpl.php
  58. 1 1
      htdocs/bom/tpl/objectline_view.tpl.php
  59. 1 0
      htdocs/bookmarks/card.php
  60. 1 1
      htdocs/bookmarks/list.php
  61. 23 1
      htdocs/categories/class/categorie.class.php
  62. 9 8
      htdocs/comm/action/card.php
  63. 2 2
      htdocs/comm/action/class/actioncomm.class.php
  64. 1 1
      htdocs/comm/action/document.php
  65. 78 17
      htdocs/comm/action/index.php
  66. 51 7
      htdocs/comm/action/list.php
  67. 1 1
      htdocs/comm/action/pertype.php
  68. 57 9
      htdocs/comm/action/peruser.php
  69. 4 5
      htdocs/comm/action/rapport/index.php
  70. 10 8
      htdocs/comm/card.php
  71. 17 3
      htdocs/comm/propal/card.php
  72. 9 7
      htdocs/comm/propal/class/propal.class.php
  73. 3 2
      htdocs/comm/prospect/index.php
  74. 3 3
      htdocs/comm/remise.php
  75. 12 6
      htdocs/commande/card.php
  76. 1 0
      htdocs/commande/class/commande.class.php
  77. 1 1
      htdocs/commande/list.php
  78. 72 18
      htdocs/compta/bank/account_statement_document.php
  79. 1 1
      htdocs/compta/bank/class/account.class.php
  80. 0 6
      htdocs/compta/bank/document.php
  81. 10 10
      htdocs/compta/bank/releve.php
  82. 1 1
      htdocs/compta/bank/various_payment/list.php
  83. 2 0
      htdocs/compta/charges/index.php
  84. 10 2
      htdocs/compta/facture/card.php
  85. 1 1
      htdocs/compta/facture/class/facture-rec.class.php
  86. 3 2
      htdocs/compta/facture/class/facture.class.php
  87. 8 1
      htdocs/compta/facture/invoicetemplate_list.php
  88. 9 4
      htdocs/compta/facture/list.php
  89. 8 3
      htdocs/compta/facture/prelevement.php
  90. 10 2
      htdocs/compta/index.php
  91. 1 1
      htdocs/compta/paiement/class/paiement.class.php
  92. 3 2
      htdocs/compta/paiement_charge.php
  93. 4 3
      htdocs/compta/paymentbybanktransfer/index.php
  94. 25 14
      htdocs/compta/prelevement/card.php
  95. 459 220
      htdocs/compta/prelevement/class/bonprelevement.class.php
  96. 1 1
      htdocs/compta/prelevement/class/ligneprelevement.class.php
  97. 16 9
      htdocs/compta/prelevement/create.php
  98. 23 10
      htdocs/compta/prelevement/demandes.php
  99. 69 35
      htdocs/compta/prelevement/factures.php
  100. 24 15
      htdocs/compta/prelevement/fiche-rejet.php

+ 1 - 0
.travis.yml

@@ -5,6 +5,7 @@
 # We use dist: xenial to have php 5.6+ available
 os: linux
 dist: xenial
+#dist: bionic
 sudo: required
 
 language: php

+ 6 - 0
.tx/config

@@ -332,6 +332,12 @@ source_file = htdocs/langs/en_US/receptions.lang
 source_lang = en_US
 type = MOZILLAPROPERTIES
 
+[dolibarr.recruitment]
+file_filter = htdocs/langs/<lang>/recruitment.lang
+source_file = htdocs/langs/en_US/recruitment.lang
+source_lang = en_US
+type = MOZILLAPROPERTIES
+
 [dolibarr.resource]
 file_filter = htdocs/langs/<lang>/resource.lang
 source_file = htdocs/langs/en_US/resource.lang

+ 1 - 1
COPYRIGHT

@@ -39,7 +39,7 @@ TCPDI                  1.0.0         LGPL-3+ / Apache 2.0        Yes
 JS libraries:
 Ace                    1.4.8         BSD                         Yes             JS library to get code syntaxique coloration in a textarea.
 ChartJS				   2.9.3         MIT License                 Yes             JS library for graph
-jQuery                 3.4.1         MIT License                 Yes             JS library
+jQuery                 3.5.1         MIT License                 Yes             JS library
 jQuery UI              1.12.1        GPL and MIT License         Yes             JS library plugin UI
 jQuery select2         4.0.13         GPL and Apache License      Yes             JS library plugin for sexier multiselect. Warning: 4.0.6+ create troubles without patching css
 jQuery blockUI         2.70.0        GPL and MIT License         Yes             JS library plugin blockUI (to use ajax popups)

+ 99 - 1
ChangeLog

@@ -4,7 +4,7 @@ English Dolibarr ChangeLog
 
 ***** ChangeLog for 13.0.0 compared to 12.0.0 *****
 For users:
-
+NEW: Add module Credit transfer SEPA to manage payment of supplier using bank credit transfer SEPA files
 
 
 WARNING:
@@ -14,6 +14,104 @@ Following changes may create regressions for some external modules, but were nec
 
 
 
+***** ChangeLog for 12.0.2 compared to 12.0.1 *****
+FIX: computation of the bottom margin of <body> returns NaN because body is not loaded yet
+FIX: DebugBar hides content at page bottom
+FIX: allow more harmless html tags
+FIX: Bad back to link
+FIX: Bad param
+FIX: Can go on page even when module is disabled
+FIX: Change position of line in BOM
+FIX: Checkbox "drop table" was not checked when using php method to generate backup dump
+FIX: ClickToDial tab of users has disappeared
+FIX: CSS
+FIX: date in supplier price log tooltip.
+FIX: Debug module direct debit order. Solve conflict with credit transfer
+FIX: Debug setup of receipt printer module
+FIX: dolGetElementUrl and agenda page for external modules
+FIX: DO not erase variable $key and $label during output of extrafields
+FIX: duration fields size with firefox
+FIX: Edit extrafield of type long text loose carriage returns
+FIX: Fails to retraive accounting code of social contribution sometimes
+FIX: Filter too large for extrafields with type text or html
+FIX: If using a rounding step, localtax1+2 not included in total
+FIX: input field of extrafields must keep data if form submit fails.
+FIX: Label of opportunities in graph with special chars badly encoded
+FIX: locataxes lost on lines when cloning a vendor invoice
+FIX: Look and feel v12
+FIX: Missing PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE conf support in supplier order
+FIX: Navigation in object fails to find the next ref in some cases
+FIX: null required
+FIX: order by amount ht uses wrong column
+FIX: Order by amount in product propal stats must be done on d.total_ht and not p.total
+FIX: page for confirmation of payments is empty
+FIX: Param of fetch_name_optionals_label must be object->table_element
+FIX: Picto of HRM module
+FIX: product label and desc were never updated when modifying translation
+FIX: redirect on contact card from main search
+FIX: Reposition and nav
+FIX: search warehouse list
+FIX: Setup of clicktodial hang on smartphone
+FIX: Setup of currency limit and accuracy
+FIX: shipping creation: checks not done on weight and sizes
+FIX: Should not be able to edit qty on shipment when no stock available
+FIX: Size of image on the help popup of modules
+FIX: Sql error on stat by referring entries of a product
+FIX: Warning if no bank account defined
+FIX: We need to see unit line on PDF even though it's an option
+FIX: wrong element var for fetch_name_optionals_label function with expeditions
+FIX: wrong link to third invoice templates
+FIX: Disable svg as supported image by default (can contains javascript). Set MAIN_ALLOW_SVG_FILES_AS_IMAGES to 1 to have svg accepted
+FIX: #14076
+FIX: #14146
+FIX: #14209
+FIX: #14222
+FIX: #14236
+FIX: #14241 Mysql 8 compatibility
+FIX: #14253
+FIX: #14256
+FIX: #14259
+FIX: #14279
+FIX: #14291
+FIX: #14292
+FIX: #14336
+
+***** ChangeLog for 12.0.1 compared to 12.0.0 *****
+FIX: reposition was broken if url end with #anchor
+FIX: $_POST must be GETPOST
+FIX: 10.0 - fatal with postgreSQL
+FIX: #14109
+FIX: #14112
+FIX: #14142
+FIX: all extrafields cleared after update of one of them
+FIX: Avoid warning when creating a module with already existing files
+FIX: change selected fields on company card
+FIX: Correct ModuleBuilder left menu
+FIX: create a deposit with amount using comma didn't work
+FIX: CSS
+FIX: Entry from stripe intent were reported into SEPA payments
+FIX: Filter on status, closing opening status
+FIX: html lost on html extrafield
+FIX: Label of popup on thirdparty
+FIX: missing possibility to change entity when propal cloning
+FIX: missing setup of extrafields for MO
+FIX: Missing the tooltip when creating bank account
+FIX: Missing token
+FIX: non numeric value on comm/card.php
+FIX: SQL Problem in customer invoice list
+FIX: SQL Problem in social contribution list
+FIX: SQL Problem in supplier invoice list
+FIX: SQL syntax error when editing extrafields
+FIX: Sql type
+FIX: takepos 12 hook
+FIX: Update form erased extrafields that were hidden
+FIX: Update of extrafields date
+FIX: Update of extrafiels on draft object
+FIX: upload documents into manual ECM was reported a permission error
+FIX: Use of office365 TLS with SMTPs method.
+FIX: wrong origin
+FIX: Permission error during import
+
 ***** ChangeLog for 12.0.0 compared to 11.0.0 *****
 For users:
 

+ 1 - 1
build/debian/control

@@ -14,7 +14,7 @@ Architecture: all
 Depends: libapache2-mod-php5 | libapache2-mod-php5filter | php5-cgi | php5-fpm | php5 | libapache2-mod-php | libapache2-mod-phpfilter | php-cgi | php-fpm | php,
     php5-cli | php-cli,
 # Required PHP extensions
-    php5-mysql | php5-mysqli | php-mysql | php-mysqli, php5-curl | php-curl, php5-gd | php-gd, php5-ldap | php-gd,
+    php5-mysql | php5-mysqli | php-mysql | php-mysqli, php5-curl | php-curl, php5-gd | php-gd, php5-ldap | php-gd, php5-zip | php-zip,
 # Required PHP libraries
     php-pear, php-mail-mime,
 #    php-tcpdf,

+ 15 - 2
dev/dolibarr_changes.txt

@@ -8,6 +8,7 @@ ALL:
 Check "@CHANGE"
 
 
+
 PrestaShopWebservice:
 ---------------------
 Replace
@@ -27,6 +28,19 @@ With
 
 
 
+DEBUGBAR:
+---------
+
+Move
+    this.options = {
+                bodyMarginBottom: true,
+                bodyMarginBottomHeight: parseInt($('body').css('margin-bottom')),
+    };
+few line lower in the  
+	initialize: function() {
+
+
+
 ESCPOS:
 -------
 Replace
@@ -167,6 +181,7 @@ In htdocs/includes/tecnickcom/tcpdf/tcpdf.php
 TCPDI:
 ------
 Add fpdf_tpl.php 1.2
+
 Add tcpdi.php
 
 Add tcpdi_parser.php and replace:
@@ -205,8 +220,6 @@ with
 
 
 
-
-
 JCROP:
 ------
 * Remove analytics tag into file index.html

+ 172 - 0
dev/resources/sepa/sample-credit-transfer.xml

@@ -0,0 +1,172 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03">
+	<CstmrCdtTrfInitn>
+		<GrpHdr>
+			<MsgId>message-id-001</MsgId>
+			<CreDtTm>2010-09-28T14:07:00</CreDtTm>
+			<NbOfTxs>1</NbOfTxs>
+			<CtrlSum>10.1</CtrlSum>
+			<InitgPty>
+				<Nm>Bedrijfsnaam</Nm>
+				<Id>
+					<OrgId>
+						<Othr>
+							<Id>123456789123456</Id>
+						</Othr>
+					</OrgId>
+				</Id>
+			</InitgPty>
+		</GrpHdr>
+		<PmtInf>
+			<PmtInfId>minimaal gevuld</PmtInfId>
+			<PmtMtd>TRF</PmtMtd>
+			<NbOfTxs>1</NbOfTxs>
+			<CtrlSum>10.1</CtrlSum>
+			<ReqdExctnDt>2009-11-01</ReqdExctnDt>
+			<Dbtr>
+				<Nm>Naam</Nm>
+			</Dbtr>
+			<DbtrAcct>
+				<Id>
+					<IBAN>NL44RABO0123456789</IBAN>
+				</Id>
+			</DbtrAcct>
+			<DbtrAgt>
+				<FinInstnId>
+					<BIC>RABONL2U</BIC>
+				</FinInstnId>
+			</DbtrAgt>
+			<CdtTrfTxInf>
+				<PmtId>
+					<EndToEndId>non ref</EndToEndId>
+				</PmtId>
+				<Amt>
+					<InstdAmt Ccy="EUR">10.1</InstdAmt>
+				</Amt>
+				<ChrgBr>SLEV</ChrgBr>
+				<CdtrAgt>
+					<FinInstnId>
+						<BIC>ABNANL2A</BIC>
+					</FinInstnId>
+				</CdtrAgt>
+				<Cdtr>
+					<Nm>Naam creditor</Nm>
+				</Cdtr>
+				<CdtrAcct>
+					<Id>
+						<IBAN>NL90ABNA0111111111</IBAN>
+					</Id>
+				</CdtrAcct>
+				<RmtInf>
+					<Ustrd>vrije tekst</Ustrd>
+				</RmtInf>
+			</CdtTrfTxInf>
+		</PmtInf>
+		<PmtInf>
+			<PmtInfId>maximaal gevuld</PmtInfId>
+			<PmtMtd>TRF</PmtMtd>
+			<BtchBookg>true</BtchBookg>
+			<NbOfTxs>1</NbOfTxs>
+			<CtrlSum>20.2</CtrlSum>
+			<PmtTpInf>
+				<InstrPrty>NORM</InstrPrty>
+				<SvcLvl>
+					<Cd>SEPA</Cd>
+				</SvcLvl>
+				<LclInstrm>
+					<Cd>IDEAL</Cd>
+				</LclInstrm>
+				<CtgyPurp>
+					<Cd>SECU</Cd>
+				</CtgyPurp>
+			</PmtTpInf>
+			<ReqdExctnDt>2009-11-01</ReqdExctnDt>
+			<Dbtr>
+				<Nm>Naam</Nm>
+				<PstlAdr>
+					<Ctry>NL</Ctry>
+					<AdrLine>Debtor straat 1</AdrLine>
+					<AdrLine>9999 XX Plaats debtor</AdrLine>
+				</PstlAdr>
+			</Dbtr>
+			<DbtrAcct>
+				<Id>
+					<IBAN>NL44RABO0123456789</IBAN>
+				</Id>
+			</DbtrAcct>
+			<DbtrAgt>
+				<FinInstnId>
+					<BIC>RABONL2U</BIC>
+				</FinInstnId>
+			</DbtrAgt>
+			<UltmtDbtr>
+				<Id>
+					<OrgId>
+						<Othr>
+							<Id>12345678</Id>
+							<SchmeNm>
+								<Prtry>klantnummer</Prtry>
+							</SchmeNm>
+							<Issr>klantnummer uitgifte instantie</Issr>
+						</Othr>
+					</OrgId>
+				</Id>
+			</UltmtDbtr>
+			<ChrgBr>SLEV</ChrgBr>
+			<CdtTrfTxInf>
+				<PmtId>
+					<InstrId>debtor-to-debtor-bank-01</InstrId>
+					<EndToEndId>End-to-end-id-debtor-to-creditor-01</EndToEndId>
+				</PmtId>
+				<Amt>
+					<InstdAmt Ccy="EUR">20.2</InstdAmt>
+				</Amt>
+				<CdtrAgt>
+					<FinInstnId>
+						<BIC>ABNANL2A</BIC>
+					</FinInstnId>
+				</CdtrAgt>
+				<Cdtr>
+					<Nm>Naam creditor</Nm>
+					<PstlAdr>
+						<Ctry>NL</Ctry>
+						<AdrLine>Straat creditor 1</AdrLine>
+						<AdrLine>9999 XX Plaats creditor</AdrLine>
+					</PstlAdr>
+				</Cdtr>
+				<CdtrAcct>
+					<Id>
+						<IBAN>NL90ABNA0111111111</IBAN>
+					</Id>
+				</CdtrAcct>
+				<UltmtCdtr>
+					<Id>
+						<PrvtId>
+							<DtAndPlcOfBirth>
+								<BirthDt>1969-07-03</BirthDt>
+								<CityOfBirth>PLAATS</CityOfBirth>
+								<CtryOfBirth>NL</CtryOfBirth>
+							</DtAndPlcOfBirth>
+						</PrvtId>
+					</Id>
+				</UltmtCdtr>
+				<Purp>
+					<Cd>CHAR</Cd>
+				</Purp>
+				<RmtInf>
+					<Strd>
+						<CdtrRefInf>
+							<Tp>
+								<CdOrPrtry>
+									<Cd>SCOR</Cd>
+								</CdOrPrtry>
+								<Issr>CUR</Issr>
+							</Tp>
+							<Ref>1234567</Ref>
+						</CdtrRefInf>
+					</Strd>
+				</RmtInf>
+			</CdtTrfTxInf>
+		</PmtInf>
+	</CstmrCdtTrfInitn>
+</Document>

+ 0 - 0
dev/resources/sepa/test.xml → dev/resources/sepa/sample-direct-debit.xml


+ 6 - 0
dev/resources/sepa/text.txt

@@ -1,2 +1,8 @@
+Spec for credit transfer: 
+https://docs.oracle.com/cd/E39124_01/doc.91/e60210/fields_sepa_pay_file_appx.htm#EOAEL00515
+
+To validate a SEPA file:
+xmllint --schema pain.001.001.03.xsd T200801.xml --noout
+
 To test a SEPA file: 
 https://www.mesfluxdepaiement.fr/testez-vos-fichiers-sepa 

+ 3 - 1
htdocs/accountancy/bookkeeping/listbyaccount.php

@@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
 
 // Load translation files required by the page
@@ -78,6 +79,7 @@ if ($sortfield == "") $sortfield = "t.doc_date,t.rowid";
 
 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
 $object = new BookKeeping($db);
+$formfile = new FormFile($db);
 $hookmanager->initHooks(array('bookkeepingbyaccountlist'));
 
 $formaccounting = new FormAccounting($db);
@@ -543,7 +545,7 @@ while ($i < min($num, $limit))
 
 		// Show the break account
 		print "<tr>";
-		print '<td colspan="'.$totalarray['nbfield'].'" style="font-weight:bold; border-bottom: 1pt solid black;">';
+		print '<td colspan="'.($totalarray['nbfield'] ? $totalarray['nbfield'] : 9).'" style="font-weight:bold; border-bottom: 1pt solid black;">';
 		if ($line->numero_compte != "" && $line->numero_compte != '-1') print length_accountg($line->numero_compte).' : '.$object->get_compte_desc($line->numero_compte);
 		else print '<span class="error">'.$langs->trans("Unknown").'</span>';
 		print '</td>';

+ 7 - 2
htdocs/accountancy/journal/bankjournal.php

@@ -254,6 +254,8 @@ if ($result) {
 		} else {
 			$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
 		}
+
+		// Load of url links to the line into llx_bank
 		$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
 
 		//var_dump($i);
@@ -319,6 +321,7 @@ if ($result) {
 					$chargestatic->ref = $links[$key]['url_id'];
 
 					$tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
+					$reg = array();
 					if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
 						if ($reg[1] == 'socialcontribution')
 							$reg[1] = 'SocialContribution';
@@ -330,11 +333,13 @@ if ($result) {
 					$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
 					$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
 
+					// Retreive the accounting code of the social contribution of the payment from link of payment.
+					// Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
 					$sqlmid = 'SELECT cchgsoc.accountancy_code';
-					$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc ";
+					$sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
 					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type=cchgsoc.id";
 					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge=chgsoc.rowid";
-					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid";
+					$sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'";
 					$sqlmid .= " WHERE bkurl.fk_bank=".$obj->rowid;
 
 					dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);

+ 3 - 3
htdocs/accountancy/journal/expensereportsjournal.php

@@ -263,7 +263,7 @@ if ($action == 'writebookkeeping') {
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 						$bookkeeping->debit = ($mt > 0) ? $mt : 0;
-						$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
+						$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
 						$bookkeeping->code_journal = $journal;
 						$bookkeeping->journal_label = $journal_label;
 						$bookkeeping->fk_user_author = $user->id;
@@ -321,7 +321,7 @@ if ($action == 'writebookkeeping') {
 						$bookkeeping->montant = $mt;
 						$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
 						$bookkeeping->debit = ($mt > 0) ? $mt : 0;
-						$bookkeeping->credit = ($mt <= 0) ? $mt : 0;
+						$bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
 						$bookkeeping->code_journal = $journal;
 						$bookkeeping->journal_label = $journal_label;
 						$bookkeeping->fk_user_author = $user->id;
@@ -610,7 +610,7 @@ if (empty($action) || $action == 'view') {
 			} else print $accountoshow;
 			print '</td>';
 			print "<td>".$userstatic->getNomUrl(0, 'user', 16).' - '.$langs->trans("SubledgerAccount")."</td>";
-			print '<td class="right nowraponall">'.($mt < 0 ? -price(-$mt) : '')."</td>";
+			print '<td class="right nowraponall">'.($mt < 0 ? price(-$mt) : '')."</td>";
 			print '<td class="right nowraponall">'.($mt >= 0 ? price($mt) : '')."</td>";
 			print "</tr>";
 		}

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

@@ -401,8 +401,8 @@ if ($result) {
 
 		// Ref product
 		print '<td class="tdoverflowmax100">';
-		if ($product_static->id > 0) print $product_static->getNomUrl(1);
-		if ($product_static->id > 0 && $objp->product_label) print '<br>';
+		if ($productstatic->id > 0) print $productstatic->getNomUrl(1);
+		if ($productstatic->id > 0 && $objp->product_label) print '<br>';
 		if ($objp->product_label) print '<span class="opacitymedium">'.$objp->product_label.'</span>';
 		print '</td>';
 

+ 1 - 17
htdocs/adherents/admin/adherent_emails.php

@@ -88,6 +88,7 @@ if ($action == 'update' || $action == 'add') {
 	$constnote = (GETPOSTISSET('constnote_'.$constname) ? GETPOST('constnote_'.$constname, 'none') : GETPOST('constnote'));
 
 	$typetouse = empty($oldtypetonewone[$consttype]) ? $consttype : $oldtypetonewone[$consttype];
+	$constvalue = preg_replace('/:member$/', '', $constvalue);
 
 	$res = dolibarr_set_const($db, $constname, $constvalue, $typetouse, 0, $constnote, $conf->entity);
 
@@ -100,23 +101,6 @@ if ($action == 'update' || $action == 'add') {
 	}
 }
 
-// Action to enable a submodule of the adherent module
-if ($action == 'set') {
-    $result = dolibarr_set_const($db, GETPOST('name', 'alpha'), GETPOST('value'), '', 0, '', $conf->entity);
-    if ($result < 0) {
-        print $db->error();
-    }
-}
-
-// Action to disable a submodule of the adherent module
-if ($action == 'unset') {
-    $result = dolibarr_del_const($db, GETPOST('name', 'alpha'), $conf->entity);
-    if ($result < 0) {
-        print $db->error();
-    }
-}
-
-
 
 /*
  * View

+ 8 - 2
htdocs/adherents/subscription.php

@@ -890,7 +890,10 @@ if ($rowid > 0) {
                     if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
 					if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
 						$prodtmp = new Product($db);
-						$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+						$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+						if ($result < 0) {
+							setEventMessage($prodtmp->error, 'errors');
+						}
 						print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
 					}
                     print '<br>';
@@ -912,7 +915,10 @@ if ($rowid > 0) {
                     if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. <span class="opacitymedium">'.$langs->trans("NoVatOnSubscription", 0).'</span>';
 					if (!empty($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS) && (!empty($conf->product->enabled) || !empty($conf->service->enabled))) {
 						$prodtmp = new Product($db);
-						$prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+						$result = $prodtmp->fetch($conf->global->ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS);
+						if ($result < 0) {
+							setEventMessage($prodtmp->error, 'errors');
+						}
 						print '. '.$langs->transnoentitiesnoconv("ADHERENT_PRODUCT_ID_FOR_SUBSCRIPTIONS", $prodtmp->getNomUrl(1)); // must use noentitiesnoconv to avoid to encode html into getNomUrl of product
 					}
                     print '<br>';

+ 1 - 1
htdocs/admin/bom_extrafields.php

@@ -68,7 +68,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu
 print load_fiche_titre($langs->trans("BOMsSetup"), $linkback, 'title_setup');
 
 
-$head = bomAdminPrepareHead(null);
+$head = bomAdminPrepareHead();
 
 dol_fiche_head($head, 'bom_extrafields', $langs->trans("ExtraFields"), -1, 'account');
 

+ 3 - 3
htdocs/admin/boxes.php

@@ -314,7 +314,7 @@ $boxactivated = InfoBox::listBoxes($db, 'activated', -1, null);
 
 print "<br>\n";
 print "\n\n".'<!-- Boxes Available -->'."\n";
-print load_fiche_titre($langs->trans("BoxesAvailable"));
+print load_fiche_titre($langs->trans("BoxesAvailable"), '', '');
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">'."\n";
 print '<input type="hidden" name="token" value="'.newToken().'">'."\n";
@@ -377,7 +377,7 @@ print "\n".'<!-- End Boxes Available -->'."\n";
 
 //var_dump($boxactivated);
 print "<br>\n\n";
-print load_fiche_titre($langs->trans("BoxesActivated"));
+print load_fiche_titre($langs->trans("BoxesActivated"), '', '');
 
 print '<div class="div-table-responsive-no-min">';
 print '<table class="tagtable liste">'."\n";
@@ -436,7 +436,7 @@ print '<br>';
 // Other parameters
 
 print "\n\n".'<!-- Other Const -->'."\n";
-print load_fiche_titre($langs->trans("Other"));
+print load_fiche_titre($langs->trans("Other"), '', '');
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="addconst">';

+ 9 - 1
htdocs/admin/clicktodial.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2005-2011 Laurent Destailleur  <eldy@users.sourceforge.org>
+ * Copyright (C) 2005-2020 Laurent Destailleur  <eldy@users.sourceforge.org>
  * Copyright (C) 2011-2013 Juanjo Menent		<jmenent@2byte.es>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -33,6 +33,10 @@ if (!$user->admin) accessforbidden();
 
 $action = GETPOST('action', 'aZ09');
 
+if (! in_array('clicktodial', $conf->modules)) {
+	accessforbidden($langs->trans("WarningModuleNotActive", $langs->transnoentitiesnoconv("Module58Name")));
+}
+
 
 /*
  *	Actions
@@ -56,6 +60,8 @@ if ($action == 'setvalue' && $user->admin)
  * View
  */
 
+$form = new Form($db);
+
 $user->fetch_clicktodial();
 
 $wikihelp = 'EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
@@ -71,6 +77,7 @@ print '<form method="post" action="clicktodial.php">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="setvalue">';
 
+print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder centpercent">';
 print '<tr class="liste_titre">';
 print '<td>'.$langs->trans("Name").'</td>';
@@ -103,6 +110,7 @@ print $langs->trans("Example").':<br>http://myphoneserver/mypage?login=__LOGIN__
 print '</td></tr>';
 
 print '</table>';
+print '</div>';
 
 print '<div class="center"><br><input type="submit" class="button" value="'.$langs->trans("Modify").'"></div>';
 

+ 29 - 8
htdocs/admin/company.php

@@ -109,6 +109,12 @@ 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.
+			$langs->load("errors");
+			setEventMessages($langs->trans("ErrorBadImageFormat"), null, 'errors');
+			break;
+		}
+
 		if ($_FILES[$varforimage]["tmp_name"])
 		{
 			$reg = array();
@@ -473,10 +479,17 @@ if (!empty($mysoc->logo_mini)) {
 		print '</div>';
 	}
 	print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
-} else {
-	print '<div class="inline-block valignmiddle">';
-	print '<img height="60" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
-	print '</div>';
+} elseif (!empty($mysoc->logo)) {
+	if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo)) {
+		print '<div class="inline-block valignmiddle">';
+		print '<img style="max-height: 60px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo).'">';
+		print '</div>';
+		print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogo">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
+	} else {
+		print '<div class="inline-block valignmiddle">';
+		print '<img height="60" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
+		print '</div>';
+	}
 }
 print '</div>';
 print '</td></tr>';
@@ -493,10 +506,18 @@ if (!empty($mysoc->logo_squarred_mini)) {
 		print '</div>';
 	}
 	print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
-} else {
-	print '<div class="inline-block valignmiddle">';
-	print '<img height="60" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
-	print '</div>';
+} elseif (!empty($mysoc->logo_squarred)) {
+	if (file_exists($conf->mycompany->dir_output.'/logos/'.$mysoc->logo_squarred)) {
+		print '<div class="inline-block valignmiddle">';
+		print '<img style="max-height: 60px" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/'.$mysoc->logo_squarred).'">';
+		print '</div>';
+		print '<div class="inline-block valignmiddle marginrightonly"><a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=removelogosquarred">'.img_delete($langs->trans("Delete"), '', 'marginleftonly').'</a></div>';
+	}
+	else {
+		print '<div class="inline-block valignmiddle">';
+		print '<img height="60" src="'.DOL_URL_ROOT.'/public/theme/common/nophoto.png">';
+		print '</div>';
+	}
 }
 print '</div>';
 print '</td></tr>';

+ 1 - 1
htdocs/admin/confexped.php

@@ -92,7 +92,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'sending');
+dol_fiche_head($head, 'general', $langs->trans("Sendings"), -1, 'shipment');
 
 // Miscellaneous parameters
 

+ 44 - 17
htdocs/admin/dict.php

@@ -12,6 +12,7 @@
  * Copyright (C) 2015		Ferran Marcet			<fmarcet@2byte.es>
  * Copyright (C) 2016		Raphaël Doursenaud		<rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2019       Frédéric France         <frederic.france@netlogic.fr>
+ * Copyright (C) 2020		Open-Dsi				<support@open-dsi.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -90,7 +91,11 @@ $hookmanager->initHooks(array('admin'));
 // Put here declaration of dictionaries properties
 
 // Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
-$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 27, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 39, 0, 15, 30, 0, 37, 0, 25, 0);
+if (! empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)) {
+	$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 39, 27, 40, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 0, 15, 30, 0, 37, 0, 25, 0);
+} else {
+	$taborder = array(9, 0, 4, 3, 2, 0, 1, 8, 19, 16, 27, 38, 0, 5, 11, 0, 32, 33, 34, 0, 6, 0, 29, 0, 7, 24, 28, 17, 35, 36, 0, 10, 23, 12, 13, 0, 14, 0, 22, 20, 18, 21, 0, 15, 30, 0, 37, 0, 25, 0);
+}
 
 // Name of SQL tables of dictionaries
 $tabname = array();
@@ -128,12 +133,14 @@ $tabname[30] = MAIN_DB_PREFIX."c_format_cards";
 $tabname[32] = MAIN_DB_PREFIX."c_hrm_public_holiday";
 $tabname[33] = MAIN_DB_PREFIX."c_hrm_department";
 $tabname[34] = MAIN_DB_PREFIX."c_hrm_function";
-
 $tabname[35] = MAIN_DB_PREFIX."c_exp_tax_cat";
 $tabname[36] = MAIN_DB_PREFIX."c_exp_tax_range";
 $tabname[37] = MAIN_DB_PREFIX."c_units";
 $tabname[38] = MAIN_DB_PREFIX."c_socialnetworks";
-$tabname[39]= MAIN_DB_PREFIX."c_transport_mode";
+$tabname[39] = MAIN_DB_PREFIX."c_prospectcontactlevel";
+$tabname[40] = MAIN_DB_PREFIX."c_stcommcontact";
+$tabname[41] = MAIN_DB_PREFIX."c_transport_mode";
+
 // Dictionary labels
 $tablib = array();
 $tablib[1] = "DictionaryCompanyJuridicalType";
@@ -174,7 +181,9 @@ $tablib[35] = "DictionaryExpenseTaxCat";
 $tablib[36] = "DictionaryExpenseTaxRange";
 $tablib[37] = "DictionaryMeasuringUnits";
 $tablib[38] = "DictionarySocialNetworks";
-$tablib[39] = "DictionaryTransportMode";
+$tablib[39] = "DictionaryProspectContactLevel";
+$tablib[40] = "DictionaryProspectContactStatus";
+$tablib[41] = "DictionaryTransportMode";
 
 // Requests to extract data
 $tabsql = array();
@@ -204,7 +213,7 @@ $tabsql[23] = "SELECT t.rowid as rowid, t.taux, t.revenuestamp_type, c.label as
 $tabsql[24] = "SELECT rowid   as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_type_resource";
 $tabsql[25] = "SELECT rowid   as rowid, code, label, active, module FROM ".MAIN_DB_PREFIX."c_type_container as t WHERE t.entity IN (".getEntity('c_type_container').")";
 //$tabsql[26]= "SELECT rowid   as rowid, code, label, short_label, active FROM ".MAIN_DB_PREFIX."c_units";
-$tabsql[27] = "SELECT id      as rowid, code, libelle, active FROM ".MAIN_DB_PREFIX."c_stcomm";
+$tabsql[27] = "SELECT id      as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcomm";
 $tabsql[28] = "SELECT h.rowid as rowid, h.code, h.label, h.affect, h.delay, h.newbymonth, h.fk_country as country_id, c.code as country_code, c.label as country, h.active FROM ".MAIN_DB_PREFIX."c_holiday_types as h LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON h.fk_country=c.rowid";
 $tabsql[29] = "SELECT rowid   as rowid, code, label, percent, position, active FROM ".MAIN_DB_PREFIX."c_lead_status";
 $tabsql[30] = "SELECT rowid, code, name, paper_size, orientation, metric, leftmargin, topmargin, nx, ny, spacex, spacey, width, height, font_size, custom_x, custom_y, active FROM ".MAIN_DB_PREFIX."c_format_cards";
@@ -216,7 +225,9 @@ $tabsql[35] = "SELECT c.rowid, c.label, c.active, c.entity FROM ".MAIN_DB_PREFIX
 $tabsql[36] = "SELECT r.rowid, r.fk_c_exp_tax_cat, r.range_ik, r.active, r.entity FROM ".MAIN_DB_PREFIX."c_exp_tax_range r";
 $tabsql[37] = "SELECT r.rowid, r.code, r.label, r.short_label, r.unit_type, r.scale, r.active FROM ".MAIN_DB_PREFIX."c_units r";
 $tabsql[38] = "SELECT rowid, entity, code, label, url, icon, active FROM ".MAIN_DB_PREFIX."c_socialnetworks";
-$tabsql[39] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode";
+$tabsql[39] = "SELECT code, label as libelle, sortorder, active FROM ".MAIN_DB_PREFIX."c_prospectcontactlevel";
+$tabsql[40] = "SELECT id      as rowid, code, libelle, picto, active FROM ".MAIN_DB_PREFIX."c_stcommcontact";
+$tabsql[41] = "SELECT rowid as rowid, code, label, active FROM ".MAIN_DB_PREFIX."c_transport_mode";
 
 // Criteria to sort dictionaries
 $tabsqlsort = array();
@@ -258,7 +269,9 @@ $tabsqlsort[35] = "c.label ASC";
 $tabsqlsort[36] = "r.fk_c_exp_tax_cat ASC, r.range_ik ASC";
 $tabsqlsort[37] = "r.unit_type ASC, r.scale ASC, r.code ASC";
 $tabsqlsort[38] = "rowid, code ASC";
-$tabsqlsort[39] = "code ASC";
+$tabsqlsort[39] = "sortorder ASC";
+$tabsqlsort[40] = "code ASC";
+$tabsqlsort[41] = "code ASC";
 
 // Field names in select result for dictionary display
 $tabfield = array();
@@ -288,7 +301,7 @@ $tabfield[23] = "country_id,country,taux,revenuestamp_type,accountancy_code_sell
 $tabfield[24] = "code,label";
 $tabfield[25] = "code,label";
 //$tabfield[26]= "code,label,short_label";
-$tabfield[27] = "code,libelle";
+$tabfield[27] = "code,libelle,picto";
 $tabfield[28] = "code,label,affect,delay,newbymonth,country_id,country";
 $tabfield[29] = "code,label,percent,position";
 $tabfield[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
@@ -300,7 +313,9 @@ $tabfield[35] = "label";
 $tabfield[36] = "range_ik,fk_c_exp_tax_cat";
 $tabfield[37] = "code,label,short_label,unit_type,scale";
 $tabfield[38] = "code,label,url,icon,entity";
-$tabfield[39] = "code,label";
+$tabfield[39] = "code,libelle,sortorder";
+$tabfield[40] = "code,libelle,picto";
+$tabfield[41] = "code,label";
 
 // Edit field names for editing a record
 $tabfieldvalue = array();
@@ -330,7 +345,7 @@ $tabfieldvalue[23] = "country,taux,revenuestamp_type,accountancy_code_sell,accou
 $tabfieldvalue[24] = "code,label";
 $tabfieldvalue[25] = "code,label";
 //$tabfieldvalue[26]= "code,label,short_label";
-$tabfieldvalue[27] = "code,libelle";
+$tabfieldvalue[27] = "code,libelle,picto";
 $tabfieldvalue[28] = "code,label,affect,delay,newbymonth,country";
 $tabfieldvalue[29] = "code,label,percent,position";
 $tabfieldvalue[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
@@ -342,7 +357,9 @@ $tabfieldvalue[35] = "label";
 $tabfieldvalue[36] = "range_ik,fk_c_exp_tax_cat";
 $tabfieldvalue[37] = "code,label,short_label,unit_type,scale";
 $tabfieldvalue[38] = "code,label,url,icon";
-$tabfieldvalue[39] = "code,label";
+$tabfieldvalue[39] = "code,libelle,sortorder";
+$tabfieldvalue[40] = "code,libelle,picto";
+$tabfieldvalue[41] = "code,label";
 
 // Field names in the table for inserting a record
 $tabfieldinsert = array();
@@ -372,7 +389,7 @@ $tabfieldinsert[23] = "fk_pays,taux,revenuestamp_type,accountancy_code_sell,acco
 $tabfieldinsert[24] = "code,label";
 $tabfieldinsert[25] = "code,label";
 //$tabfieldinsert[26]= "code,label,short_label";
-$tabfieldinsert[27] = "code,libelle";
+$tabfieldinsert[27] = "code,libelle,picto";
 $tabfieldinsert[28] = "code,label,affect,delay,newbymonth,fk_country";
 $tabfieldinsert[29] = "code,label,percent,position";
 $tabfieldinsert[30] = "code,name,paper_size,orientation,metric,leftmargin,topmargin,nx,ny,spacex,spacey,width,height,font_size,custom_x,custom_y";
@@ -385,7 +402,9 @@ $tabfieldinsert[35] = "label";
 $tabfieldinsert[36] = "range_ik,fk_c_exp_tax_cat";
 $tabfieldinsert[37] = "code,label,short_label,unit_type,scale";
 $tabfieldinsert[38] = "code,label,url,icon,entity";
-$tabfieldinsert[39] = "code,label";
+$tabfieldinsert[39] = "code,label,sortorder";
+$tabfieldinsert[40] = "code,libelle,picto";
+$tabfieldinsert[41] = "code,label";
 
 // Rowid name of field depending if field is autoincrement on or off..
 // Use "" if id field is "rowid" and has autoincrement on
@@ -429,7 +448,9 @@ $tabrowid[35] = "";
 $tabrowid[36] = "";
 $tabrowid[37] = "";
 $tabrowid[38] = "";
-$tabrowid[39] = "";
+$tabrowid[39] = "code";
+$tabrowid[40] = "id";
+$tabrowid[41] = "";
 
 // Condition to show dictionary in setup page
 $tabcond = array();
@@ -471,7 +492,9 @@ $tabcond[35] = !empty($conf->expensereport->enabled);
 $tabcond[36] = !empty($conf->expensereport->enabled);
 $tabcond[37] = !empty($conf->product->enabled);
 $tabcond[38] = !empty($conf->socialnetworks->enabled);
-$tabcond[39] = !empty($conf->intracommreport->enabled);
+$tabcond[39] = (! empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS));
+$tabcond[40] = !empty($conf->societe->enabled);
+$tabcond[41] = !empty($conf->intracommreport->enabled);
 
 // List of help for fields
 $tabhelp = array();
@@ -501,7 +524,7 @@ $tabhelp[23] = array('revenuestamp_type'=>'FixedOrPercent');
 $tabhelp[24] = array('code'=>$langs->trans("EnterAnyCode"));
 $tabhelp[25] = array('code'=>$langs->trans('EnterAnyCode'));
 //$tabhelp[26] = array('code'=>$langs->trans("EnterAnyCode"));
-$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[27] = array('code'=>$langs->trans("EnterAnyCode"),'picto'=>$langs->trans("PictoHelp"));
 $tabhelp[28] = array('affect'=>$langs->trans("FollowedByACounter"), 'delay'=>$langs->trans("MinimumNoticePeriod"), 'newbymonth'=>$langs->trans("NbAddedAutomatically"));
 $tabhelp[29] = array('code'=>$langs->trans("EnterAnyCode"), 'percent'=>$langs->trans("OpportunityPercent"), 'position'=>$langs->trans("PositionIntoComboList"));
 $tabhelp[30] = array('code'=>$langs->trans("EnterAnyCode"), 'name'=>$langs->trans("LabelName"), 'paper_size'=>$langs->trans("LabelPaperSize"));
@@ -514,6 +537,8 @@ $tabhelp[36] = array('range_ik'=>$langs->trans('PrevRangeToThisRange'));
 $tabhelp[37] = array('code'=>$langs->trans("EnterAnyCode"), 'unit_type' => $langs->trans('MeasuringUnitTypeDesc'), 'scale' => $langs->trans('MeasuringScaleDesc'));
 $tabhelp[38] = array('code'=>$langs->trans("EnterAnyCode"), 'url' => $langs->trans('UrlSocialNetworksDesc'), 'icon' => $langs->trans('FafaIconSocialNetworksDesc'));
 $tabhelp[39] = array('code'=>$langs->trans("EnterAnyCode"));
+$tabhelp[40] = array('code'=>$langs->trans("EnterAnyCode"),'picto'=>$langs->trans("PictoHelp"));
+$tabhelp[41] = array('code'=>$langs->trans("EnterAnyCode"));
 
 // List of check for fields (NOT USED YET)
 $tabfieldcheck = array();
@@ -556,6 +581,8 @@ $tabfieldcheck[36] = array();
 $tabfieldcheck[37] = array();
 $tabfieldcheck[38] = array();
 $tabfieldcheck[39] = array();
+$tabfieldcheck[40] = array();
+$tabfieldcheck[41] = array();
 
 // Complete all arrays with entries found into modules
 complete_dictionary_with_modules($taborder, $tabname, $tablib, $tabsql, $tabsqlsort, $tabfield, $tabfieldvalue, $tabfieldinsert, $tabrowid, $tabcond, $tabhelp, $tabfieldcheck);
@@ -657,7 +684,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
 		if ($value == 'dayrule' && empty($_POST['dayrule'])) continue;
 		if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position'
 		if ((!isset($_POST[$value]) || $_POST[$value] == '')
-        	&& (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking'))  // Fields that are not mandatory
+        	&& (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto'))  // Fields that are not mandatory
         	&& (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
         	)
 		) {

+ 1 - 1
htdocs/admin/emailcollector_list.php

@@ -209,7 +209,7 @@ $sql .= $hookmanager->resPrint;
 
 /* If a group by is required
 $sql.= " GROUP BY "
-foreach($object->fields as $key => $val)
+foreach ($object->fields as $key => $val)
 {
 	$sql.='t.'.$key.', ';
 }

+ 1 - 1
htdocs/admin/events.php

@@ -102,7 +102,7 @@ print '<input type="hidden" name="action" value="save">';
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'audit', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'audit', '', -1);
 
 print '<table class="noborder" width="100%">';
 print "<tr class=\"liste_titre\">";

+ 1 - 1
htdocs/admin/expedition.php

@@ -184,7 +184,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'sending');
+dol_fiche_head($head, 'shipment', $langs->trans("Sendings"), -1, 'shipment');
 
 // Shipment numbering model
 

+ 1 - 1
htdocs/admin/expedition_extrafields.php

@@ -76,7 +76,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), -1, 'sending');
+dol_fiche_head($head, 'attributes_shipment', $langs->trans("Sendings"), -1, 'shipment');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 1 - 1
htdocs/admin/expeditiondet_extrafields.php

@@ -77,7 +77,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), -1, 'sending');
+dol_fiche_head($head, 'attributeslines_shipment', $langs->trans("Sendings"), -1, 'shipment');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 35 - 65
htdocs/admin/limits.php

@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2007-2012	Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C) 2007-2020	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2009-2018	Regis Houssin		<regis.houssin@inodbox.com>
  * Copyright (C) 2010		Juanjo Menent		<jmenent@2byte.es>
  *
@@ -34,11 +34,21 @@ if (!$user->admin) accessforbidden();
 $action = GETPOST('action', 'alpha');
 $currencycode = GETPOST('currencycode', 'alpha');
 
+if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY)) {
+    // When MULTICURRENCY_USE_LIMIT_BY_CURRENCY is on, we use always a defined currency code instead of '' even for default.
+    $currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
+}
+
 $mainmaxdecimalsunit = 'MAIN_MAX_DECIMALS_UNIT'.(!empty($currencycode) ? '_'.$currencycode : '');
 $mainmaxdecimalstot = 'MAIN_MAX_DECIMALS_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
 $mainmaxdecimalsshown = 'MAIN_MAX_DECIMALS_SHOWN'.(!empty($currencycode) ? '_'.$currencycode : '');
 $mainroundingruletot = 'MAIN_ROUNDING_RULE_TOT'.(!empty($currencycode) ? '_'.$currencycode : '');
 
+$valmainmaxdecimalsunit = GETPOST($mainmaxdecimalsunit, 'int');
+$valmainmaxdecimalstot = GETPOST($mainmaxdecimalstot, 'int');
+$valmainmaxdecimalsshown = GETPOST($mainmaxdecimalsshown, 'int');
+$valmainroundingruletot = price2num(GETPOST($mainroundingruletot, 'alpha'));
+
 if ($action == 'update')
 {
 	$error = 0;
@@ -60,9 +70,9 @@ if ($action == 'update')
 	    setEventMessages($langs->trans("ErrorNegativeValueNotAllowed"), null, 'errors');
     }
 
-    if ($_POST[$mainroundingruletot])
+    if ($valmainroundingruletot)
     {
-        if ($_POST[$mainroundingruletot] * pow(10, $_POST[$mainmaxdecimalstot]) < 1)
+        if ($valmainroundingruletot * pow(10, $valmainmaxdecimalstot) < 1)
         {
             $langs->load("errors");
             $error++;
@@ -72,11 +82,11 @@ if ($action == 'update')
 
     if (!$error)
     {
-    	dolibarr_set_const($db, $mainmaxdecimalsunit, $_POST[$mainmaxdecimalsunit], 'chaine', 0, '', $conf->entity);
-    	dolibarr_set_const($db, $mainmaxdecimalstot, $_POST[$mainmaxdecimalstot], 'chaine', 0, '', $conf->entity);
-    	dolibarr_set_const($db, $mainmaxdecimalsshown, $_POST[$mainmaxdecimalsshown], 'chaine', 0, '', $conf->entity);
+        dolibarr_set_const($db, $mainmaxdecimalsunit, $valmainmaxdecimalsunit, 'chaine', 0, '', $conf->entity);
+        dolibarr_set_const($db, $mainmaxdecimalstot, $valmainmaxdecimalstot, 'chaine', 0, '', $conf->entity);
+        dolibarr_set_const($db, $mainmaxdecimalsshown, $valmainmaxdecimalsshown, 'chaine', 0, '', $conf->entity);
 
-    	dolibarr_set_const($db, $mainroundingruletot, $_POST[$mainroundingruletot], 'chaine', 0, '', $conf->entity);
+    	dolibarr_set_const($db, $mainroundingruletot, $valmainroundingruletot, 'chaine', 0, '', $conf->entity);
 
         header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup".(!empty($currencycode) ? '&currencycode='.$currencycode : ''));
         exit;
@@ -94,7 +104,6 @@ llxHeader();
 
 print load_fiche_titre($langs->trans("LimitsSetup"), '', 'title_setup');
 
-$currencycode = (!empty($currencycode) ? $currencycode : $conf->currency);
 $aCurrencies = array($conf->currency); // Default currency always first position
 
 if (!empty($conf->multicurrency->enabled) && !empty($conf->global->MULTICURRENCY_USE_LIMIT_BY_CURRENCY))
@@ -232,9 +241,9 @@ if (empty($mysoc->country_code))
 	// Add vat rates examples specific to country
 	$vat_rates = array();
 
-	$sql = "SELECT taux as vat_rate";
+	$sql = "SELECT taux as vat_rate, t.code as vat_code, t.localtax1 as localtax_rate1, t.localtax2 as localtax_rate2";
 	$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
-	$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND t.taux <> 0";
+	$sql .= " WHERE t.active=1 AND t.fk_pays = c.rowid AND c.code='".$mysoc->country_code."' AND (t.taux <> 0 OR t.localtax1 <>0 OR t.localtax2 <>0)";
 	$sql .= " ORDER BY t.taux ASC";
 	$resql = $db->query($sql);
 	if ($resql)
@@ -245,23 +254,31 @@ if (empty($mysoc->country_code))
 	        for ($i = 0; $i < $num; $i++)
 	        {
 	            $obj = $db->fetch_object($resql);
-	            $vat_rates[$i] = $obj->vat_rate;
+	            $vat_rates[] = array('vat_rate'=>$obj->vat_rate, 'code'=>$obj->vat_code, 'localtax_rate1'=>$obj->localtax_rate1, 'locltax_rate2'=>$obj->localtax_rate2);
 	        }
 	    }
 	} else dol_print_error($db);
 
 	if (count($vat_rates))
 	{
-	    foreach ($vat_rates as $vat)
+	    foreach ($vat_rates as $vatarray)
 	    {
+	        $vat = $vatarray['vat_rate'];
 	        for ($qty = 1; $qty <= 2; $qty++)
 	        {
+	            $vattxt = $vat.($vatarray['code'] ? ' ('.$vatarray['code'].')' : '');
+
+	            $localtax_array = getLocalTaxesFromRate($vattxt, 0, $mysoc, $mysoc);
+
 	            $s = 10 / 3;
-	            $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	            $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
 	            print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	            print " x ".$langs->trans("Quantity").": ".$qty;
 	            print " - ".$langs->trans("VAT").": ".$vat.'%';
-	            print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
+	            print ($vatarray['code'] ? ' ('.$vatarray['code'].')' : '');
+	            print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ";
+	            print $tmparray[0].' / '.$tmparray[1].($tmparray[9] ? '+'.$tmparray[9] : '').($tmparray[10] ? '+'.$tmparray[10] : '').' / '.$tmparray[2];
+	            print "<br>\n";
 	        }
 	    }
 	} else {
@@ -269,69 +286,22 @@ if (empty($mysoc->country_code))
 	    // This example must be kept for test purpose with current value because value used (2/7, 10/3, and vat 0, 10)
 	    // were calculated to show all possible cases of rounding. If we change this, examples becomes useless or show the same rounding rule.
 
+	    $localtax_array = array();
+
 	    $s = 10 / 3; $qty = 1; $vat = 10;
-	    $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	    $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
 	    print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	    print " x ".$langs->trans("Quantity").": ".$qty;
 	    print " - ".$langs->trans("VAT").": ".$vat.'%';
 	    print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").": ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 
 	    $s = 10 / 3; $qty = 2; $vat = 10;
-	    $tmparray = calcul_price_total(1, $qty * price2num($s, 'MU'), 0, $vat, 0, 0, 0, 'HT', 0, 0, $mysoc);
+	    $tmparray = calcul_price_total($qty, price2num($s, 'MU'), 0, $vat, -1, -1, 0, 'HT', 0, 0, $mysoc, $localtax_array);
 	    print '<span class="opacitymedium">'.$langs->trans("UnitPriceOfProduct").":</span> ".price2num($s, 'MU');
 	    print " x ".$langs->trans("Quantity").": ".$qty;
 	    print " - ".$langs->trans("VAT").": ".$vat.'%';
 	    print ' &nbsp; -> &nbsp; <span class="opacitymedium">'.$langs->trans("TotalPriceAfterRounding").":</span> ".$tmparray[0].' / '.$tmparray[1].' / '.$tmparray[2]."<br>\n";
 	}
-
-	// Important: can debug rounding, to simulate the rounded total
-	/*
-	print '<br><b>'.$langs->trans("VATRoundedByLine").' ('.$langs->trans("DolibarrDefault").')</b><br>';
-
-	foreach($vat_rates as $vat)
-	{
-		for ($qty=1; $qty<=2; $qty++)
-		{
-			$s1=10/3;
-			$s2=2/7;
-
-			// Round by line
-			$tmparray1=calcul_price_total(1,$qty*price2num($s1,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
-			$tmparray2=calcul_price_total(1,$qty*price2num($s2,'MU'),0,$vat,0,0,0,'HT',0, 0,$mysoc);
-			$total_ht = $tmparray1[0] + $tmparray2[0];
-			$total_tva = $tmparray1[1] + $tmparray2[1];
-			$total_ttc = $tmparray1[2] + $tmparray2[2];
-
-			print $langs->trans("UnitPriceOfProduct").": ".(price2num($s1,'MU') + price2num($s2,'MU'));
-			print " x ".$langs->trans("Quantity").": ".$qty;
-			print " - ".$langs->trans("VAT").": ".$vat.'%';
-			print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
-		}
-	}
-
-	print '<br><b>'.$langs->trans("VATRoundedOnTotal").'</b><br>';
-
-	foreach($vat_rates as $vat)
-	{
-		for ($qty=1; $qty<=2; $qty++)
-		{
-			$s1=10/3;
-			$s2=2/7;
-
-			// Global round
-			$subtotal_ht = (($qty*price2num($s1,'MU')) + ($qty*price2num($s2,'MU')));
-			$tmparray3=calcul_price_total(1,$subtotal_ht,0,$vat,0,0,0,'HT',0, 0,$mysoc);
-			$total_ht = $tmparray3[0];
-			$total_tva = $tmparray3[1];
-			$total_ttc = $tmparray3[2];
-
-			print $langs->trans("UnitPriceOfProduct").": ".price2num($s1+$s2,'MU');
-			print " x ".$langs->trans("Quantity").": ".$qty;
-			print " - ".$langs->trans("VAT").": ".$vat.'%';
-			print " &nbsp; -> &nbsp; ".$langs->trans("TotalPriceAfterRounding").": ".$total_ht.' / '.$total_tva.' / '.$total_ttc."<br>\n";
-		}
-	}
-	*/
 }
 
 // End of page

+ 1 - 1
htdocs/admin/livraison.php

@@ -179,7 +179,7 @@ print load_fiche_titre($langs->trans("SendingsSetup"), $linkback, 'title_setup')
 print '<br>';
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'sending');
+dol_fiche_head($head, 'receivings', $langs->trans("Receivings"), -1, 'shipment');
 
 
 // Delivery numbering model

+ 1 - 1
htdocs/admin/livraison_extrafields.php

@@ -76,7 +76,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), -1, 'sending');
+dol_fiche_head($head, 'attributes_receivings', $langs->trans("Receivings"), -1, 'shipment');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 1 - 1
htdocs/admin/livraisondet_extrafields.php

@@ -77,7 +77,7 @@ print "<br>\n";
 
 $head = expedition_admin_prepare_head();
 
-dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), -1, 'sending');
+dol_fiche_head($head, 'attributeslines_receivings', $langs->trans("Receivings"), -1, 'shipment');
 
 require DOL_DOCUMENT_ROOT.'/core/tpl/admin_extrafields_view.tpl.php';
 

+ 24 - 18
htdocs/admin/mails_templates.php

@@ -153,20 +153,20 @@ $sourceList = array();
 
 // We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
 $elementList = array();
-if ($conf->propal->enabled)            $elementList['propal_send'] = $langs->trans('MailToSendProposal');
-if ($conf->commande->enabled)          $elementList['order_send'] = $langs->trans('MailToSendOrder');
-if ($conf->facture->enabled)           $elementList['facture_send'] = $langs->trans('MailToSendInvoice');
+if ($conf->propal->enabled && $user->rights->propal->lire)     $elementList['propal_send'] = $langs->trans('MailToSendProposal');
+if ($conf->commande->enabled && $user->rights->commande->lire) $elementList['order_send'] = $langs->trans('MailToSendOrder');
+if ($conf->facture->enabled && $user->rights->facture->lire)   $elementList['facture_send'] = $langs->trans('MailToSendInvoice');
 if ($conf->expedition->enabled)        $elementList['shipping_send'] = $langs->trans('MailToSendShipment');
 if ($conf->reception->enabled) 		   $elementList['reception_send'] = $langs->trans('MailToSendReception');
 if ($conf->ficheinter->enabled)        $elementList['fichinter_send'] = $langs->trans('MailToSendIntervention');
 if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send'] = $langs->trans('MailToSendSupplierRequestForQuotation');
-if ($conf->fournisseur->enabled && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_order->enabled)	$elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder');
-if ($conf->fournisseur->enabled && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || $conf->supplier_invoice->enabled)	$elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice');
-if ($conf->societe->enabled)           $elementList['thirdparty'] = $langs->trans('MailToThirdparty');
-if ($conf->adherent->enabled)          $elementList['member'] = $langs->trans('MailToMember');
-if ($conf->contrat->enabled)           $elementList['contract'] = $langs->trans('MailToSendContract');
+if (($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_order->enabled && $user->rights->supplier_order->lire))	$elementList['order_supplier_send'] = $langs->trans('MailToSendSupplierOrder');
+if (($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || ($conf->supplier_invoice->enabled && $user->rights->supplier_invoice->lire))	$elementList['invoice_supplier_send'] = $langs->trans('MailToSendSupplierInvoice');
+if ($conf->societe->enabled && $user->rights->societe->lire)           $elementList['thirdparty'] = $langs->trans('MailToThirdparty');
+if ($conf->adherent->enabled && $user->rights->adherent->lire)          $elementList['member'] = $langs->trans('MailToMember');
+if ($conf->contrat->enabled && $user->rights->contrat->lire)           $elementList['contract'] = $langs->trans('MailToSendContract');
 if ($conf->projet->enabled)            $elementList['project'] = $langs->trans('MailToProject');
-if ($conf->ticket->enabled)            $elementList['ticket_send'] = $langs->trans('MailToTicket');
+if ($conf->ticket->enabled && $user->rights->ticket->read)            $elementList['ticket_send'] = $langs->trans('MailToTicket');
 $elementList['user'] = $langs->trans('MailToUser');
 
 $parameters = array('elementList'=>$elementList);
@@ -544,6 +544,7 @@ if (!empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) { $fieldsforco
 foreach ($fieldsforcontent as $tmpfieldlist)
 {
 	print '<tr class="impair nodrag nodrop nohover"><td colspan="6" class="nobottom">';
+
 	// Label
 	if ($tmpfieldlist == 'topic')
 	{
@@ -557,6 +558,7 @@ foreach ($fieldsforcontent as $tmpfieldlist)
 		print $form->textwithpicto($langs->trans("Content"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
 	if ($tmpfieldlist == 'content_lines')
 		print $form->textwithpicto($langs->trans("ContentForLines"), $tabhelp[$id][$tmpfieldlist], 1, 'help', '', 0, 2, $tmpfieldlist).'<br>';
+
 	// Input field
 	if ($tmpfieldlist == 'topic') {
 		print '<input type="text" class="flat minwidth500" name="'.$tmpfieldlist.'" value="'.(!empty($obj->{$tmpfieldlist}) ? $obj->{$tmpfieldlist} : '').'">';
@@ -633,30 +635,34 @@ if ($resql)
 
     // Title line with search boxes
     print '<tr class="liste_titre">';
+
     $filterfound = 0;
     foreach ($fieldlist as $field => $value)
     {
-        if ($value == 'label') print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>';
-        elseif ($value == 'lang')
-        {
+    	if ($value == 'label') {
+    		print '<td class="liste_titre"><input type="text" name="search_label" class="maxwidth100" value="'.dol_escape_htmltag($search_label).'"></td>';
+    	} elseif ($value == 'lang') {
         	print '<td class="liste_titre">';
         	print $formadmin->select_language($search_lang, 'search_lang', 0, null, 1, 0, 0, 'maxwidth100');
         	print '</td>';
-        } elseif ($value == 'fk_user')
-        {
+        } elseif ($value == 'fk_user') {
         	print '<td class="liste_titre">';
         	$restrictid = array();
         	if (!$user->admin) $restrictid = array($user->id);
         	//var_dump($restrictid);
         	print $form->select_dolusers($search_fk_user, 'search_fk_user', 1, null, 0, 'hierarchyme', null, 0, 0, 1, '', 0, '', 'maxwidth100');
         	print '</td>';
-        } elseif ($value == 'topic') print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
-        elseif ($value == 'type_template')
-        {
+        } elseif ($value == 'topic') {
+        	print '<td class="liste_titre"><input type="text" name="search_topic" value="'.dol_escape_htmltag($search_topic).'"></td>';
+        } elseif ($value == 'type_template') {
         	print '<td class="liste_titre">'.$form->selectarray('search_type_template', $elementList, $search_type_template, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100 maxwidth100onsmartphone').'</td>';
-        } elseif (!in_array($value, array('content', 'content_lines'))) print '<td class="liste_titre"></td>';
+        } elseif (!in_array($value, array('content', 'content_lines'))) {
+        	print '<td class="liste_titre"></td>';
+        }
     }
+
     if (empty($conf->global->MAIN_EMAIL_TEMPLATES_FOR_OBJECT_LINES)) print '<td class="liste_titre"></td>';
+
     // Action column
     print '<td class="liste_titre right" width="64">';
     $searchpicto = $form->showFilterButtons();

+ 1 - 1
htdocs/admin/menus.php

@@ -151,7 +151,7 @@ print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="update">';
 
-dol_fiche_head($head, 'handler', $langs->trans("Menus"), -1);
+dol_fiche_head($head, 'handler', '', -1);
 
 print '<span class="opacitymedium">'.$langs->trans("MenusDesc")."</span><br>\n";
 print "<br>\n";

+ 1 - 1
htdocs/admin/menus/index.php

@@ -229,7 +229,7 @@ $head[$h][1] = $langs->trans("Miscellaneous");
 $head[$h][2] = 'misc';
 $h++;
 
-dol_fiche_head($head, 'editor', $langs->trans("Menus"), -1);
+dol_fiche_head($head, 'editor', '', -1);
 
 print '<span class="opacitymedium">'.$langs->trans("MenusEditorDesc")."</span><br>\n";
 print "<br>\n";

+ 1 - 1
htdocs/admin/menus/other.php

@@ -75,7 +75,7 @@ $head[$h][1] = $langs->trans("Miscellaneous");
 $head[$h][2] = 'misc';
 $h++;
 
-dol_fiche_head($head, 'misc', $langs->trans("Menus"), -1);
+dol_fiche_head($head, 'misc', '', -1);
 
 
 // Other Options

+ 2 - 2
htdocs/admin/modulehelp.php

@@ -262,7 +262,7 @@ print '<div class="centpercent">';
 
 $picto = 'object_'.$objMod->picto;
 
-print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto);
+print load_fiche_titre(($modulename ? $modulename : $moduledesc), $moreinfo, $picto, 0, '', 'titlemodulehelp');
 print '<br>';
 
 dol_fiche_head($head, $mode, '', -1);
@@ -341,7 +341,7 @@ if ($mode == 'feature')
     $text .= '<br><br>';
 
     $text .= '<br><strong>'.$langs->trans("AddDataTables").':</strong> ';
-	$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql'));
+	$sqlfiles = dol_dir_list(dol_buildpath($moduledir.'/sql/'), 'files', 0, 'llx.*\.sql', array('\.key\.sql', '\.sql\.back'));
     if (count($sqlfiles) > 0)
     {
     	$text .= $langs->trans("Yes").' (';

+ 16 - 14
htdocs/admin/modules.php

@@ -38,7 +38,7 @@ require_once DOL_DOCUMENT_ROOT.'/admin/dolistore/class/dolistore.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array("errors", "admin", "modulebuilder"));
 
-$mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : 'commonkanban';
+$mode = GETPOSTISSET('mode') ? GETPOST('mode', 'alpha') : (empty($conf->global->MAIN_MODULE_SETUP_ON_LIST_BY_DEFAULT) ? 'commonkanban' : 'common');
 if (empty($mode)) $mode = 'common';
 $action = GETPOST('action', 'alpha');
 //var_dump($_POST);exit;
@@ -460,8 +460,9 @@ asort($orders);
 //var_dump($modules);
 
 $nbofactivatedmodules = count($conf->modules);
-$moreinfo = $langs->trans("TotalNumberOfActivatedModules", ($nbofactivatedmodules - 1), count($modules));
-if ($nbofactivatedmodules <= 1) $moreinfo .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
+$moreinfo = $langs->trans("TitleNumberOfActivatedModules");
+$moreinfo2 = ($nbofactivatedmodules - 1)." / ".count($modules);
+if ($nbofactivatedmodules <= 1) $moreinfo2 .= ' '.img_warning($langs->trans("YouMustEnableOneModule"));
 
 print load_fiche_titre($langs->trans("ModulesSetup"), '', 'title_setup');
 
@@ -496,11 +497,19 @@ if ($mode == 'common' || $mode == 'commonkanban')
 	dol_fiche_head($head, $newmode, '', -1);
 
 	$moreforfilter = '<div class="valignmiddle">';
+
+	$moreforfilter .= '<div class="floatright right pagination"><ul><li>';
+	$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'common' ? '' : ' btnTitleSelected')));
+	$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'commonkanban' ? '' : ' btnTitleSelected')));
+	$moreforfilter .= '</li></ul></div>';
+
+	$moreforfilter .= '<div class="floatright center marginrightonly hideonsmartphone" style="padding-top: 3px"><span class="">'.$moreinfo.'</span><br><b class="largenumber">'.$moreinfo2.'</b></div>';
+
 	$moreforfilter .= '<div class="colorbacktimesheet float valignmiddle">';
-	$moreforfilter .= '<div class="divsearchfield">';
+	$moreforfilter .= '<div class="divsearchfield paddingtop">';
 	$moreforfilter .= $langs->trans('Keyword').': <input type="text" id="search_keyword" name="search_keyword" class="maxwidth100" value="'.dol_escape_htmltag($search_keyword).'">';
 	$moreforfilter .= '</div>';
-	$moreforfilter .= '<div class="divsearchfield">';
+	$moreforfilter .= '<div class="divsearchfield paddingtop">';
 	$moreforfilter .= $langs->trans('Origin').': '.$form->selectarray('search_nature', $arrayofnatures, dol_escape_htmltag($search_nature), 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
 	$moreforfilter .= '</div>';
 	if (!empty($conf->global->MAIN_FEATURES_LEVEL))
@@ -509,11 +518,11 @@ if ($mode == 'common' || $mode == 'commonkanban')
 		if ($conf->global->MAIN_FEATURES_LEVEL < 0) $array_version['deprecated'] = $langs->trans("Deprecated");
 		if ($conf->global->MAIN_FEATURES_LEVEL > 0) $array_version['experimental'] = $langs->trans("Experimental");
 		if ($conf->global->MAIN_FEATURES_LEVEL > 1) $array_version['development'] = $langs->trans("Development");
-		$moreforfilter .= '<div class="divsearchfield">';
+		$moreforfilter .= '<div class="divsearchfield paddingtop">';
 		$moreforfilter .= $langs->trans('Version').': '.$form->selectarray('search_version', $array_version, $search_version, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
 		$moreforfilter .= '</div>';
 	}
-	$moreforfilter .= '<div class="divsearchfield">';
+	$moreforfilter .= '<div class="divsearchfield paddingtop">';
 	$moreforfilter .= $langs->trans('Status').': '.$form->selectarray('search_status', array('active'=>$langs->transnoentitiesnoconv("Enabled"), 'disabled'=>$langs->transnoentitiesnoconv("Disabled")), $search_status, 1, 0, 0, '', 0, 0, 0, '', 'maxwidth100');
 	$moreforfilter .= '</div>';
 	$moreforfilter .= ' ';
@@ -524,13 +533,6 @@ if ($mode == 'common' || $mode == 'commonkanban')
 	$moreforfilter .= '</div>';
 	$moreforfilter .= '</div>';
 
-	$moreforfilter .= '<div class="floatright right">';
-	$moreforfilter .= dolGetButtonTitle($langs->trans('ViewKanban'), '', 'fa fa-th-list paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=commonkanban'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'common' ? '' : ' btnTitleSelected')));
-	$moreforfilter .= dolGetButtonTitle($langs->trans('ViewList'), '', 'fa fa-list-alt paddingleft imgforviewmode', $_SERVER["PHP_SELF"].'?mode=common'.$param, '', 1, array('morecss'=>'reposition'.($mode == 'commonkanban' ? '' : ' btnTitleSelected')));
-	$moreforfilter .= '</div>';
-
-	$moreforfilter .= '<div class="floatright right margintoponly marginrightonly" style="padding-top: 3px">'.$moreinfo.'</div>';
-
 	$moreforfilter .= '</div>';
 
 	if (!empty($moreforfilter))

+ 1 - 1
htdocs/admin/mrp_extrafields.php

@@ -68,7 +68,7 @@ $linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_valu
 print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup');
 
 
-$head = mrpAdminPrepareHead(null);
+$head = mrpAdminPrepareHead();
 
 dol_fiche_head($head, 'mrp_extrafields', $langs->trans("ExtraFields"), -1, 'account');
 

+ 41 - 57
htdocs/admin/pdf.php

@@ -72,6 +72,7 @@ if ($action == 'update')
 	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"], 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"], 'chaine', 0, '', $conf->entity);
 
+	dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", $_POST["MAIN_INVERT_SENDER_RECIPIENT"], 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", $_POST["MAIN_PDF_USE_ISO_LOCATION"], 'chaine', 0, '', $conf->entity);
 	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"], 'chaine', 0, '', $conf->entity);
@@ -82,6 +83,7 @@ if ($action == 'update')
 
     dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
 
+	setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 
 	header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");
 	exit;
@@ -119,9 +121,41 @@ $arraydetailsforpdffoot = array(
 	3 => $langs->transnoentitiesnoconv('DisplayCompanyInfoAndManagers')
 );
 
+$s = $langs->trans("LibraryToBuildPDF")."<br>";
+$i = 0;
+$pdf = pdf_getInstance('A4');
+if (class_exists('FPDF') && !class_exists('TCPDF'))
+{
+	if ($i) $s .= ' + ';
+	$s .= 'FPDF';
+	$s .= ' ('.@constant('FPDF_PATH').')';
+	$i++;
+}
+if (class_exists('TCPDF'))
+{
+	if ($i) $s .= ' + ';
+	$s .= 'TCPDF';
+	$s .= ' ('.@constant('TCPDF_PATH').')';
+	$i++;
+}
+if (class_exists('FPDI'))
+{
+	if ($i) $s .= ' + ';
+	$s .= 'FPDI';
+	$s .= ' ('.@constant('FPDI_PATH').')';
+	$i++;
+}
+if (class_exists('TCPDI'))
+{
+	if ($i) $s .= ' + ';
+	$s .= 'TCPDI';
+	$s .= ' ('.@constant('TCPDI_PATH').')';
+	$i++;
+}
+
 print load_fiche_titre($langs->trans("PDF"), '', 'title_setup');
 
-print '<span class="opacitymedium">'.$langs->trans("PDFDesc")."</span><br>\n";
+print '<span class="opacitymedium">'.$form->textwithpicto($langs->trans("PDFDesc"), $s)."</span><br>\n";
 print "<br>\n";
 
 $noCountryCode = (empty($mysoc->country_code) ? true : false);
@@ -261,6 +295,12 @@ print '<div class="div-table-responsive-no-min">';
 print '<table summary="more" class="noborder centpercent">';
 print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td width="200px">'.$langs->trans("Value").'</td></tr>';
 
+// Height of logo
+
+print '<tr class="oddeven"><td>'.$langs->trans("MAIN_DOCUMENTS_LOGO_HEIGHT").'</td><td>';
+print '<input type="text" class="maxwidth50" name="MAIN_DOCUMENTS_LOGO_HEIGHT" value="'.(!empty($conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT) ? $conf->global->MAIN_DOCUMENTS_LOGO_HEIGHT : 20).'">';
+print '</td></tr>';
+
 //Desc
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideDescOnPDF").'</td><td>';
@@ -309,62 +349,6 @@ print '</td></tr>';
 print '</table>';
 print '</div>';
 
-
-/*
- *  Library
- */
-
-print '<br>';
-print load_fiche_titre($langs->trans("Library"), '', '');
-
-print '<div class="div-table-responsive-no-min">';
-print '<table class="noborder centpercent">'."\n";
-
-print '<tr class="liste_titre">'."\n";
-print '<td>'.$langs->trans("Name").'</td>'."\n";
-print '<td>'.$langs->trans("Value").'</td>'."\n";
-print "</tr>\n";
-
-print '<tr class="oddeven">'."\n";
-print '<td>'.$langs->trans("LibraryToBuildPDF").'</td>'."\n";
-print '<td>';
-$i = 0;
-$pdf = pdf_getInstance('A4');
-if (class_exists('FPDF') && !class_exists('TCPDF'))
-{
-	if ($i) print ' + ';
-	print 'FPDF';
-	print ' ('.@constant('FPDF_PATH').')';
-	$i++;
-}
-if (class_exists('TCPDF'))
-{
-	if ($i) print ' + ';
-	print 'TCPDF';
-	print ' ('.@constant('TCPDF_PATH').')';
-	$i++;
-}
-if (class_exists('FPDI'))
-{
-	if ($i) print ' + ';
-	print 'FPDI';
-	print ' ('.@constant('FPDI_PATH').')';
-	$i++;
-}
-if (class_exists('TCPDI'))
-{
-	if ($i) print ' + ';
-	print 'TCPDI';
-	print ' ('.@constant('TCPDI_PATH').')';
-	$i++;
-}
-print '</td>'."\n";
-print '</tr>'."\n";
-
-print "</table>\n";
-print '</div>';
-
-
 print '<br><div class="center">';
 print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
 print '</div>';

+ 1 - 1
htdocs/admin/perms.php

@@ -116,7 +116,7 @@ $db->commit();
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'default', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'default', '', -1);
 
 
 // Show warning about external users

+ 1 - 1
htdocs/admin/proxy.php

@@ -94,7 +94,7 @@ print '<input type="hidden" name="action" value="set_proxy">';
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'proxy', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'proxy', '', -1);
 
 
 if ($conf->use_javascript_ajax)

+ 81 - 57
htdocs/admin/receiptprinter.php

@@ -65,13 +65,13 @@ if (!function_exists('gzdecode')) {
     }
 }
 
+
 /*
  * Action
  */
 
 if ($action == 'addprinter' && $user->admin) {
     $error = 0;
-    $db->begin();
     if (empty($printername)) {
         $error++;
         setEventMessages($langs->trans("PrinterNameEmpty"), null, 'errors');
@@ -82,7 +82,8 @@ if ($action == 'addprinter' && $user->admin) {
     }
 
     if (!$error) {
-        $result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
+    	$db->begin();
+    	$result = $printer->addPrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter);
         if ($result > 0) $error++;
 
         if (!$error)
@@ -99,14 +100,14 @@ if ($action == 'addprinter' && $user->admin) {
 
 if ($action == 'deleteprinter' && $user->admin) {
     $error = 0;
-    $db->begin();
     if (empty($printerid)) {
         $error++;
         setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
     }
 
     if (!$error) {
-        $result = $printer->deletePrinter($printerid);
+    	$db->begin();
+    	$result = $printer->deletePrinter($printerid);
         if ($result > 0) $error++;
 
         if (!$error)
@@ -123,14 +124,14 @@ if ($action == 'deleteprinter' && $user->admin) {
 
 if ($action == 'updateprinter' && $user->admin) {
     $error = 0;
-    $db->begin();
     if (empty($printerid)) {
         $error++;
         setEventMessages($langs->trans("PrinterIdEmpty"), null, 'errors');
     }
 
     if (!$error) {
-        $result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
+    	$db->begin();
+    	$result = $printer->updatePrinter($printername, GETPOST('printertypeid', 'int'), GETPOST('printerprofileid', 'int'), $parameter, $printerid);
         if ($result > 0) $error++;
 
         if (!$error) {
@@ -189,14 +190,14 @@ if ($action == 'testtemplate' && $user->admin) {
 
 if ($action == 'updatetemplate' && $user->admin) {
     $error = 0;
-    $db->begin();
     if (empty($templateid)) {
         $error++;
         setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors');
     }
 
     if (!$error) {
-        $result = $printer->updateTemplate($templatename, $template, $templateid);
+    	$db->begin();
+    	$result = $printer->updateTemplate($templatename, $template, $templateid);
         if ($result > 0) $error++;
 
         if (!$error) {
@@ -212,14 +213,14 @@ if ($action == 'updatetemplate' && $user->admin) {
 
 if ($action == 'addtemplate' && $user->admin) {
     $error = 0;
-    $db->begin();
     if (empty($templatename)) {
         $error++;
         setEventMessages($langs->trans("TemplateNameEmpty"), null, 'errors');
     }
 
     if (!$error) {
-        $result = $printer->addTemplate($templatename, $template);
+    	$db->begin();
+    	$result = $printer->addTemplate($templatename, $template);
         if ($result > 0) $error++;
 
         if (!$error) {
@@ -233,6 +234,29 @@ if ($action == 'addtemplate' && $user->admin) {
     $action = '';
 }
 
+if ($action == 'deletetemplate' && $user->admin) {
+	$error = 0;
+	if (empty($templateid)) {
+		$error++;
+		setEventMessages($langs->trans("TemplateIdEmpty"), null, 'errors');
+	}
+
+	if (!$error) {
+		$db->begin();
+		$result = $printer->deleteTemplate($templateid);
+		if ($result > 0) $error++;
+
+		if (!$error) {
+			$db->commit();
+			setEventMessages($langs->trans("TemplateDeleted", $templatename), null);
+		} else {
+			$db->rollback();
+			dol_print_error($db);
+		}
+	}
+	$action = '';
+}
+
 
 /*
  * View
@@ -247,6 +271,7 @@ print load_fiche_titre($langs->trans("ReceiptPrinterSetup"), $linkback, 'title_s
 
 $head = receiptprinteradmin_prepare_head($mode);
 
+// mode = config
 if ($mode == 'config' && $user->admin) {
     print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=config" autocomplete="off">';
     print '<input type="hidden" name="token" value="'.newToken().'">';
@@ -259,7 +284,7 @@ if ($mode == 'config' && $user->admin) {
 
     dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
 
-    print $langs->trans("ReceiptPrinterDesc")."<br><br>\n";
+    print '<span class="opacitymedium">'.$langs->trans("ReceiptPrinterDesc")."</span><br><br>\n";
 
     print '<table class="noborder centpercent">'."\n";
     print '<tr class="liste_titre">';
@@ -272,6 +297,22 @@ if ($mode == 'config' && $user->admin) {
     $ret = $printer->listprinters();
     $nbofprinters = count($printer->listprinters);
 
+    if ($action != 'editprinter') {
+    	print '<tr>';
+    	print '<td><input size="50" type="text" name="printername"></td>';
+    	$ret = $printer->selectTypePrinter();
+    	print '<td>'.$printer->resprint.'</td>';
+    	$ret = $printer->selectProfilePrinter();
+    	print '<td>'.$printer->profileresprint.'</td>';
+    	print '<td><input size="60" type="text" name="parameter"></td>';
+    	print '<td class="right">';
+    	if ($action != 'editprinter') {
+    		print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
+    	}
+    	print '</td>';
+    	print '</tr>';
+    }
+
     if ($ret > 0) {
         setEventMessages($printer->error, $printer->errors, 'errors');
     } else {
@@ -285,7 +326,9 @@ if ($mode == 'config' && $user->admin) {
                 $ret = $printer->selectProfilePrinter($printer->listprinters[$line]['fk_profile']);
                 print '<td>'.$printer->profileresprint.'</td>';
                 print '<td><input size="60" type="text" name="parameter" value="'.$printer->listprinters[$line]['parameter'].'"></td>';
-                print '<td></td>';
+                print '<td>';
+                print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
+                print '</td>';
                 print '</tr>';
             } else {
                 print '<td>'.$printer->listprinters[$line]['name'].'</td>';
@@ -293,15 +336,15 @@ if ($mode == 'config' && $user->admin) {
                 print '<td>'.$langs->trans($printer->listprinters[$line]['fk_profile_name']).'</td>';
                 print '<td>'.$printer->listprinters[$line]['parameter'].'</td>';
                 // edit icon
-                print '<td><a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=editprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'">';
+                print '<td class="right"><a class="editfielda marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=editprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'">';
                 print img_picto($langs->trans("Edit"), 'edit');
                 print '</a>';
                 // delete icon
-                print '<a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=deleteprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
+                print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=deleteprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
                 print img_picto($langs->trans("Delete"), 'delete');
                 print '</a>';
                 // test icon
-                print '<a href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=testprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
+                print '<a class="marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=config&amp;action=testprinter&amp;printerid='.$printer->listprinters[$line]['rowid'].'&amp;printername='.$printer->listprinters[$line]['name'].'">';
                 print img_picto($langs->trans("TestPrinter"), 'printer');
                 print '</a></td>';
                 print '</tr>';
@@ -309,38 +352,10 @@ if ($mode == 'config' && $user->admin) {
         }
     }
 
-    if ($action != 'editprinter') {
-        if ($nbofprinters > 0) {
-            print '<tr class="liste_titre">';
-            print '<th>'.$langs->trans("Name").'</th>';
-            print '<th>'.$langs->trans("Type").'</th>';
-            print '<th>'.$langs->trans("Profile").'</th>';
-            print '<th>'.$langs->trans("Parameters").'</th>';
-            print '<th></th>';
-            print "</tr>\n";
-        }
-
-        print '<tr>';
-        print '<td><input size="50" type="text" name="printername"></td>';
-        $ret = $printer->selectTypePrinter();
-        print '<td>'.$printer->resprint.'</td>';
-        $ret = $printer->selectProfilePrinter();
-        print '<td>'.$printer->profileresprint.'</td>';
-        print '<td><input size="60" type="text" name="parameter"></td>';
-        print '<td></td>';
-        print '<td></td>';
-        print '<td></td>';
-        print '</tr>';
-    }
     print '</table>';
 
     dol_fiche_end();
 
-    if ($action != 'editprinter') {
-        print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
-    } else {
-        print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
-    }
     print '</form>';
 
     print '<br>';
@@ -370,8 +385,11 @@ if ($mode == 'config' && $user->admin) {
     print '</table>';
 }
 
+// mode = template
 if ($mode == 'template' && $user->admin) {
-    print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
+	dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), -1, 'technic');
+
+	print '<form method="post" action="'.$_SERVER["PHP_SELF"].'?mode=template" autocomplete="off">';
     print '<input type="hidden" name="token" value="'.newToken().'">';
     if ($action != 'edittemplate') {
         print '<input type="hidden" name="action" value="addtemplate">';
@@ -379,16 +397,11 @@ if ($mode == 'template' && $user->admin) {
         print '<input type="hidden" name="action" value="updatetemplate">';
     }
 
-
-    print load_fiche_titre($langs->trans("ReceiptPrinterTemplateDesc"), '', '')."<br><br>\n";
-
     print '<table class="noborder centpercent">'."\n";
     print '<tr class="liste_titre">';
     print '<th>'.$langs->trans("Name").'</th>';
     print '<th>'.$langs->trans("Template").'</th>';
     print '<th></th>';
-    print '<th></th>';
-    print '<th></th>';
     print "</tr>\n";
     $ret = $printer->listPrintersTemplates();
     //print '<pre>'.print_r($printer->listprinterstemplates, true).'</pre>';
@@ -401,22 +414,23 @@ if ($mode == 'template' && $user->admin) {
             if ($action == 'edittemplate' && $printer->listprinterstemplates[$line]['rowid'] == $templateid) {
                 print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
                 print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
-                print '<td><textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
+                print '<td>';
+                print '<textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
                 print '</td>';
                 print '<td></td>';
             } else {
                 print '<td>'.$printer->listprinterstemplates[$line]['name'].'</td>';
                 print '<td>'.nl2br(htmlentities($printer->listprinterstemplates[$line]['template'])).'</td>';
                 // edit icon
-                print '<td><a class="editfielda paddingleftonly paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
+                print '<td><a class="editfielda paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=edittemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'">';
                 print img_picto($langs->trans("Edit"), 'edit');
                 print '</a>';
                 // delete icon
-                print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=deletetemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
+                print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=deletetemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
                 print img_picto($langs->trans("Delete"), 'delete');
                 print '</a>';
                 // test icon
-                print '<a class="paddingleftonly paddingrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=testtemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
+                print '<a class="paddingleftonly marginrightonly" href="'.$_SERVER['PHP_SELF'].'?mode=template&amp;action=testtemplate&amp;templateid='.$printer->listprinterstemplates[$line]['rowid'].'&amp;templatename='.$printer->listprinterstemplates[$line]['name'].'">';
                 print img_picto($langs->trans("TestPrinterTemplate"), 'printer');
                 print '</a></td>';
             }
@@ -424,20 +438,30 @@ if ($mode == 'template' && $user->admin) {
         }
     }
 
-    print '</table>';
     if ($action != 'edittemplate') {
-		print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
+    	print '<tr>';
 		print '<td><input size="50" type="text" name="templatename" value="'.$printer->listprinterstemplates[$line]['name'].'"></td>';
-		print '<td><textarea name="template" wrap="soft" cols="120" rows="12">'.$printer->listprinterstemplates[$line]['template'].'</textarea>';
+		print '<td>';
+		print '<textarea name="template" wrap="soft" cols="120" rows="12">';
+		print GETPOSTISSET('template') ? GETPOST('template', 'alpha') : $printer->listprinterstemplates[$line]['template'];
+		print '</textarea>';
 		print '</td>';
 		print '<td></td>';
+		print '</tr>';
+    }
+
+    print '</table>';
 
-        print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
+    if ($action != 'edittemplate') {
+		print '<input type="hidden" name="templateid" value="'.$printer->listprinterstemplates[$line]['rowid'].'">';
+		print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Add")).'"></div>';
     } else {
         print '<div class="center"><input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("Save")).'"></div>';
     }
     print '</form>';
 
+    dol_fiche_end();
+
     print '<br>';
 
     print '<table class="noborder centpercent">'."\n";

+ 1 - 1
htdocs/admin/resource.php

@@ -28,7 +28,7 @@ require '../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/resource.lib.php';
-if (!empty($conf->resouce->enabled)) require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
+require_once DOL_DOCUMENT_ROOT.'/resource/class/html.formresource.class.php';
 
 // Load translation files required by the page
 $langs->loadLangs(array("admin", "resource"));

+ 1 - 1
htdocs/admin/security.php

@@ -197,7 +197,7 @@ print "<br>\n";
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'passwords', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'passwords', '', -1);
 
 
 // Choix du gestionnaire du generateur de mot de passe

+ 1 - 1
htdocs/admin/security_file.php

@@ -100,7 +100,7 @@ print '<input type="hidden" name="action" value="updateform">';
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'file', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'file', '', -1);
 
 
 // Upload options

+ 1 - 1
htdocs/admin/security_other.php

@@ -93,7 +93,7 @@ print '<input type="hidden" name="action" value="updateform">';
 
 $head = security_prepare_head();
 
-dol_fiche_head($head, 'misc', $langs->trans("Security"), -1);
+dol_fiche_head($head, 'misc', '', -1);
 
 
 // Other Options

+ 26 - 17
htdocs/admin/system/database-tables.php

@@ -28,21 +28,27 @@ require '../../main.inc.php';
 
 $langs->load("admin");
 
-if (!$user->admin)
+if (!$user->admin) {
 	accessforbidden();
+}
 
 $action = GETPOST('action', 'alpha');
 
 
 if ($action == 'convert')
 {
-    $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
+	$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ENGINE=INNODB";
 	$db->query($sql);
 }
 if ($action == 'convertutf8')
 {
-    $sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
-    $db->query($sql);
+	$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." CHARACTER SET utf8 COLLATE utf8_unicode_ci";
+	$db->query($sql);
+}
+if ($action == 'convertdynamic')
+{
+	$sql = "ALTER TABLE ".$db->escape(GETPOST("table", "aZ09"))." ROW_FORMAT=DYNAMIC;";
+	$db->query($sql);
 }
 
 
@@ -82,8 +88,8 @@ if (!$base)
 } else {
 	if ($base == 1)
 	{
-        print '<div class="div-table-responsive-no-min">';
-	    print '<table class="noborder">';
+		print '<div class="div-table-responsive-no-min">';
+		print '<table class="noborder">';
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans("TableName").'</td>';
 		print '<td colspan="2">'.$langs->trans("Type").'</td>';
@@ -112,13 +118,17 @@ if (!$base)
 
 				print '<td><a href="dbtable.php?table='.$obj->Name.'">'.$obj->Name.'</a></td>';
 				print '<td>'.$obj->Engine.'</td>';
-				if (isset($obj->Engine) && $obj->Engine == "MyISAM")
-				{
-				    print '<td><a class="reposition" href="database-tables.php?action=convert&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' InnoDB</a></td>';
+				if (isset($obj->Engine) && $obj->Engine == "MyISAM") {
+				    print '<td><a class="reposition" href="database-tables.php?action=convert&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' InnoDb</a></td>';
 				} else {
 					print '<td>&nbsp;</td>';
 				}
-				print '<td>'.$obj->Row_format.'</td>';
+				print '<td>';
+				print $obj->Row_format;
+				if (isset($obj->Row_format) && (in_array($obj->Row_format, array("Compact")))) {
+					print '<br><a class="reposition" href="database-tables.php?action=convertdynamic&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' Dynamic</a>';
+				}
+				print '</td>';
 				print '<td align="right">'.$obj->Rows.'</td>';
 				print '<td align="right">'.$obj->Avg_row_length.'</td>';
 				print '<td align="right">'.$obj->Data_length.'</td>';
@@ -127,9 +137,8 @@ if (!$base)
 				print '<td align="right">'.$obj->Auto_increment.'</td>';
 				print '<td align="right">'.$obj->Check_time.'</td>';
 				print '<td align="right">'.$obj->Collation;
-				if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "utf8mb4_unicode_ci", "latin1_swedish_ci"))))
-				{
-				    print '<br><a class="reposition" href="database-tables.php?action=convertutf8&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' UTF8</a>';
+				if (isset($obj->Collation) && (in_array($obj->Collation, array("utf8mb4_general_ci", "utf8mb4_unicode_ci", "latin1_swedish_ci")))) {
+					print '<br><a class="reposition" href="database-tables.php?action=convertutf8&amp;table='.$obj->Name.'">'.$langs->trans("Convert").' UTF8</a>';
 				}
 				print '</td>';
 				print '</tr>';
@@ -142,8 +151,8 @@ if (!$base)
 
 	if ($base == 2)
 	{
-        print '<div class="div-table-responsive-no-min">';
-	    print '<table class="noborder">';
+		print '<div class="div-table-responsive-no-min">';
+		print '<table class="noborder">';
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans("TableName").'</td>';
 		print '<td>Nb of tuples</td>';
@@ -182,8 +191,8 @@ if (!$base)
 	if ($base == 4)
 	{
 		// Sqlite by PDO or by Sqlite3
-        print '<div class="div-table-responsive-no-min">';
-	    print '<table class="noborder">';
+		print '<div class="div-table-responsive-no-min">';
+		print '<table class="noborder">';
 		print '<tr class="liste_titre">';
 		print '<td>'.$langs->trans("TableName").'</td>';
 		print '<td>'.$langs->trans("NbOfRecord").'</td>';

+ 2 - 1
htdocs/admin/tools/dolibarr_export.php

@@ -237,7 +237,8 @@ if (in_array($type, array('mysql', 'mysqli'))) {
     print '<input type="checkbox" name="sql_structure" value="structure" id="checkbox_sql_structure" checked />';
     print '<label for="checkbox_sql_structure">'.$langs->trans('ExportStructure').'</label>';
     print '</legend>';
-    print '<input type="checkbox" name="drop"'.(((!isset($_GET["drop"]) && !isset($_POST["drop"])) || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
+
+    print '<input type="checkbox" name="drop"'.((! GETPOSTISSET("drop") || GETPOST('drop')) ? ' checked' : '').' id="checkbox_dump_drop" />';
     print '<label for="checkbox_dump_drop">'.$langs->trans("AddDropTable").'</label>';
     print '<br>';
     print '</fieldset>';

+ 4 - 4
htdocs/admin/translation.php

@@ -40,7 +40,7 @@ $transkey = GETPOST('transkey', 'alphanohtml');
 $transvalue = GETPOST('transvalue', 'none');
 
 
-$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'overwrite';
+$mode = GETPOST('mode', 'aZ09') ?GETPOST('mode', 'aZ09') : 'searchkey';
 
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -496,7 +496,7 @@ if ($mode == 'searchkey')
         if ($i > ($offset + $limit)) break;
         print '<tr class="oddeven"><td>'.$langcode.'</td><td>'.$key.'</td><td>';
         print dol_escape_htmltag($val);
-        print '</td><td class="right">';
+        print '</td><td class="right nowraponall">';
         if (!empty($newlangfileonly->tab_translate[$key]))
         {
             if ($val != $newlangfileonly->tab_translate[$key])
@@ -516,7 +516,7 @@ if ($mode == 'searchkey')
                 print ' ';
                 print '<a href="'.$_SERVER['PHP_SELF'].'?rowid='.$obj->rowid.'&entity='.$conf->entity.'&action=delete">'.img_delete().'</a>';
                 print '&nbsp;&nbsp;';
-                $htmltext = $langs->trans("OriginalValueWas", $newlangfileonly->tab_translate[$key]);
+                $htmltext = $langs->trans("OriginalValueWas", '<i>'.$newlangfileonly->tab_translate[$key].'</i>');
                 print $form->textwithpicto('', $htmltext, 1, 'info');
             } elseif (!empty($conf->global->MAIN_ENABLE_OVERWRITE_TRANSLATION))
             {
@@ -530,7 +530,7 @@ if ($mode == 'searchkey')
             	//$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?key='.$key;
             	$transifexurl = 'https://www.transifex.com/dolibarr-association/dolibarr/translate/#'.$langcode.'/'.$transifexlangfile.'?q=key%3A'.$key;
 
-            	print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto('FixOnTransifex', 'globe').'</a>';
+            	print ' &nbsp; <a href="'.$transifexurl.'" target="transifex">'.img_picto($langs->trans('FixOnTransifex'), 'globe').'</a>';
             }
         } else {
             $htmltext = $langs->trans("TransKeyWithoutOriginalValue", $key);

+ 4 - 2
htdocs/api/class/api_documents.class.php

@@ -419,8 +419,10 @@ class Documents extends DolibarrApi
 
 			$object = new Product($this->db);
 			$result = $object->fetch($id, $ref);
-			if (!$result) {
+			if ($result==0) {
 				throw new RestException(404, 'Product not found');
+			} elseif ($result<0) {
+				throw new RestException(500, 'Error while fetching object: '.$object->error);
 			}
 
 			$upload_dir = $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 0, $object, 'product').dol_sanitizeFileName($object->ref);
@@ -630,7 +632,7 @@ class Documents extends DolibarrApi
 			    }
 				elseif ($result < 0)
 				{
-					throw new RestException(500, 'Error while fetching object.');
+					throw new RestException(500, 'Error while fetching object: '.$object->error);
 				}
 			}
 

+ 7 - 5
htdocs/api/index.php

@@ -251,15 +251,17 @@ if (!empty($reg[1]) && ($reg[1] != 'explorer' || ($reg[2] != '/swagger.json' &&
 	if ($tmpmodule != 'api')
 		$tmpmodule = preg_replace('/api$/i', '', $tmpmodule);
 	$classfile = str_replace('_', '', $tmpmodule);
-	if ($module == 'supplierproposals')
+
+	// Special cases that does not match name rules conventions
+	if ($moduleobject == 'supplierproposals')
 		$classfile = 'supplier_proposals';
-	if ($module == 'supplierorders')
+	if ($moduleobject == 'supplierorders')
 		$classfile = 'supplier_orders';
-	if ($module == 'supplierinvoices')
+	if ($moduleobject == 'supplierinvoices')
 		$classfile = 'supplier_invoices';
-	if ($module == 'ficheinter')
+	if ($moduleobject == 'ficheinter')
 		$classfile = 'interventions';
-	if ($module == 'interventions')
+	if ($moduleobject == 'interventions')
 		$classfile = 'interventions';
 
 	$dir_part_file = dol_buildpath('/'.$moduledirforclass.'/class/api_'.$classfile.'.class.php', 0, 2);

+ 5 - 3
htdocs/barcode/printsheet.php

@@ -57,9 +57,11 @@ $thirdpartytmp = new Societe($db);
 if (GETPOST('submitproduct') && GETPOST('submitproduct'))
 {
 	$action = ''; // We reset because we don't want to build doc
-	if (GETPOST('productid') > 0)
-	{
-		$producttmp->fetch(GETPOST('productid'));
+	if (GETPOST('productid') > 0) {
+		$result = $producttmp->fetch(GETPOST('productid'));
+		if ($result < 0) {
+			setEventMessage($producttmp->error, 'errors');
+		}
 		$forbarcode = $producttmp->barcode;
 		$fk_barcode_type = $producttmp->barcode_type;
 

+ 1 - 1
htdocs/bom/bom_agenda.php

@@ -130,7 +130,7 @@ if ($object->id > 0)
 
 	// Object card
 	// ------------------------------------------------------------
-	$linkback = '<a href="'.dol_buildpath('/bom/myobject_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
+	$linkback = '<a href="'.dol_buildpath('/bom/bom_list.php', 1).'?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
 
 	$morehtmlref = '<div class="refidno">';
 	/*

+ 5 - 3
htdocs/bom/bom_card.php

@@ -192,10 +192,10 @@ if (empty($reshook))
 		$error = 0;
 
 		// Set if we used free entry or predefined product
-		$qty = GETPOST('qty', 'int');
+		$qty = price2num(GETPOST('qty', 'int'));
 		$qty_frozen = GETPOST('qty_frozen', 'int');
 		$disable_stock_change = GETPOST('disable_stock_change', 'int');
-		$efficiency = GETPOST('efficiency', 'int');
+		$efficiency = price2num(GETPOST('efficiency', 'int'));
 
 		if ($qty == '') {
 			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
@@ -219,6 +219,8 @@ if (empty($reshook))
 			unset($_POST['qty']);
 			unset($_POST['qty_frozen']);
 		    unset($_POST['disable_stock_change']);
+
+		    $object->fetchLines();
 		}
 	}
 }
@@ -541,7 +543,7 @@ 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' : '#line_'.GETPOST('lineid', 'int')).'" 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="">

+ 7 - 2
htdocs/bom/class/bom.class.php

@@ -251,7 +251,7 @@ class BOM extends CommonObject
 	    if ($result > 0 && !empty($object->table_element_line)) $object->fetchLines();
 
 	    // Get lines so they will be clone
-	    //foreach($object->lines as $line)
+	    //foreach ($object->lines as $line)
 	    //	$line->fetch_optionals();
 
 	    // Reset some properties
@@ -929,6 +929,7 @@ class BOM extends CommonObject
 		global $conf, $langs;
 
 		$langs->load("mrp");
+		$outputlangs->load("products");
 
 		if (!dol_strlen($modele)) {
 			$modele = 'standard';
@@ -1004,7 +1005,11 @@ class BOM extends CommonObject
 
 		foreach ($this->lines as &$line) {
 			$tmpproduct = new Product($this->db);
-			$tmpproduct->fetch($line->fk_product);
+			$result= $tmpproduct->fetch($line->fk_product);
+			if ($result < 0) {
+				$this->error=$tmpproduct->error;
+				return -1;
+			}
 			$line->unit_cost = price2num((!empty($tmpproduct->cost_price)) ? $tmpproduct->cost_price : $tmpproduct->pmp);
 			if (empty($line->unit_cost)) {
 				if ($productFournisseur->find_min_price_product_fournisseur($line->fk_product) > 0)

+ 9 - 2
htdocs/bom/tpl/linkedobjectblock.tpl.php

@@ -52,8 +52,15 @@ foreach ($linkedObjectBlock as $key => $objectlink)
     }
     echo '</td>';
     echo '<td class="linkedcol-name nowraponall" >'.$objectlink->getNomUrl(1).'</td>';
-    $product_static->fetch($objectlink->fk_product);
-    echo '<td class="linkedcol-ref" align="center">'.$product_static->getNomUrl(1).'</td>';
+
+    echo '<td class="linkedcol-ref" align="center">';
+	$result=$product_static->fetch($objectlink->fk_product);
+	if ($result<0) {
+		setEventMessage($product_static->error, 'errors');
+	} elseif ($result>0)  {
+		$product_static->getNomUrl(1);
+	}
+    print '</td>';
     echo '<td class="linkedcol-date" align="center">'.dol_print_date($objectlink->date_creation, 'day').'</td>';
     echo '<td class="linkedcol-amount right">';
     if ($user->rights->commande->lire) {

+ 1 - 2
htdocs/bom/tpl/objectline_create.tpl.php

@@ -58,7 +58,6 @@ if ($nolinesbefore) {
     }
     print '<td class="linecoldescription minwidth500imp">';
 	print '<div id="add"></div><span class="hideonsmartphone">'.$langs->trans('AddNewLine').'</span>';
-	// echo $langs->trans("FreeZone");
 	print '</td>';
 	print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
 	if ($conf->global->PRODUCT_USE_UNITS)
@@ -114,7 +113,7 @@ if ($conf->global->PRODUCT_USE_UNITS)
 {
     $coldisplay++;
 	print '<td class="nobottom linecoluseunit left">';
-	print $form->selectUnits($line->fk_unit, "units");
+	print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit, "units");
 	print '</td>';
 }
 

+ 1 - 1
htdocs/bom/tpl/objectline_title.tpl.php

@@ -69,7 +69,7 @@ print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs
 print '<td class="linecolefficiency right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
 
 // Cost
-print '<td class="linecolcost right">'.$langs->trans('CostPrice').'</td>';
+print '<td class="linecolcost right">'.$form->textwithpicto($langs->trans("TotalCost"), $langs->trans("BOMTotalCost")).'</td>';
 
 print '<td class="linecoledit"></td>'; // No width to allow autodim
 

+ 1 - 1
htdocs/bom/tpl/objectline_view.tpl.php

@@ -113,7 +113,7 @@ if ($this->status == 0 && ($object_rights->write) && $action != 'selectlines') {
 	$coldisplay++;
     if (($line->info_bits & 2) == 2 || !empty($disableedit)) {
     } else {
-        print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'#line_'.$line->id.'">'.img_edit().'</a>';
+        print '<a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$this->id.'&amp;action=editline&amp;lineid='.$line->id.'">'.img_edit().'</a>';
     }
     print '</td>';
 

+ 1 - 0
htdocs/bookmarks/card.php

@@ -145,6 +145,7 @@ if ($action == 'create')
 	print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST" enctype="multipart/form-data">'."\n";
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print '<input type="hidden" name="action" value="add">';
+	print '<input type="hidden" name="backtopage" value="'.$backtopage.'">';
 
 	print load_fiche_titre($langs->trans("NewBookmark"));
 

+ 1 - 1
htdocs/bookmarks/list.php

@@ -154,7 +154,7 @@ print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
 
 $newcardbutton = '';
-$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create', '', !empty($user->rights->bookmark->creer));
+$newcardbutton .= dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/bookmarks/card.php?action=create&backtopage='.urlencode(DOL_URL_ROOT.'/bookmarks/list.php'), '', !empty($user->rights->bookmark->creer));
 
 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'bookmark', 0, $newcardbutton, '', $limit, 0, 0, 1);
 

+ 23 - 1
htdocs/categories/class/categorie.class.php

@@ -1213,7 +1213,8 @@ class Categorie extends CommonObject
 		//print 'Result for id_categ='.$id_categ.' : '.$this->cats[$id_categ]['fullpath'].'<br>'."\n";
 
 		// We count number of _ to have level
-		$this->cats[$id_categ]['level'] = dol_strlen(preg_replace('/[^_]/i', '', $this->cats[$id_categ]['fullpath']));
+		$nbunderscore = substr_count($this->cats[$id_categ]['fullpath'], '_');
+		$this->cats[$id_categ]['level'] = ($nbunderscore ? $nbunderscore : null);
 
         return;
     }
@@ -2009,4 +2010,25 @@ class Categorie extends CommonObject
 			return "";
 		}
 	}
+
+	/**
+	 *      Count all categories
+	 *
+	 *      @return int                             Number of categories, -1 on error
+	 */
+	public function countNbOfCategories()
+	{
+		dol_syslog(get_class($this)."::count_all_categories", LOG_DEBUG);
+		$sql = "SELECT COUNT(rowid) FROM ".MAIN_DB_PREFIX."categorie";
+		$sql .= " WHERE entity IN (".getEntity('category').")";
+
+		$res = $this->db->query($sql);
+		if ($res) {
+			$obj = $this->db->fetch_object($res);
+			return $obj->count;
+		} else {
+			dol_print_error($this->db);
+			return -1;
+		}
+	}
 }

+ 9 - 8
htdocs/comm/action/card.php

@@ -6,8 +6,8 @@
  * Copyright (C) 2010-2013 Juanjo Menent        <jmenent@2byte.es>
  * Copyright (C) 2013      Florian Henry        <florian.henry@open-concept.pro>
  * Copyright (C) 2014      Cedric GROSS         <c.gross@kreiz-it.fr>
- * Copyright (C) 2015       Alexandre Spangaro      <aspangaro@open-dsi.fr>
- * Copyright (C) 2018-2019  Frédéric France         <frederic.france@netlogic.fr>
+ * Copyright (C) 2015      Alexandre Spangaro   <aspangaro@open-dsi.fr>
+ * Copyright (C) 2018-2019 Frédéric France      <frederic.france@netlogic.fr>
  * Copyright (C) 2019	   Ferran Marcet	    <fmarcet@2byte.es>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -111,6 +111,7 @@ $parameters = array('socid' => $socid);
 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
 
+
 /*
  * Actions
  */
@@ -310,7 +311,7 @@ if (empty($reshook) && $action == 'add')
 		if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby", "int");
 	}
 
-	$object->note_private = trim(GETPOST("note"));
+	$object->note_private = trim(GETPOST("note", "none"));
 
 	if (isset($_POST["contactid"])) $object->contact = $contact;
 
@@ -451,7 +452,7 @@ if (empty($reshook) && $action == 'update')
             $object->contact_id = key($object->socpeopleassigned);
         }
 		$object->fk_project  = GETPOST("projectid", 'int');
-		$object->note_private = GETPOST("note", "none");
+		$object->note_private = trim(GETPOST("note", "none"));
 		$object->fk_element	 = GETPOST("fk_element", "int");
 		$object->elementtype = GETPOST("elementtype", "alphanohtml");
 
@@ -1028,14 +1029,13 @@ if ($action == 'create')
 	// Project
 	if (!empty($conf->projet->enabled))
 	{
-		// Projet associe
 		$langs->load("projects");
 
 		$projectid = GETPOST('projectid', 'int');
 
 		print '<tr><td class="titlefieldcreate">'.$langs->trans("Project").'</td><td id="project-input-container" >';
 
-		$numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1);
+		$numproject = $formproject->select_projects((!empty($societe->id) ? $societe->id : -1), $projectid, 'projectid', 0, 0, 1, 1, 0, 0, 0, '', 0, 0, 'maxwidth500');
 
 		print ' <a href="'.DOL_URL_ROOT.'/projet/card.php?socid='.$societe->id.'&action=create"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans("AddProject").'"></span></a>';
 		$urloption = '?action=create&donotclearsession=1';
@@ -1077,6 +1077,7 @@ if ($action == 'create')
 		print '<input type="hidden" name="origin" size="10" value="'.GETPOST('origin').'">';
 	}
 
+	$reg = array();
 	if (GETPOST("datep") && preg_match('/^([0-9][0-9][0-9][0-9])([0-9][0-9])([0-9][0-9])$/', GETPOST("datep"), $reg))
 	{
 		$object->datep = dol_mktime(0, 0, 0, $reg[2], $reg[3], $reg[1]);
@@ -1090,7 +1091,7 @@ if ($action == 'create')
     // Description
     print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
     require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-    $doleditor = new DolEditor('note', (GETPOST('note', 'none') ?GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%');
+    $doleditor = new DolEditor('note', (GETPOST('note', 'none') ? GETPOST('note', 'none') : $object->note_private), '', 180, 'dolibarr_notes', 'In', true, true, $conf->fckeditor->enabled, ROWS_4, '90%');
     $doleditor->Create();
     print '</td></tr>';
 
@@ -1541,7 +1542,7 @@ if ($id > 0)
 		$linkback = '';
 		// Link to other agenda views
 		$linkback .= img_picto($langs->trans("BackToList"), 'object_list-alt', 'class="hideonsmartphone pictoactionview"');
-		$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
+		$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 		$linkback .= '</li>';
 		$linkback .= '<li class="noborder litext">';
 		$linkback .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="hideonsmartphone pictoactionview"');

+ 2 - 2
htdocs/comm/action/class/actioncomm.class.php

@@ -1207,8 +1207,8 @@ class ActionComm extends CommonObject
 	    		$response->warning_delay = $conf->agenda->warning_delay / 60 / 60 / 24;
 	    		$response->label = $langs->trans("ActionsToDo");
 	    		$response->labelShort = $langs->trans("ActionsToDoShort");
-	    		$response->url = DOL_URL_ROOT.'/comm/action/list.php?actioncode=0&amp;status=todo&amp;mainmenu=agenda';
-	    		if ($user->rights->agenda->allactions->read) $response->url .= '&amp;filtert=-1';
+	    		$response->url = DOL_URL_ROOT.'/comm/action/list.php?action=show_list&actioncode=0&status=todo&mainmenu=agenda';
+	    		if ($user->rights->agenda->allactions->read) $response->url .= '&filtert=-1';
 	    		$response->img = img_object('', "action", 'class="inline-block valigntextmiddle"');
     		}
     		// This assignment in condition is not a bug. It allows walking the results.

+ 1 - 1
htdocs/comm/action/document.php

@@ -123,7 +123,7 @@ if ($object->id > 0)
 	dol_fiche_head($head, 'documents', $langs->trans("Action"), -1, 'action');
 
 	$linkback = img_picto($langs->trans("BackToList"), 'object_list', 'class="hideonsmartphone pictoactionview"');
-	$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php">'.$langs->trans("BackToList").'</a>';
+	$linkback .= '<a href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list">'.$langs->trans("BackToList").'</a>';
 
 	// Link to other agenda views
 	$out = '';

+ 78 - 17
htdocs/comm/action/index.php

@@ -150,6 +150,7 @@ if (GETPOST("viewlist", 'alpha') || $action == 'show_list')
             $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;
@@ -329,9 +330,10 @@ if ($action == 'show_day')
 //print dol_print_date($firstdaytoshow,'day');
 //print dol_print_date($lastdaytoshow,'day');
 
-$title = $langs->trans("DoneAndToDoActions");
+/*$title = $langs->trans("DoneAndToDoActions");
 if ($status == 'done') $title = $langs->trans("DoneActions");
 if ($status == 'todo') $title = $langs->trans("ToDoActions");
+*/
 
 $param = '';
 if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_actioncode'])) {
@@ -340,7 +342,7 @@ if ($actioncode || isset($_GET['search_actioncode']) || isset($_POST['search_act
 	} else $param .= "&search_actioncode=".urlencode($actioncode);
 }
 if ($resourceid > 0)  $param .= "&search_resourceid=".urlencode($resourceid);
-if ($status || isset($_GET['status']) || isset($_POST['status'])) $param .= "&search_status=".urlencode($status);
+if ($status || GETPOSTISSET('status')) $param .= "&search_status=".urlencode($status);
 if ($filter)       $param .= "&search_filter=".urlencode($filter);
 if ($filtert)      $param .= "&search_filtert=".urlencode($filtert);
 if ($usergroup)    $param .= "&search_usergroup=".urlencode($usergroup);
@@ -358,7 +360,7 @@ if (empty($action) || $action == 'show_month')
     $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>)";
+    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth.$param."\">".$langs->trans("Today")."</a> ";
     $picto = 'calendar';
 }
 if ($action == 'show_week')
@@ -367,7 +369,7 @@ if ($action == 'show_week')
     $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>)";
+    $nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
     $picto = 'calendarweek';
 }
 if ($action == 'show_day')
@@ -376,12 +378,13 @@ if ($action == 'show_day')
     $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>)";
+    $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);
-$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
+//$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
+$nav .= '<button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
 
 // Must be after the nav definition
 $param .= '&year='.$year.'&month='.$month.($day ? '&day='.$day : '');
@@ -404,10 +407,55 @@ print '<form method="POST" id="searchFormList" class="listactionsfilter" action=
 if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 
-dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
-print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
-dol_fiche_end();
+//dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
+//print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
+//dol_fiche_end();
+
+$viewmode = '';
+$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
+
+$viewmode .= '<a class="btnTitle'.($action == 'show_month' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
+
+$viewmode .= '<a class="btnTitle'.($action == 'show_week' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
+
+$viewmode .= '<a class="btnTitle'.($action == 'show_day' ? ' btnTitleSelected' : '').' reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
+
+$viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
+
+$viewmode .= '<span class="marginrightonly"></span>';
+
+
+$newcardbutton = '';
+if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
+{
+	$tmpforcreatebutton = dol_getdate(dol_now(), true);
+
+	$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
 
+	//$param='month='.$monthshown.'&year='.$year;
+	$hourminsec = '100000';
+	$newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
+}
 
 // Define the legend/list of calendard to show
 $s = ''; $link = '';
@@ -440,7 +488,7 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
     $s .= '</script>'."\n";
 
 	// Local calendar
-	$s .= '<div class="nowrap inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
+	$s .= '<div class="nowrap inline-block minheight30"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
 
 	// External calendars
 	if (is_array($showextcals) && count($showextcals) > 0)
@@ -487,9 +535,6 @@ if (!empty($conf->use_javascript_ajax))	// If javascript on
     $link .= '</a>';
 }
 
-print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav, '', 0, 0, 'tablelistofcalendars');
-
-
 // Load events from database into $eventarray
 $eventarray = array();
 
@@ -1109,6 +1154,11 @@ if (is_readable($color_file))
 if (!is_array($theme_datacolor)) $theme_datacolor = array(array(120, 130, 150), array(200, 160, 180), array(190, 190, 220));
 
 
+print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
+
+print $s;
+
+
 if (empty($action) || $action == 'show_month')      // View by month
 {
     $newparam = $param; // newparam is for birthday links
@@ -1122,6 +1172,9 @@ if (empty($action) || $action == 'show_month')      // View by month
     $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
     $newparam .= '&viewcal=1';
 
+    print '<div class="liste_titre liste_titre_bydiv centpercent">';
+    print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+    print '</div>';
 
     print '<div class="div-table-responsive-no-min">';
     print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
@@ -1200,6 +1253,10 @@ if (empty($action) || $action == 'show_month')      // View by month
     $newparam = preg_replace('/showbirthday_=/i', 'showbirthday=', $newparam); // Restore correct parameter
     $newparam .= '&viewweek=1';
 
+    print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
+    print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+    print '</div></div>';
+
     print '<div class="div-table-responsive-no-min">';
     print '<table width="100%" class="noborder nocellnopadd cal_pannel cal_month">';
     print ' <tr class="liste_titre">';
@@ -1256,7 +1313,11 @@ if (empty($action) || $action == 'show_month')      // View by month
     $timestamp = dol_mktime(12, 0, 0, $month, $day, $year);
     $arraytimestamp = dol_getdate($timestamp);
 
-    //echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month">';
+    print '<div class="liste_titre liste_titre_bydiv centpercent"><div class="divsearchfield">';
+    print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+    print '</div></div>';
+
+    print '<div class="div-table-responsive-no-min">';
     echo '<table class="tagtable centpercent noborder nocellnopadd cal_pannel cal_month noborderbottom" style="margin-bottom: 5px !important;">';
 
     echo ' <tr class="tagtr liste_titre">';
@@ -1274,6 +1335,7 @@ if (empty($action) || $action == 'show_month')      // View by month
 	*/
 
     echo '</table>';
+	print '</div>';
 
     /* WIP View per hour */
     $useviewhour = 0;
@@ -1301,9 +1363,8 @@ if (empty($action) || $action == 'show_month')      // View by month
 		{
 		    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">';
-		    echo "  </div>\n";
-		    echo " </div>\n";
+		    echo '  <div class="tagtd '.$style.' tdtop"></div>'."\n";
+		    echo ' </div>'."\n";
 		    $i++;
 		    $j++;
 		}

+ 51 - 7
htdocs/comm/action/list.php

@@ -152,6 +152,7 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
 $object->fields = dol_sort_array($object->fields, 'position');
 $arrayfields = dol_sort_array($arrayfields, 'position');
 
+//var_dump($_POST);exit;
 
 /*
  *	Actions
@@ -301,7 +302,7 @@ if ($user->rights->agenda->allactions->delete)
 {
 	$arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
 }
-
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
 
 $sql = "SELECT";
@@ -428,7 +429,9 @@ if ($resql)
 	$arrayofselected = is_array($toselect) ? $toselect : array();
 
 	// Local calendar
-	$newtitle = '<div class="nowrap clear inline-block minheight20"><input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; </div>';
+	$newtitle = '<div class="nowrap clear inline-block minheight30">';
+	$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
+	$newtitle .= '</div>';
 	//$newtitle=$langs->trans($title);
 
 	$tabactive = 'cardlist';
@@ -439,7 +442,6 @@ if ($resql)
 
 	if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
 	print '<input type="hidden" name="token" value="'.newToken().'">';
-	print '<input type="hidden" name="action" value="list">';
 	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
@@ -450,9 +452,9 @@ if ($resql)
 	if ($showbirthday)    $nav .= '<input type="hidden" name="search_showbirthday" value="1">';
 	print $nav;
 
-    dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
-    print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
-    dol_fiche_end();
+    //dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
+    //print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+    //dol_fiche_end();
 
     // Add link to show birthdays
     $link = '';
@@ -484,6 +486,39 @@ if ($resql)
     	$s = $hookmanager->resPrint;
     }
 
+    $viewmode = '';
+    $viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
+    //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+    $viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
+    //$viewmode .= '</span>';
+    $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
+
+    $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+    //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+    $viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
+    //$viewmode .= '</span>';
+    $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
+
+    $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+    //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+    $viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
+    //$viewmode .= '</span>';
+    $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
+
+    $viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+    //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+    $viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
+    //$viewmode .= '</span>';
+    $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
+
+    $viewmode .= '<a class="btnTitle reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+    //$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+    $viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
+    //$viewmode .= '</span>';
+    $viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
+
+	$viewmode .= '<span class="marginrightonly"></span>';
+
     $newcardbutton = '';
     if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
     {
@@ -495,8 +530,12 @@ if ($resql)
         $hourminsec = '100000';
         $newcardbutton .= dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
     }
+	$param .= '&action='.$action;
+
+
+	print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, 'object_action', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1, $viewmode);
 
-    print_barre_liste($s, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1 * $nbtotalofrecords, '', 0, $nav.$newcardbutton, '', $limit, 0, 0, 1);
+	print $s;
 
     include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
 
@@ -506,6 +545,11 @@ if ($resql)
 	$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
 	if ($massactionbutton) $selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
     $i = 0;
+
+    print '<div class="liste_titre liste_titre_bydiv centpercent">';
+    print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+    print '</div>';
+
     print '<div class="div-table-responsive">';
     print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 

+ 1 - 1
htdocs/comm/action/pertype.php

@@ -700,7 +700,7 @@ jQuery(document).ready(function() {
 		else if (ids.indexOf(",") > -1)	/* There is several events */
 		{
 			/* alert(\'several events\'); */
-			url = "'.DOL_URL_ROOT.'/comm/action/list.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
+			url = "'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
 			window.location.href = url;
 		}
 		else	/* One event */

+ 57 - 9
htdocs/comm/action/peruser.php

@@ -284,7 +284,7 @@ $nav = "<a href=\"?year=".$prev_year."&amp;month=".$prev_month."&amp;day=".$prev
 $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>)";
+$nav .= " &nbsp; <a href=\"?year=".$nowyear."&amp;month=".$nowmonth."&amp;day=".$nowday.$param."\">".$langs->trans("Today")."</a> ";
 
 /*$nav.=' &nbsp; <form name="dateselect" action="'.$_SERVER["PHP_SELF"].'?action=show_peruser'.$param.'">';
 $nav.='<input type="hidden" name="token" value="' . newToken() . '">';
@@ -303,7 +303,8 @@ $nav.='<input type="hidden" name="end_d" value="' . $end_d . '">';
 $nav.='<input type="hidden" name="showbirthday" value="' . $showbirthday . '">';
 */
 $nav .= $form->selectDate($dateselect, 'dateselect', 0, 0, 1, '', 1, 0);
-$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
+//$nav .= ' <input type="submit" name="submitdateselect" class="button" value="'.$langs->trans("Refresh").'">';
+$nav .= ' <button type="submit" class="liste_titre button_search" name="button_search_x" value="x"><span class="fa fa-search"></span></button>';
 //$nav.='</form>';
 
 // Must be after the nav definition
@@ -325,10 +326,6 @@ $head = calendars_prepare_head($paramnoaction);
 
 print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
 
-dol_fiche_head($head, $tabactive, $langs->trans('Agenda'), 0, 'action');
-print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, $listofextcals, $actioncode, $usergroup, '', $resourceid);
-dol_fiche_end();
-
 $showextcals = $listofextcals;
 // Legend
 if ($conf->use_javascript_ajax)
@@ -381,6 +378,41 @@ if ($conf->use_javascript_ajax)
 	}
 }
 
+$massactionbutton = '';
+
+$viewmode = '';
+$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("List"), 'object_list-alt', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewList").'</span></a>';
+
+$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendar', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewCal").'</span></a>';
+
+$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewWeek"), 'object_calendarweek', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewWeek").'</span></a>';
+
+$viewmode .= '<a class="btnTitle reposition" href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewDay"), 'object_calendarday', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewDay").'</span></a>';
+
+$viewmode .= '<a class="btnTitle btnTitleSelected reposition marginrightonly" href="'.DOL_URL_ROOT.'/comm/action/peruser.php?action=show_peruser&year='.dol_print_date($object->datep, '%Y').'&month='.dol_print_date($object->datep, '%m').'&day='.dol_print_date($object->datep, '%d').'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewPerUser"), 'object_calendarperuser', 'class="pictoactionview block"');
+//$viewmode .= '</span>';
+$viewmode .= '<span class="valignmiddle text-plus-circle btnTitle-label hideonsmartphone">'.$langs->trans("ViewPerUser").'</span></a>';
+
+$viewmode .= '<span class="marginrightonly"></span>';
+
 
 $newcardbutton = '';
 if ($user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create)
@@ -394,8 +426,24 @@ if ($user->rights->agenda->myactions->create || $user->rights->agenda->allaction
     $newcardbutton .= dolGetButtonTitle($langs->trans("AddAction"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : '')));
 }
 
+print_barre_liste($langs->trans("Agenda"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, -1, 'object_action', 0, $nav.'<span class="marginleftonly"></span>'.$newcardbutton, '', $limit, 1, 0, 1, $viewmode);
+
 $link = '';
-print load_fiche_titre($s, $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
+//print load_fiche_titre('', $link.' &nbsp; &nbsp; '.$nav.' '.$newcardbutton, '');
+
+// Local calendar
+$newtitle = '<div class="nowrap clear inline-block minheight30">';
+$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
+$newtitle .= '</div>';
+//$newtitle=$langs->trans($title);
+
+$s = $newtitle;
+
+print $s;
+
+print '<div class="liste_titre liste_titre_bydiv centpercent">';
+print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid);
+print '</div>';
 
 
 
@@ -650,7 +698,7 @@ while ($currentdaytoshow < $lastdaytoshow) {
 			continue;
 		}
 		echo '<td align="center" colspan="'.($end_h - $begin_h).'">';
-		echo $langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7));
+		echo '<span class="opacitymedium spandayofweek">'.$langs->trans("Day".(($i + (isset($conf->global->MAIN_START_WEEK) ? $conf->global->MAIN_START_WEEK : 1)) % 7)).'</span>';
 		print "<br>";
 		if ($i) print dol_print_date(dol_time_plus_duree($currentdaytoshow, $i, 'd'), 'day');
 		else print dol_print_date($currentdaytoshow, 'day');
@@ -864,7 +912,7 @@ jQuery(document).ready(function() {
 		else if (ids.indexOf(",") > -1)	/* There is several events */
 		{
 			/* alert(\'several events\'); */
-			url = "'.DOL_URL_ROOT.'/comm/action/list.php?filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
+			url = "'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&filtert="+userid+"&dateselectyear="+year+"&dateselectmonth="+month+"&dateselectday="+day;
 			window.location.href = url;
 		}
 		else	/* One event */

+ 4 - 5
htdocs/comm/action/rapport/index.php

@@ -35,8 +35,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/modules/action/rapport.pdf.php';
 $langs->loadLangs(array("agenda", "commercial"));
 
 $action = GETPOST('action', 'alpha');
-$month = GETPOST('month');
-$year = GETPOST('year');
+$month = GETPOST('month', 'int');
+$year = GETPOST('year', 'int');
 
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
 $sortfield = GETPOST("sortfield", 'alpha');
@@ -119,9 +119,8 @@ if ($resql)
 	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_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
+	print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit, 0, 0, 1);
 
 	$moreforfilter = '';
 
@@ -154,7 +153,7 @@ if ($resql)
 
 			// Button to build doc
 			print '<td class="center">';
-			print '<a href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
+			print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=builddoc&amp;page='.$page.'&amp;month='.$obj->month.'&amp;year='.$obj->year.'">'.img_picto($langs->trans('BuildDoc'), 'filenew').'</a>';
 			print '</td>';
 
 			$name = "actions-".$obj->month."-".$obj->year.".pdf";

+ 10 - 8
htdocs/comm/card.php

@@ -9,6 +9,7 @@
  * Copyright (C) 2013      Alexandre Spangaro          <aspangaro@open-dsi.fr>
  * Copyright (C) 2015-2019 Frédéric France             <frederic.france@netlogic.fr>
  * Copyright (C) 2015      Marcos García               <marcosgdf@gmail.com>
+ * Copyright (C) 2020      Open-Dsi         		   <support@open-dsi.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -547,6 +548,7 @@ if ($object->id > 0)
 
 	print "</table>";
 
+	// Prospection level and status
 	if ($object->client == 2 || $object->client == 3)
 	{
     	print '<br>';
@@ -554,12 +556,12 @@ if ($object->id > 0)
     	print '<div class="underbanner clearboth"></div>';
     	print '<table class="border centpercent tableforfield">';
 
-	    // Level of prospect
+	    // Level of prospection
 	    print '<tr><td class="titlefield nowrap">';
 	    print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
 	    print $langs->trans('ProspectLevel');
 	    print '<td>';
-	    if ($action != 'editlevel' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
+	    if ($action != 'editlevel' && $user->rights->societe->creer) print '<td class="right"><a class="editfielda reposition" href="'.$_SERVER["PHP_SELF"].'?action=editlevel&amp;socid='.$object->id.'">'.img_edit($langs->trans('Modify'), 1).'</a></td>';
 	    print '</tr></table>';
 	    print '</td><td>';
 	    if ($action == 'editlevel')
@@ -571,17 +573,17 @@ if ($object->id > 0)
         print "</td>";
         print '</tr>';
 
-        // Status
+        // Status of prospection
         $object->loadCacheOfProspStatus();
         print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
         print ' &nbsp; &nbsp; ';
         print '<div class="floatright">';
         foreach ($object->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 ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt, $val['code']).'</a>';
-        }
+			$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 ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus reposition" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt, $val['code'], $val['picto']).'</a>';
+		}
         print '</div></td></tr>';
         print "</table>";
 	}
@@ -1148,7 +1150,7 @@ if ($object->id > 0)
 	}
 
 	/*
-	 *   Last invoices
+	 *   Latest invoices
 	 */
 	if (!empty($conf->facture->enabled) && $user->rights->facture->lire)
 	{

+ 17 - 3
htdocs/comm/propal/card.php

@@ -230,6 +230,7 @@ if (empty($reshook))
 				$outputlangs->setDefaultLang($newlang);
 			}
 			$ret = $object->fetch($id); // Reload to get new records
+			if ($ret > 0) $object->fetch_thirdparty();
 			$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
 		}
 
@@ -253,6 +254,9 @@ if (empty($reshook))
 				}
 				$model = $object->modelpdf;
 				$ret = $object->fetch($id); // Reload to get new records
+				if ($ret > 0) {
+					$object->fetch_thirdparty();
+				}
 
 				$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
 			}
@@ -764,6 +768,7 @@ if (empty($reshook))
 				$outputlangs->setDefaultLang($newlang);
 			}
 			$ret = $object->fetch($id); // Reload to get new records
+			if ($ret > 0) $object->fetch_thirdparty();
 			$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
 		}
 	} elseif ($action == "setabsolutediscount" && $usercancreate) {
@@ -775,11 +780,19 @@ if (empty($reshook))
 				}
 			}
 		}
-	} // Add line
-	elseif ($action == 'addline' && $usercancreate) {
+	} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
+		// Define vat_rate
+		$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
+		$vat_rate = str_replace('*', '', $vat_rate);
+		$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
+		$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
+		foreach ($object->lines as $line) {
+			$result = $object->updateline($line->id, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, $line->desc, 'HT', $line->info_bits, $line->special_code, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->product_type, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
+		}
+	} elseif ($action == 'addline' && $usercancreate) {		// Add line
 		// Set if we used free entry or predefined product
 		$predef = '';
-		$product_desc = (GETPOST('dp_desc') ?GETPOST('dp_desc') : '');
+		$product_desc = (GETPOST('dp_desc', 'none') ?GETPOST('dp_desc', 'none') : '');
 		$price_ht = GETPOST('price_ht');
 		$price_ht_devise = GETPOST('multicurrency_price_ht');
 		$prod_entry_mode = GETPOST('prod_entry_mode');
@@ -1229,6 +1242,7 @@ if (empty($reshook))
 						$outputlangs->setDefaultLang($newlang);
 					}
 					$ret = $object->fetch($id); // Reload to get new records
+					if ($ret > 0) $object->fetch_thirdparty();
 					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
 				}
 

+ 9 - 7
htdocs/comm/propal/class/propal.class.php

@@ -725,15 +725,15 @@ class Propal extends CommonObject
 	/**
 	 *  Update a proposal line
 	 *
-	 *  @param      int			$rowid           	Id de la ligne
-	 *  @param      float		$pu		     	  	Prix unitaire (HT ou TTC selon price_base_type)
+	 *  @param      int			$rowid           	Id of line
+	 *  @param      float		$pu		     	  	Unit price (HT or TTC depending on price_base_type)
 	 *  @param      float		$qty            	Quantity
-	 *  @param      float		$remise_percent  	Remise effectuee sur le produit
-	 *  @param      float		$txtva	          	Taux de TVA
+	 *  @param      float		$remise_percent  	Discount on line
+	 *  @param      float		$txtva	          	VAT Rate (Can be '1.23' or '1.23 (ABC)')
 	 * 	@param	  	float		$txlocaltax1		Local tax 1 rate
 	 *  @param	  	float		$txlocaltax2		Local tax 2 rate
 	 *  @param      string		$desc            	Description
-	 *	@param	  	string		$price_base_type	HT ou TTC
+	 *	@param	  	string		$price_base_type	HT or TTC
 	 *	@param      int			$info_bits        	Miscellaneous informations
 	 *	@param		int			$special_code		Special code (also used by externals modules!)
 	 * 	@param		int			$fk_parent_line		Id of parent line (0 in most cases, used by modules adding sublevels into lines).
@@ -3664,6 +3664,7 @@ class Propal extends CommonObject
 		global $conf, $langs;
 
 		$langs->load("propale");
+		$outputlangs->load("products");
 
 		if (!dol_strlen($modele)) {
 			$modele = 'azur';
@@ -4121,6 +4122,8 @@ class PropaleLigne extends CommonObjectLine
 
 		$pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'.
 
+		if (empty($this->id) && ! empty($this->rowid)) $this->id = $this->rowid;
+
 		// Clean parameters
 		if (empty($this->tva_tx)) $this->tva_tx = 0;
 		if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
@@ -4194,7 +4197,7 @@ class PropaleLigne extends CommonObjectLine
 		$sql .= ", multicurrency_total_tva=".price2num($this->multicurrency_total_tva)."";
 		$sql .= ", multicurrency_total_ttc=".price2num($this->multicurrency_total_ttc)."";
 
-		$sql .= " WHERE rowid = ".$this->rowid;
+		$sql .= " WHERE rowid = ".$this->id;
 
 		dol_syslog(get_class($this)."::update", LOG_DEBUG);
 		$resql = $this->db->query($sql);
@@ -4202,7 +4205,6 @@ class PropaleLigne extends CommonObjectLine
 		{
 			if (!$error)
 			{
-				$this->id = $this->rowid;
 				$result = $this->insertExtraFields();
 				if ($result < 0)
 				{

+ 3 - 2
htdocs/comm/prospect/index.php

@@ -2,6 +2,7 @@
 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2009 Regis Houssin        <regis.houssin@inodbox.com>
+ * Copyright (C) 2020      Open-Dsi        		<support@open-dsi.fr>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -71,7 +72,7 @@ if (!empty($conf->propal->enabled))
  *
  */
 
-$sql = "SELECT count(*) as cc, st.libelle, st.id";
+$sql = "SELECT count(*) as cc, st.libelle, st.picto, st.id";
 $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
 $sql .= ", ".MAIN_DB_PREFIX."c_stcomm as st ";
 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -98,7 +99,7 @@ if ($resql)
 
 			print '<tr class="oddeven"><td>';
 			print '<a href="prospects.php?page=0&amp;stcomm='.$obj->id.'">';
-			print img_action($langs->trans("Show"), $obj->id).' ';
+			print img_action($langs->trans("Show"), $obj->id, $obj->picto).' ';
 			print $langs->trans("StatusProspect".$obj->id);
 			print '</a></td><td class="right">'.$obj->cc.'</td></tr>';
 			$i++;

+ 3 - 3
htdocs/comm/remise.php

@@ -59,9 +59,9 @@ if (GETPOST('action', 'aZ09') == 'setremise')
 	$discount_type = GETPOST('discount_type', 'int');
 
 	if (!empty($discount_type)) {
-		$result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note"), $user);
+		$result = $object->set_remise_supplier(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user);
 	} else {
-		$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note"), $user);
+		$result = $object->set_remise_client(price2num(GETPOST("remise")), GETPOST("note", "alphanohtml"), $user);
 	}
 
 	if ($result > 0)
@@ -183,7 +183,7 @@ if ($socid > 0)
 
 	// Motif/Note
 	print '<tr><td class="fieldrequired">';
-	print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note")).'"></td></tr>';
+	print $langs->trans("NoteReason").'</td><td><input type="text" size="60" name="note" value="'.dol_escape_htmltag(GETPOST("note", "alphanohtml")).'"></td></tr>';
 
 	print "</table>";
 

+ 12 - 6
htdocs/commande/card.php

@@ -624,10 +624,16 @@ if (empty($reshook))
 		$result = $object->set_remise($user, GETPOST('remise_percent'));
 	} elseif ($action == 'setremiseabsolue' && $usercancreate) {
 		$result = $object->set_remise_absolue($user, GETPOST('remise_absolue'));
-	}
-
-	// Add a new line
-	elseif ($action == 'addline' && $usercancreate)
+	} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
+		// Define vat_rate
+		$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
+		$vat_rate = str_replace('*', '', $vat_rate);
+		$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
+		$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
+		foreach ($object->lines as $line) {
+			$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->date_start, $line->date_end, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->fk_unit, $line->multicurrency_subprice);
+		}
+	} elseif ($action == 'addline' && $usercancreate)		// Add a new line
 	{
 		$langs->load('errors');
 		$error = 0;
@@ -1574,7 +1580,7 @@ if ($action == 'create' && $usercancreate)
 		print '</td>';
 	} else {
 		print '<td>';
-		print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
+		print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3)', 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
 		// reload page to retrieve customer informations
 		if (!empty($conf->global->RELOAD_PAGE_ON_CUSTOMER_CHANGE))
 		{
@@ -1997,7 +2003,7 @@ if ($action == 'create' && $usercancreate)
 		if ($action == 'clone') {
 			// Create an array for form
 			$formquestion = array(
-				array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client=3)'))
+				array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid', 'int'), 'socid', '(s.client=1 OR s.client = 2 OR s.client=3)'))
 			);
 			$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneOrder', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
 		}

+ 1 - 0
htdocs/commande/class/commande.class.php

@@ -3859,6 +3859,7 @@ class Commande extends CommonOrder
 		global $conf, $langs;
 
 		$langs->load("orders");
+		$outputlangs->load("products");
 
 		if (!dol_strlen($modele)) {
 			$modele = 'einstein';

+ 1 - 1
htdocs/commande/list.php

@@ -116,7 +116,7 @@ $hookmanager->initHooks(array('orderlist'));
 $extrafields = new ExtraFields($db);
 
 // fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('commande');
+$extrafields->fetch_name_optionals_label($object->table_element);
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 
 // List of fields to search into when doing a "search in all"

+ 72 - 18
htdocs/compta/bank/account_statement_document.php

@@ -40,13 +40,7 @@ $id = (GETPOST('id', 'int') ? GETPOST('id', 'int') : GETPOST('account', 'int'));
 $ref = GETPOST('ref', 'alpha');
 $action = GETPOST('action', 'alpha');
 $confirm = GETPOST('confirm', 'alpha');
-$num = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha'));
-
-$mesg = '';
-if (isset($_SESSION['DolMessage'])) {
-	$mesg = $_SESSION['DolMessage'];
-	unset($_SESSION['DolMessage']);
-}
+$numref = (GETPOST('num', 'alpha') ? GETPOST('num', 'alpha') : GETPOST('sectionid', 'alpha'));
 
 // Security check
 if ($user->socid) {
@@ -71,21 +65,74 @@ if (!$sortfield)
 	$sortfield = "name";
 
 $object = new Account($db);
-if ($id > 0 || !empty($ref)) $object->fetch($id, $ref);
+if ($id > 0 || !empty($ref))
+{
+	$result = $object->fetch($id, $ref);
+	$account = $object->id; // Force the search field on id of account
+}
 
 $result = restrictedArea($user, 'banque', $object->id, 'bank_account', '', '');
 
+// Define number of receipt to show (current, previous or next one ?)
+$found = false;
+if ($_GET["rel"] == 'prev')
+{
+	// Recherche valeur pour num = numero releve precedent
+	$sql = "SELECT DISTINCT(b.num_releve) as num";
+	$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+	$sql .= " WHERE b.num_releve < '".$db->escape($numref)."'";
+	$sql .= " AND b.fk_account = ".$id;
+	$sql .= " ORDER BY b.num_releve DESC";
+
+	dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
+	$resql = $db->query($sql);
+	if ($resql)
+	{
+		$numrows = $db->num_rows($resql);
+		if ($numrows > 0)
+		{
+			$obj = $db->fetch_object($resql);
+			$numref = $obj->num;
+			$found = true;
+		}
+	}
+} elseif ($_GET["rel"] == 'next')
+{
+	// Recherche valeur pour num = numero releve precedent
+	$sql = "SELECT DISTINCT(b.num_releve) as num";
+	$sql .= " FROM ".MAIN_DB_PREFIX."bank as b";
+	$sql .= " WHERE b.num_releve > '".$db->escape($numref)."'";
+	$sql .= " AND b.fk_account = ".$id;
+	$sql .= " ORDER BY b.num_releve ASC";
+
+	dol_syslog("htdocs/compta/bank/releve.php", LOG_DEBUG);
+	$resql = $db->query($sql);
+	if ($resql)
+	{
+		$numrows = $db->num_rows($resql);
+		if ($numrows > 0)
+		{
+			$obj = $db->fetch_object($resql);
+			$numref = $obj->num;
+			$found = true;
+		}
+	}
+} else {
+	// On veut le releve num
+	$found = true;
+}
+
 
 /*
  * Actions
  */
 
-if (!empty($num))
+if (!empty($numref))
 {
 	$object->fetch_thirdparty();
-	$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
+	$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref);
 }
-$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$num;
+$backtopage = $_SERVER['PHP_SELF']."?account=".$id."&num=".$numref;
 include_once DOL_DOCUMENT_ROOT.'/core/actions_linkedfiles.inc.php';
 
 
@@ -101,10 +148,10 @@ llxHeader('', $title, $helpurl);
 
 if ($id > 0 || !empty($ref)) {
 	if ($object->fetch($id, $ref)) {
-		$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($num);
+		$upload_dir = $conf->bank->dir_output."/".$id."/statement/".dol_sanitizeFileName($numref);
 
 		// Onglets
-		$head = account_statement_prepare_head($object, $num);
+		$head = account_statement_prepare_head($object, $numref);
 		dol_fiche_head($head, 'document', $langs->trans("AccountStatement"), -1, 'account');
 
 
@@ -115,8 +162,15 @@ if ($id > 0 || !empty($ref)) {
 			$totalsize += $file['size'];
 		}
 
-		$title = $langs->trans("AccountStatement").' '.$num.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
-		print load_fiche_titre($title, '', '');
+		$morehtmlright = '';
+		$morehtmlright .= '<div class="pagination"><ul>';
+		$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
+		$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
+		$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
+		$morehtmlright .= '</ul></div>';
+
+		$title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
+		print load_fiche_titre($title, $morehtmlright, '');
 
 		print '<div class="fichecenter">';
 		print '<div class="underbanner clearboth"></div>';
@@ -134,9 +188,9 @@ if ($id > 0 || !empty($ref)) {
 		$modulepart = 'bank';
 		$permission = $user->rights->banque->modifier;
 		$permtoedit = $user->rights->banque->modifier;
-		$param = '&id='.$object->id.'&num='.urlencode($num);
-		$moreparam = '&num='.urlencode($num); ;
-		$relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($num)."/";
+		$param = '&id='.$object->id.'&num='.urlencode($numref);
+		$moreparam = '&num='.urlencode($numref); ;
+		$relativepathwithnofile = $id."/statement/".dol_sanitizeFileName($numref)."/";
 		include_once DOL_DOCUMENT_ROOT.'/core/tpl/document_actions_post_headers.tpl.php';
 	} else {
 		dol_print_error($db);

+ 1 - 1
htdocs/compta/bank/class/account.class.php

@@ -469,7 +469,7 @@ class Account extends CommonObject
 	 *  Add an entry into table ".MAIN_DB_PREFIX."bank
 	 *
 	 *  @param	int	        $date			Date operation
-	 *  @param	string		$oper			1,2,3,4... (deprecated) or 'TYP','VIR','PRE','LIQ','VAD','CB','CHQ'...
+	 *  @param	string		$oper			'VIR','PRE','LIQ','VAD','CB','CHQ'...
 	 *  @param	string		$label			Descripton
 	 *  @param	float		$amount			Amount
 	 *  @param	string		$num_chq		Numero cheque ou virement

+ 0 - 6
htdocs/compta/bank/document.php

@@ -39,12 +39,6 @@ $ref = GETPOST('ref', 'alpha');
 $action = GETPOST('action', 'alpha');
 $confirm = GETPOST('confirm', 'alpha');
 
-$mesg = '';
-if (isset($_SESSION['DolMessage'])) {
-    $mesg = $_SESSION['DolMessage'];
-    unset($_SESSION['DolMessage']);
-}
-
 // Security check
 if ($user->socid) {
     $action = '';

+ 10 - 10
htdocs/compta/bank/releve.php

@@ -247,6 +247,8 @@ if (empty($numref))
 
 		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/bank/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
+		$morehtmlref = '';
+
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
 
 		dol_fiche_end();
@@ -362,17 +364,15 @@ if (empty($numref))
 	dol_fiche_head($head, 'statement', $langs->trans("AccountStatement"), -1, 'account');
 
 
-	$mesprevnext = '';
-	$mesprevnext .= '<div class="pagination"><ul>';
-	$mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
-	//$mesprevnext.=' &nbsp; ';
-	$mesprevnext .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
-	//$mesprevnext.=' &nbsp; ';
-    $mesprevnext .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
-    $mesprevnext .= '</ul></div>';
+	$morehtmlright = '';
+	$morehtmlright .= '<div class="pagination"><ul>';
+	$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=prev&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-left" title="'.dol_escape_htmltag($langs->trans("Previous")).'"></i></a></li>';
+	$morehtmlright .= '<li class="pagination"><span class="active">'.$langs->trans("AccountStatement")." ".$numref.'</span></li>';
+	$morehtmlright .= '<li class="pagination"><a class="paginationnext" href="'.$_SERVER["PHP_SELF"].'?rel=next&amp;num='.$numref.'&amp;ve='.$ve.'&amp;account='.$object->id.'"><i class="fa fa-chevron-right" title="'.dol_escape_htmltag($langs->trans("Next")).'"></i></a></li>';
+	$morehtmlright .= '</ul></div>';
 
     $title = $langs->trans("AccountStatement").' '.$numref.' - '.$langs->trans("BankAccount").' '.$object->getNomUrl(1, 'receipts');
-	print load_fiche_titre($title, $mesprevnext, '');
+    print load_fiche_titre($title, $morehtmlright, '');
 	//print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, 0, $nbtotalofrecords, 'bank_account', 0, '', '', 0, 1);
 
 	print "<form method=\"post\" action=\"releve.php\">";
@@ -620,7 +620,7 @@ if (empty($numref))
 
 			if ($user->rights->banque->modifier || $user->rights->banque->consolidate)
 			{
-				print '<td class="center"><a href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.$numref).'">';
+				print '<td class="center"><a class="editfielda reposition" href="'.DOL_URL_ROOT.'/compta/bank/line.php?rowid='.$objp->rowid.'&account='.$object->id.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?account='.$object->id.'&num='.$numref).'">';
 				print img_edit();
 				print "</a></td>";
 			} else {

+ 1 - 1
htdocs/compta/bank/various_payment/list.php

@@ -178,7 +178,7 @@ if ($result)
 	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 
-	print_barre_liste($langs->trans("VariousPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
+	print_barre_liste($langs->trans("MenuVariousPayment"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'object_payment', 0, $newcardbutton, '', $limit, 0, 0, 1);
 
 	print '<div class="div-table-responsive">';
 	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";

+ 2 - 0
htdocs/compta/charges/index.php

@@ -451,6 +451,7 @@ while ($j < $numlt)
 
 
 // Payment Salary
+/*
 if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
 {
     if (!$mode || $mode != 'sconly')
@@ -558,6 +559,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read))
         }
     }
 }
+*/
 
 print '</form>';
 

+ 10 - 2
htdocs/compta/facture/card.php

@@ -1867,8 +1867,16 @@ if (empty($reshook))
 			$_GET["originid"] = $_POST["originid"];
 			setEventMessages($object->error, $object->errors, 'errors');
 		}
-	} // Add a new line
-	elseif ($action == 'addline' && $usercancreate)
+	} elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) {
+		// Define vat_rate
+		$vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0);
+		$vat_rate = str_replace('*', '', $vat_rate);
+		$localtax1_rate = get_localtax($vat_rate, 1, $object->thirdparty, $mysoc);
+		$localtax2_rate = get_localtax($vat_rate, 2, $object->thirdparty, $mysoc);
+		foreach ($object->lines as $line) {
+			$result = $object->updateline($line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $vat_rate, $localtax1_rate, $localtax2_rate, 'HT', $line->info_bits, $line->product_type, $line->fk_parent_line, 0, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $line->multicurrency_subprice);
+		}
+	} elseif ($action == 'addline' && $usercancreate)		// Add a new line
 	{
 		$langs->load('errors');
 		$error = 0;

+ 1 - 1
htdocs/compta/facture/class/facture-rec.class.php

@@ -1333,7 +1333,7 @@ class FactureRec extends CommonInvoice
 
 		$result = '';
 
-		$label = '<u>'.$langs->trans("ShowInvoice").'</u>';
+		$label = '<u>'.$langs->trans("RepeatableInvoice").'</u>';
 		if (!empty($this->ref)) {
 			$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
 		}

+ 3 - 2
htdocs/compta/facture/class/facture.class.php

@@ -423,7 +423,7 @@ class Facture extends CommonInvoice
 		$this->brouillon = 1;
 
 		// Multicurrency (test on $this->multicurrency_tx because we should take the default rate only if not using origin rate)
-		if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
+		if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency, $this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code, $this->date);
 		else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
 		if (empty($this->fk_multicurrency))
 		{
@@ -2415,7 +2415,7 @@ class Facture extends CommonInvoice
 	 * @param   string	$force_number	Reference to force on invoice
 	 * @param	int		$idwarehouse	Id of warehouse to use for stock decrease if option to decreasenon stock is on (0=no decrease)
 	 * @param	int		$notrigger		1=Does not execute triggers, 0= execute triggers
-	 * @param	int		$batch_rule		[=0] 0 not decrement batch, else batch rule to use
+	 * @param	int		$batch_rule		0=do not decrement batch, else batch rule to use
 	 *                                 	1=take in batches ordered by sellby and eatby dates
      * @return	int						<0 if KO, 0=Nothing done because invoice is not a draft, >0 if OK
 	 */
@@ -4296,6 +4296,7 @@ class Facture extends CommonInvoice
 		global $conf, $langs;
 
 		$langs->load("bills");
+		$outputlangs->load("products");
 
 		if (!dol_strlen($modele))
 		{

+ 8 - 1
htdocs/compta/facture/invoicetemplate_list.php

@@ -53,6 +53,8 @@ $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'inv
 
 $socid = GETPOST('socid', 'int');
 
+$socid = GETPOST('socid', 'int');
+
 // Security check
 $id = (GETPOST('facid', 'int') ?GETPOST('facid', 'int') : GETPOST('id', 'int'));
 $lineid = GETPOST('lineid', 'int');
@@ -106,7 +108,7 @@ $hookmanager->initHooks(array('invoicereclist'));
 $extrafields = new ExtraFields($db);
 
 // fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('facture_rec');
+$extrafields->fetch_name_optionals_label($object->table_element);
 
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 
@@ -151,6 +153,11 @@ if ($socid > 0) {
 }
 
 
+if ($socid > 0) {
+        $tmpthirdparty = new Societe($db);
+        $res = $tmpthirdparty->fetch($socid);
+        if ($res > 0) $search_societe = $tmpthirdparty->name;
+}
 
 /*
  * Actions

+ 9 - 4
htdocs/compta/facture/list.php

@@ -5,7 +5,7 @@
  * Copyright (C) 2005      Marc Barilley / Ocebo <marc@ocebo.com>
  * Copyright (C) 2005-2015 Regis Houssin         <regis.houssin@inodbox.com>
  * Copyright (C) 2006      Andre Cianfarani      <acianfa@free.fr>
- * Copyright (C) 2010-2012 Juanjo Menent         <jmenent@2byte.es>
+ * Copyright (C) 2010-2020 Juanjo Menent         <jmenent@2byte.es>
  * Copyright (C) 2012      Christophe Battarel   <christophe.battarel@altairis.fr>
  * Copyright (C) 2013      Florian Henry         <florian.henry@open-concept.pro>
  * Copyright (C) 2013      Cédric Salvador       <csalvador@gpcsolutions.fr>
@@ -150,7 +150,7 @@ $hookmanager->initHooks(array('invoicelist'));
 $extrafields = new ExtraFields($db);
 
 // fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('facture');
+$extrafields->fetch_name_optionals_label($object->table_element);
 
 $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
 
@@ -545,6 +545,8 @@ if (!$sall)
 	$sql .= ' f.paye, f.fk_statut, f.close_code,';
 	$sql .= ' f.datec, f.tms, f.date_closing,';
 	$sql .= ' f.retained_warranty, f.retained_warranty_date_limit, f.situation_final, f.situation_cycle_ref, f.situation_counter,';
+	$sql .= ' f.fk_user_author, f.fk_multicurrency, f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva,';
+	$sql .= ' f.multicurrency_total_tva, f.multicurrency_total_ttc,';
 	$sql .= ' s.rowid, s.nom, s.email, s.town, s.zip, s.fk_pays, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,';
 	$sql .= ' typent.code,';
 	$sql .= ' state.code_departement, state.nom,';
@@ -830,12 +832,15 @@ if ($resql)
 	{
 		print '<td class="liste_titre center">';
 		print '<div class="nowrap">';
+		/*
 		print $langs->trans('From').' ';
 		print $form->selectDate($search_datelimit_start ? $search_datelimit_start : -1, 'search_datelimit_start', 0, 0, 1);
 		print '</div>';
 		print '<div class="nowrap">';
-		print $langs->trans('to').' ';
+		print $langs->trans('to').' ';*/
+		print $langs->trans("Before").' ';
 		print $form->selectDate($search_datelimit_end ? $search_datelimit_end : -1, 'search_datelimit_end', 0, 0, 1);
+		print '<br><input type="checkbox" name="search_option" value="late"'.($option == 'late' ? ' checked' : '').'> '.$langs->trans("Alert");
 		print '</div>';
 		print '</td>';
 	}
@@ -1442,7 +1447,7 @@ if ($resql)
 			{
 				$userstatic->id = $obj->fk_user_author;
 				$userstatic->login = $obj->login;
-				print '<td align="center">';
+				print '<td class="center tdoverflowmax100">';
 				if ($userstatic->id) print $userstatic->getLoginUrl(1);
 				else print '&nbsp;';
 				print "</td>\n";

+ 8 - 3
htdocs/compta/facture/prelevement.php

@@ -38,8 +38,6 @@ require_once DOL_DOCUMENT_ROOT.'/societe/class/companybankaccount.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
 
-if (!$user->rights->facture->lire) accessforbidden();
-
 // Load translation files required by the page
 $langs->loadLangs(array('bills', 'banks', 'withdrawals', 'companies'));
 
@@ -51,7 +49,6 @@ $type = GETPOST('type', 'aZ09');
 
 $fieldid = (!empty($ref) ? 'ref' : 'rowid');
 if ($user->socid) $socid = $user->socid;
-$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid);
 
 if ($type == 'bank-transfer') {
 	$object = new FactureFournisseur($db);
@@ -63,6 +60,7 @@ if ($type == 'bank-transfer') {
 if ($id > 0 || !empty($ref))
 {
 	$ret = $object->fetch($id, $ref);
+	$isdraft = (($object->statut == FactureFournisseur::STATUS_DRAFT) ? 1 : 0);
 	if ($ret > 0)
 	{
 		$object->fetch_thirdparty();
@@ -71,6 +69,13 @@ if ($id > 0 || !empty($ref))
 
 $hookmanager->initHooks(array('directdebitcard', 'globalcard'));
 
+if ($type == 'bank-transfer') {
+	$result = restrictedArea($user, 'fournisseur', $id, 'facture_fourn', 'facture', 'fk_soc', $fieldid, $isdraft);
+	if (!$user->rights->fournisseur->facture->lire) accessforbidden();
+} else {
+	$result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid, $isdraft);
+	if (!$user->rights->facture->lire) accessforbidden();
+}
 
 
 /*

+ 10 - 2
htdocs/compta/index.php

@@ -2,7 +2,7 @@
 /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2013 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2015 Regis Houssin        <regis.houssin@inodbox.com>
- * Copyright (C) 2015-2016 Juanjo Menent	<jmenent@2byte.es>
+ * Copyright (C) 2015-2020 Juanjo Menent	<jmenent@2byte.es>
  * Copyright (C) 2015      Jean-François Ferry	<jfefe@aternatik.fr>
  * Copyright (C) 2015      Raphaël Doursenaud   <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2016      Marcos García        <marcosgdf@gmail.com>
@@ -161,6 +161,14 @@ 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";
+
+	// Add Group from hooks
+	$parameters = array();
+	$reshook = $hookmanager->executeHooks('printFieldListGroupByCustomerDraft', $parameters);
+	$sql .= $hookmanager->resPrint;
+
 	$resql = $db->query($sql);
 
 	if ($resql)
@@ -458,7 +466,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 	$sql .= $hookmanager->resPrint;
 
 	$sql .= " GROUP BY ff.rowid, ff.ref, ff.fk_statut, ff.libelle, ff.total_ht, ff.tva, ff.total_tva, ff.total_ttc, ff.tms, ff.paye,";
-	$sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur";
+	$sql .= " s.nom, s.rowid, s.code_fournisseur, s.code_compta_fournisseur, s.email";
 	$sql .= " ORDER BY ff.tms DESC ";
 	$sql .= $db->plimit($max, 0);
 

+ 1 - 1
htdocs/compta/paiement/class/paiement.class.php

@@ -1154,7 +1154,7 @@ class Paiement extends CommonObject
 		if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
 
 		$result = '';
-        $label = '<u>'.$langs->trans("ShowPayment").'</u><br>';
+        $label = '<u>'.$langs->trans("Payment").'</u><br>';
         $label .= '<strong>'.$langs->trans("Ref").':</strong> '.$this->ref;
         if ($this->datepaye ? $this->datepaye : $this->date) $label .= '<br><strong>'.$langs->trans("Date").':</strong> '.dol_print_date($this->datepaye ? $this->datepaye : $this->date, 'dayhour');
         if ($mode == 'withlistofinvoices')

+ 3 - 2
htdocs/compta/paiement_charge.php

@@ -41,6 +41,8 @@ if ($user->socid > 0)
 	$socid = $user->socid;
 }
 
+$charge = new ChargeSociales($db);
+
 
 /*
  * Actions
@@ -161,7 +163,6 @@ $form = new Form($db);
 // Formulaire de creation d'un paiement de charge
 if ($action == 'create')
 {
-	$charge = new ChargeSociales($db);
 	$charge->fetch($chid);
     $charge->accountid = $charge->fk_account ? $charge->fk_account : $charge->accountid;
     $charge->paiementtype = $charge->mode_reglement_id ? $charge->mode_reglement_id : $charge->paiementtype;
@@ -223,7 +224,7 @@ if ($action == 'create')
 	print '<tr><td class="fieldrequired">'.$langs->trans("Date").'</td><td>';
 	$datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]);
 	$datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0;
-	print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1);
+	print $form->selectDate($datepayment, '', '', '', 0, "add_payment", 1, 1, 0, '', '', $charge->date_ech, '', 1, $langs->trans("DateOfSocialContribution"));
 	print "</td>";
 	print '</tr>';
 

+ 4 - 3
htdocs/compta/paymentbybanktransfer/index.php

@@ -68,7 +68,7 @@ print '<div class="fichecenter"><div class="fichethirdleft">';
 
 
 $thirdpartystatic = new Societe($db);
-$invoicestatic = new Facture($db);
+$invoicestatic = new FactureFournisseur($db);
 $bprev = new BonPrelevement($db);
 
 print '<div class="div-table-responsive-no-min">';
@@ -94,7 +94,7 @@ print '</td></tr></table></div><br>';
  */
 $sql = "SELECT f.ref, f.rowid, f.total_ttc, f.fk_statut, f.paye, f.type,";
 $sql .= " pfd.date_demande, pfd.amount,";
-$sql .= " s.nom as name, s.email, s.rowid as socid";
+$sql .= " s.nom as name, s.email, s.rowid as socid, s.tva_intra";
 $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f,";
 $sql .= " ".MAIN_DB_PREFIX."societe as s";
 if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -138,13 +138,14 @@ if ($resql)
             $thirdpartystatic->id = $obj->socid;
             $thirdpartystatic->name = $obj->name;
             $thirdpartystatic->email = $obj->email;
+            $thirdpartystatic->tva_intra = $obj->tva_intra;
 
             print '<tr class="oddeven"><td>';
             print $invoicestatic->getNomUrl(1, 'withdraw');
             print '</td>';
 
             print '<td>';
-            print $thirdpartystatic->getNomUrl(1, 'customer');
+            print $thirdpartystatic->getNomUrl(1, 'supplier');
             print '</td>';
 
             print '<td class="right">';

+ 25 - 14
htdocs/compta/prelevement/card.php

@@ -31,10 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/prelevement/class/bonprelevement.class.p
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'bills', 'withdrawals'));
-
-if (!$user->rights->prelevement->bons->lire)
-accessforbidden();
+$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
 
 // Security check
 if ($user->socid > 0) accessforbidden();
@@ -44,7 +41,6 @@ $action = GETPOST('action', 'alpha');
 $id = GETPOST('id', 'int');
 $ref = GETPOST('ref', 'alpha');
 $socid = GETPOST('socid', 'int');
-
 $type = GETPOST('type', 'aZ09');
 
 // Load variable for pagination
@@ -67,6 +63,13 @@ include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be includ
 
 $hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
 
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+	accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+	accessforbidden();
+}
+
 
 /*
  * Actions
@@ -83,7 +86,11 @@ if (empty($reshook))
         $res = $object->delete($user);
         if ($res > 0)
         {
-            header("Location: index.php");
+        	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;
         }
     }
@@ -139,11 +146,9 @@ if (empty($reshook))
 		$dt = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int'));
 
         $error = $object->set_infocredit($user, $dt);
-
         if ($error)
         {
-            header("Location: card.php?id=".$id."&error=$error");
-            exit;
+        	setEventMessages($object->error, $object->errors, 'errors');
         }
     }
 }
@@ -174,7 +179,7 @@ if ($id > 0 || $ref)
 
 	}*/
 
-	$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php">'.$langs->trans("BackToList").'</a>';
+	$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
 
 	dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
 
@@ -200,7 +205,7 @@ if ($id > 0 || $ref)
 
 		print '<tr><td>'.$langs->trans("TransData").'</td><td>';
 		print dol_print_date($object->date_trans, 'day');
-		print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
+		print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
 		print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
 		print $object->methodes_trans[$object->method_trans];
 		print '</td></tr>';
@@ -223,7 +228,9 @@ if ($id > 0 || $ref)
 	$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
 
 	print '<tr><td class="titlefield">';
-	print $langs->trans("BankToReceiveWithdraw");
+	$labelofbankfield = "BankToReceiveWithdraw";
+	if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+	print $langs->trans($labelofbankfield);
 	print '</td>';
 	print '<td>';
 	if ($acc->id > 0)
@@ -232,9 +239,13 @@ if ($id > 0 || $ref)
 	print '</tr>';
 
 	print '<tr><td class="titlefield">';
-	print $langs->trans("WithdrawalFile").'</td><td>';
+	$labelfororderfield = 'WithdrawalFile';
+	if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+	print $langs->trans($labelfororderfield).'</td><td>';
 	$relativepath = 'receipts/'.$object->ref.'.xml';
-	print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
+	$modulepart = 'prelevement';
+	if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+	print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
 	print '</td></tr></table>';
 
 	print '</div>';

File diff suppressed because it is too large
+ 459 - 220
htdocs/compta/prelevement/class/bonprelevement.class.php


+ 1 - 1
htdocs/compta/prelevement/class/ligneprelevement.class.php

@@ -59,7 +59,7 @@ class LignePrelevement
 
 		$langs->load("withdrawals");
 		$this->statuts[0] = $langs->trans("StatusWaiting");
-		$this->statuts[2] = $langs->trans("StatusCredited");
+		$this->statuts[2] = $langs->trans("StatusPaid");
 		$this->statuts[3] = $langs->trans("StatusRefused");
 	}
 

+ 16 - 9
htdocs/compta/prelevement/create.php

@@ -88,11 +88,9 @@ if (empty($reshook))
 
 	    // $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)
-		{
+		if ($result < 0) {
 			setEventMessages($bprev->error, $bprev->errors, 'errors');
-		} elseif ($result == 0)
-		{
+		} elseif ($result == 0) {
 			$mesg = $langs->trans("NoInvoiceCouldBeWithdrawed", $format);
 			setEventMessages($mesg, null, 'errors');
 			$mesg .= '<br>'."\n";
@@ -101,7 +99,11 @@ if (empty($reshook))
 				$mesg .= '<span class="warning">'.$val."</span><br>\n";
 			}
 		} else {
-			setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+			if ($type != 'bank-transfer') {
+				setEventMessages($langs->trans("DirectDebitOrderCreated", $bprev->getNomUrl(1)), null);
+			} else {
+				setEventMessages($langs->trans("CreditTransferOrderCreated", $bprev->getNomUrl(1)), null);
+			}
 
 			header("Location: ".DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$bprev->id);
 			exit;
@@ -366,10 +368,15 @@ if ($resql)
 
 			// RUM
 			print '<td>';
-			print $thirdpartystatic->display_rib('rum');
-			$format = $thirdpartystatic->display_rib('format');
-			if ($type != 'bank-transfer') {
-				if ($format) print ' ('.$format.')';
+			$rumtoshow = $thirdpartystatic->display_rib('rum');
+			if ($rumtoshow) {
+				print $rumtoshow;
+				$format = $thirdpartystatic->display_rib('format');
+				if ($type != 'bank-transfer') {
+					if ($format) print ' ('.$format.')';
+				}
+			} else {
+				print img_warning($langs->trans("NoBankAccount"));
 			}
 			print '</td>';
 			// Amount

+ 23 - 10
htdocs/compta/prelevement/demandes.php

@@ -105,14 +105,17 @@ if ($type != 'bank-transfer') {
 llxHeader('', $title);
 
 $thirdpartystatic = new Societe($db);
-$invoicestatic = new Facture($db);
+if ($type == 'bank-transfer') {
+	$invoicestatic = new FactureFournisseur($db);
+} else {
+	$invoicestatic = new Facture($db);
+}
 
 // List of requests
 
 $sql = "SELECT f.ref, f.rowid, f.total_ttc,";
 $sql .= " s.nom as name, s.rowid as socid,";
-$sql .= " pfd.date_demande as date_demande,";
-$sql .= " pfd.fk_user_demande";
+$sql .= " pfd.date_demande as date_demande, pfd.amount, pfd.fk_user_demande";
 if ($type != 'bank-transfer') {
 	$sql .= " FROM ".MAIN_DB_PREFIX."facture as f,";
 } else {
@@ -126,6 +129,7 @@ $sql .= " AND f.entity IN (".getEntity('invoice').")";
 if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
 if ($socid) $sql .= " AND f.fk_soc = ".$socid;
 if (!$status) $sql .= " AND pfd.traite = 0";
+$sql .= " AND pfd.ext_payment_id IS NULL";
 if ($status) $sql .= " AND pfd.traite = ".$status;
 $sql .= " AND f.total_ttc > 0";
 if (empty($conf->global->WITHDRAWAL_ALLOW_ANY_INVOICE_STATUS))
@@ -141,7 +145,6 @@ if ($search_facture) $sql .= natural_search("f.ref", $search_facture);
 if ($search_societe) $sql .= natural_search("s.nom", $search_societe);
 $sql .= $db->order($sortfield, $sortorder);
 
-
 // Count total nb of records
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
@@ -173,9 +176,9 @@ if (is_numeric($nbtotalofrecords) && $limit > $nbtotalofrecords)
 
 
 
-$newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/index.php">'.$langs->trans("Back").'</a>';
+$newcardbutton = '<a class="marginrightonly" href="'.DOL_URL_ROOT.'/compta/prelevement/index.php">'.$langs->trans("Back").'</a>';
 if ($type == 'bank-transfer') {
-	$newcardbutton = '<a href="'.DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php">'.$langs->trans("Back").'</a>';
+	$newcardbutton = '<a class="marginrightonly" href="'.DOL_URL_ROOT.'/compta/paymentbybanktransfer/index.php">'.$langs->trans("Back").'</a>';
 }
 
 print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST"  id="searchFormList" name="searchFormList">';
@@ -190,6 +193,14 @@ print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
 
 $param = '';
 
+$label = 'NewStandingOrder';
+$typefilter = '';
+if ($type == 'bank-transfer') {
+	$label = 'NewPaymentByBankTransfer';
+	$typefilter = 'type='.$type;
+}
+$newcardbutton .= dolGetButtonTitle($langs->trans($label), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/prelevement/create.php'.($typefilter ? '?'.$typefilter : ''));
+
 print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'generic', 0, $newcardbutton, '', $limit);
 
 print '<table class="liste centpercent">';
@@ -197,7 +208,7 @@ print '<table class="liste centpercent">';
 print '<tr class="liste_titre">';
 print_liste_field_titre("Bill", $_SERVER["PHP_SELF"]);
 print_liste_field_titre("Company", $_SERVER["PHP_SELF"]);
-print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right ');
+print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'right ');
 print_liste_field_titre("DateRequest", $_SERVER["PHP_SELF"], "", "", $param, '', '', '', 'center ');
 print_liste_field_titre('');
 print '</tr>';
@@ -220,12 +231,12 @@ while ($i < min($num, $limit))
 	$obj = $db->fetch_object($resql);
 	if (empty($obj)) break; // Should not happen
 
+	$invoicestatic->fetch($obj->rowid);
+
 	print '<tr class="oddeven">';
 
 	// Ref facture
 	print '<td>';
-	$invoicestatic->id = $obj->rowid;
-	$invoicestatic->ref = $obj->ref;
 	print $invoicestatic->getNomUrl(1, 'withdraw');
 	print '</td>';
 
@@ -235,7 +246,9 @@ while ($i < min($num, $limit))
 	print $thirdpartystatic->getNomUrl(1, 'customer');
 	print '</td>';
 
-	print '<td class="right">'.price($obj->total_ttc).'</td>';
+	print '<td class="right">';
+	print price($obj->amount, 1, $langs, 1, -1, -1, $conf->currency).' / '.price($obj->total_ttc, 1, $langs, 1, -1, -1, $conf->currency);
+	print '</td>';
 
 	print '<td class="center">'.dol_print_date($db->jdate($obj->date_demande), 'day').'</td>';
 

+ 69 - 35
htdocs/compta/prelevement/factures.php

@@ -32,21 +32,21 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
 require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array('banks', 'categories', 'companies', 'withdrawals', 'bills'));
+$langs->loadLangs(array('banks', 'categories', 'bills', 'companies', 'withdrawals'));
 
 // Securite acces client
 if ($user->socid > 0) accessforbidden();
 
 // Get supervariables
 $id = GETPOST('id', 'int');
-$socid = GETPOST('socid', 'int');
 $ref = GETPOST('ref', 'alpha');
-
+$socid = GETPOST('socid', 'int');
 $type = GETPOST('type', 'aZ09');
 
+// Load variable for pagination
 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
-$sortfield = GETPOST("sortfield", 'alpha');
-$sortorder = GETPOST("sortorder", 'alpha');
+$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;
@@ -57,6 +57,17 @@ if (!$sortorder) $sortorder = 'DESC';
 
 $object = new BonPrelevement($db);
 
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+$hookmanager->initHooks(array('directdebitprevcard', 'globalcard', 'directdebitprevlist'));
+
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+	accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+	accessforbidden();
+}
 
 
 /*
@@ -75,19 +86,17 @@ if ($id > 0 || $ref)
     	$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">'.$langs->trans("BackToList").'</a>';
+		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
 
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
 
 		print '<div class="fichecenter">';
 		print '<div class="underbanner clearboth"></div>';
-      	print '<table class="border centpercent tableforfield">';
+		print '<table class="border centpercent tableforfield">'."\n";
 
 		//print '<tr><td class="titlefield">'.$langs->trans("Ref").'</td><td>'.$object->getNomUrl(1).'</td></tr>';
 		print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
 		print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
-		// Status
-		//print '<tr><td>'.$langs->trans('Status').'</td><td>'.$object->getLibStatut(1).'</td></tr>';
 
 		if ($object->date_trans <> 0)
 		{
@@ -96,7 +105,7 @@ if ($id > 0 || $ref)
 
 			print '<tr><td>'.$langs->trans("TransData").'</td><td>';
 			print dol_print_date($object->date_trans, 'day');
-			print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
+			print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
 			print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
 			print $object->methodes_trans[$object->method_trans];
 			print '</td></tr>';
@@ -119,7 +128,9 @@ if ($id > 0 || $ref)
 		$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
 
 		print '<tr><td class="titlefield">';
-		print $langs->trans("BankToReceiveWithdraw");
+		$labelofbankfield = "BankToReceiveWithdraw";
+		if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+		print $langs->trans($labelofbankfield);
 		print '</td>';
 		print '<td>';
 		if ($acc->id > 0)
@@ -128,9 +139,13 @@ if ($id > 0 || $ref)
 		print '</tr>';
 
 		print '<tr><td class="titlefield">';
-		print $langs->trans("WithdrawalFile").'</td><td>';
+		$labelfororderfield = 'WithdrawalFile';
+		if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+		print $langs->trans($labelfororderfield).'</td><td>';
 		$relativepath = 'receipts/'.$object->ref.'.xml';
-		print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
+		$modulepart = 'prelevement';
+		if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+		print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
 		print '</td></tr></table>';
 
 		print '</div>';
@@ -143,19 +158,31 @@ if ($id > 0 || $ref)
 
 
 // List of invoices
-$sql = "SELECT pf.rowid,";
+$sql = "SELECT pf.rowid, p.type,";
 $sql .= " f.rowid as facid, f.ref as ref, f.total_ttc,";
 $sql .= " s.rowid as socid, s.nom as name, pl.statut, pl.amount as amount_requested";
 $sql .= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
 $sql .= ", ".MAIN_DB_PREFIX."prelevement_lignes as pl";
 $sql .= ", ".MAIN_DB_PREFIX."prelevement_facture as pf";
-$sql .= ", ".MAIN_DB_PREFIX."facture as f";
+if ($object->type != 'bank-transfer') {
+	$sql .= ", ".MAIN_DB_PREFIX."facture as f";
+} else {
+	$sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f";
+}
 $sql .= ", ".MAIN_DB_PREFIX."societe as s";
 $sql .= " WHERE pf.fk_prelevement_lignes = pl.rowid";
 $sql .= " AND pl.fk_prelevement_bons = p.rowid";
 $sql .= " AND f.fk_soc = s.rowid";
-$sql .= " AND pf.fk_facture = f.rowid";
-$sql .= " AND f.entity IN (".getEntity('invoice').")";
+if ($object->type != 'bank-transfer') {
+	$sql .= " AND pf.fk_facture = f.rowid";
+} else {
+	$sql .= " AND pf.fk_facture_fourn = f.rowid";
+}
+if ($object->type != 'bank-transfer') {
+	$sql .= " AND f.entity IN (".getEntity('invoice').")";
+} else {
+	$sql .= " AND f.entity IN (".getEntity('supplier_invoice').")";
+}
 if ($object->id > 0) $sql .= " AND p.rowid=".$object->id;
 if ($socid) $sql .= " AND s.rowid = ".$socid;
 $sql .= $db->order($sortfield, $sortorder);
@@ -164,8 +191,8 @@ $sql .= $db->order($sortfield, $sortorder);
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 {
-    $result = $db->query($sql);
-    $nbtotalofrecords = $db->num_rows($result);
+    $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;
@@ -175,10 +202,10 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
 
 $sql .= $db->plimit($limit + 1, $offset);
 
-$result = $db->query($sql);
-if ($result)
+$resql = $db->query($sql);
+if ($resql)
 {
-  	$num = $db->num_rows($result);
+  	$num = $db->num_rows($resql);
   	$i = 0;
 
   	$param = "&id=".$id;
@@ -207,22 +234,28 @@ if ($result)
   	print_liste_field_titre("ThirdParty", $_SERVER["PHP_SELF"], "s.nom", '', $param, '', $sortfield, $sortorder);
   	print_liste_field_titre("AmountInvoice", $_SERVER["PHP_SELF"], "f.total_ttc", "", $param, 'class="right"', $sortfield, $sortorder);
   	print_liste_field_titre("AmountRequested", $_SERVER["PHP_SELF"], "pl.amount", "", $param, 'class="right"', $sortfield, $sortorder);
-  	print_liste_field_titre("StatusDebitCredit", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder);
+  	print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "", "", $param, 'align="center"', $sortfield, $sortorder);
 	print_liste_field_titre('');
 	print "</tr>\n";
 
   	$totalinvoices = 0;
 	$totalamount_requested = 0;
 
+	$invoicetmpcustomer = new Facture($db);
+	$invoicetmpsupplier = new FactureFournisseur($db);
+
   	while ($i < min($num, $limit))
     {
-     	$obj = $db->fetch_object($result);
+     	$obj = $db->fetch_object($resql);
 
-     	$invoicetmp->id = $obj->facid;
-     	$invoicetmp->ref = $obj->ref;
+     	if ($obj->type == 'bank-transfer') {
+     		$invoicetmp = $invoicetmpsupplier;
+     	} else {
+     		$invoicetmp = $invoicetmpcustomer;
+     	}
+     	$invoicetmp->fetch($obj->facid);
 
-     	$thirdpartytmp->id = $obj->socid;
-     	$thirdpartytmp->name = $obj->name;
+     	$thirdpartytmp->fetch($obj->socid);
 
       	print '<tr class="oddeven">';
 
@@ -243,14 +276,15 @@ if ($result)
       	// Status of requests
       	print '<td class="center">';
 
-      	if ($obj->statut == 0)
-		{
+      	if ($obj->statut == 0) {
 	  		print '-';
-		} elseif ($obj->statut == 2)
-		{
-	  		print $langs->trans("StatusCredited");
-		} elseif ($obj->statut == 3)
-		{
+		} elseif ($obj->statut == 2) {
+			if ($obj->type == 'bank-transfer') {
+				print $langs->trans("StatusDebited");
+			} else {
+				print $langs->trans("StatusCredited");
+			}
+		} elseif ($obj->statut == 3) {
 	  		print '<b>'.$langs->trans("StatusRefused").'</b>';
 		}
 

+ 24 - 15
htdocs/compta/prelevement/fiche-rejet.php

@@ -21,7 +21,7 @@
 /**
  * 		\file       htdocs/compta/prelevement/fiche-rejet.php
  *      \ingroup    prelevement
- *		\brief      Withdraw reject
+ *		\brief      Debit order or credit transfer reject
  */
 
 require '../../main.inc.php';
@@ -34,7 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
 // Load translation files required by the page
 $langs->loadLangs(array("banks", "categories", 'withdrawals', 'bills'));
 
-// Securite acces client
+// Security check
 if ($user->socid > 0) accessforbidden();
 
 // Get supervariables
@@ -55,6 +55,15 @@ $pagenext = $page + 1;
 
 $object = new BonPrelevement($db);
 
+// Load object
+include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once  // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals
+
+if (!$user->rights->prelevement->bons->lire && $object->type != 'bank-transfer') {
+	accessforbidden();
+}
+if (!$user->rights->paymentbybanktransfer->read && $object->type == 'bank-transfer') {
+	accessforbidden();
+}
 
 
 
@@ -71,7 +80,7 @@ if ($prev_id > 0 || $ref)
     	$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">'.$langs->trans("BackToList").'</a>';
+		$linkback = '<a href="'.DOL_URL_ROOT.'/compta/prelevement/bons.php'.($object->type != 'bank-transfer' ? '' : '?type=bank-transfer').'">'.$langs->trans("BackToList").'</a>';
 
 		dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref');
 
@@ -83,13 +92,6 @@ if ($prev_id > 0 || $ref)
 		print '<tr><td class="titlefield">'.$langs->trans("Date").'</td><td>'.dol_print_date($object->datec, 'day').'</td></tr>';
 		print '<tr><td>'.$langs->trans("Amount").'</td><td>'.price($object->amount).'</td></tr>';
 
-		// Status
-		/*
-		print '<tr><td>'.$langs->trans('Status').'</td>';
-		print '<td>'.$object->getLibStatut(1).'</td>';
-		print '</tr>';
-		*/
-
 		if ($object->date_trans <> 0)
 		{
 			$muser = new User($db);
@@ -97,7 +99,7 @@ if ($prev_id > 0 || $ref)
 
 			print '<tr><td>'.$langs->trans("TransData").'</td><td>';
 			print dol_print_date($object->date_trans, 'day');
-			print ' '.$langs->trans("By").' '.$muser->getFullName($langs).'</td></tr>';
+			print ' <span class="opacitymedium">'.$langs->trans("By").'</span> '.$muser->getFullName($langs).'</td></tr>';
 			print '<tr><td>'.$langs->trans("TransMetod").'</td><td>';
 			print $object->methodes_trans[$object->method_trans];
 			print '</td></tr>';
@@ -120,7 +122,9 @@ if ($prev_id > 0 || $ref)
 		$result = $acc->fetch($conf->global->PRELEVEMENT_ID_BANKACCOUNT);
 
 		print '<tr><td class="titlefield">';
-		print $langs->trans("BankToReceiveWithdraw");
+		$labelofbankfield = "BankToReceiveWithdraw";
+		if ($object->type == 'bank-transfer') $labelofbankfield = 'BankToPayCreditTransfer';
+		print $langs->trans($labelofbankfield);
 		print '</td>';
 		print '<td>';
 		if ($acc->id > 0)
@@ -129,9 +133,13 @@ if ($prev_id > 0 || $ref)
 		print '</tr>';
 
 		print '<tr><td class="titlefield">';
-		print $langs->trans("WithdrawalFile").'</td><td>';
+		$labelfororderfield = 'WithdrawalFile';
+		if ($object->type == 'bank-transfer') $labelfororderfield = 'CreditTransferFile';
+		print $langs->trans($labelfororderfield).'</td><td>';
 		$relativepath = 'receipts/'.$object->ref.'.xml';
-		print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart=prelevement&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
+		$modulepart = 'prelevement';
+		if ($object->type == 'bank-transfer') $modulepart = 'paymentbybanktransfer';
+		print '<a data-ajax="false" href="'.DOL_URL_ROOT.'/document.php?type=text/plain&amp;modulepart='.$modulepart.'&amp;file='.urlencode($relativepath).'">'.$relativepath.'</a>';
 		print '</td></tr></table>';
 
 		print '</div>';
@@ -142,6 +150,7 @@ if ($prev_id > 0 || $ref)
     }
 }
 
+
 $rej = new RejetPrelevement($db, $user);
 
 /*
@@ -221,7 +230,7 @@ if ($resql)
     		$i++;
     	}
 	} else {
-	    print '<tr><td colspan="5" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
+	    print '<tr><td colspan="6" class="opacitymedium">'.$langs->trans("None").'</td></tr>';
 	}
 
   	if ($num > 0)

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