Просмотр исходного кода

Merge branch 'develop' into patch-169

Laurent Destailleur 3 лет назад
Родитель
Сommit
84073c6373
100 измененных файлов с 1783 добавлено и 5022 удалено
  1. 1 1
      .github/PULL_REQUEST_TEMPLATE.md
  2. 42 24
      ChangeLog
  3. 1 1
      README.md
  4. 145 0
      dev/tools/spider.php
  5. 0 1
      htdocs/accountancy/admin/index.php
  6. 5 3
      htdocs/accountancy/bookkeeping/card.php
  7. 20 20
      htdocs/accountancy/bookkeeping/list.php
  8. 69 24
      htdocs/accountancy/bookkeeping/listbyaccount.php
  9. 71 29
      htdocs/accountancy/bookkeeping/listbysubaccount.php
  10. 94 16
      htdocs/accountancy/class/accountancyexport.class.php
  11. 21 3
      htdocs/accountancy/class/bookkeeping.class.php
  12. 1 1
      htdocs/accountancy/index.php
  13. 57 12
      htdocs/accountancy/journal/bankjournal.php
  14. 4 0
      htdocs/accountancy/tpl/export_journal.tpl.php
  15. 0 2
      htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php
  16. 2 2
      htdocs/adherents/card.php
  17. 2 1
      htdocs/adherents/list.php
  18. 9 4
      htdocs/adherents/note.php
  19. 2 2
      htdocs/adherents/subscription/list.php
  20. 6 4
      htdocs/adherents/type.php
  21. 1 1
      htdocs/adherents/type_translation.php
  22. 1 0
      htdocs/admin/agenda_reminder.php
  23. 4 4
      htdocs/admin/clicktodial.php
  24. 5 0
      htdocs/admin/dav.php
  25. 26 11
      htdocs/admin/dict.php
  26. 16 8
      htdocs/admin/eventorganization.php
  27. 229 151
      htdocs/admin/holiday.php
  28. 5 2
      htdocs/admin/index.php
  29. 3 0
      htdocs/admin/mails_templates.php
  30. 42 16
      htdocs/admin/notification.php
  31. 13 11
      htdocs/admin/paymentbybanktransfer.php
  32. 97 51
      htdocs/admin/pdf.php
  33. 10 0
      htdocs/admin/pdf_other.php
  34. 11 9
      htdocs/admin/prelevement.php
  35. 5 0
      htdocs/admin/supplier_invoice.php
  36. 9 5
      htdocs/admin/system/database-tables.php
  37. 8 0
      htdocs/admin/system/dolibarr.php
  38. 32 10
      htdocs/admin/system/security.php
  39. 7 2
      htdocs/admin/tools/dolibarr_export.php
  40. 10 2
      htdocs/admin/tools/dolibarr_import.php
  41. 4 0
      htdocs/admin/tools/export_files.php
  42. 8 3
      htdocs/admin/tools/listsessions.php
  43. 9 4
      htdocs/admin/tools/purge.php
  44. 11 6
      htdocs/admin/tools/update.php
  45. 8 2
      htdocs/admin/workflow.php
  46. 7 2
      htdocs/asset/note.php
  47. 4 1
      htdocs/blockedlog/admin/blockedlog.php
  48. 2 1
      htdocs/blockedlog/admin/blockedlog_list.php
  49. 2 2
      htdocs/bom/bom_list.php
  50. 7 1
      htdocs/bom/bom_note.php
  51. 11 7
      htdocs/bookmarks/bookmarks.lib.php
  52. 2 2
      htdocs/bookmarks/card.php
  53. 0 191
      htdocs/cashdesk/admin/cashdesk.php
  54. 0 100
      htdocs/cashdesk/affContenu.php
  55. 0 78
      htdocs/cashdesk/affIndex.php
  56. 0 52
      htdocs/cashdesk/affPied.php
  57. 0 144
      htdocs/cashdesk/class/Auth.class.php
  58. 0 558
      htdocs/cashdesk/class/Facturation.class.php
  59. 0 455
      htdocs/cashdesk/css/style.css
  60. 0 61
      htdocs/cashdesk/css/ticket.css
  61. 0 48
      htdocs/cashdesk/deconnexion.php
  62. 0 159
      htdocs/cashdesk/facturation.php
  63. 0 129
      htdocs/cashdesk/facturation_dhtml.php
  64. 0 225
      htdocs/cashdesk/facturation_verif.php
  65. BIN
      htdocs/cashdesk/img/basket_delete.png
  66. BIN
      htdocs/cashdesk/img/bg_conteneur_droite.png
  67. BIN
      htdocs/cashdesk/img/bg_conteneur_gauche.png
  68. BIN
      htdocs/cashdesk/img/bg_entete.png
  69. BIN
      htdocs/cashdesk/img/bg_pied.png
  70. BIN
      htdocs/cashdesk/img/calendrier.png
  71. BIN
      htdocs/cashdesk/img/decrypted.png
  72. BIN
      htdocs/cashdesk/img/gescom.png
  73. BIN
      htdocs/cashdesk/img/lock.png
  74. BIN
      htdocs/cashdesk/img/login.png
  75. BIN
      htdocs/cashdesk/img/new.png
  76. 0 50
      htdocs/cashdesk/include/environnement.php
  77. 0 56
      htdocs/cashdesk/include/keypad.php
  78. 0 232
      htdocs/cashdesk/index.php
  79. 0 126
      htdocs/cashdesk/index_verif.php
  80. 0 73
      htdocs/cashdesk/javascript/dhtml.js
  81. 0 175
      htdocs/cashdesk/javascript/facturation1.js
  82. 0 36
      htdocs/cashdesk/javascript/keypad.js
  83. 0 225
      htdocs/cashdesk/tpl/facturation1.tpl.php
  84. 0 73
      htdocs/cashdesk/tpl/liste_articles.tpl.php
  85. 0 90
      htdocs/cashdesk/tpl/menu.tpl.php
  86. 0 119
      htdocs/cashdesk/tpl/ticket.tpl.php
  87. 0 118
      htdocs/cashdesk/tpl/validation1.tpl.php
  88. 0 57
      htdocs/cashdesk/tpl/validation2.tpl.php
  89. 0 27
      htdocs/cashdesk/validation.php
  90. 0 25
      htdocs/cashdesk/validation_ok.php
  91. 0 50
      htdocs/cashdesk/validation_ticket.php
  92. 0 361
      htdocs/cashdesk/validation_verif.php
  93. 10 3
      htdocs/categories/class/categorie.class.php
  94. 83 1
      htdocs/categories/viewcat.php
  95. 3 3
      htdocs/comm/action/class/actioncomm.class.php
  96. 460 443
      htdocs/comm/action/list.php
  97. 50 6
      htdocs/comm/index.php
  98. 4 3
      htdocs/comm/mailing/cibles.php
  99. 2 2
      htdocs/comm/propal/card.php
  100. 10 4
      htdocs/comm/propal/list.php

+ 1 - 1
.github/PULL_REQUEST_TEMPLATE.md

@@ -3,7 +3,7 @@
 *Please:*
 - *only keep the "Fix", "Close" or "New" section*
 - *follow the project [contributing guidelines](/.github/CONTRIBUTING.md)*
-- *replace the bracket enclosed textswith meaningful informations*
+- *replace the bracket enclosed texts with meaningful information*
 
 
 # Fix #[*issue_number Short description*]

+ 42 - 24
ChangeLog

@@ -3,11 +3,24 @@ English Dolibarr ChangeLog
 --------------------------------------------------------------
 
 
+***** ChangeLog for 15.0.0 compared to 14.0.0 *****
+
+For developers:
+---------------
+
+WARNING:
+
+Following changes may create regressions for some external modules, but were necessary to make Dolibarr better:
+* Update hook 'printOriginObjectLine', removed check on product type and special code. Need now reshook.
+* Old deprecated module "SimplePOS" has been completely removed. Use module "TakePOS" is you need a Point Of Sale.
+
+
+
 ***** ChangeLog for 14.0.0 compared to 13.0.0 *****
 
 For users:
 ----------
-NEW: Module Recruitement to follow application to job positions is now stable.
+NEW: Module Recruitment to follow application to job positions is now stable.
 NEW: Feature to make Stock Inventories
 NEW: Several security issues after a second private bug hunting campaign. 
 NEW: A lot of fix into english text after a small proofreading campaign (still not perfect, but really better)
@@ -50,7 +63,7 @@ NEW: Make public bookmarks editable by admin users only
 NEW: If main logo not defined, can use the squarred logo on login page
 NEW: The manifest file can use the squared image if available
 NEW: Enhance the multicurrency rate editor
-NEW: Normalyse Type company field with ajax combobox
+NEW: Normalise Type company field with ajax combobox
 NEW: preload product description on selection for customer propal/order/invoice
 NEW: Search usergroups & resources
 NEW: Setup Page for module creation with module builder enhancement #FoundationFunding
@@ -67,14 +80,15 @@ NEW: #16378 more E-Mail Contact substitution Values for better salutation
 NEW: option to keep the "Automatically create the payment" checkbox empty on the tax creation page
 
  Accountancy
-NEW: Accountancy - Add FEC import
-NEW: Accountancy - Add a confirmation form with options on export
-NEW: Accountancy - Add select date from/to in already bind customer and supplier list
-NEW: Accountancy - Format FEC - Add new field DateLimitReglmt
-NEW: Accountancy - In ledger & journals, show link on bank transaction
-NEW: Accountancy - Possibility to filter on journals in balance
-NEW: Accountancy - Add a page to list subledger accounts
-NEW: Multiselect ledger account code filter on book keeping list
+NEW: Add FEC import
+NEW: Add a confirmation form with options on export (for notified export and validate operations)
+NEW: Add select date from/to in already bind customer and supplier list
+NEW: FEC / FEC2 export - Add new field DateLimitReglmt
+NEW: In ledger & journals, show link on bank transaction
+NEW: Possibility to filter on journals in balance
+NEW: Add a page to list subledger accounts
+NEW: Multiselect journal code filter on journal / balance / ledger
+NEW: Add first step to close fiscal year
 
  Agenda
 NEW: add support for Friday as a non working day
@@ -93,7 +107,7 @@ NEW: can filter files in ECM/GED on status Shared / Not shared
 NEW: add a check to avoid an invoice date in the future
 NEW: add the total of margin in invoice list
 NEW: can set a percentage when creating an invoice from another object
-NEW: Support down payment on supplier invoice (& somes ajustments)
+NEW: Support down payment on supplier invoice (& some adjustments)
 
  Margin
 NEW: add the total of margin in invoice list
@@ -162,7 +176,7 @@ NEW: Add a security center page with all information and advices related to the
 NEW: Add a performance center page with all information and advices related to the performance of your instance 
 
  Modules
-NEW: Module Recruitement is now stable
+NEW: Module Recruitment is now stable
 NEW: start new experimental module Event Organization Management
 NEW: start new experimental module Partnership Management
 NEW: start new experimental module Knowledge Management
@@ -171,11 +185,14 @@ NEW: Check update availability for externals modules using a button on module pa
 Module SimplePOS is deprecated - TakePOS is recommended for the future
 
  new Options
-NEW: add option  CONTRACT_ALLOW_EXTERNAL_DOWNLOAD            to make generated doc automatically shared
-NEW: add option  SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD   to make generated doc automatically shared
-NEW: add option  MAIN_SECURITY_ANTI_SSRF_SERVER_IP           to define list of IPs that are local IPs
-NEW: add option  SOCIETE_DISABLE_WORKFORCE                   to hide staff field
-NEW: add constant  MAIN_BUGTRACK_URL                         to set a custom url to redirect to when clicking on link "declare a bug"
+NEW: add option  CONTRACT_ALLOW_EXTERNAL_DOWNLOAD                   to make generated doc automatically shared
+NEW: add option  SUPPLIER_PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD          to make generated doc automatically shared
+NEW: add option  MAIN_SECURITY_ANTI_SSRF_SERVER_IP                  to define list of IPs that are local IPs
+NEW: add option  SOCIETE_DISABLE_WORKFORCE                          to hide staff field
+NEW: add constant  MAIN_BUGTRACK_URL                                to set a custom url to redirect to when clicking on link "declare a bug"
+NEW: add constant  ACCOUNTANCY_USE_PRODUCT_ACCOUNT_ON_THIRDPARTY    to manage binding with accountancy account declared on thirdparty card
+NEW: add constant  MAIN_PRODUCT_PERENTITY_SHARED                    to manage some informations (Accounting account) when product is shared on several entities
+NEW: add constant  MAIN_COMPANY_PERENTITY_SHARED                    to manage some informations (Accounting account) when company is shared on several entities
 
 
 For developers:
@@ -209,7 +226,7 @@ NEW: hook printFieldListTitle for cabyprodserv.php
 NEW: hook to allow external modules to add their own shortlist of recent objects
 NEW: SQL-altering hooks in the turnover by product report
 NEW: add form confirm hook on company card
-NEW: add hook addSectionECMAuto method to add custom diretory into ECM auto files
+NEW: add hook addSectionECMAuto method to add custom directory into ECM auto files
 
 
 WARNING:
@@ -219,23 +236,24 @@ Following changes may create regressions for some external modules, but were nec
 * The ICS value for direct debit or credit transfer is now stored on each bank account instead of into the global setup.
 * API /setup/shipment_methods has been replaced with API /setup/shipping_methods
 * Field "total" renamed into "total_ht"  for table llx_facture, llx_facture_rec for better field name consistency
-* Field "tva"   renamed into "total_tva" for table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
+* Field "tva"   renamed into "total_tva" for llx_facture, table llx_propal, llx_supplier_proposal, llx_commande, llx_commande_fournisseur for better field name consistency
 * Field "total" renamed into "total_ttc" for table llx_propal, llx_supplier_proposal for better field name consistency
 * If your database is PostgreSQL, you must use version 9.1.0 or more (Dolibarr need the SQL function CONCAT)
 * If your database is MySQL or MariaDB, you need at least version 5.1
 * Function set_price_level() has been renamed into setPriceLevel() to follow camelcase rules
-* removed deprecated subtituion key  __REFCLIENT__  (replaced with __REF_CLIENT__)
+* Removed deprecated substitution key  __REFCLIENT__  (replaced with __REF_CLIENT__)
 * Removed constant MAIN_COUNTRIES_IN_EEC. You can now set if country is in Europe or not from the dictionary of countries.
+* v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8.
 
 
 ***** ChangeLog for 13.0.4 compared to 13.0.3 *****
 
 FIX: Allow disabling of a module (not a dangerous action) even if there is problem with token (due to bugged modules).
-FIX: 13.0 - fatal - missing inclusion of ajax.lib.php for calling `ajax_autocompleter()`
-FIX: #17919 pictures in docs.
+FIX: 13.0 - fatal - missing inclusion of ajax.lib.php for calling 'ajax_autocompleter()'
+FIX: #17919 pictures in docs
 FIX: #18006
 FIX: Accountancy - if we define a date start, automatic binding try to continue to solve old binding
-FIX: Accoutancy Limit date payment not registered on purchases operations
+FIX: Accountancy - Limit date payment not registered on purchases operations
 FIX: Can't edit replacement invoice
 FIX: deposit can create credit note in payment conf
 FIX: division by zero on create
@@ -339,7 +357,7 @@ FIX: File attachment on lots/batches
 FIX: handling $heightforinfotot when he's superior to a page height on Supplier Invoice
 FIX: hourglass and hide button to pay
 FIX: massaction validate invoice do not regenerate PDF
-FIX: missing mp4 video mime
+FIX: #16627 fix missing mp4 video mime
 FIX: picto on shipment to reset qty to 0. Some quantities were not reset.
 FIX: Protection to avoid #16504
 FIX: rounding amount on card updating

+ 1 - 1
README.md

@@ -79,7 +79,7 @@ If you don't have time to install it yourself, you can try some commercial 'read
 
 ## UPGRADING
 
-Dolibarr supports upgrading usually wihtout the need for any (commercial) support (depending on if you use any commercial extensions) and supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate!
+Dolibarr supports upgrading, usually without the need for any (commercial) support (depending on if you use any commercial extensions). It supports upgrading all the way from any version after 2.8 without breakage. This is unique in the ERP ecosystem and a benefit our users highly appreciate!
  
 - At first make a backup of your Dolibarr files & than [see](https://wiki.dolibarr.org/index.php/Installation_-_Upgrade#Upgrade_Dolibarr)
 - Check that your installed PHP version is supported by the new version [see PHP support](./doc/phpmatrix.md).

+ 145 - 0
dev/tools/spider.php

@@ -0,0 +1,145 @@
+#!/usr/bin/env php
+<?php
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+/**
+ * \file 	dev/tools/spider.php
+ * \brief 	Script to spider Dolibarr app.
+ *
+ * To use it:
+ * - Disable module "bookmark"
+ * - Exclude param  optioncss, token, sortfield, sortorder
+ */
+
+$crawledLinks=array();
+const MAX_DEPTH=2;
+
+
+/**
+ * @param string $url	URL
+ * @param string $depth	Depth
+ * @return string		String
+ */
+function followLink($url, $depth = 0)
+{
+	global $crawledLinks;
+	$crawling=array();
+	if ($depth>MAX_DEPTH) {
+		echo "<div style='color:red;'>The Crawler is giving up!</div>";
+		return;
+	}
+	$options=array(
+		'http'=>array(
+			'method'=>"GET",
+			'user-agent'=>"gfgBot/0.1\n"
+		)
+	);
+	$context=stream_context_create($options);
+	$doc=new DomDocument();
+	@$doc->loadHTML(file_get_contents($url, false, $context));
+	$links=$doc->getElementsByTagName('a');
+	$pageTitle=getDocTitle($doc, $url);
+	$metaData=getDocMetaData($doc);
+	foreach ($links as $i) {
+		$link=$i->getAttribute('href');
+		if (ignoreLink($link)) continue;
+		$link=convertLink($url, $link);
+		if (!in_array($link, $crawledLinks)) {
+			$crawledLinks[]=$link;
+			$crawling[]=$link;
+			insertIntoDatabase($link, $pageTitle, $metaData, $depth);
+		}
+	}
+	foreach ($crawling as $crawlURL)
+		followLink($crawlURL, $depth+1);
+}
+
+/**
+ * @param string $site	Site
+ * @param string $path	Path
+ * @return string		String
+ */
+function convertLink($site, $path)
+{
+	if (substr_compare($path, "//", 0, 2)==0)
+		return parse_url($site)['scheme'].$path;
+	elseif (substr_compare($path, "http://", 0, 7)==0 or
+		substr_compare($path, "https://", 0, 8)==0 or
+		substr_compare($path, "www.", 0, 4)==0)
+		return $path;
+	else return $site.'/'.$path;
+}
+
+/**
+ * @param string $url	URL
+ * @return boolean
+ */
+function ignoreLink($url)
+{
+	return $url[0]=="#" or substr($url, 0, 11) == "javascript:";
+}
+
+/**
+ * @param string 	$link		URL
+ * @param string	$title		Title
+ * @param string 	$metaData	Array
+ * @param int 		$depth		Depth
+ * @return void
+ */
+function insertIntoDatabase($link, $title, &$metaData, $depth)
+{
+	//global $crawledLinks;
+
+	echo "Inserting new record {URL= ".$link.", Title = '$title', Description = '".$metaData['description']."', Keywords = ' ".$metaData['keywords']."'}<br/><br/><br/>";
+
+	//²$crawledLinks[]=$link;
+}
+
+/**
+ * @param string 	$doc		Doc
+ * @param string	$url		URL
+ * @return string				URL/Title
+ */
+function getDocTitle(&$doc, $url)
+{
+	$titleNodes=$doc->getElementsByTagName('title');
+	if (count($titleNodes)==0 or !isset($titleNodes[0]->nodeValue))
+		return $url;
+	$title=str_replace('', '\n', $titleNodes[0]->nodeValue);
+	return (strlen($title)<1)?$url:$title;
+}
+
+/**
+ * @param string 	$doc		Doc
+ * @return array				Array
+ */
+function getDocMetaData(&$doc)
+{
+	$metaData=array();
+	$metaNodes=$doc->getElementsByTagName('meta');
+	foreach ($metaNodes as $node)
+		$metaData[$node->getAttribute("name")] = $node->getAttribute("content");
+	if (!isset($metaData['description']))
+		$metaData['description']='No Description Available';
+	if (!isset($metaData['keywords'])) $metaData['keywords']='';
+	return array(
+		'keywords'=>str_replace('', '\n', $metaData['keywords']),
+		'description'=>str_replace('', '\n', $metaData['description'])
+	);
+}
+
+
+followLink("http://localhost/dolibarr_dev/htdocs");

+ 0 - 1
htdocs/accountancy/admin/index.php

@@ -91,7 +91,6 @@ if ($action == 'update') {
 	if (!$error) {
 		foreach ($list as $constname) {
 			$constvalue = GETPOST($constname, 'alpha');
-			var_dump($constname);
 			if (!dolibarr_set_const($db, $constname, $constvalue, 'chaine', 0, '', $conf->entity)) {
 				$error++;
 			}

+ 5 - 3
htdocs/accountancy/bookkeeping/card.php

@@ -637,6 +637,8 @@ if ($action == 'create') {
 				print_liste_field_titre("Credit", "", "", "", "", 'class="right"');
 				if (empty($object->date_validation)) {
 					print_liste_field_titre("Action", "", "", "", "", 'width="60" class="center"');
+				} else {
+					print_liste_field_titre("");
 				}
 
 				print "</tr>\n";
@@ -683,8 +685,8 @@ if ($action == 'create') {
 						print '<td class="right nowraponall amount">'.price($line->debit).'</td>';
 						print '<td class="right nowraponall amount">'.price($line->credit).'</td>';
 
-						if (empty($line->date_export) || empty($line->date_validation)) {
-							print '<td class="center">';
+						print '<td class="center">';
+						if (empty($line->date_export) && empty($line->date_validation)) {
 							print '<a class="editfielda reposition" href="' . $_SERVER["PHP_SELF"] . '?action=update&id=' . $line->id . '&piece_num=' . urlencode($line->piece_num) . '&mode=' . urlencode($mode) . '&token=' . urlencode(newToken()) . '">';
 							print img_edit('', 0, 'class="marginrightonly"');
 							print '</a> &nbsp;';
@@ -713,7 +715,7 @@ if ($action == 'create') {
 					setEventMessages(null, array($langs->trans('MvtNotCorrectlyBalanced', $total_debit, $total_credit)), 'warnings');
 				}
 
-				if (empty($object->date_export) || empty($object->date_validation)) {
+				if (empty($object->date_export) && empty($object->date_validation)) {
 					if ($action == "" || $action == 'add') {
 						print '<tr class="oddeven">';
 						print '<!-- td columns in add mode -->';

+ 20 - 20
htdocs/accountancy/bookkeeping/list.php

@@ -366,42 +366,42 @@ if (empty($reshook)) {
 	if (!empty($search_date_creation_start)) {
 		$filter['t.date_creation>='] = $search_date_creation_start;
 		$tmp = dol_getdate($search_date_creation_start);
-		$param .= '&date_creation_startmonth='.urlencode($tmp['mon']).'&date_creation_startday='.urlencode($tmp['mday']).'&date_creation_startyear='.urlencode($tmp['year']);
+		$param .= '&search_date_creation_startmonth='.urlencode($tmp['mon']).'&search_date_creation_startday='.urlencode($tmp['mday']).'&search_date_creation_startyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_creation_end)) {
 		$filter['t.date_creation<='] = $search_date_creation_end;
 		$tmp = dol_getdate($search_date_creation_end);
-		$param .= '&date_creation_endmonth='.urlencode($tmp['mon']).'&date_creation_endday='.urlencode($tmp['mday']).'&date_creation_endyear='.urlencode($tmp['year']);
+		$param .= '&search_date_creation_endmonth='.urlencode($tmp['mon']).'&search_date_creation_endday='.urlencode($tmp['mday']).'&search_date_creation_endyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_modification_start)) {
 		$filter['t.tms>='] = $search_date_modification_start;
 		$tmp = dol_getdate($search_date_modification_start);
-		$param .= '&date_modification_startmonth='.urlencode($tmp['mon']).'&date_modification_startday='.urlencode($tmp['mday']).'&date_modification_startyear='.urlencode($tmp['year']);
+		$param .= '&search_date_modification_startmonth='.urlencode($tmp['mon']).'&search_date_modification_startday='.urlencode($tmp['mday']).'&search_date_modification_startyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_modification_end)) {
 		$filter['t.tms<='] = $search_date_modification_end;
 		$tmp = dol_getdate($search_date_modification_end);
-		$param .= '&date_modification_endmonth='.urlencode($tmp['mon']).'&date_modification_endday='.urlencode($tmp['mday']).'&date_modification_endyear='.urlencode($tmp['year']);
+		$param .= '&search_date_modification_endmonth='.urlencode($tmp['mon']).'&search_date_modification_endday='.urlencode($tmp['mday']).'&search_date_modification_endyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_export_start)) {
 		$filter['t.date_export>='] = $search_date_export_start;
 		$tmp = dol_getdate($search_date_export_start);
-		$param .= '&date_export_startmonth='.urlencode($tmp['mon']).'&date_export_startday='.urlencode($tmp['mday']).'&date_export_startyear='.urlencode($tmp['year']);
+		$param .= '&search_date_export_startmonth='.urlencode($tmp['mon']).'&search_date_export_startday='.urlencode($tmp['mday']).'&search_date_export_startyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_export_end)) {
 		$filter['t.date_export<='] = $search_date_export_end;
 		$tmp = dol_getdate($search_date_export_end);
-		$param .= '&date_export_endmonth='.urlencode($tmp['mon']).'&date_export_endday='.urlencode($tmp['mday']).'&date_export_endyear='.urlencode($tmp['year']);
+		$param .= '&search_date_export_endmonth='.urlencode($tmp['mon']).'&search_date_export_endday='.urlencode($tmp['mday']).'&search_date_export_endyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_validation_start)) {
 		$filter['t.date_validated>='] = $search_date_validation_start;
 		$tmp = dol_getdate($search_date_validation_start);
-		$param .= '&date_validation_startmonth='.urlencode($tmp['mon']).'&date_validation_startday='.urlencode($tmp['mday']).'&date_validation_startyear='.urlencode($tmp['year']);
+		$param .= '&search_date_validation_startmonth='.urlencode($tmp['mon']).'&search_date_validation_startday='.urlencode($tmp['mday']).'&search_date_validation_startyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_date_validation_end)) {
 		$filter['t.date_validated<='] = $search_date_validation_end;
 		$tmp = dol_getdate($search_date_validation_end);
-		$param .= '&date_validation_endmonth='.urlencode($tmp['mon']).'&date_validation_endday='.urlencode($tmp['mday']).'&date_validation_endyear='.urlencode($tmp['year']);
+		$param .= '&search_date_validation_endmonth='.urlencode($tmp['mon']).'&search_date_validation_endday='.urlencode($tmp['mday']).'&search_date_validation_endyear='.urlencode($tmp['year']);
 	}
 	if (!empty($search_debit)) {
 		$filter['t.debit'] = $search_debit;
@@ -576,7 +576,7 @@ if (!empty($sortfield)) {
 // Export into a file with format defined into setup (FEC, CSV, ...)
 // Must be after definition of $sql
 if ($action == 'export_fileconfirm' && $user->rights->accounting->mouvements->export) {
-	// TODO Replace the fetchAll + ->export later that consume too much memory on large export with the query($sql) and loop on each line to export them.
+	// TODO Replace the fetchAll to get all ->line followed by call to ->export(). It consumew too much memory on large export. Replace this with the query($sql) and loop on each line to export them.
 	$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter, 'AND', (empty($conf->global->ACCOUNTING_REEXPORT) ? 0 : 1));
 
 	if ($result < 0) {
@@ -822,7 +822,7 @@ if (!empty($arrayfields['t.piece_num']['checked'])) {
 // Code journal
 if (!empty($arrayfields['t.code_journal']['checked'])) {
 	print '<td class="liste_titre center">';
-	print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
+	print $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1, 'maxwidth150');
 	print '</td>';
 }
 // Date document
@@ -865,7 +865,7 @@ if (!empty($arrayfields['t.subledger_account']['checked'])) {
 		print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', $langs->trans('to'), 'maxwidth250', 'subledgeraccount');
 		print '</div>';
 	} else {
-		print '<input type="text" class="maxwidth100" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.'">';
+		print '<input type="text" class="maxwidth75" name="search_accountancy_aux_code" value="'.$search_accountancy_aux_code.'">';
 	}
 	print '</td>';
 }
@@ -904,10 +904,10 @@ print $hookmanager->resPrint;
 if (!empty($arrayfields['t.date_creation']['checked'])) {
 	print '<td class="liste_titre center">';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_creation_start, 'date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print $form->selectDate($search_date_creation_start, 'search_date_creation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
 	print '</div>';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_creation_end, 'date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
+	print $form->selectDate($search_date_creation_end, 'search_date_creation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
 	print '</div>';
 	print '</td>';
 }
@@ -915,10 +915,10 @@ if (!empty($arrayfields['t.date_creation']['checked'])) {
 if (!empty($arrayfields['t.tms']['checked'])) {
 	print '<td class="liste_titre center">';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_modification_start, 'date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print $form->selectDate($search_date_modification_start, 'search_date_modification_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
 	print '</div>';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_modification_end, 'date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print $form->selectDate($search_date_modification_end, 'search_date_modification_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
 	print '</div>';
 	print '</td>';
 }
@@ -926,10 +926,10 @@ if (!empty($arrayfields['t.tms']['checked'])) {
 if (!empty($arrayfields['t.date_export']['checked'])) {
 	print '<td class="liste_titre center">';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_export_start, 'date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print $form->selectDate($search_date_export_start, 'search_date_export_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
 	print '</div>';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_export_end, 'date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
+	print $form->selectDate($search_date_export_end, 'search_date_export_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
 	print '</div>';
 	print '</td>';
 }
@@ -937,10 +937,10 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
 if (!empty($arrayfields['t.date_validated']['checked'])) {
 	print '<td class="liste_titre center">';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_validation_start, 'date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
 	print '</div>';
 	print '<div class="nowrap">';
-	print $form->selectDate($search_date_validation_end, 'date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
+	print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
 	print '</div>';
 	print '</td>';
 }
@@ -1243,7 +1243,7 @@ while ($i < min($num, $limit)) {
 
 	// Action column
 	print '<td class="nowraponall center">';
-	if (empty($line->date_export) || empty($line->date_validation)) {
+	if (empty($line->date_export) && empty($line->date_validation)) {
 		if ($user->rights->accounting->mouvements->creer) {
 			print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
 		}

+ 69 - 24
htdocs/accountancy/bookkeeping/listbyaccount.php

@@ -2,7 +2,7 @@
 /* Copyright (C) 2016       Neil Orley          <neil.orley@oeris.fr>
  * Copyright (C) 2013-2016  Olivier Geffroy     <jeff@jeffinfo.com>
  * Copyright (C) 2013-2020  Florian Henry       <florian.henry@open-concept.pro>
- * Copyright (C) 2013-2020  Alexandre Spangaro  <aspangaro@open-dsi.fr>
+ * Copyright (C) 2013-2021  Alexandre Spangaro  <aspangaro@open-dsi.fr>
  * Copyright (C) 2018       Frédéric France     <frederic.france@netlogic.fr>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -56,6 +56,14 @@ $search_date_export_endmonth =  GETPOST('search_date_export_endmonth', 'int');
 $search_date_export_endday =  GETPOST('search_date_export_endday', 'int');
 $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
 $search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
+$search_date_validation_startyear =  GETPOST('search_date_validation_startyear', 'int');
+$search_date_validation_startmonth =  GETPOST('search_date_validation_startmonth', 'int');
+$search_date_validation_startday =  GETPOST('search_date_validation_startday', 'int');
+$search_date_validation_endyear =  GETPOST('search_date_validation_endyear', 'int');
+$search_date_validation_endmonth =  GETPOST('search_date_validation_endmonth', 'int');
+$search_date_validation_endday =  GETPOST('search_date_validation_endday', 'int');
+$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
+$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
 
 $search_accountancy_code = GETPOST("search_accountancy_code");
 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
@@ -81,7 +89,7 @@ if (GETPOST("button_delmvt_x") || GETPOST("button_delmvt.x") || GETPOST("button_
 }
 
 // Load variable for pagination
-$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
+$limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : (empty($conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION) ? $conf->liste_limit : $conf->global->ACCOUNTING_LIMIT_LIST_VENTILATION);
 $sortfield = GETPOST('sortfield', 'aZ09comma');
 $sortorder = GETPOST('sortorder', 'aZ09comma');
 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
@@ -144,6 +152,7 @@ $arrayfields = array(
 	't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
 	't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
 	't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
+	't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
 );
 
 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
@@ -221,6 +230,14 @@ if (empty($reshook)) {
 		$search_date_export_endyear = '';
 		$search_date_export_endmonth = '';
 		$search_date_export_endday = '';
+		$search_date_validation_start = '';
+		$search_date_validation_end = '';
+		$search_date_validation_startyear = '';
+		$search_date_validation_startmonth = '';
+		$search_date_validation_startday = '';
+		$search_date_validation_endyear = '';
+		$search_date_validation_endmonth = '';
+		$search_date_validation_endday = '';
 		$search_debit = '';
 		$search_credit = '';
 		$search_lettering_code = '';
@@ -301,6 +318,14 @@ if (empty($reshook)) {
 		$filter['t.date_export<='] = $search_date_export_end;
 		$param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear;
 	}
+	if (!empty($search_date_validation_start)) {
+		$filter['t.date_validated>='] = $search_date_validation_start;
+		$param .= '&search_date_validation_startmonth='.$search_date_validation_startmonth.'&search_date_validation_startday='.$search_date_validation_startday.'&search_date_validation_startyear='.$search_date_validation_startyear;
+	}
+	if (!empty($search_date_validation_end)) {
+		$filter['t.date_validated<='] = $search_date_validation_end;
+		$param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear;
+	}
 }
 
 if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
@@ -484,10 +509,9 @@ $moreforfilter = '';
 $moreforfilter .= '<div class="divsearchfield">';
 $moreforfilter .= $langs->trans('AccountAccounting').': ';
 $moreforfilter .= '<div class="nowrap inline-block">';
-$moreforfilter .= $langs->trans('From').' ';
-$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', 1, array(), 1, 1, 'maxwidth200');
-$moreforfilter .= ' '.$langs->trans('to').' ';
-$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', 1, array(), 1, 1, 'maxwidth200');
+$moreforfilter .= $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, 'maxwidth200');
+$moreforfilter .= ' ';
+$moreforfilter .= $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, 'maxwidth200');
 $moreforfilter .= '</div>';
 $moreforfilter .= '</div>';
 
@@ -564,6 +588,17 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
 	print '</div>';
 	print '</td>';
 }
+// Date validation
+if (!empty($arrayfields['t.date_validated']['checked'])) {
+	print '<td class="liste_titre center">';
+	print '<div class="nowrap">';
+	print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print '</div>';
+	print '<div class="nowrap">';
+	print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
+	print '</div>';
+	print '</td>';
+}
 
 // Fields from hook
 $parameters = array('arrayfields'=>$arrayfields);
@@ -605,6 +640,9 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) {
 if (!empty($arrayfields['t.date_export']['checked'])) {
 	print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
 }
+if (!empty($arrayfields['t.date_validated']['checked'])) {
+	print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
+}
 // Hook fields
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@@ -632,20 +670,19 @@ while ($i < min($num, $limit)) {
 	$accountg = length_accountg($line->numero_compte);
 	//if (empty($accountg)) $accountg = '-';
 
+	$colspan = 0;			// colspan before field 'label of operation'
+	$colspanend = 3;		// colspan after debit/credit
+	if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
+	if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
+	if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
+
 	// Is it a break ?
 	if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
-		$colnumber = 5;
-		$colnumberend = 7;
-
-		if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
-			$colnumber--;
-		}
-		if (empty($arrayfields['t.date_export']['checked'])) {
-			$colnumber--;
-		}
-
-		$colspan = $totalarray['nbfield'] - $colnumber;
-		$colspanend = $totalarray['nbfield'] - $colnumberend;
 		// Show a subtotal by accounting account
 		if (isset($displayed_account_number)) {
 			print '<tr class="liste_total">';
@@ -845,6 +882,14 @@ while ($i < min($num, $limit)) {
 		}
 	}
 
+	// Validated operation date
+	if (!empty($arrayfields['t.date_validated']['checked'])) {
+		print '<td class="center">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
+		if (!$i) {
+			$totalarray['nbfield']++;
+		}
+	}
+
 	// Fields from hook
 	$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
 	$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
@@ -852,12 +897,14 @@ while ($i < min($num, $limit)) {
 
 	// Action column
 	print '<td class="nowraponall center">';
-	if (empty($line->date_export)) {
+	if (empty($line->date_export) && empty($line->date_validation)) {
 		if ($user->rights->accounting->mouvements->creer) {
-			print '<a class="editfielda" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
+			print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
 		}
+	}
+	if (empty($line->date_validation)) {
 		if ($user->rights->accounting->mouvements->supprimer) {
-			print ' &nbsp; <a class="paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
+			print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
 		}
 	}
 	print '</td>';
@@ -874,9 +921,7 @@ while ($i < min($num, $limit)) {
 	$i++;
 }
 
-if ($num > 0) {
-	$colspan = $totalarray['nbfield'] - $colnumber;
-	$colspanend = $totalarray['nbfield'] - $colnumberend;
+if ($num > 0 && $colspan > 0) {
 	print '<tr class="liste_total">';
 	print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
 	print '<td class="nowrap right">'.price($sous_total_debit).'</td>';

+ 71 - 29
htdocs/accountancy/bookkeeping/listbysubaccount.php

@@ -2,8 +2,8 @@
 /* Copyright (C) 2016       Neil Orley          <neil.orley@oeris.fr>
  * Copyright (C) 2013-2016  Olivier Geffroy     <jeff@jeffinfo.com>
  * Copyright (C) 2013-2020  Florian Henry       <florian.henry@open-concept.pro>
- * Copyright (C) 2013-2020  Alexandre Spangaro  <aspangaro@open-dsi.fr>
- * Copyright (C) 2018-2020  Frédéric France         <frederic.france@netlogic.fr>
+ * Copyright (C) 2013-2021  Alexandre Spangaro  <aspangaro@open-dsi.fr>
+ * Copyright (C) 2018-2020  Frédéric France		<frederic.france@netlogic.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
@@ -46,7 +46,7 @@ $search_date_endyear = GETPOST('search_date_endyear', 'int');
 $search_date_endmonth = GETPOST('search_date_endmonth', 'int');
 $search_date_endday = GETPOST('search_date_endday', 'int');
 $search_date_start = dol_mktime(0, 0, 0, $search_date_startmonth, $search_date_startday, $search_date_startyear);
-$search_date_end = dol_mktime(0, 0, 0, $search_date_endmonth, $search_date_endday, $search_date_endyear);
+$search_date_end = dol_mktime(23, 59, 59, $search_date_endmonth, $search_date_endday, $search_date_endyear);
 $search_doc_date = dol_mktime(0, 0, 0, GETPOST('doc_datemonth', 'int'), GETPOST('doc_dateday', 'int'), GETPOST('doc_dateyear', 'int'));
 $search_date_export_startyear =  GETPOST('search_date_export_startyear', 'int');
 $search_date_export_startmonth =  GETPOST('search_date_export_startmonth', 'int');
@@ -55,7 +55,15 @@ $search_date_export_endyear =  GETPOST('search_date_export_endyear', 'int');
 $search_date_export_endmonth =  GETPOST('search_date_export_endmonth', 'int');
 $search_date_export_endday =  GETPOST('search_date_export_endday', 'int');
 $search_date_export_start = dol_mktime(0, 0, 0, $search_date_export_startmonth, $search_date_export_startday, $search_date_export_startyear);
-$search_date_export_end = dol_mktime(0, 0, 0, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
+$search_date_export_end = dol_mktime(23, 59, 59, $search_date_export_endmonth, $search_date_export_endday, $search_date_export_endyear);
+$search_date_validation_startyear =  GETPOST('search_date_validation_startyear', 'int');
+$search_date_validation_startmonth =  GETPOST('search_date_validation_startmonth', 'int');
+$search_date_validation_startday =  GETPOST('search_date_validation_startday', 'int');
+$search_date_validation_endyear =  GETPOST('search_date_validation_endyear', 'int');
+$search_date_validation_endmonth =  GETPOST('search_date_validation_endmonth', 'int');
+$search_date_validation_endday =  GETPOST('search_date_validation_endday', 'int');
+$search_date_validation_start = dol_mktime(0, 0, 0, $search_date_validation_startmonth, $search_date_validation_startday, $search_date_validation_startyear);
+$search_date_validation_end = dol_mktime(23, 59, 59, $search_date_validation_endmonth, $search_date_validation_endday, $search_date_validation_endyear);
 
 $search_accountancy_code = GETPOST("search_accountancy_code");
 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
@@ -144,6 +152,7 @@ $arrayfields = array(
 	't.credit'=>array('label'=>$langs->trans("Credit"), 'checked'=>1),
 	't.lettering_code'=>array('label'=>$langs->trans("LetteringCode"), 'checked'=>1),
 	't.date_export'=>array('label'=>$langs->trans("DateExport"), 'checked'=>1),
+	't.date_validated'=>array('label'=>$langs->trans("DateValidation"), 'checked'=>1),
 );
 
 if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING)) {
@@ -221,6 +230,14 @@ if (empty($reshook)) {
 		$search_date_export_endyear = '';
 		$search_date_export_endmonth = '';
 		$search_date_export_endday = '';
+		$search_date_validation_start = '';
+		$search_date_validation_end = '';
+		$search_date_validation_startyear = '';
+		$search_date_validation_startmonth = '';
+		$search_date_validation_startday = '';
+		$search_date_validation_endyear = '';
+		$search_date_validation_endmonth = '';
+		$search_date_validation_endday = '';
 		$search_debit = '';
 		$search_credit = '';
 		$search_lettering_code = '';
@@ -301,6 +318,14 @@ if (empty($reshook)) {
 		$filter['t.date_export<='] = $search_date_export_end;
 		$param .= '&search_date_export_endmonth='.$search_date_export_endmonth.'&search_date_export_endday='.$search_date_export_endday.'&search_date_export_endyear='.$search_date_export_endyear;
 	}
+	if (!empty($search_date_validation_start)) {
+		$filter['t.date_validated>='] = $search_date_validation_start;
+		$param .= '&search_date_validation_startmonth='.$search_date_validation_startmonth.'&search_date_validation_startday='.$search_date_validation_startday.'&search_date_validation_startyear='.$search_date_validation_startyear;
+	}
+	if (!empty($search_date_validation_end)) {
+		$filter['t.date_validated<='] = $search_date_validation_end;
+		$param .= '&search_date_validation_endmonth='.$search_date_validation_endmonth.'&search_date_validation_endday='.$search_date_validation_endday.'&search_date_validation_endyear='.$search_date_validation_endyear;
+	}
 }
 
 if ($action == 'delbookkeeping' && $user->rights->accounting->mouvements->supprimer) {
@@ -373,7 +398,6 @@ $title_page = $langs->trans("Operations").' - '.$langs->trans("VueByAccountAccou
 
 llxHeader('', $title_page);
 
-
 // List
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
@@ -448,7 +472,6 @@ print '<input type="hidden" name="formfilteraction" id="formfilteraction" value=
 print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
 print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
 
-
 $parameters = array();
 $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
 if (empty($reshook)) {
@@ -488,10 +511,9 @@ $moreforfilter = '';
 $moreforfilter .= '<div class="divsearchfield">';
 $moreforfilter .= $langs->trans('AccountAccounting').': ';
 $moreforfilter .= '<div class="nowrap inline-block">';
-$moreforfilter .= $langs->trans('From').' ';
-$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', 1, 'maxwidth200');
-$moreforfilter .= ' '.$langs->trans('to').' ';
-$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', 1, 'maxwidth200');
+$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), 'maxwidth200');
+$moreforfilter .= ' ';
+$moreforfilter .= $formaccounting->select_auxaccount($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), 'maxwidth200');
 $moreforfilter .= '</div>';
 $moreforfilter .= '</div>';
 
@@ -568,6 +590,17 @@ if (!empty($arrayfields['t.date_export']['checked'])) {
 	print '</div>';
 	print '</td>';
 }
+// Date validation
+if (!empty($arrayfields['t.date_validated']['checked'])) {
+	print '<td class="liste_titre center">';
+	print '<div class="nowrap">';
+	print $form->selectDate($search_date_validation_start, 'search_date_validation_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From"));
+	print '</div>';
+	print '<div class="nowrap">';
+	print $form->selectDate($search_date_validation_end, 'search_date_validation_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to"));
+	print '</div>';
+	print '</td>';
+}
 
 // Fields from hook
 $parameters = array('arrayfields'=>$arrayfields);
@@ -609,6 +642,9 @@ if (!empty($arrayfields['t.lettering_code']['checked'])) {
 if (!empty($arrayfields['t.date_export']['checked'])) {
 	print_liste_field_titre($arrayfields['t.date_export']['label'], $_SERVER['PHP_SELF'], "t.date_export", "", $param, '', $sortfield, $sortorder, 'center ');
 }
+if (!empty($arrayfields['t.date_validated']['checked'])) {
+	print_liste_field_titre($arrayfields['t.date_validated']['label'], $_SERVER['PHP_SELF'], "t.date_validated", "", $param, '', $sortfield, $sortorder, 'center ');
+}
 // Hook fields
 $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
 $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
@@ -636,21 +672,19 @@ while ($i < min($num, $limit)) {
 	$accountg = length_accounta($line->subledger_account);
 	//if (empty($accountg)) $accountg = '-';
 
+	$colspan = 0;			// colspan before field 'label of operation'
+	$colspanend = 3;		// colspan after debit/credit
+	if (!empty($arrayfields['t.piece_num']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.code_journal']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.doc_date']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.doc_ref']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.label_operation']['checked'])) { $colspan++; }
+	if (!empty($arrayfields['t.date_export']['checked'])) { $colspanend++; }
+	if (!empty($arrayfields['t.date_validating']['checked'])) { $colspanend++; }
+	if (!empty($arrayfields['t.lettering_code']['checked'])) { $colspanend++; }
+
 	// Is it a break ?
 	if ($accountg != $displayed_account_number || !isset($displayed_account_number)) {
-		$colnumber = 5;
-		$colnumberend = 7;
-
-		if (empty($conf->global->ACCOUNTING_ENABLE_LETTERING) || empty($arrayfields['t.lettering_code']['checked'])) {
-			$colnumber--;
-		}
-		if (empty($arrayfields['t.date_export']['checked'])) {
-			$colnumber--;
-		}
-
-		$colspan = $totalarray['nbfield'] - $colnumber;
-		$colspanend = $totalarray['nbfield'] - $colnumberend;
-
 		// Show a subtotal by accounting account
 		if (isset($displayed_account_number)) {
 			print '<tr class="liste_total">';
@@ -859,6 +893,14 @@ while ($i < min($num, $limit)) {
 		}
 	}
 
+	// Validated operation date
+	if (!empty($arrayfields['t.date_validated']['checked'])) {
+		print '<td class="center">'.dol_print_date($line->date_validation, 'dayhour').'</td>';
+		if (!$i) {
+			$totalarray['nbfield']++;
+		}
+	}
+
 	// Fields from hook
 	$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj);
 	$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
@@ -866,12 +908,14 @@ while ($i < min($num, $limit)) {
 
 	// Action column
 	print '<td class="nowraponall center">';
-	if (empty($line->date_export)) {
+	if (empty($line->date_export) && empty($line->date_validation)) {
 		if ($user->rights->accounting->mouvements->creer) {
-			print '<a class="editfielda" href="'.DOL_URL_ROOT.'/accountancy/bookkeeping/card.php?piece_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_edit().'</a>';
+			print '<a class="editfielda paddingleft marginrightonly" href="' . DOL_URL_ROOT . '/accountancy/bookkeeping/card.php?piece_num=' . $line->piece_num . $param . '&page=' . $page . ($sortfield ? '&sortfield=' . $sortfield : '') . ($sortorder ? '&sortorder=' . $sortorder : '') . '">' . img_edit() . '</a>';
 		}
+	}
+	if (empty($line->date_validation)) {
 		if ($user->rights->accounting->mouvements->supprimer) {
-			print ' &nbsp; <a class="paddingleft" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
+			print '<a class="reposition paddingleft marginrightonly" href="'.$_SERVER['PHP_SELF'].'?action=delmouv&mvt_num='.$line->piece_num.$param.'&page='.$page.($sortfield ? '&sortfield='.$sortfield : '').($sortorder ? '&sortorder='.$sortorder : '').'">'.img_delete().'</a>';
 		}
 	}
 	print '</td>';
@@ -888,9 +932,7 @@ while ($i < min($num, $limit)) {
 	$i++;
 }
 
-if ($num > 0) {
-	$colspan = $totalarray['nbfield'] - $colnumber;
-	$colspanend = $totalarray['nbfield'] - $colnumberend;
+if ($num > 0 && $colspan > 0) {
 	print '<tr class="liste_total">';
 	print '<td class="right" colspan="'.$colspan.'">'.$langs->trans("TotalForAccount").' '.$accountg.':</td>';
 	print '<td class="nowrap right">'.price($sous_total_debit).'</td>';

+ 94 - 16
htdocs/accountancy/class/accountancyexport.class.php

@@ -5,7 +5,7 @@
  * Copyright (C) 2015       Florian Henry       <florian.henry@open-concept.pro>
  * Copyright (C) 2015       Raphaël Doursenaud  <rdoursenaud@gpcsolutions.fr>
  * Copyright (C) 2016       Pierre-Henry Favre  <phf@atm-consulting.fr>
- * Copyright (C) 2016-2020  Alexandre Spangaro  <aspangaro@open-dsi.fr>
+ * Copyright (C) 2016-2021  Alexandre Spangaro  <aspangaro@open-dsi.fr>
  * Copyright (C) 2013-2017  Olivier Geffroy     <jeff@jeffinfo.com>
  * Copyright (C) 2017       Elarifr. Ari Elbaz  <github@accedinfo.com>
  * Copyright (C) 2017-2019  Frédéric France     <frederic.france@netlogic.fr>
@@ -59,6 +59,8 @@ class AccountancyExport
 	public static $EXPORT_TYPE_LDCOMPTA10 = 120;
 	public static $EXPORT_TYPE_GESTIMUMV3 = 130;
 	public static $EXPORT_TYPE_GESTIMUMV5 = 135;
+	public static $EXPORT_TYPE_ISUITEEXPERT = 200;
+	// Generic FEC after that
 	public static $EXPORT_TYPE_FEC = 1000;
 	public static $EXPORT_TYPE_FEC2 = 1010;
 
@@ -123,6 +125,7 @@ class AccountancyExport
 			self::$EXPORT_TYPE_GESTIMUMV5 => $langs->trans('Modelcsv_Gestinum_v5'),
 			self::$EXPORT_TYPE_FEC => $langs->trans('Modelcsv_FEC'),
 			self::$EXPORT_TYPE_FEC2 => $langs->trans('Modelcsv_FEC2'),
+			self::$EXPORT_TYPE_ISUITEEXPERT => 'Export iSuite Expert',
 		);
 
 		ksort($listofexporttypes, SORT_NUMERIC);
@@ -158,6 +161,7 @@ class AccountancyExport
 			self::$EXPORT_TYPE_GESTIMUMV5 => 'gestimumv5',
 			self::$EXPORT_TYPE_FEC => 'fec',
 			self::$EXPORT_TYPE_FEC2 => 'fec2',
+			self::$EXPORT_TYPE_ISUITEEXPERT => 'isuiteexpert',
 		);
 
 		return $formatcode[$type];
@@ -243,6 +247,10 @@ class AccountancyExport
 					'label' => $langs->trans('Modelcsv_FEC2'),
 					'ACCOUNTING_EXPORT_FORMAT' => 'txt',
 				),
+				self::$EXPORT_TYPE_ISUITEEXPERT => array(
+					'label' => 'iSuite Expert',
+					'ACCOUNTING_EXPORT_FORMAT' => 'csv',
+				),
 			),
 			'cr'=> array(
 				'1' => $langs->trans("Unix"),
@@ -334,6 +342,9 @@ class AccountancyExport
 			case self::$EXPORT_TYPE_FEC2:
 				$this->exportFEC2($TData);
 				break;
+			case self::$EXPORT_TYPE_ISUITEEXPERT :
+				$this->exportiSuiteExpert($TData);
+				break;
 			default:
 				$this->errors[] = $langs->trans('accountancy_error_modelnotfound');
 				break;
@@ -466,34 +477,43 @@ class AccountancyExport
 	}
 
 	/**
-	 * Export format : CIEL
+	 * Export format : CIEL (Format XIMPORT)
+	 * Format since 2003 compatible CIEL version > 2002 / Sage50
+	 * Last review for this format : 2021/07/28 Alexandre Spangaro (aspangaro@open-dsi.fr)
+	 *
+	 * Help : https://sage50c.online-help.sage.fr/aide-technique/
+	 * In sage software | Use menu : "Exchange" > "Importing entries..."
+	 *
+	 * If you want to force filename to "XIMPORT.TXT" for automatically import file present in a directory :
+	 * use constant ACCOUNTING_EXPORT_XIMPORT_FORCE_FILENAME
 	 *
 	 * @param array $TData data
 	 * @return void
 	 */
 	public function exportCiel(&$TData)
 	{
-		global $conf;
-
 		$end_line = "\r\n";
 
 		$i = 1;
-		$date_ecriture = dol_print_date(dol_now(), $conf->global->ACCOUNTING_EXPORT_DATE); // format must be yyyymmdd
+
 		foreach ($TData as $data) {
-			$code_compta = $data->numero_compte;
+			$code_compta = length_accountg($data->numero_compte);
 			if (!empty($data->subledger_account)) {
-				$code_compta = $data->subledger_account;
+				$code_compta = length_accounta($data->subledger_account);
 			}
 
+			$date_document = dol_print_date($data->doc_date, '%Y%m%d');
+			$date_echeance = dol_print_date($data->date_lim_reglement, '%Y%m%d');
+
 			$Tab = array();
-			$Tab['num_ecriture'] = str_pad($i, 5);
+			$Tab['num_ecriture'] = str_pad($data->piece_num, 5);
 			$Tab['code_journal'] = str_pad($data->code_journal, 2);
-			$Tab['date_ecriture'] = $date_ecriture;
-			$Tab['date_ope'] = dol_print_date($data->doc_date, $conf->global->ACCOUNTING_EXPORT_DATE);
-			$Tab['num_piece'] = str_pad(self::trunc($data->piece_num, 12), 12);
+			$Tab['date_ecriture'] = str_pad($date_document, 8, ' ', STR_PAD_LEFT);
+			$Tab['date_echeance'] = str_pad($date_echeance, 8, ' ', STR_PAD_LEFT);
+			$Tab['num_piece'] = str_pad(self::trunc($data->doc_ref, 12), 12);
 			$Tab['num_compte'] = str_pad(self::trunc($code_compta, 11), 11);
 			$Tab['libelle_ecriture'] = str_pad(self::trunc(dol_string_unaccent($data->doc_ref).dol_string_unaccent($data->label_operation), 25), 25);
-			$Tab['montant'] = str_pad(abs($data->debit - $data->credit), 13, ' ', STR_PAD_LEFT);
+			$Tab['montant'] = str_pad(price2fec(abs($data->debit - $data->credit)), 13, ' ', STR_PAD_LEFT);
 			$Tab['type_montant'] = str_pad($data->sens, 1);
 			$Tab['vide'] = str_repeat(' ', 18);
 			$Tab['intitule_compte'] = str_pad(self::trunc(dol_string_unaccent($data->label_operation), 34), 34);
@@ -1287,7 +1307,9 @@ class AccountancyExport
 
 	/**
 	 * Export format : LD Compta version 10 & higher
-	 * http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
+	 * Last review for this format : 08-15-2021 Alexandre Spangaro (aspangaro@open-dsi.fr)
+	 *
+	 * Help : http://www.ldsysteme.fr/fileadmin/telechargement/np/ldcompta/Documentation/IntCptW10.pdf
 	 *
 	 * @param array $objectLines data
 	 *
@@ -1450,14 +1472,14 @@ class AccountancyExport
 			print $date_lim_reglement.$separator;
 			// CNPI
 			if ($line->doc_type == 'supplier_invoice') {
-				if (($line->debit - $line->credit) > 0) {
+				if (($line->amount) < 0) {		// Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
 					$nature_piece = 'AF';
 				} else {
 					$nature_piece = 'FF';
 				}
 			} elseif ($line->doc_type == 'customer_invoice') {
-				if (($line->debit - $line->credit) < 0) {
-					$nature_piece = 'AC';
+				if (($line->amount) < 0) {
+					$nature_piece = 'AC';		// Currently, only the sign of amount allows to know the type of invoice (standard or credit note). Other solution is to analyse debit/credit/role of account. TODO Add column doc_type_long or make amount mandatory with rule on sign.
 				} else {
 					$nature_piece = 'FC';
 				}
@@ -1752,6 +1774,62 @@ class AccountancyExport
 		}
 	}
 
+	/**
+	* Export format : iSuite Expert
+	*
+	* by OpenSolus [https://opensolus.fr]
+	*
+	* @param array $objectLines data
+	*
+	* @return void
+	*/
+	public function exportiSuiteExpert($objectLines)
+	{
+		$this->separator = ';';
+		$this->end_line = "\r\n";
+
+
+		foreach ($objectLines as $line) {
+			$tab = array();
+
+			$date = dol_print_date($line->doc_date, '%d/%m/%Y');
+
+			$tab[] = $line->piece_num;
+			$tab[] = $date;
+			$tab[] = substr($date, 6, 4);
+			$tab[] = substr($date, 3, 2);
+			$tab[] = substr($date, 0, 2);
+			$tab[] = $line->doc_ref;
+			//Conversion de chaine UTF8 en Latin9
+			$tab[] = mb_convert_encoding(str_replace(' - Compte auxiliaire', '', $line->label_operation), "Windows-1252", 'UTF-8');
+
+			//Calcul de la longueur des numéros de comptes
+			$taille_numero = strlen(length_accountg($line->numero_compte));
+
+			//Création du numéro de client générique
+			$numero_cpt_client = '411';
+			for ($i = 1; $i <= ($taille_numero - 3); $i++) {
+				$numero_cpt_client .= '0';
+			}
+
+			//Création des comptes auxiliaire des clients
+			if (length_accountg($line->numero_compte) == $numero_cpt_client) {
+				$tab[] = rtrim(length_accounta($line->subledger_account), "0");
+			} else {
+				$tab[] = length_accountg($line->numero_compte);
+			}
+			$nom_client = explode(" - ", $line->label_operation);
+			$tab[] = mb_convert_encoding($nom_client[0], "Windows-1252", 'UTF-8');
+			$tab[] = price($line->debit);
+			$tab[] = price($line->credit);
+			$tab[] = price($line->montant);
+			$tab[] = $line->code_journal;
+
+			$separator = $this->separator;
+			print implode($separator, $tab) . $this->end_line;
+		}
+	}
+
 	/**
 	 * trunc
 	 *

+ 21 - 3
htdocs/accountancy/class/bookkeeping.class.php

@@ -729,7 +729,10 @@ class BookKeeping extends CommonObject
 		$sql .= " t.journal_label,";
 		$sql .= " t.piece_num,";
 		$sql .= " t.date_creation,";
-		$sql .= " t.date_export,";
+		// In llx_accounting_bookkeeping_tmp, field date_export doesn't exist
+		if ($mode != "_tmp") {
+			$sql .= " t.date_export,";
+		}
 		$sql .= " t.date_validated as date_validation";
 		$sql .= ' FROM '.MAIN_DB_PREFIX.$this->table_element.$mode.' as t';
 		$sql .= ' WHERE 1 = 1';
@@ -1024,6 +1027,12 @@ class BookKeeping extends CommonObject
 					$sqlwhere[] = $key.'\''.$this->db->idate($value).'\'';
 				} elseif ($key == 't.credit' || $key == 't.debit') {
 					$sqlwhere[] = natural_search($key, $value, 1, 1);
+				} elseif ($key == 't.code_journal' && !empty($value)) {
+					if (is_array($value)) {
+						$sqlwhere[] = natural_search("t.code_journal", join(',', $value), 3, 1);
+					} else {
+						$sqlwhere[] = natural_search("t.code_journal", $value, 3, 1);
+					}
 				} else {
 					$sqlwhere[] = natural_search($key, $value, 0, 1);
 				}
@@ -1506,6 +1515,7 @@ class BookKeeping extends CommonObject
 		$sql = "DELETE";
 		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element;
 		$sql .= " WHERE piece_num = ".(int) $piecenum;
+		$sql .= " AND date_validated IS NULL";		// For security, exclusion of validated entries at the time of deletion
 		$sql .= " AND entity IN (".getEntity('accountancy').")";
 
 		$resql = $this->db->query($sql);
@@ -1621,7 +1631,11 @@ class BookKeeping extends CommonObject
 		global $conf;
 
 		$sql = "SELECT piece_num, doc_date,code_journal, journal_label, doc_ref, doc_type,";
-		$sql .= " date_creation, tms as date_modification, date_export, date_validated as date_validation";
+		$sql .= " date_creation, tms as date_modification, date_validated as date_validation";
+		// In llx_accounting_bookkeeping_tmp, field date_export doesn't exist
+		if ($mode != "_tmp") {
+			$sql .= ", date_export";
+		}
 		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
 		$sql .= " WHERE piece_num = ".$piecenum;
 		$sql .= " AND entity IN (".getEntity('accountancy').")";
@@ -1698,7 +1712,11 @@ class BookKeeping extends CommonObject
 		$sql .= " doc_ref, fk_doc, fk_docdet, thirdparty_code, subledger_account, subledger_label,";
 		$sql .= " numero_compte, label_compte, label_operation, debit, credit,";
 		$sql .= " montant as amount, sens, fk_user_author, import_key, code_journal, journal_label, piece_num,";
-		$sql .= " date_creation, tms as date_modification, date_export, date_validated as date_validation";
+		$sql .= " date_creation, tms as date_modification, date_validated as date_validation";
+		// In llx_accounting_bookkeeping_tmp, field date_export doesn't exist
+		if ($mode != "_tmp") {
+			$sql .= ", date_export";
+		}
 		$sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element.$mode;
 		$sql .= " WHERE piece_num = ".$piecenum;
 		$sql .= " AND entity IN (".getEntity('accountancy').")";

+ 1 - 1
htdocs/accountancy/index.php

@@ -49,7 +49,7 @@ if (empty($user->rights->accounting->mouvements->lire)) {
 if (empty($conf->comptabilite->enabled) && empty($conf->accounting->enabled) && empty($conf->asset->enabled) && empty($conf->intracommreport->enabled)) {
 	accessforbidden();
 }
-if (empty($user->rights->compta->resultat->lire) && empty($user->rights->accounting->mouvements->lire) && empty($user->rights->asset->read) && empty($user->rights->intracommreport->read)) {
+if (empty($user->rights->compta->resultat->lire) && empty($user->rights->accounting->comptarapport->lire) && empty($user->rights->accounting->mouvements->lire) && empty($user->rights->asset->read) && empty($user->rights->intracommreport->read)) {
 	accessforbidden();
 }
 

+ 57 - 12
htdocs/accountancy/journal/bankjournal.php

@@ -177,7 +177,7 @@ $accountingjournalstatic->fetch($id_journal);
 $journal = $accountingjournalstatic->code;
 $journal_label = $accountingjournalstatic->label;
 
-
+//print $sql;
 dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
 $result = $db->query($sql);
 if ($result) {
@@ -252,6 +252,7 @@ if ($result) {
 		);
 
 		// Set accountancy code for user
+		// $obj->accountancy_code is the accountancy_code of table u=user but it is defined only if a link with type 'user' exists)
 		$compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');
 
 		$tabuser[$obj->rowid] = array(
@@ -277,7 +278,7 @@ if ($result) {
 			$tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
 		}
 
-		// Load of url links to the line into llx_bank
+		// Load of url links to the line into llx_bank (so load llx_bank_url)
 		$links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
 
 		// By default
@@ -287,7 +288,7 @@ if ($result) {
 
 		// get_url may return -1 which is not traversable
 		if (is_array($links) && count($links) > 0) {
-			// Now loop on each link of record in bank.
+			// Now loop on each link of record in bank (code similar to bankentries_list.php)
 			foreach ($links as $key => $val) {
 				if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) {
 					// So we excluded 'company' and 'user' here. We want only payment lines
@@ -302,6 +303,7 @@ if ($result) {
 					}
 				}
 
+				// Special case to ask later to add more request to get information for old links without company link.
 				if ($links[$key]['type'] == 'withdraw') {
 					$tabmoreinfo[$obj->rowid]['withdraw'] = 1;
 				}
@@ -401,6 +403,44 @@ if ($result) {
 					$paymentsalstatic->label = $links[$key]['label'];
 					$tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
 					$tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
+
+					// This part of code is no more required. it is here to solve case where a link were missing (ith v14.0.0) and keep writing in accountancy complete.
+					// Note: A better way to fix this is to delete payement of salary and recreate it, or to fix the bookkeeping table manually after.
+					if (!empty($conf->global->ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USEr_ON_SALARY_BANK_PAYMENT)) {
+						$tmpsalary = new Salary($db);
+						$tmpsalary->fetch($paymentsalstatic->id);
+						$tmpsalary->fetch_user($tmpsalary->fk_user);
+
+						$userstatic->id = $tmpsalary->user->id;
+						$userstatic->name = $tmpsalary->user->name;
+						$userstatic->email = $tmpsalary->user->email;
+						$userstatic->firstname = $tmpsalary->user->firstname;
+						$userstatic->lastname = $tmpsalary->user->lastname;
+						$userstatic->statut = $tmpsalary->user->statut;
+						$userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
+
+						if ($userstatic->id > 0) {
+							$tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
+						} else {
+							$tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen
+						}
+
+						if (empty($obj->typeop_user)) {	// Add test to avoid to add amount twice if a link already exists also on user.
+							$compta_user = $userstatic->accountancy_code;
+							if ($compta_user) {
+								$tabtp[$obj->rowid][$compta_user] += $obj->amount;
+								$tabuser[$obj->rowid] = array(
+								'id' => $userstatic->id,
+								'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname),
+								'lastname' => $userstatic->lastname,
+								'firstname' => $userstatic->firstname,
+								'email' => $userstatic->email,
+								'accountancy_code' => $compta_user,
+								'status' => $userstatic->statut
+								);
+							}
+						}
+					}
 				} elseif ($links[$key]['type'] == 'payment_expensereport') {
 					$paymentexpensereportstatic->id = $links[$key]['url_id'];
 					$tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2);
@@ -468,7 +508,7 @@ if ($result) {
 			}
 		}
 
-		// If no links were found to know the amount on thirdparty, we init it to account 'NotDefined'.
+		// If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'.
 		if (empty($tabtp[$obj->rowid])) {
 			$tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
 		}
@@ -1162,9 +1202,9 @@ if (empty($action) || $action == 'view') {
 						if ($tabtype[$key] == 'unknown') {
 							// We will accept writing, but into a waiting account
 							if (empty($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) || $conf->global->ACCOUNTING_ACCOUNT_SUSPENSE == '-1') {
-								print '<span class="error">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
+								print '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
 							} else {
-								print '<span class="warning">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
+								print '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE)).'</span>'; // We will use a waiting account
 							}
 						} else {
 							// We will refuse writing
@@ -1187,7 +1227,7 @@ if (empty($action) || $action == 'view') {
 							if ($tabtype[$key] == 'member') {
 								$errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
 							}
-							print '<span class="error">'.$langs->trans($errorstring).'</span>';
+							print '<span class="error small">'.$langs->trans($errorstring).'</span>';
 						}
 					} else {
 						print $accounttoshow;
@@ -1196,7 +1236,7 @@ if (empty($action) || $action == 'view') {
 
 					// Subledger account
 					print "<td>";
-					if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) {	// Type of payment with subledger
+					if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) {	// Type of payments that uses a subledger
 						$accounttoshowsubledger = length_accounta($k);
 						if ($accounttoshow != $accounttoshowsubledger) {
 							if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') {
@@ -1205,14 +1245,14 @@ if (empty($action) || $action == 'view') {
 								var_dump($tabbq[$key]);*/
 								//print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
 								if (!empty($tabcompany[$key]['code_compta'])) {
-									if (in_array($tabtype[$key], array('payment_various'))) {
+									if (in_array($tabtype[$key], array('payment_various', 'payment_salary'))) {
 										// For such case, if subledger is not defined, we won't use subledger accounts.
-										print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>';
+										print '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>';
 									} else {
-										print '<span class="warning">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
+										print '<span class="warning small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
 									}
 								} else {
-									print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
+									print '<span class="error small">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
 								}
 							} else {
 								print $accounttoshowsubledger;
@@ -1220,10 +1260,15 @@ if (empty($action) || $action == 'view') {
 						}
 					}
 					print "</td>";
+
 					print "<td>".$reflabel."</td>";
+
 					print '<td class="center">'.$val["type_payment"]."</td>";
+
 					print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
+
 					print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
+
 					print "</tr>";
 				}
 			}

+ 4 - 0
htdocs/accountancy/tpl/export_journal.tpl.php

@@ -16,6 +16,8 @@
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
  */
 
+// $formatexportset ùust be defined
+
 // Protection to avoid direct call of template
 if (empty($conf) || !is_object($conf)) {
 	print "Error, template page can't be called as URL";
@@ -56,6 +58,8 @@ if ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$
 	$endaccountingperiod = dol_print_date(dol_get_last_day($tmparray['year'], $tmparray['mon']), 'dayxcard');
 
 	$completefilename = $siren."FEC".$endaccountingperiod.".txt";
+} elseif ($accountancyexport->getFormatCode($formatexportset) == $accountancyexport::$EXPORT_TYPE_CIEL && $type_export == "general_ledger" && !empty($conf->global->ACCOUNTING_EXPORT_XIMPORT_FORCE_FILENAME)) {
+	$completefilename = "XIMPORT.TXT";
 } else {
 	$completefilename = ($code ? $code."_" : "").($prefix ? $prefix."_" : "").$filename.($nodateexport ? "" : $date_export).".".$format;
 }

+ 0 - 2
htdocs/adherents/canvas/default/tpl/adherentcard_create.tpl.php

@@ -31,8 +31,6 @@ print load_fiche_titre($this->control->tpl['title']);
 
 dol_htmloutput_errors((is_numeric($object->error) ? '' : $object->error), $object->errors);
 
-dol_htmloutput_errors((is_numeric($GLOBALS['error']) ? '' : $GLOBALS['error']), $GLOBALS['errors']);
-
 dol_htmloutput_errors($this->control->tpl['error'], $this->control->tpl['errors']);
 
 echo $this->control->tpl['ajax_selectcountry']; ?>

+ 2 - 2
htdocs/adherents/card.php

@@ -535,7 +535,7 @@ if (empty($reshook)) {
 			$error++;
 			setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), null, 'errors');
 		}
-		if ($conf->global->ADHERENT_MAIL_REQUIRED && !isValidEMail($email)) {
+		if (!empty($conf->global->ADHERENT_MAIL_REQUIRED) && !isValidEMail($email)) {
 			$error++;
 			$langs->load("errors");
 			setEventMessages($langs->trans("ErrorBadEMail", $email), null, 'errors');
@@ -1032,7 +1032,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
 		print '</td></tr>';
 
 		// EMail
-		print '<tr><td>'.($conf->global->ADHERENT_MAIL_REQUIRED ? '<span class="fieldrequired">' : '').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED ? '</span>' : '').'</td>';
+		print '<tr><td>'.(!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? '<span class="fieldrequired">' : '').$langs->trans("EMail").(!empty($conf->global->ADHERENT_MAIL_REQUIRED) ? '</span>' : '').'</td>';
 		print '<td>'.img_picto('', 'object_email').' <input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOSTISSET('member_email') ? GETPOST('member_email', 'alpha') : $object->email).'"></td></tr>';
 
 		// Website

+ 2 - 1
htdocs/adherents/list.php

@@ -65,6 +65,7 @@ $search_filter = GETPOST("search_filter", 'alpha');
 $search_status = GETPOST("search_status", 'intcomma');
 $catid        = GETPOST("catid", 'int');
 $optioncss = GETPOST('optioncss', 'alpha');
+$socid = GETPOST('socid', 'int');
 
 $filter = GETPOST("filter", 'alpha');
 if ($filter) {
@@ -175,7 +176,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
 	$massaction = '';
 }
 
-$parameters = array('socid'=>$socid);
+$parameters = array('socid'=>isset($socid) ? $socid : null);
 $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');

+ 9 - 4
htdocs/adherents/note.php

@@ -68,16 +68,21 @@ if ($id) {
 	$caneditfieldmember = $user->rights->adherent->creer;
 }
 
+$hookmanager->initHooks(array('membernote'));
+
 // Security check
 $result = restrictedArea($user, 'adherent', $object->id, '', '', 'socid', 'rowid', 0);
 
-
 /*
  * Actions
  */
-
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
-
+$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+if (empty($reshook)) {
+	include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+}
 
 
 /*

+ 2 - 2
htdocs/adherents/subscription/list.php

@@ -115,7 +115,7 @@ if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massa
 	$massaction = '';
 }
 
-$parameters = array('socid'=>$socid);
+$parameters = array('socid'=>isset($socid) ? $socid : null);
 $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');
@@ -496,7 +496,7 @@ while ($i < min($num, $limit)) {
 	$adherent->gender = $obj->gender;
 	$adherent->morphy = $obj->morphy;
 	$adherent->email = $obj->email;
-	$adherent->typeid = $obj->type;
+	$adherent->typeid = $obj->fk_type;
 	$adherent->datefin = $db->jdate($obj->datef);
 
 	$typeid = ($obj->fk_type > 0 ? $obj->fk_type : $adherent->typeid);

+ 6 - 4
htdocs/adherents/type.php

@@ -43,6 +43,8 @@ $action = GETPOST('action', 'aZ09');
 $cancel = GETPOST('cancel', 'alpha');
 $backtopage = GETPOST('backtopage', 'alpha');
 
+$sall = GETPOST("sall", "alpha");
+$filter = GETPOST("filter", 'alpha');
 $search_lastname = GETPOST('search_lastname', 'alpha');
 $search_login = GETPOST('search_login', 'alpha');
 $search_email = GETPOST('search_email', 'alpha');
@@ -379,12 +381,12 @@ if ($action == 'create') {
 
 	print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+	$doleditor = new DolEditor('comment', $object->note, '', 200, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
 	$doleditor->Create();
 
 	print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
 	require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+	$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 250, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
 	$doleditor->Create();
 	print '</td></tr>';
 
@@ -812,12 +814,12 @@ if ($rowid > 0) {
 
 		print '<tr><td class="tdtop">'.$langs->trans("Description").'</td><td>';
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-		$doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+		$doleditor = new DolEditor('comment', $object->note, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
 		$doleditor->Create();
 		print "</td></tr>";
 
 		print '<tr><td class="tdtop">'.$langs->trans("WelcomeEMail").'</td><td>';
-		$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, $conf->fckeditor->enabled, 15, '90%');
+		$doleditor = new DolEditor('mail_valid', $object->mail_valid, '', 280, 'dolibarr_notes', '', false, true, empty($conf->fckeditor->enabled) ? false : $conf->fckeditor->enabled, 15, '90%');
 		$doleditor->Create();
 		print "</td></tr>";
 

+ 1 - 1
htdocs/adherents/type_translation.php

@@ -157,7 +157,7 @@ $form = new Form($db);
 $formadmin = new FormAdmin($db);
 
 $head = member_type_prepare_head($object);
-$titre = $langs->trans("MemberType".$object->type);
+$titre = $langs->trans("MemberType".$object->id);
 
 // Calculate $cnt_trans
 $cnt_trans = 0;

+ 1 - 0
htdocs/admin/agenda_reminder.php

@@ -226,6 +226,7 @@ if (empty($conf->cron->enabled)) {
 		// Get the max frequency of reminder
 		if ($job->id > 0) {
 			if ($job->status != $job::STATUS_ENABLED) {
+				$langs->load("cron");
 				print '<span class="opacitymedium warning">'.$langs->trans("JobXMustBeEnabled", $langs->transnoentitiesnoconv("sendEmailsReminder")).'</span>';
 			} else {
 				print '<a href="'.$_SERVER['PHP_SELF'].'?action=del_AGENDA_REMINDER_EMAIL&amp;token='.newToken().'">'.img_picto($langs->trans('Enabled'), 'switch_on').'</a>';

+ 4 - 4
htdocs/admin/clicktodial.php

@@ -101,8 +101,8 @@ print '<br>';
 print $langs->trans("ClickToDialUrlDesc").'<br>';
 print '<br>';
 print '<span class="opacitymedium">';
-print $langs->trans("Example").':<br>';
-print 'http://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
+print $langs->trans("Examples").':<br>';
+print 'https://myphoneserver/mypage?login=__LOGIN__&password=__PASS__&caller=__PHONEFROM__&called=__PHONETO__<br>';
 print 'sip:__PHONETO__@my.sip.server';
 print '</span>';
 
@@ -134,7 +134,7 @@ if (!empty($conf->global->CLICKTODIAL_URL)) {
 	print '<input type="hidden" name="token" value="'.newToken().'">';
 	print $langs->trans("LinkToTestClickToDial", $user->login).' : ';
 	print '<input class="flat" type="text" name="phonefortest" value="'.dol_escape_htmltag($phonefortest).'">';
-	print '<input type="submit" class="button" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
+	print '<input type="submit" class="button small" value="'.dol_escape_htmltag($langs->trans("RefreshPhoneLink")).'">';
 	print '</form>';
 
 	$setupcomplete = 1;
@@ -149,7 +149,7 @@ if (!empty($conf->global->CLICKTODIAL_URL)) {
 	}
 
 	if ($setupcomplete) {
-		print $langs->trans("LinkToTest", $user->login).': '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL');
+		print $langs->trans("LinkToTest", $user->login).': &nbsp; '.dol_print_phone($phonefortest, '', 0, 0, 'AC_TEL', '', 'mobile');
 	} else {
 		$langs->load("errors");
 		print '<div class="warning">'.$langs->trans("WarningClickToDialUserSetupNotComplete").'</div>';

+ 5 - 0
htdocs/admin/dav.php

@@ -45,6 +45,11 @@ $arrayofparameters = array(
 	'DAV_ALLOW_ECM_DIR'=>array('css'=>'minwidth200', 'enabled'=>$conf->ecm->enabled)
 );
 
+// To fix when dire does not exists
+dol_mkdir($conf->dav->dir_output.'/temp');
+dol_mkdir($conf->dav->dir_output.'/public');
+dol_mkdir($conf->dav->dir_output.'/private');
+
 
 /*
  * Actions

+ 26 - 11
htdocs/admin/dict.php

@@ -202,7 +202,7 @@ $tabsql[3] = "SELECT r.rowid as rowid, r.code_region as state_code, r.nom as lib
 $tabsql[4] = "SELECT c.rowid as rowid, c.code, c.label, c.active, c.favorite FROM ".MAIN_DB_PREFIX."c_country AS c";
 $tabsql[5] = "SELECT c.rowid as rowid, c.code as code, c.label, c.active FROM ".MAIN_DB_PREFIX."c_civility AS c";
 $tabsql[6] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.type, a.active, a.module, a.color, a.position FROM ".MAIN_DB_PREFIX."c_actioncomm AS a";
-$tabsql[7] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, a.deductible, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
+$tabsql[7] = "SELECT a.id    as rowid, a.code as code, a.libelle AS libelle, a.accountancy_code as accountancy_code, c.code as country_code, c.label as country, a.fk_pays as country_id, a.active FROM ".MAIN_DB_PREFIX."c_chargesociales AS a, ".MAIN_DB_PREFIX."c_country as c WHERE a.fk_pays=c.rowid and c.active=1";
 $tabsql[8] = "SELECT t.id	 as rowid, t.code as code, t.libelle, t.fk_country as country_id, c.code as country_code, c.label as country, t.position, t.active FROM ".MAIN_DB_PREFIX."c_typent as t LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON t.fk_country=c.rowid";
 $tabsql[9] = "SELECT c.code_iso as code, c.label, c.unicode, c.active FROM ".MAIN_DB_PREFIX."c_currencies AS c";
 $tabsql[10] = "SELECT t.rowid, t.code, t.taux, t.localtax1_type, t.localtax1, t.localtax2_type, t.localtax2, c.label as country, c.code as country_code, t.fk_pays as country_id, t.recuperableonly, t.note, t.active, t.accountancy_code_sell, t.accountancy_code_buy FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c WHERE t.fk_pays=c.rowid";
@@ -294,7 +294,7 @@ $tabfield[3] = "code,libelle,country_id,country";
 $tabfield[4] = "code,label";
 $tabfield[5] = "code,label";
 $tabfield[6] = "code,libelle,type,color,position";
-$tabfield[7] = "code,libelle,country,accountancy_code,deductible";
+$tabfield[7] = "code,libelle,country,accountancy_code";
 $tabfield[8] = "code,libelle,country_id,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
 $tabfield[9] = "code,label,unicode";
 $tabfield[10] = "country_id,country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
@@ -340,7 +340,7 @@ $tabfieldvalue[3] = "code,libelle,country";
 $tabfieldvalue[4] = "code,label";
 $tabfieldvalue[5] = "code,label";
 $tabfieldvalue[6] = "code,libelle,type,color,position";
-$tabfieldvalue[7] = "code,libelle,country,accountancy_code,deductible";
+$tabfieldvalue[7] = "code,libelle,country,accountancy_code";
 $tabfieldvalue[8] = "code,libelle,country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
 $tabfieldvalue[9] = "code,label,unicode";
 $tabfieldvalue[10] = "country,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
@@ -386,7 +386,7 @@ $tabfieldinsert[3] = "code_region,nom,fk_pays";
 $tabfieldinsert[4] = "code,label";
 $tabfieldinsert[5] = "code,label";
 $tabfieldinsert[6] = "code,libelle,type,color,position";
-$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code,deductible";
+$tabfieldinsert[7] = "code,libelle,fk_pays,accountancy_code";
 $tabfieldinsert[8] = "code,libelle,fk_country".(!empty($conf->global->SOCIETE_SORT_ON_TYPEENT) ? ',position' : '');
 $tabfieldinsert[9] = "code_iso,label,unicode";
 $tabfieldinsert[10] = "fk_pays,code,taux,localtax1_type,localtax1,localtax2_type,localtax2,recuperableonly,accountancy_code_sell,accountancy_code_buy,note";
@@ -695,7 +695,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify')) {
 	$listfieldmodify = explode(',', $tabfieldinsert[$id]);
 	$listfieldvalue = explode(',', $tabfieldvalue[$id]);
 
-	// Check that all fields are filled
+	// Check that all mandatory fields are filled
 	$ok = 1;
 	foreach ($listfield as $f => $value) {
 		// Discard check of mandatory fields for country for some tables
@@ -1341,6 +1341,9 @@ if ($id) {
 			if ($value == 'short_label') {
 				$valuetoshow = $langs->trans("ShortLabel");
 			}
+			if ($value == 'fk_parent') {
+				$valuetoshow = $langs->trans("ParentID"); $class = 'center';
+			}
 			if ($value == 'range_account') {
 				$valuetoshow = $langs->trans("Range");
 			}
@@ -1683,6 +1686,9 @@ if ($id) {
 			if ($value == 'short_label') {
 				$valuetoshow = $langs->trans("ShortLabel");
 			}
+			if ($value == 'fk_parent') {
+				$valuetoshow = $langs->trans("ParentID"); $cssprefix = 'center ';
+			}
 			if ($value == 'range_account') {
 				$valuetoshow = $langs->trans("Range");
 			}
@@ -1992,10 +1998,7 @@ if ($id) {
 							if (in_array($value, array('pos', 'position'))) {
 								$class .= ' right';
 							}
-							if ($value == 'localtax1_type') {
-								$class .= ' nowrap';
-							}
-							if ($value == 'localtax2_type') {
+							if (in_array($value, array('localtax1_type', 'localtax2_type'))) {
 								$class .= ' nowrap';
 							}
 							if (in_array($value, array('use_default', 'fk_parent'))) {
@@ -2265,7 +2268,13 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
 			print '<td>';
 			print $form->selectarray('source', $sourceList, (!empty($obj->{$value}) ? $obj->{$value}:''));
 			print '</td>';
+		} elseif (in_array($value, array('public', 'use_default'))) {
+			// Fields 0/1 with a combo select Yes/No
+			print '<td class="center">';
+			print $form->selectyesno($value, (!empty($obj->{$value}) ? $obj->{$value}:''), 1);
+			print '</td>';
 		} elseif ($value == 'private') {
+			// Fields 'no'/'yes' with a combo select Yes/No
 			print '<td>';
 			print $form->selectyesno("private", (!empty($obj->{$value}) ? $obj->{$value}:''));
 			print '</td>';
@@ -2361,7 +2370,7 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
 			print $form->selectExpenseRanges($obj->fk_range);
 			print '</td>';
 		} else {
-			$fieldValue = isset($obj->{$value}) ? $obj->{$value}:'';
+			$fieldValue = isset($obj->{$value}) ? $obj->{$value}: '';
 
 			if ($value == 'sortorder') {
 				$fieldlist[$field] = 'position';
@@ -2377,12 +2386,18 @@ function fieldList($fieldlist, $obj = '', $tabname = '', $context = '')
 			if (in_array($fieldlist[$field], array('dayrule', 'day', 'month', 'year', 'use_default', 'affect', 'delay', 'public', 'sortorder', 'sens', 'category_type', 'fk_parent'))) {
 				$class = 'maxwidth50 center';
 			}
-			if (in_array($fieldlist[$field], array('use_default', 'public'))) {
+			if (in_array($fieldlist[$field], array('use_default', 'public', 'fk_parent'))) {
 				$classtd = 'center';
 			}
 			if (in_array($fieldlist[$field], array('libelle', 'label', 'tracking'))) {
 				$class = 'quatrevingtpercent';
 			}
+			// Fields that must be suggested as '0' instead of ''
+			if ($fieldlist[$field] == 'fk_parent') {
+				if (empty($fieldValue)) {
+					$fieldValue = '0';
+				}
+			}
 			print '<td class="'.$classtd.'">';
 			$transfound = 0;
 			$transkey = '';

+ 16 - 8
htdocs/admin/eventorganization.php

@@ -34,13 +34,9 @@ require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
 // Translations
 $langs->loadLangs(array("admin", "eventorganization"));
 
-// Access control
-if (!$user->admin) {
-	accessforbidden();
-}
-
 // Parameters
 $action = GETPOST('action', 'aZ09');
+$cancel = GETPOST('cancel', 'aZ09');
 $backtopage = GETPOST('backtopage', 'alpha');
 
 $value = GETPOST('value', 'alpha');
@@ -70,11 +66,21 @@ $setupnotempty = 0;
 
 $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']);
 
+// Access control
+if (empty($user->admin)) {
+	accessforbidden();
+}
+
+
 
 /*
  * Actions
  */
 
+if ($cancel) {
+	$action  ='';
+}
+
 if ((float) DOL_VERSION >= 6) {
 	include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
 }
@@ -207,7 +213,7 @@ if ($action == 'edit') {
 	print '<input type="hidden" name="action" value="update">';
 
 	print '<table class="noborder centpercent">';
-	print '<tr class="liste_titre"><td class="titlefieldcreate">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+	print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
 	foreach ($arrayofparameters as $constname => $val) {
 		if ($val['enabled']==1) {
@@ -293,7 +299,9 @@ if ($action == 'edit') {
 	print '</table>';
 
 	print '<br><div class="center">';
-	print '<input class="button button-save" type="submit" value="'.$langs->trans("Save").'">';
+	print '<input class="button button-save" type="submit" name="save" value="'.$langs->trans("Save").'">';
+	print ' &nbsp; ';
+	print '<input class="button button-cancel" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
 	print '</div>';
 
 	print '</form>';
@@ -301,7 +309,7 @@ if ($action == 'edit') {
 } else {
 	if (!empty($arrayofparameters)) {
 		print '<table class="noborder centpercent">';
-		print '<tr class="liste_titre"><td class="titlefieldcreate">'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
+		print '<tr class="liste_titre"><td>'.$langs->trans("Parameter").'</td><td>'.$langs->trans("Value").'</td></tr>';
 
 		foreach ($arrayofparameters as $constname => $val) {
 			if ($val['enabled']==1) {

+ 229 - 151
htdocs/admin/holiday.php

@@ -274,147 +274,141 @@ print '</div>';
 print '<br>';
 
 
-if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
-	print dol_get_fiche_end();
-	// End of page
-	llxFooter();
-	$db->close();
-	exit;
-}
-
 /*
  *  Documents models for Holidays
  */
 
-print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', '');
-
-// Defined model definition table
-$def = array();
-$sql = "SELECT nom";
-$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
-$sql .= " WHERE type = '".$db->escape($type)."'";
-$sql .= " AND entity = ".$conf->entity;
-$resql = $db->query($sql);
-if ($resql) {
-	$i = 0;
-	$num_rows = $db->num_rows($resql);
-	while ($i < $num_rows) {
-		$array = $db->fetch_array($resql);
-		array_push($def, $array[0]);
-		$i++;
+if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+	print load_fiche_titre($langs->trans("TemplatePDFHolidays"), '', '');
+
+	// Defined model definition table
+	$def = array();
+	$sql = "SELECT nom";
+	$sql .= " FROM ".MAIN_DB_PREFIX."document_model";
+	$sql .= " WHERE type = '".$db->escape($type)."'";
+	$sql .= " AND entity = ".$conf->entity;
+	$resql = $db->query($sql);
+	if ($resql) {
+		$i = 0;
+		$num_rows = $db->num_rows($resql);
+		while ($i < $num_rows) {
+			$array = $db->fetch_array($resql);
+			array_push($def, $array[0]);
+			$i++;
+		}
+	} else {
+		dol_print_error($db);
 	}
-} else {
-	dol_print_error($db);
-}
 
 
-print '<div class="div-table-responsive-no-min">';
-print '<table class="noborder centpercent">';
-print '<tr class="liste_titre">';
-print '<td>'.$langs->trans("Name").'</td>';
-print '<td>'.$langs->trans("Description").'</td>';
-print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
-print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
-print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
-print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
-print "</tr>\n";
+	print '<div class="div-table-responsive-no-min">';
+	print '<table class="noborder centpercent">';
+	print '<tr class="liste_titre">';
+	print '<td>'.$langs->trans("Name").'</td>';
+	print '<td>'.$langs->trans("Description").'</td>';
+	print '<td align="center" width="60">'.$langs->trans("Status")."</td>\n";
+	print '<td align="center" width="60">'.$langs->trans("Default")."</td>\n";
+	print '<td align="center" width="80">'.$langs->trans("ShortInfo").'</td>';
+	print '<td align="center" width="80">'.$langs->trans("Preview").'</td>';
+	print "</tr>\n";
 
-clearstatcache();
-
-foreach ($dirmodels as $reldir) {
-	foreach (array('', '/doc') as $valdir) {
-		$realpath = $reldir."core/modules/holiday".$valdir;
-		$dir = dol_buildpath($realpath);
-
-		if (is_dir($dir)) {
-			$handle = opendir($dir);
-			if (is_resource($handle)) {
-				while (($file = readdir($handle)) !== false) {
-					$filelist[] = $file;
-				}
-				closedir($handle);
-				arsort($filelist);
+	clearstatcache();
 
-				foreach ($filelist as $file) {
-					if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
-						if (file_exists($dir.'/'.$file)) {
-							$name = substr($file, 4, dol_strlen($file) - 16);
-							$classname = substr($file, 0, dol_strlen($file) - 12);
+	foreach ($dirmodels as $reldir) {
+		foreach (array('', '/doc') as $valdir) {
+			$realpath = $reldir."core/modules/holiday".$valdir;
+			$dir = dol_buildpath($realpath);
+
+			if (is_dir($dir)) {
+				$handle = opendir($dir);
+				if (is_resource($handle)) {
+					while (($file = readdir($handle)) !== false) {
+						$filelist[] = $file;
+					}
+					closedir($handle);
+					arsort($filelist);
 
-							require_once $dir.'/'.$file;
-							$module = new $classname($db);
+					foreach ($filelist as $file) {
+						if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
+							if (file_exists($dir.'/'.$file)) {
+								$name = substr($file, 4, dol_strlen($file) - 16);
+								$classname = substr($file, 0, dol_strlen($file) - 12);
 
-							$modulequalified = 1;
-							if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
-								$modulequalified = 0;
-							}
-							if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
-								$modulequalified = 0;
-							}
+								require_once $dir.'/'.$file;
+								$module = new $classname($db);
 
-							if ($modulequalified) {
-								print '<tr class="oddeven"><td width="100">';
-								print (empty($module->name) ? $name : $module->name);
-								print "</td><td>\n";
-								if (method_exists($module, 'info')) {
-									print $module->info($langs);
-								} else {
-									print $module->description;
+								$modulequalified = 1;
+								if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) {
+									$modulequalified = 0;
 								}
-								print '</td>';
-
-								// Active
-								if (in_array($name, $def)) {
-									print '<td class="center">'."\n";
-									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
-									print img_picto($langs->trans("Enabled"), 'switch_on');
-									print '</a>';
-									print '</td>';
-								} else {
-									print '<td class="center">'."\n";
-									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-									print "</td>";
+								if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) {
+									$modulequalified = 0;
 								}
 
-								// Default
-								print '<td class="center">';
-								if ($conf->global->HOLIDAY_ADDON_PDF == $name) {
-									print img_picto($langs->trans("Default"), 'on');
-								} else {
-									print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
-								}
-								print '</td>';
+								if ($modulequalified) {
+									print '<tr class="oddeven"><td width="100">';
+									print (empty($module->name) ? $name : $module->name);
+									print "</td><td>\n";
+									if (method_exists($module, 'info')) {
+										print $module->info($langs);
+									} else {
+										print $module->description;
+									}
+									print '</td>';
 
-								// Info
-								$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
-								$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
-								if ($module->type == 'pdf') {
-									$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-								}
-								$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
-
-								$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-								$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
-								$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-								$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-								$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-								$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-								print '<td class="center">';
-								print $form->textwithpicto('', $htmltooltip, 1, 0);
-								print '</td>';
-
-								// Preview
-								print '<td class="center">';
-								if ($module->type == 'pdf') {
-									print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
-								} else {
-									print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-								}
-								print '</td>';
+									// Active
+									if (in_array($name, $def)) {
+										print '<td class="center">'."\n";
+										print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=del&value='.$name.'">';
+										print img_picto($langs->trans("Enabled"), 'switch_on');
+										print '</a>';
+										print '</td>';
+									} else {
+										print '<td class="center">'."\n";
+										print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=set&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+										print "</td>";
+									}
+
+									// Default
+									print '<td class="center">';
+									if ($conf->global->HOLIDAY_ADDON_PDF == $name) {
+										print img_picto($langs->trans("Default"), 'on');
+									} else {
+										print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;token='.newToken().'&amp;value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+									}
+									print '</td>';
+
+									// Info
+									$htmltooltip = ''.$langs->trans("Name").': '.$module->name;
+									$htmltooltip .= '<br>'.$langs->trans("Type").': '.($module->type ? $module->type : $langs->trans("Unknown"));
+									if ($module->type == 'pdf') {
+										$htmltooltip .= '<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+									}
+									$htmltooltip .= '<br>'.$langs->trans("Path").': '.preg_replace('/^\//', '', $realpath).'/'.$file;
+
+									$htmltooltip .= '<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+									$htmltooltip .= '<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
+									$htmltooltip .= '<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
+									$htmltooltip .= '<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
+									$htmltooltip .= '<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+									$htmltooltip .= '<br>'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+									print '<td class="center">';
+									print $form->textwithpicto('', $htmltooltip, 1, 0);
+									print '</td>';
 
-								print "</tr>\n";
+									// Preview
+									print '<td class="center">';
+									if ($module->type == 'pdf') {
+										print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'pdf').'</a>';
+									} else {
+										print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+									}
+									print '</td>';
+
+									print "</tr>\n";
+								}
 							}
 						}
 					}
@@ -422,11 +416,11 @@ foreach ($dirmodels as $reldir) {
 			}
 		}
 	}
-}
 
-print '</table>';
-print '</div>';
-print "<br>";
+	print '</table>';
+	print '</div>';
+	print "<br>";
+}
 
 
 /*
@@ -446,34 +440,118 @@ print '<td>'.$langs->trans("Parameter").'</td>';
 print '<td align="center" width="60">'.$langs->trans("Value").'</td>';
 print "</tr>\n";
 
-$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
-$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
-$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
-foreach ($substitutionarray as $key => $val) {
-	$htmltext .= $key.'<br>';
+/*var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY);
+*/
+if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) {
+	$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY = 1;
 }
-$htmltext .= '</i>';
-
-print '<tr class="oddeven"><td colspan="2">';
-print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
-print '<br>';
-$variablename = 'HOLIDAY_FREE_TEXT';
-if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
-	print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+if (!isset($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) {
+	$conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY = 1;
+}
+/*
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY);
+var_dump($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY);
+*/
+
+// Set working days
+print '<tr class="oddeven">';
+print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Monday"))."</td>";
+print '<td class="center">';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY', array(), null, 0);
 } else {
-	include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
-	$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
-	print $doleditor->Create();
+	if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY)) {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
+	} else {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_MONDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	}
 }
-print '</td></tr>'."\n";
+print "</td>";
+print "</tr>";
+
+// Set working days
+print '<tr class="oddeven">';
+print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Friday"))."</td>";
+print '<td class="center">';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY', array(), null, 0);
+} else {
+	if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY)) {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
+	} else {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_FRIDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	}
+}
+print "</td>";
+print "</tr>";
+
+// Set working days
+print '<tr class="oddeven">';
+print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Saturday"))."</td>";
+print '<td class="center">';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY', array(), null, 0, 0, 0, 2, 0, 1);
+} else {
+	if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY)) {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
+	} else {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_SATURDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	}
+}
+print "</td>";
+print "</tr>";
+
+// Set working days
+print '<tr class="oddeven">';
+print "<td>".$langs->trans("XIsAUsualNonWorkingDay", $langs->transnoentitiesnoconv("Sunday"))."</td>";
+print '<td class="center">';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY', array(), null, 0, 0, 0, 2, 0, 1);
+} else {
+	if (!empty($conf->global->MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY)) {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=1">'.img_picto($langs->trans("Enabled"), 'on').'</a>';
+	} else {
+		print '<a href="'.$_SERVER['PHP_SELF'].'?action=set_other&MAIN_NON_WORKING_DAYS_INCLUDE_SUNDAY=0">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	}
+}
+print "</td>";
+print "</tr>";
+
+if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
+	$substitutionarray = pdf_getSubstitutionArray($langs, array('objectamount'), null, 2);
+	$substitutionarray['__(AnyTranslationKey)__'] = $langs->trans("Translation");
+	$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
+	foreach ($substitutionarray as $key => $val) {
+		$htmltext .= $key.'<br>';
+	}
+	$htmltext .= '</i>';
+
+	print '<tr class="oddeven"><td colspan="2">';
+	print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp');
+	print '<br>';
+	$variablename = 'HOLIDAY_FREE_TEXT';
+	if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) {
+		print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+	} else {
+		include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
+		$doleditor = new DolEditor($variablename, $conf->global->$variablename, '', 80, 'dolibarr_notes');
+		print $doleditor->Create();
+	}
+	print '</td></tr>'."\n";
 
-//Use draft Watermark
+	//Use draft Watermark
 
-print '<tr class="oddeven"><td>';
-print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
-print '</td><td>';
-print '<input class="flat minwidth200" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.$conf->global->HOLIDAY_DRAFT_WATERMARK.'">';
-print '</td></tr>'."\n";
+	print '<tr class="oddeven"><td>';
+	print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
+	print '</td><td>';
+	print '<input class="flat minwidth200" type="text" name="HOLIDAY_DRAFT_WATERMARK" value="'.$conf->global->HOLIDAY_DRAFT_WATERMARK.'">';
+	print '</td></tr>'."\n";
+}
 
 print '</table>';
 print '</div>';

+ 5 - 2
htdocs/admin/index.php

@@ -51,6 +51,7 @@ if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) {
 	$conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE);
 	if (!empty($conf->global->MAIN_MOTD_SETUPPAGE)) {
 		$i = 0;
+		$reg = array();
 		while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) {
 			$tmp = explode('|', $reg[1]);
 			if (!empty($tmp[1])) {
@@ -81,7 +82,8 @@ print '<br><br>';
 if (empty($conf->global->MAIN_INFO_SOCIETE_NOM) || empty($conf->global->MAIN_INFO_SOCIETE_COUNTRY)) {
 	$setupcompanynotcomplete = 1;
 }
-print img_picto('', 'company', 'class="paddingright"').' '.$langs->trans("SetupDescription3", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
+print img_picto('', 'company', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/company.php?mainmenu=home'.(empty($setupcompanynotcomplete) ? '' : '&action=edit'), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup"));
+print '<br><br>'.$langs->trans("SetupDescription3b");
 if (!empty($setupcompanynotcomplete)) {
 	$langs->load("errors");
 	$warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"');
@@ -92,7 +94,8 @@ print '<br>';
 print '<br>';
 
 // Show info setup module
-print img_picto('', 'cog', 'class="paddingright"').' '.$langs->trans("SetupDescription4", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
+print img_picto('', 'cog', 'class="paddingright valignmiddle double"').' '.$langs->trans("SetupDescriptionLink", DOL_URL_ROOT.'/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules"));
+print '<br><br>'.$langs->trans("SetupDescription4b");
 if (count($conf->modules) <= (empty($conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING) ? 1 : $conf->global->MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING)) {	// If only minimal initial modules enabled
 	$langs->load("errors");
 	$warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"');

+ 3 - 0
htdocs/admin/mails_templates.php

@@ -230,6 +230,9 @@ if (!empty($conf->agenda->enabled)) {
 if (!empty($conf->eventorganization->enabled) && !empty($user->rights->eventorganization->read)) {
 	$elementList['eventorganization_send'] = img_picto('', 'action', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToSendEventOrganization'));
 }
+if (!empty($conf->partnership->enabled) && !empty($user->rights->partnership->read)) {
+	$elementList['partnership_send'] = img_picto('', 'partnership', 'class="paddingright"').dol_escape_htmltag($langs->trans('MailToPartnership'));
+}
 
 $parameters = array('elementList'=>$elementList);
 $reshook = $hookmanager->executeHooks('emailElementlist', $parameters); // Note that $action and $object may have been modified by some hooks

+ 42 - 16
htdocs/admin/notification.php

@@ -47,7 +47,7 @@ $error = 0;
  */
 
 // Action to update or add a constant
-if ($action == 'settemplates') {
+if ($action == 'settemplates' && $user->admin) {
 	$db->begin();
 
 	if (!$error && is_array($_POST)) {
@@ -192,7 +192,8 @@ print "</tr>\n";
 print '<tr class="oddeven"><td>';
 print $langs->trans("NotificationEMailFrom").'</td>';
 print '<td>';
-print '<input size="32" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
+print img_picto('', 'email', 'class="pictofixedwidth"');
+print '<input class="width300" type="email" name="email_from" value="'.$conf->global->NOTIFICATION_EMAIL_FROM.'">';
 if (!empty($conf->global->NOTIFICATION_EMAIL_FROM) && !isValidEmail($conf->global->NOTIFICATION_EMAIL_FROM)) {
 	print ' '.img_warning($langs->trans("ErrorBadEMail"));
 }
@@ -270,7 +271,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
 	}
 
 	$helptext = '';
-	form_constantes($constantes, 3, $helptext);
+	form_constantes($constantes, 3, $helptext, 'EmailTemplate');
+
+	print '<div class="opacitymedium">';
+	print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
+	if (!empty($conf->societe->enabled)) {
+		print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
+	}
+	print '</div>';
 
 	print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
 } else {
@@ -316,15 +324,14 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
 
 	print '</td></tr>';
 	print '</table>';
-}
-
 
-print '<div class="opacitymedium">';
-print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
-if (!empty($conf->societe->enabled)) {
-	print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
+	print '<div class="opacitymedium">';
+	print '* '.$langs->trans("GoOntoUserCardToAddMore").'<br>';
+	if (!empty($conf->societe->enabled)) {
+		print '** '.$langs->trans("GoOntoContactCardToAddMore").'<br>';
+	}
+	print '</div>';
 }
-print '</div>';
 
 print '</form>';
 
@@ -335,6 +342,7 @@ print '<br><br>';
 print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
 print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<input type="hidden" name="action" value="setfixednotif">';
+print '<input type="hidden" name="page_y" value="">';
 
 print load_fiche_titre($langs->trans("ListOfFixedNotifications"), '', '');
 
@@ -376,6 +384,12 @@ foreach ($listofnotifiedevents as $notifiedevent) {
 		$elementLabel = $langs->trans('ExpenseReport');
 	}
 
+	$labelfortrigger = 'AmountHT';
+	$codehasnotrigger = 0;
+	if (preg_match('/^HOLIDAY/', $notifiedevent['code'])) {
+		$codehasnotrigger++;
+	}
+
 	print '<tr class="oddeven">';
 	print '<td>';
 	print img_picto('', $elementPicto, 'class="pictofixedwidth"');
@@ -384,6 +398,7 @@ foreach ($listofnotifiedevents as $notifiedevent) {
 	print '<td>'.$notifiedevent['code'].'</td>';
 	print '<td><span class="opacitymedium">'.$label.'</span></td>';
 	print '<td>';
+	$inputfieldalreadyshown = 0;
 	// Notification with threshold
 	foreach ($conf->global as $key => $val) {
 		if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
@@ -407,24 +422,35 @@ foreach ($listofnotifiedevents as $notifiedevent) {
 		}
 		print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
 		print '<br>';
+
+		$inputfieldalreadyshown++;
 	}
 	// New entry input fields
-	$s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_new_key" value="">'; // Do not use type="email" here, we must be able to enter a list of email with , separator.
-	print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
+	if (empty($inputfieldalreadyshown) || !$codehasnotrigger) {
+		$s = '<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_new_key" value="">'; // Do not use type="email" here, we must be able to enter a list of email with , separator.
+		print $form->textwithpicto($s, $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients").'<br>'.$langs->trans("YouCanAlsoUseSupervisorKeyword"), 1, 'help', '', 0, 2);
+	}
 	print '</td>';
 
 	print '<td>';
 	// Notification with threshold
+	$inputfieldalreadyshown = 0;
 	foreach ($conf->global as $key => $val) {
 		if ($val == '' || !preg_match('/^NOTIFICATION_FIXEDEMAIL_'.$notifiedevent['code'].'_THRESHOLD_HIGHER_(.*)/', $key, $reg)) {
 			continue;
 		}
 
-		print $langs->trans("AmountHT").' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_amount" value="'.dol_escape_htmltag($reg[1]).'">';
-		print '<br>';
+		if (!$codehasnotrigger) {
+			print $langs->trans($labelfortrigger).' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_amount" value="'.dol_escape_htmltag($reg[1]).'">';
+			print '<br>';
+
+			$inputfieldalreadyshown++;
+		}
 	}
 	// New entry input fields
-	print $langs->trans("AmountHT").' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_new_amount" value="">';
+	if (!$codehasnotrigger) {
+		print $langs->trans($labelfortrigger).' >= <input type="text" size="4" name="NOTIF_'.$notifiedevent['code'].'_new_amount" value="">';
+	}
 	print '</td>';
 
 	print '<td>';
@@ -437,7 +463,7 @@ print '</table>';
 
 print '<br>';
 
-print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
+print '<div class="center"><input type="submit" class="button button-save reposition" value="'.$langs->trans("Save").'"></div>';
 
 print '</form>';
 

+ 13 - 11
htdocs/admin/paymentbybanktransfer.php

@@ -150,42 +150,44 @@ print '<input type="hidden" name="token" value="'.newToken().'">';
 print '<table class="noborder centpercent">';
 
 print '<tr class="liste_titre">';
-print '<td class="titlefieldcreate">'.$langs->trans("Parameter").'</td>';
+print '<td>'.$langs->trans("Parameter").'</td>';
 print '<td>'.$langs->trans("Value").'</td>';
 print "</tr>";
 
 // Bank account (from Banks module)
 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("BankToPayCreditTransfer").'</td>';
-print '<td class="left">';
-$form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1);
+print '<td>';
+print img_picto('', 'bank_account', 'class="pictofixedwidth"');
+print $form->select_comptes($conf->global->PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT, 'PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT', 0, "courant=1", 1, '', 0, 'minwidth200', 1);
 print '</td></tr>';
 
 /* Moved to bank account data
 // ICS
 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ICS").'</td>';
-print '<td class="left">';
+print '<td>';
 print '<input type="text" name="PAYMENTBYBANKTRANSFER_ICS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ICS.'" size="15" ></td>';
 print '</td></tr>';
 */
 
 //User
 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';
-print '<td class="left">';
-print $form->select_dolusers($conf->global->PAYMENTBYBANKTRANSFER_USER, 'PAYMENTBYBANKTRANSFER_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print '<td>';
+print img_picto('', 'user', 'class="pictofixedwidth"');
+print $form->select_dolusers($conf->global->PAYMENTBYBANKTRANSFER_USER, 'PAYMENTBYBANKTRANSFER_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
 print '</td>';
 print '</tr>';
 
 /*
 //EntToEnd
 print '<tr class="oddeven"><td>'.$langs->trans("END_TO_END").'</td>';
-print '<td class="left">';
-print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->PRELEVEMENT_END_TO_END.'" size="15" ></td>';
+print '<td>';
+print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->PRELEVEMENT_END_TO_END.'" class="width100"></td>';
 print '</td></tr>';
 
 //USTRD
 print '<tr class="oddeven"><td>'.$langs->trans("USTRD").'</td>';
-print '<td class="left">';
-print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->PRELEVEMENT_USTRD.'" size="15" ></td>';
+print '<td>';
+print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->PRELEVEMENT_USTRD.'" class="width100"></td>';
 print '</td></tr>';
 */
 
@@ -195,7 +197,7 @@ print '<td class="left">';
 if (!$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS) {
 	$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS = 0;
 }
-print '<input type="text" name="PAYMENTBYBANKTRANSFER_ADDDAYS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS.'" size="15" ></td>';
+print '<input type="text" name="PAYMENTBYBANKTRANSFER_ADDDAYS" value="'.$conf->global->PAYMENTBYBANKTRANSFER_ADDDAYS.'" class="width50"></td>';
 print '</td></tr>';
 print '</table>';
 print '<br>';

+ 97 - 51
htdocs/admin/pdf.php

@@ -52,22 +52,27 @@ if ($cancel) {
 }
 
 if ($action == 'update') {
-	dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_FORMAT')) dolibarr_set_const($db, "MAIN_PDF_FORMAT", GETPOST("MAIN_PDF_FORMAT"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_MARGIN_LEFT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_LEFT", GETPOST("MAIN_PDF_MARGIN_LEFT"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_MARGIN_RIGHT')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_RIGHT", GETPOST("MAIN_PDF_MARGIN_TOP"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_MARGIN_BOTTOM')) dolibarr_set_const($db, "MAIN_PDF_MARGIN_BOTTOM", GETPOST("MAIN_PDF_MARGIN_BOTTOM"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID1_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID1_IN_ADDRESS", GETPOST("MAIN_PROFID1_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID2_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID2_IN_ADDRESS", GETPOST("MAIN_PROFID2_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID3_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID3_IN_ADDRESS", GETPOST("MAIN_PROFID3_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID4_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", GETPOST("MAIN_PROFID4_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID5_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID5_IN_ADDRESS", GETPOST("MAIN_PROFID5_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PROFID6_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_PROFID6_IN_ADDRESS", GETPOST("MAIN_PROFID6_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_NO_SENDER_FRAME')) dolibarr_set_const($db, "MAIN_PDF_NO_SENDER_FRAME", GETPOST("MAIN_PDF_NO_SENDER_FRAME"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_NO_RECIPENT_FRAME')) dolibarr_set_const($db, "MAIN_PDF_NO_RECIPENT_FRAME", GETPOST("MAIN_PDF_NO_RECIPENT_FRAME"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_HIDE_SENDER_NAME')) dolibarr_set_const($db, "MAIN_PDF_HIDE_SENDER_NAME", GETPOST("MAIN_PDF_HIDE_SENDER_NAME"), 'chaine', 0, '', $conf->entity);
+
+	if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", GETPOST("MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"), 'chaine', 0, '', $conf->entity);
+
+	if (GETPOSTISSET('MAIN_TVAINTRA_NOT_IN_ADDRESS')) dolibarr_set_const($db, "MAIN_TVAINTRA_NOT_IN_ADDRESS", GETPOST("MAIN_TVAINTRA_NOT_IN_ADDRESS"), 'chaine', 0, '', $conf->entity);
 
 	if (!empty($conf->projet->enabled)) {
 		if (GETPOST('PDF_SHOW_PROJECT_REF_OR_LABEL') == 'no') {
@@ -82,20 +87,22 @@ if ($action == 'update') {
 		}
 	}
 
-	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_DESC')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_DESC"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_HIDE_REF')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", GETPOST("MAIN_GENERATE_DOCUMENTS_HIDE_REF"), 'chaine', 0, '', $conf->entity);
+
+	if (GETPOSTISSET('MAIN_DOCUMENTS_LOGO_HEIGHT')) dolibarr_set_const($db, "MAIN_DOCUMENTS_LOGO_HEIGHT", GETPOST("MAIN_DOCUMENTS_LOGO_HEIGHT", 'int'), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_INVERT_SENDER_RECIPIENT')) dolibarr_set_const($db, "MAIN_INVERT_SENDER_RECIPIENT", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_USE_ISO_LOCATION')) dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_NO_CUSTOMER_CODE')) dolibarr_set_const($db, "MAIN_PDF_NO_CUSTOMER_CODE", GETPOST("MAIN_PDF_NO_CUSTOMER_CODE"), '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", GETPOST("MAIN_INVERT_SENDER_RECIPIENT"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PDF_USE_ISO_LOCATION", GETPOST("MAIN_PDF_USE_ISO_LOCATION"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS')) dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS", GETPOST("MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_SECOND_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_SECOND_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_SECOND_TAX"), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('MAIN_PDF_MAIN_HIDE_THIRD_TAX')) dolibarr_set_const($db, "MAIN_PDF_MAIN_HIDE_THIRD_TAX", GETPOST("MAIN_PDF_MAIN_HIDE_THIRD_TAX"), 'chaine', 0, '', $conf->entity);
 
-	dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
-	dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE')) dolibarr_set_const($db, "PDF_USE_ALSO_LANGUAGE_CODE", GETPOST('PDF_USE_ALSO_LANGUAGE_CODE', 'alpha'), 'chaine', 0, '', $conf->entity);
+	if (GETPOSTISSET('SHOW_SUBPRODUCT_REF_IN_PDF')) dolibarr_set_const($db, "SHOW_SUBPRODUCT_REF_IN_PDF", GETPOST('SHOW_SUBPRODUCT_REF_IN_PDF', 'alpha'), 'chaine', 0, '', $conf->entity);
 
 	setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 
@@ -253,6 +260,55 @@ for ($i = 1; $i <= 6; $i++) {
 	}
 }
 
+// Borders on address frame
+
+print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_NO_SENDER_FRAME").'</td><td>';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_PDF_NO_SENDER_FRAME');
+} else {
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("MAIN_PDF_NO_SENDER_FRAME", $arrval, $conf->global->MAIN_PDF_NO_SENDER_FRAME);
+}
+print '</td></tr>';
+
+print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_NO_RECIPENT_FRAME").'</td><td>';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_PDF_NO_RECIPENT_FRAME');
+} else {
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("MAIN_PDF_NO_RECIPENT_FRAME", $arrval, $conf->global->MAIN_PDF_NO_RECIPENT_FRAME);
+}
+
+// Show sender name
+
+print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_HIDE_SENDER_NAME").'</td><td>';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_PDF_HIDE_SENDER_NAME');
+} else {
+	print $form->selectyesno('MAIN_PDF_HIDE_SENDER_NAME', (!empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) ? $conf->global->MAIN_PDF_HIDE_SENDER_NAME : 0, 1);
+}
+print '</td></tr>';
+
+//Invert sender and recipient
+
+print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_INVERT_SENDER_RECIPIENT');
+} else {
+	print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1);
+}
+print '</td></tr>';
+
+// Place customer adress to the ISO location
+
+print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
+if ($conf->use_javascript_ajax) {
+	print ajax_constantonoff('MAIN_PDF_USE_ISO_LOCATION');
+} else {
+	print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1);
+}
+print '</td></tr>';
+
 print '</table>';
 print '</div>';
 
@@ -323,14 +379,24 @@ 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
+// Use 2 languages into PDF
 
+print '<tr class="oddeven"><td>'.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").'</td><td>';
+//if (! empty($conf->global->MAIN_MULTILANGS))
+	//{
+$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0);
+print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1);
+//} else {
+//	print '<span class="opacitymedium">'.$langs->trans("MultiLangNotEnabled").'</span>';
+//}
+print '</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>';
 
 // Show project
-
 if (!empty($conf->projet->enabled)) {
 	print '<tr class="oddeven"><td>'.$langs->trans("PDF_SHOW_PROJECT").'</td><td>';
 	$tmparray = array('no' => 'No', 'showprojectref' => 'RefProject', 'showprojectlabel' => 'ShowProjectLabel');
@@ -339,38 +405,18 @@ if (!empty($conf->projet->enabled)) {
 	print '</td></tr>';
 }
 
-//Invert sender and recipient
-
-print '<tr class="oddeven"><td>'.$langs->trans("SwapSenderAndRecipientOnPDF").'</td><td>';
-if ($conf->use_javascript_ajax) {
-	print ajax_constantonoff('MAIN_INVERT_SENDER_RECIPIENT');
-} else {
-	print $form->selectyesno('MAIN_INVERT_SENDER_RECIPIENT', (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) ? $conf->global->MAIN_INVERT_SENDER_RECIPIENT : 0, 1);
-}
-print '</td></tr>';
-
-// Place customer adress to the ISO location
+//
 
-print '<tr class="oddeven"><td>'.$langs->trans("PlaceCustomerAddressToIsoLocation").'</td><td>';
+print '<tr class="oddeven"><td>'.$langs->trans("MAIN_PDF_HIDE_CUSTOMER_CODE");
+print '</td><td>';
 if ($conf->use_javascript_ajax) {
-	print ajax_constantonoff('MAIN_PDF_USE_ISO_LOCATION');
+	print ajax_constantonoff('MAIN_PDF_HIDE_CUSTOMER_CODE');
 } else {
-	print $form->selectyesno('MAIN_PDF_USE_ISO_LOCATION', (!empty($conf->global->MAIN_PDF_USE_ISO_LOCATION)) ? $conf->global->MAIN_PDF_USE_ISO_LOCATION : 0, 1);
+	$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
+	print $form->selectarray("MAIN_PDF_HIDE_CUSTOMER_CODE", $arrval, $conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE);
 }
 print '</td></tr>';
 
-// Use 2 languages into PDF
-
-print '<tr class="oddeven"><td>'.$langs->trans("PDF_USE_ALSO_LANGUAGE_CODE").'</td><td>';
-//if (! empty($conf->global->MAIN_MULTILANGS))
-//{
-$selected = GETPOSTISSET('PDF_USE_ALSO_LANGUAGE_CODE') ? GETPOST('PDF_USE_ALSO_LANGUAGE_CODE') : (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) ? $conf->global->PDF_USE_ALSO_LANGUAGE_CODE : 0);
-print $formadmin->select_language($selected, 'PDF_USE_ALSO_LANGUAGE_CODE', 0, null, 1);
-//} else {
-//	print '<span class="opacitymedium">'.$langs->trans("MultiLangNotEnabled").'</span>';
-//}
-print '</td></tr>';
-
 // Ref
 
 print '<tr class="oddeven"><td>'.$langs->trans("HideRefOnPDF").'</td><td>';

+ 10 - 0
htdocs/admin/pdf_other.php

@@ -53,6 +53,16 @@ if ($cancel) {
 }
 
 if ($action == 'update') {
+	if (GETPOSTISSET('PROPOSAL_PDF_HIDE_PAYMENTTERM')) {
+		dolibarr_set_const($db, "PROPOSAL_PDF_HIDE_PAYMENTTERM", GETPOST("PROPOSAL_PDF_HIDE_PAYMENTTERM"), 'chaine', 0, '', $conf->entity);
+	}
+	if (GETPOSTISSET('PROPOSAL_PDF_HIDE_PAYMENTMODE')) {
+		dolibarr_set_const($db, "PROPOSAL_PDF_HIDE_PAYMENTMODE", GETPOST("PROPOSAL_PDF_HIDE_PAYMENTMODE"), 'chaine', 0, '', $conf->entity);
+	}
+	if (GETPOSTISSET('MAIN_GENERATE_PROPOSALS_WITH_PICTURE')) {
+		dolibarr_set_const($db, "MAIN_GENERATE_PROPOSALS_WITH_PICTURE", GETPOST("MAIN_GENERATE_PROPOSALS_WITH_PICTURE"), 'chaine', 0, '', $conf->entity);
+	}
+
 	setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
 
 	header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup");

+ 11 - 9
htdocs/admin/prelevement.php

@@ -160,8 +160,9 @@ print "</tr>";
 
 // Bank account (from Banks module)
 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("BankToReceiveWithdraw").'</td>';
-print '<td class="left">';
-$form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1);
+print '<td>';
+print img_picto('', 'bank_account', 'class="pictofixedwidth"');
+print $form->select_comptes($conf->global->PRELEVEMENT_ID_BANKACCOUNT, 'PRELEVEMENT_ID_BANKACCOUNT', 0, "courant=1", 1, '', 0, 'minwidth200', 1);
 print '</td></tr>';
 
 /* Moved to bank account data
@@ -179,8 +180,9 @@ print '</td></tr>';
 
 //User
 print '<tr class="oddeven"><td class="fieldrequired">'.$langs->trans("ResponsibleUser").'</td>';
-print '<td class="left">';
-print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
+print '<td>';
+print img_picto('', 'user', 'class="pictofixedwidth"');
+print $form->select_dolusers($conf->global->PRELEVEMENT_USER, 'PRELEVEMENT_USER', 1, '', 0, '', '', 0, 0, 0, '', 0, '', 'minwidth200 maxwidth500');
 print '</td>';
 print '</tr>';
 
@@ -189,8 +191,8 @@ print '<tr class="oddeven"><td>';
 $htmltext = $langs->trans("KeepThisEmptyInMostCases");
 print $form->textwithpicto($langs->trans("END_TO_END"), $htmltext);
 print '</td>';
-print '<td class="left">';
-print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->PRELEVEMENT_END_TO_END.'" size="15" ></td>';
+print '<td>';
+print '<input type="text" name="PRELEVEMENT_END_TO_END" value="'.$conf->global->PRELEVEMENT_END_TO_END.'" class="width100"></td>';
 print '</td></tr>';
 
 //USTRD
@@ -199,16 +201,16 @@ $htmltext = $langs->trans("KeepThisEmptyInMostCases");
 print $form->textwithpicto($langs->trans("USTRD"), $htmltext);
 print '</td>';
 print '<td class="left">';
-print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->PRELEVEMENT_USTRD.'" size="15" ></td>';
+print '<input type="text" name="PRELEVEMENT_USTRD" value="'.$conf->global->PRELEVEMENT_USTRD.'" class="width100"></td>';
 print '</td></tr>';
 
 //ADDDAYS
 print '<tr class="oddeven"><td>'.$langs->trans("ADDDAYS").'</td>';
-print '<td class="left">';
+print '<td>';
 if (empty($conf->global->PRELEVEMENT_ADDDAYS)) {
 	$conf->global->PRELEVEMENT_ADDDAYS = 0;
 }
-print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'" size="5" ></td>';
+print '<input type="text" name="PRELEVEMENT_ADDDAYS" value="'.$conf->global->PRELEVEMENT_ADDDAYS.'"  class="width50"></td>';
 print '</td></tr>';
 
 print '</table>';

+ 5 - 0
htdocs/admin/supplier_invoice.php

@@ -59,8 +59,10 @@ $specimenthirdparty->initAsSpecimen();
 if ($action == 'updateMask') {
 	$maskconstinvoice = GETPOST('maskconstinvoice', 'alpha');
 	$maskconstcredit = GETPOST('maskconstcredit', 'alpha');
+	$maskconstdeposit = GETPOST('maskconstdeposit', 'alpha');
 	$maskinvoice = GETPOST('maskinvoice', 'alpha');
 	$maskcredit = GETPOST('maskcredit', 'alpha');
+	$maskdeposit = GETPOST('maskdeposit', 'alpha');
 
 	if ($maskconstinvoice) {
 		$res = dolibarr_set_const($db, $maskconstinvoice, $maskinvoice, 'chaine', 0, '', $conf->entity);
@@ -68,6 +70,9 @@ if ($action == 'updateMask') {
 	if ($maskconstcredit) {
 		$res = dolibarr_set_const($db, $maskconstcredit, $maskcredit, 'chaine', 0, '', $conf->entity);
 	}
+	if ($maskconstdeposit) {
+		$res = dolibarr_set_const($db, $maskconstdeposit, $maskdeposit, 'chaine', 0, '', $conf->entity);
+	}
 
 	if (!($res > 0)) {
 		$error++;

+ 9 - 5
htdocs/admin/system/database-tables.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2003		Rodolphe Quiedeville	<rodolphe@quiedeville.org>
- * Copyright (C) 2004-2005	Laurent Destailleur		<eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2021	Laurent Destailleur		<eldy@users.sourceforge.net>
  * Copyright (C) 2004		Sebastien Di Cintio		<sdicintio@ressource-toi.org>
  * Copyright (C) 2004		Benoit Mortier			<benoit.mortier@opensides.be>
  * Copyright (C) 2005-2012	Regis Houssin			<regis.houssin@inodbox.com>
@@ -21,9 +21,13 @@
 
 /**
  *	\file       htdocs/admin/system/database-tables.php
- *	\brief      Page with information on database tables
+ *	\brief      Page with information on database tables. Add also some maintenance action to convert tables.
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -126,14 +130,14 @@ if (!$base) {
 				print '</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>';
+					print '<td><a class="reposition" href="database-tables.php?action=convert&table='.urlencode($obj->Name).'&token='.newToken().'">'.$langs->trans("Convert").' InnoDb</a></td>';
 				} else {
 					print '<td>&nbsp;</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 '<br><a class="reposition" href="database-tables.php?action=convertdynamic&table='.urlencode($obj->Name).'&token='.newToken().'">'.$langs->trans("Convert").' Dynamic</a>';
 				}
 				print '</td>';
 				print '<td align="right">'.$obj->Rows.'</td>';
@@ -145,7 +149,7 @@ if (!$base) {
 				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>';
+					print '<br><a class="reposition" href="database-tables.php?action=convertutf8&table='.urlencode($obj->Name).'&token='.newtoken().'">'.$langs->trans("Convert").' UTF8</a>';
 				}
 				print '</td>';
 				print '</tr>';

+ 8 - 0
htdocs/admin/system/dolibarr.php

@@ -327,6 +327,7 @@ $configfileparameters = array(
 	'dolibarr_main_db_character_set' => $langs->trans("DBStoringCharset"),
 	'dolibarr_main_db_collation' => $langs->trans("DBSortingCollation"),
 	'?dolibarr_main_db_prefix' => $langs->trans("DatabasePrefix"),
+	'dolibarr_main_db_readonly' => $langs->trans("ReadOnlyMode"),
 	'separator2' => '',
 	'dolibarr_main_authentication' => $langs->trans("AuthenticationMode"),
 	'?multicompany_transverse_mode'=>  $langs->trans("MultiCompanyMode"),
@@ -449,6 +450,13 @@ foreach ($configfileparameters as $key => $value) {
 				if (!empty($valuetoshow)) {
 					print img_warning($langs->trans('SwitchThisForABetterSecurity', 0));
 				}
+			} elseif ($newkey == 'dolibarr_main_db_readonly') {
+				print ${$newkey};
+
+				$valuetoshow = ${$newkey};
+				if (!empty($valuetoshow)) {
+					print img_warning($langs->trans('ReadOnlyMode', 1));
+				}
 			} else {
 				print (empty(${$newkey}) ? '' : ${$newkey});
 			}

+ 32 - 10
htdocs/admin/system/security.php

@@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/class/events.class.php';
 
 // Load translation files required by the page
-$langs->loadLangs(array("install", "other", "admin"));
+$langs->loadLangs(array("install", "other", "admin", "errors"));
 
 if (!$user->admin) {
 	accessforbidden();
@@ -88,10 +88,14 @@ if (function_exists('exec')) {
 }
 print '<br>';
 
-print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' &nbsp; <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
+print "<strong>PHP session.use_strict_mode</strong> = ".(ini_get('session.use_strict_mode') ? ini_get('session.use_strict_mode') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
+print "<strong>PHP session.use_only_cookies</strong> = ".(ini_get('session.use_only_cookies') ? ini_get('session.use_only_cookies') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
+print "<strong>PHP session.cookie_httponly</strong> = ".(ini_get('session.cookie_httponly') ? ini_get('session.cookie_httponly') : '').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", '1').")</span><br>\n";
+print "<strong>PHP session.cookie_samesite</strong> = ".(ini_get('session.cookie_samesite') ? ini_get('session.cookie_samesite') : 'None').' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", 'Strict').")</span><br>\n";
 print "<strong>PHP open_basedir</strong> = ".(ini_get('open_basedir') ? ini_get('open_basedir') : yn(0).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("ARestrictedPath").', '.$langs->transnoentitiesnoconv("Example").' '.$_SERVER["DOCUMENT_ROOT"]).')</span>')."<br>\n";
 print "<strong>PHP allow_url_fopen</strong> = ".(ini_get('allow_url_fopen') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_fopen') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
 print "<strong>PHP allow_url_include</strong> = ".(ini_get('allow_url_include') ? img_picto($langs->trans("YouShouldSetThisToOff"), 'warning').' '.ini_get('allow_url_include') : yn(0)).' &nbsp; <span class="opacitymedium">('.$langs->trans("RecommendedValueIs", $langs->transnoentitiesnoconv("No")).")</span><br>\n";
+//print "<strong>PHP safe_mode</strong> = ".(ini_get('safe_mode') ? ini_get('safe_mode') : yn(0)).' &nbsp; <span class="opacitymedium">'.$langs->trans("Deprecated")." (removed in PHP 5.4)</span><br>\n";
 print "<strong>PHP disable_functions</strong> = ";
 $arrayoffunctionsdisabled = explode(',', ini_get('disable_functions'));
 $arrayoffunctionstodisable = explode(',', 'pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals');
@@ -198,6 +202,7 @@ if (empty($fileswithwritepermission)) {
 	}
 }
 print '<br>';
+print '<br>';
 
 print '<strong>'.$langs->trans("PermissionsOnFile", $conffile).'</strong>: ';		// $conffile is defined into filefunc.inc.php
 $perms = fileperms($dolibarr_main_document_root.'/'.$conffile);
@@ -219,6 +224,16 @@ if ($perms) {
 	print img_warning().' '.$langs->trans("FailedToReadFile", $conffile);
 }
 print '<br>';
+print '<br>';
+
+$installlock = DOL_DATA_ROOT.'/install.lock';
+print '<strong>'.$langs->trans("DolibarrSetup").'</strong>: ';
+if (file_exists($installlock)) {
+	print img_picto('', 'tick').' '.$langs->trans("InstallAndUpgradeLockedBy", $installlock);
+} else {
+	print img_warning().' '.$langs->trans("WarningLockFileDoesNotExists", DOL_DATA_ROOT);
+}
+print '<br>';
 
 
 // File conf.php
@@ -234,7 +249,7 @@ if (empty($dolibarr_main_prod)) {
 }
 print '<br>';
 
-print '<strong>$dolibarr_nocsrfcheck</strong>: '.$dolibarr_nocsrfcheck;
+print '<strong>$dolibarr_nocsrfcheck</strong>: '.(empty($dolibarr_nocsrfcheck) ? '0' : $dolibarr_nocsrfcheck);
 if (!empty($dolibarr_nocsrfcheck)) {
 	print ' &nbsp; '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 0);
 }
@@ -335,7 +350,7 @@ if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) {
 if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
 	print '<br><strong>MAIN_SECURITY_SALT</strong> = '.(empty($conf->global->MAIN_SECURITY_SALT) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>' : $conf->global->MAIN_SECURITY_SALT).'<br>';
 } else {
-	print '<span class="opacitymedium">('.$langs->trans("Recommanded").': password_hash)</span>';
+	print '<span class="opacitymedium">('.$langs->trans("Recommended").': password_hash)</span>';
 	print '<br>';
 }
 if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
@@ -348,16 +363,19 @@ if ($conf->global->MAIN_SECURITY_HASH_ALGO != 'password_hash') {
 }
 print '<br>';
 
-print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> &nbsp; <span class="opacitymedium">('.$langs->trans("Example").': static-ips-of-server - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."<br>";
+print '<strong>MAIN_SECURITY_ANTI_SSRF_SERVER_IP</strong> = '.(empty($conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span> &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': List of static IPs of server separated with coma - '.$langs->trans("Note").': common loopback ip like 127.*.*.*, [::1] are already added)</span>' : $conf->global->MAIN_SECURITY_ANTI_SSRF_SERVER_IP)."<br>";
+print '<br>';
+
+print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES).' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 0)</span><br>';
 print '<br>';
 
-print '<strong>MAIN_ALLOW_SVG_FILES_AS_IMAGES</strong> = '.(empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES) ? '0 &nbsp; <span class="opacitymedium">('.$langs->trans("Recommanded").': 0)</span>' : $conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)."<br>";
+print '<strong>MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE</strong> = '.(empty($conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE) ? '<span class="opacitymedium">'.$langs->trans("Undefined").'</span>' : $conf->global->MAIN_ALWAYS_CREATE_LOCK_AFTER_LAST_UPGRADE).' &nbsp; <span class="opacitymedium">('.$langs->trans("Recommended").': 1)</span><br>';
 print '<br>';
 
-print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommanded").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."<br>";
+print '<strong>MAIN_RESTRICTHTML_ONLY_VALID_HTML</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_ONLY_VALID_HTML)."<br>";
 print '<br>';
 
-print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommanded").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."<br>";
+print '<strong>MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES</strong> = '.(empty($conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES) ? '<span class="opacitymedium">'.$langs->trans("Undefined").' &nbsp; ('.$langs->trans("Recommended").': 1)</span>' : $conf->global->MAIN_RESTRICTHTML_REMOVE_ALSO_BAD_ATTRIBUTES)."<br>";
 print '<br>';
 
 print '<strong>MAIN_EXEC_USE_POPEN</strong> = ';
@@ -367,10 +385,14 @@ if (empty($conf->global->MAIN_EXEC_USE_POPEN)) {
 	print $conf->global->MAIN_EXEC_USE_POPEN;
 }
 if ($execmethod == 1) {
-	print ' &nbsp; <span class="opacitymedium">("exec" PHP method will be used for shell commands)</span>';
+	print '<span class="opacitymedium">, "exec" PHP method will be used for shell commands';
+	print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
+	print '</span>';
 }
 if ($execmethod == 2) {
-	print ' &nbsp; <span class="opacitymedium">("popen" PHP method will be used for shell commands)</span>';
+	print '<span class="opacitymedium">, "popen" PHP method will be used for shell commands';
+	print ' &nbsp; ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 1)';
+	print '</span>';
 }
 print "<br>";
 print '<br>';

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

@@ -136,7 +136,7 @@ $title = $langs->trans("Backup");
 print load_fiche_titre($title, '', 'title_setup');
 //print_barre_liste($langs->trans("Backup"), '', '', '', '', '', $langs->trans("BackupDesc",DOL_DATA_ROOT), 0, 0, 'title_setup');
 
-print '<div class="center opacitymedium">';
+print '<div class="center">';
 print $langs->trans("BackupDesc", DOL_DATA_ROOT);
 print '</div>';
 print '<br>';
@@ -147,8 +147,11 @@ print '<input type="hidden" name="token" value="'.newToken().'" />';
 print '<input type="hidden" name="export_type" value="server" />';
 print '<fieldset id="fieldsetexport"><legend class="legendforfieldsetstep" style="font-size: 3em">1</legend>';
 
+print '<span class="opacitymedium">';
 print $langs->trans("BackupDesc3", $dolibarr_main_db_name).'<br>';
 //print $langs->trans("BackupDescY").'<br>';
+print '</span>';
+
 print '<br>';
 
 print '<div id="backupdatabaseleft" class="fichehalfleft" >';
@@ -157,7 +160,7 @@ $title = $langs->trans("BackupDumpWizard");
 
 print load_fiche_titre($title);
 
-print '<table width="100%" class="'.(!empty($useinecm) ? 'nobordernopadding' : 'liste').' nohover">';
+print '<table class="'.(!empty($useinecm) ? 'nobordernopadding' : 'liste noborderbottom').' nohover centpercent">';
 print '<tr class="liste_titre">';
 print '<td class="liste_titre">';
 print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b><br>';
@@ -554,8 +557,10 @@ print '<input type="hidden" name="page_y" value="" />';
 
 print '<fieldset><legend class="legendforfieldsetstep" style="font-size: 3em">2</legend>';
 
+print '<span class="opacitymedium">';
 print $langs->trans("BackupDesc2", DOL_DATA_ROOT).'<br>';
 print $langs->trans("BackupDescX").'<br><br>';
+print '</span>';
 
 print '<div id="backupfilesleft" class="fichehalfleft">';
 

+ 10 - 2
htdocs/admin/tools/dolibarr_import.php

@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2006-2012	Laurent Destailleur	<eldy@users.sourceforge.net>
+/* Copyright (C) 2006-2021	Laurent Destailleur	<eldy@users.sourceforge.net>
  * Copyright (C) 2006-2012	Regis Houssin		<regis.houssin@inodbox.com>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -22,6 +22,10 @@
  * 		\brief      Page to import database
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 
 // Load translation files required by the page
@@ -72,7 +76,7 @@ jQuery(document).ready(function() {
 
 print load_fiche_titre($langs->trans("Restore"), '', 'title_setup');
 
-print '<div class="center opacitymedium">';
+print '<div class="center">';
 print $langs->trans("RestoreDesc", DOL_DATA_ROOT);
 print '</div>';
 print '<br>';
@@ -81,7 +85,9 @@ print '<br>';
 <fieldset>
 <legend style="font-size: 3em">1</legend>
 <?php
+print '<span class="opacitymedium">';
 print $langs->trans("RestoreDesc2", DOL_DATA_ROOT).'<br><br>';
+print '</span>';
 ?>
 </fieldset>
 
@@ -90,7 +96,9 @@ print $langs->trans("RestoreDesc2", DOL_DATA_ROOT).'<br><br>';
 <fieldset>
 <legend style="font-size: 3em">2</legend>
 <?php
+print '<span class="opacitymedium">';
 print $langs->trans("RestoreDesc3", $dolibarr_main_db_name).'<br><br>';
+print '</span>';
 ?>
 
 <?php print $langs->trans("DatabaseName").' : <b>'.$dolibarr_main_db_name.'</b>'; ?><br><br>

+ 4 - 0
htdocs/admin/tools/export_files.php

@@ -22,6 +22,10 @@
  *		\brief      Page to export documents into a compressed file
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';

+ 8 - 3
htdocs/admin/tools/listsessions.php

@@ -22,9 +22,14 @@
  *      \brief      List of PHP sessions
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 
+
 // Load translation files required by the page
 $langs->loadLangs(array("companies", "install", "users", "other"));
 
@@ -185,14 +190,14 @@ print '<div class="tabsAction">';
 
 
 if (empty($conf->global->MAIN_ONLY_LOGIN_ALLOWED)) {
-	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=lock">'.$langs->trans("LockNewSessions").'</a>';
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=lock&token='.newToken().'">'.$langs->trans("LockNewSessions").'</a>';
 } else {
-	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=confirm_unlock">'.$langs->trans("UnlockNewSessions").'</a>';
+	print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?action=confirm_unlock&token='.newToken().'">'.$langs->trans("UnlockNewSessions").'</a>';
 }
 
 if ($savehandler == 'files') {
 	if (count($listofsessions)) {
-		print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=purge">'.$langs->trans("PurgeSessions").'</a>';
+		print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?action=purge&token='.newToken().'">'.$langs->trans("PurgeSessions").'</a>';
 	}
 }
 

+ 9 - 4
htdocs/admin/tools/purge.php

@@ -21,15 +21,15 @@
  *		\brief      Page to purge files (temporary or not)
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 $langs->load("admin");
 
-if (!$user->admin) {
-	accessforbidden();
-}
-
 $action = GETPOST('action', 'aZ09');
 $confirm = GETPOST('confirm', 'alpha');
 $choice = GETPOST('choice', 'aZ09');
@@ -42,10 +42,15 @@ if (!empty($conf->syslog->enabled)) {
 	$filelog = preg_replace('/DOL_DATA_ROOT/i', DOL_DATA_ROOT, $filelog);
 }
 
+if (!$user->admin) {
+	accessforbidden();
+}
+
 
 /*
  *	Actions
  */
+
 if ($action == 'purge' && !preg_match('/^confirm/i', $choice) && ($choice != 'allfiles' || $confirm == 'yes')) {
 	// Increase limit of time. Works only if we are not in safe mode
 	$ExecTimeLimit = 600;

+ 11 - 6
htdocs/admin/tools/update.php

@@ -22,6 +22,10 @@
  *		\brief      Page to make a Dolibarr online upgrade
  */
 
+if (! defined('CSRFCHECK_WITH_TOKEN')) {
+	define('CSRFCHECK_WITH_TOKEN', '1');		// Force use of CSRF protection with tokens even for GET
+}
+
 require '../../main.inc.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
@@ -100,7 +104,7 @@ if (function_exists('curl_init')) {
 			print $langs->trans("LastStableVersion").' : <b>'.$langs->trans("UpdateServerOffline").'</b><br>';
 		}
 	} else {
-		print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion" class="button">'.$langs->trans("Check").'</a><br>';
+		print $langs->trans("LastStableVersion").' : <a href="'.$_SERVER["PHP_SELF"].'?action=getlastversion&token='.newToken().'" class="button smallpaddingimp">'.$langs->trans("Check").'</a><br>';
 	}
 }
 
@@ -113,14 +117,14 @@ print '<hr>';
 print $langs->trans("ThisIsProcessToFollow").'<br>';
 print '<b>'.$langs->trans("StepNb", 1).'</b>: ';
 $fullurl = '<a href="'.$urldolibarr.'" target="_blank">'.$urldolibarr.'</a>';
-print $langs->trans("DownloadPackageFromWebSite", $fullurl).'<br>';
+print str_replace('{s}', $fullurl, $langs->trans("DownloadPackageFromWebSite", '{s}')).'<br>';
 print '<b>'.$langs->trans("StepNb", 2).'</b>: ';
-print $langs->trans("UnpackPackageInDolibarrRoot", $dolibarrroot).'<br>';
+print str_replace('{s}', $dolibarrroot, $langs->trans("UnpackPackageInDolibarrRoot", '{s}')).'<br>';
 print '<b>'.$langs->trans("StepNb", 3).'</b>: ';
 print $langs->trans("RemoveLock", $dolibarrdataroot.'/install.lock').'<br>';
 print '<b>'.$langs->trans("StepNb", 4).'</b>: ';
 $fullurl = '<a href="'.DOL_URL_ROOT.'/install/" target="_blank">'.DOL_URL_ROOT.'/install/</a>';
-print $langs->trans("CallUpdatePage", $fullurl).'<br>';
+print str_replace('{s}', $fullurl, $langs->trans("CallUpdatePage", '{s}')).'<br>';
 print '<b>'.$langs->trans("StepNb", 5).'</b>: ';
 print $langs->trans("RestoreLock", $dolibarrdataroot.'/install.lock').'<br>';
 
@@ -133,8 +137,9 @@ print '<br>';
 
 print $langs->trans("AddExtensionThemeModuleOrOther").'<br>';
 print '<hr>';
-
-print $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', $langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"));
+$texttoshow = $langs->trans("GoModuleSetupArea", DOL_URL_ROOT.'/admin/modules.php?mode=deploy', '{s2}');
+$texttoshow = str_replace('{s2}', img_picto('', 'tools', 'class="pictofixedwidth"').$langs->transnoentities("Home").' - '.$langs->transnoentities("Setup").' - '.$langs->transnoentities("Modules"), $texttoshow);
+print $texttoshow;
 
 // End of page
 llxFooter();

+ 8 - 2
htdocs/admin/workflow.php

@@ -91,15 +91,21 @@ $workflowcodes = array(
 	),
 
 	// Automatic classification of order
-	'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array(
+	'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING'=>array(  // when shipping validated
 		'family'=>'classify_order',
 		'position'=>40,
 		'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)),
 		'picto'=>'order'
 	),
-	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array(
+	'WORKFLOW_ORDER_CLASSIFY_SHIPPED_SHIPPING_CLOSED'=>array( // when shipping closed
 		'family'=>'classify_order',
 		'position'=>41,
+		'enabled'=>(!empty($conf->expedition->enabled) && !empty($conf->commande->enabled)),
+		'picto'=>'order'
+	),
+	'WORKFLOW_INVOICE_AMOUNT_CLASSIFY_BILLED_ORDER'=>array(
+		'family'=>'classify_order',
+		'position'=>42,
 		'enabled'=>(!empty($conf->facture->enabled) && !empty($conf->commande->enabled)),
 		'picto'=>'order',
 		'warning'=>''

+ 7 - 2
htdocs/asset/note.php

@@ -70,8 +70,13 @@ $permissionnote = 1;
  * Actions
  */
 
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
-
+$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+if (empty($reshook)) {
+	include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+}
 
 /*
  * View

+ 4 - 1
htdocs/blockedlog/admin/blockedlog.php

@@ -79,7 +79,10 @@ $form = new Form($db);
 $block_static = new BlockedLog($db);
 $block_static->loadTrackedEvents();
 
-llxHeader('', $langs->trans("BlockedLogSetup"));
+$title = $langs->trans("BlockedLogSetup");
+$help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
+
+llxHeader('', $title, $help_url);
 
 $linkback = '';
 if ($withtab) {

+ 2 - 1
htdocs/blockedlog/admin/blockedlog_list.php

@@ -275,8 +275,9 @@ if (GETPOST('withtab', 'alpha')) {
 } else {
 	$title = $langs->trans("BrowseBlockedLog");
 }
+$help_url="EN:Module_Unalterable_Archives_-_Logs|FR:Module_Archives_-_Logs_Inaltérable";
 
-llxHeader('', $langs->trans("BrowseBlockedLog"));
+llxHeader('', $title, $help_url);
 
 $MAXLINES = 10000;
 

+ 2 - 2
htdocs/bom/bom_list.php

@@ -297,7 +297,7 @@ $sql .= $object->getFieldList('t');
 // Add fields from extrafields
 if (!empty($extrafields->attributes[$object->table_element]['label'])) {
 	foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) {
-		$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : '');
+		$sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.' ' : '');
 	}
 }
 // Add fields from hooks
@@ -325,7 +325,7 @@ foreach ($search as $key => $val) {
 		}
 		$mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0);
 		if ((strpos($object->fields[$key]['type'], 'integer:') === 0) || (strpos($object->fields[$key]['type'], 'sellist:') === 0) || !empty($object->fields[$key]['arrayofkeyval'])) {
-			if ($search[$key] == '-1' || $search[$key] === '0') {
+			if ($search[$key] == '-1' || ($search[$key] === '0' && (empty($object->fields[$key]['arrayofkeyval']) || !array_key_exists('0', $object->fields[$key]['arrayofkeyval'])))) {
 				$search[$key] = '';
 			}
 			$mode_search = 2;

+ 7 - 1
htdocs/bom/bom_note.php

@@ -70,7 +70,13 @@ restrictedArea($user, 'bom', $object->id, 'bom_bom', '', '', 'rowid', $isdraft);
  * Actions
  */
 
-include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+$reshook = $hookmanager->executeHooks('doActions', array(), $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) {
+	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
+}
+if (empty($reshook)) {
+	include DOL_DOCUMENT_ROOT.'/core/actions_setnotes.inc.php'; // Must be include, not include_once
+}
 
 
 /*

+ 11 - 7
htdocs/bookmarks/bookmarks.lib.php

@@ -72,10 +72,12 @@ function printDropdownBookmarksList()
 	// Url to go on create new bookmark page
 	$newbtn = '';
 	if (!empty($user->rights->bookmark->creer)) {
-		//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url);
-		$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
-		$newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >';
-		$newbtn .= img_picto('', 'add', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
+		if (!preg_match('/bookmarks\/card.php/', $_SERVER['PHP_SELF'])) {
+			//$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;urlsource='.urlencode($url).'&amp;url='.urlencode($url);
+			$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
+			$newbtn .= '<a class="top-menu-dropdown-link" title="'.$langs->trans('AddThisPageToBookmarks').'" href="'.dol_escape_htmltag($urltoadd).'" >';
+			$newbtn .= img_picto('', 'add', '', false, 0, 0, '', 'paddingright').dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
+		}
 	}
 
 	// Menu with list of bookmarks
@@ -105,9 +107,11 @@ function printDropdownBookmarksList()
 			$searchForm .= dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...</option>';
 			// Url to go on create new bookmark page
 			if (!empty($user->rights->bookmark->creer)) {
-				$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
-				$searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
-				$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
+				if (!preg_match('/bookmarks\/card.php/', $_SERVER['PHP_SELF'])) {
+					$urltoadd = DOL_URL_ROOT.'/bookmarks/card.php?action=create&amp;url='.urlencode($url);
+					$searchForm .= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
+					$searchForm .= ' data-html="'.dol_escape_htmltag(img_picto('', 'bookmark').' '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
+				}
 			}
 			$i = 0;
 			while ((empty($conf->global->BOOKMARKS_SHOW_IN_MENU) || $i < $conf->global->BOOKMARKS_SHOW_IN_MENU) && $obj = $db->fetch_object($resql)) {

+ 2 - 2
htdocs/bookmarks/card.php

@@ -40,7 +40,7 @@ $action = GETPOST("action", "alpha");
 $title = (string) GETPOST("title", "alpha");
 $url = (string) GETPOST("url", "alpha");
 $urlsource = GETPOST("urlsource", "alpha");
-$target = GETPOST("target", "alpha");
+$target = GETPOST("target", "int");
 $userid = GETPOST("userid", "int");
 $position = GETPOST("position", "int");
 $backtopage = GETPOST('backtopage', 'alpha');
@@ -169,7 +169,7 @@ if ($action == 'create') {
 	// Target
 	print '<tr><td>'.$langs->trans("BehaviourOnClick").'</td><td>';
 	$liste = array(0=>$langs->trans("ReplaceWindow"), 1=>$langs->trans("OpenANewWindow"));
-	print $form->selectarray('target', $liste, 1);
+	print $form->selectarray('target', $liste, GETPOSTISSET('target') ? GETPOST('target', 'int') : 1);
 	print '</td><td class="hideonsmartphone"><span class="opacitymedium">'.$langs->trans("ChooseIfANewWindowMustBeOpenedOnClickOnBookmark").'</span></td></tr>';
 
 	// Owner

+ 0 - 191
htdocs/cashdesk/admin/cashdesk.php

@@ -1,191 +0,0 @@
-<?php
-/* Copyright (C) 2008-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2011-2017 Juanjo Menent		<jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/admin/cashdesk.php
- *	\ingroup    cashdesk
- *	\brief      Setup page for cashdesk module
- */
-
-require '../../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
-require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-
-// If socid provided by ajax company selector
-if (!empty($_REQUEST['CASHDESK_ID_THIRDPARTY_id'])) {
-	$_GET['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
-	$_POST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
-	$_REQUEST['CASHDESK_ID_THIRDPARTY'] = GETPOST('CASHDESK_ID_THIRDPARTY_id', 'alpha');
-}
-
-// Security check
-if (!$user->admin) {
-	accessforbidden();
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("admin", "cashdesk"));
-
-
-/*
- * Actions
- */
-
-if (GETPOST('action', 'alpha') == 'set') {
-	$db->begin();
-
-	if (GETPOST('socid', 'int') < 0) {
-		$_POST["socid"] = '';
-	}
-
-	$res = dolibarr_set_const($db, "CASHDESK_ID_THIRDPARTY", (GETPOST('socid', 'int') > 0 ? GETPOST('socid', 'int') : ''), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CASH", (GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CASH', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CHEQUE", (GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CHEQUE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_ID_BANKACCOUNT_CB", (GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') > 0 ? GETPOST('CASHDESK_ID_BANKACCOUNT_CB', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_ID_WAREHOUSE", (GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') > 0 ? GETPOST('CASHDESK_ID_WAREHOUSE', 'alpha') : ''), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", GETPOST('CASHDESK_NO_DECREASE_STOCK', 'alpha'), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_SERVICES", GETPOST('CASHDESK_SERVICES', 'alpha'), 'chaine', 0, '', $conf->entity);
-	$res = dolibarr_set_const($db, "CASHDESK_DOLIBAR_RECEIPT_PRINTER", GETPOST('CASHDESK_DOLIBAR_RECEIPT_PRINTER', 'alpha'), 'chaine', 0, '', $conf->entity);
-
-	dol_syslog("admin/cashdesk: level ".GETPOST('level', 'alpha'));
-
-	if (!($res > 0)) {
-		$error++;
-	}
-
-	if (!$error) {
-		$db->commit();
-		setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-	} else {
-		$db->rollback();
-		setEventMessages($langs->trans("Error"), null, 'errors');
-	}
-}
-
-/*
- * View
- */
-
-$form = new Form($db);
-$formproduct = new FormProduct($db);
-
-llxHeader('', $langs->trans("CashDeskSetup"));
-
-$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
-print load_fiche_titre($langs->trans("CashDeskSetup").' (SimplePOS)', $linkback, 'title_setup');
-print '<br>';
-
-
-// Mode
-print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
-print '<input type="hidden" name="token" value="'.newToken().'">';
-print '<input type="hidden" name="action" value="set">';
-
-if (!empty($conf->service->enabled)) {
-	print '<table class="noborder centpercent">';
-	print '<tr class="liste_titre">';
-	print '<td>'.$langs->trans("Parameters").'</td><td>'.$langs->trans("Value").'</td>';
-	print "</tr>\n";
-
-	print '<tr class="oddeven"><td>';
-	print $langs->trans("CashdeskShowServices");
-	print '<td colspan="2">';
-	print $form->selectyesno("CASHDESK_SERVICES", $conf->global->CASHDESK_SERVICES, 1);
-	print "</td></tr>\n";
-
-	print '</table>';
-
-	print '<br>';
-}
-
-
-print '<table class="noborder centpercent">';
-print '<tr class="liste_titre">';
-print '<td>'.$langs->trans("Terminal").' 0</td><td>'.$langs->trans("Value").'</td>';
-print "</tr>\n";
-
-print '<tr class="oddeven"><td width=\"50%\">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
-print '<td colspan="2">';
-print $form->select_company($conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client in (1,3) AND s.status = 1)', 1, 0, 0, array(), 0);
-print '</td></tr>';
-if (!empty($conf->banque->enabled)) {
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForSell").'</td>';
-	print '<td colspan="2">';
-	$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CASH, 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", 1);
-	print '</td></tr>';
-
-
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
-	print '<td colspan="2">';
-	$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE, 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", 1);
-	print '</td></tr>';
-
-
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskBankAccountForCB").'</td>';
-	print '<td colspan="2">';
-	$form->select_comptes($conf->global->CASHDESK_ID_BANKACCOUNT_CB, 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", 1);
-	print '</td></tr>';
-}
-
-if (!empty($conf->stock->enabled)) {
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskDoNotDecreaseStock").'</td>'; // Force warehouse (this is not a default value)
-	print '<td colspan="2">';
-	if (empty($conf->productbatch->enabled)) {
-		print $form->selectyesno('CASHDESK_NO_DECREASE_STOCK', $conf->global->CASHDESK_NO_DECREASE_STOCK, 1);
-	} else {
-		if (!$conf->global->CASHDESK_NO_DECREASE_STOCK) {
-			$res = dolibarr_set_const($db, "CASHDESK_NO_DECREASE_STOCK", 1, 'chaine', 0, '', $conf->entity);
-		}
-		print $langs->trans("Yes").'<br>';
-		print '<span class="opacitymedium">'.$langs->trans('StockDecreaseForPointOfSaleDisabledbyBatch').'</span>';
-	}
-	print '</td></tr>';
-
-	$disabled = $conf->global->CASHDESK_NO_DECREASE_STOCK;
-
-
-	print '<tr class="oddeven"><td>'.$langs->trans("CashDeskIdWareHouse").'</td>'; // Force warehouse (this is not a default value)
-	print '<td colspan="2">';
-	if (!$disabled) {
-		print $formproduct->selectWarehouses($conf->global->CASHDESK_ID_WAREHOUSE, 'CASHDESK_ID_WAREHOUSE', '', 1, $disabled);
-		print ' <a href="'.DOL_URL_ROOT.'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER["PHP_SELF"]).'">('.$langs->trans("Create").')</a>';
-	} else {
-		print '<span class="opacitymedium">'.$langs->trans("StockDecreaseForPointOfSaleDisabled").'</span>';
-	}
-	print '</td></tr>';
-}
-
-// Use Dolibarr Receipt Printer
-if (!empty($conf->receiptprinter->enabled)) {
-	print '<tr class="oddeven"><td>';
-	print $langs->trans("DolibarrReceiptPrinter").' ('.$langs->trans("FeatureNotYetAvailable").')';
-	print '<td colspan="2">';
-	print $form->selectyesno("CASHDESK_DOLIBAR_RECEIPT_PRINTER", $conf->global->CASHDESK_DOLIBAR_RECEIPT_PRINTER, 1);
-	print "</td></tr>\n";
-}
-
-print '</table>';
-print '<br>';
-
-print '<div class="center"><input type="submit" class="button button-save" value="'.$langs->trans("Save").'"></div>';
-
-print "</form>\n";
-
-// End of page
-llxFooter();
-$db->close();

+ 0 - 100
htdocs/cashdesk/affContenu.php

@@ -1,100 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier      <jeremie.o@laposte.net>
- * Copyright (C) 2008-2009 Laurent Destailleur   <eldy@uers.sourceforge.net>
- * Copyright (C) 2009      Regis Houssin         <regis.houssin@inodbox.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/affContenu.php
- *	\ingroup    cashdesk
- *	\brief      Include to show main page for cashdesk module
- */
-
-require_once 'class/Facturation.class.php';
-
-// Si nouvelle vente, reinitialisation des donnees (destruction de l'objet et vidage de la table contenant la liste des articles)
-if (GETPOST('id', 'int') == 'NOUV') {
-	unset($_SESSION['serObjFacturation']);
-	unset($_SESSION['poscart']);
-}
-
-// Recuperation, s'il existe, de l'objet contenant les infos de la vente en cours ...
-if (isset($_SESSION['serObjFacturation'])) {
-	$obj_facturation = unserialize($_SESSION['serObjFacturation']);
-	unset($_SESSION['serObjFacturation']);
-} else {
-	// ... sinon, c'est une nouvelle vente
-	$obj_facturation = new Facturation();
-}
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-// $obj_facturation contains data for all invoice total + selection of current product
-
-$obj_facturation->calculTotaux(); // Redefine prix_total_ttc, prix_total_ht et montant_tva from $_SESSION['poscart']
-
-$total_ttc = $obj_facturation->amountWithTax();
-
-/*var_dump($obj_facturation);
-var_dump($_SESSION['poscart']);
-var_dump($total_ttc);
-exit;*/
-
-
-// Left area with selected articles (area for article, amount and payments)
-print '<div class="inline-block" style="vertical-align: top">';
-print '<div class="principal">';
-
-$page = GETPOST('menutpl', 'alpha');
-if (empty($page)) {
-	$page = 'facturation';
-}
-
-if (in_array(
-	$page,
-	array(
-			'deconnexion',
-			'index', 'index_verif', 'facturation', 'facturation_verif', 'facturation_dhtml',
-			'validation', 'validation_ok', 'validation_ticket', 'validation_verif',
-		)
-)) {
-	include $page.'.php';
-} else {
-	dol_print_error('', 'menu param '.$page.' is not inside allowed list');
-}
-
-print '</div>';
-print '</div>';
-
-
-
-// Right area with selected articles (shopping cart)
-print '<div class="inline-block" style="vertical-align: top">';
-print '<div class="liste_articles">';
-
-require 'tpl/liste_articles.tpl.php';
-
-print '</div>';
-print '</div>';
-
-$_SESSION['serObjFacturation'] = serialize($obj_facturation);

+ 0 - 78
htdocs/cashdesk/affIndex.php

@@ -1,78 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier      <jeremie.o@laposte.net>
- * Copyright (C) 2008-2010 Laurent Destailleur   <eldy@uers.sourceforge.net>
- * Copyright (C) 2009      Regis Houssin         <regis.houssin@inodbox.com>
- * Copyright (C) 2011      Juanjo Menent         <jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/affIndex.php
- *	\ingroup    cashdesk
- *	\brief      First page of point of sale module
- */
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/keypad.php';
-
-$error = GETPOST('error');
-
-// Test if already logged
-if ($_SESSION['uid'] <= 0) {
-	header('Location: index.php');
-	exit;
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("companies", "compta", "cashdesk"));
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-$arrayofjs = array();
-$arrayofcss = array('/cashdesk/css/style.css');
-
-top_htmlhead($head, $langs->trans("CashDesk"), 0, 0, $arrayofjs, $arrayofcss);
-
-print '<body>'."\n";
-
-if (!empty($error)) {
-	dol_htmloutput_events();
-}
-
-print '<div class="conteneur">'."\n";
-print '<div class="conteneur_img_gauche">'."\n";
-print '<div class="conteneur_img_droite">'."\n";
-
-print '<div class="menu_principal">'."\n";
-include_once 'tpl/menu.tpl.php';
-print '</div>'."\n";
-
-print '<div class="contenu">'."\n";
-include_once 'affContenu.php';
-print '</div>'."\n";
-
-include_once 'affPied.php';
-
-print '</div></div></div>'."\n";
-print '</body></html>'."\n";

+ 0 - 52
htdocs/cashdesk/affPied.php

@@ -1,52 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/affPied.php
- *	\ingroup    cashdesk
- *	\brief      Bottom of main page of point of sale module
- */
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-?>
-<!-- affPied.php -->
-<div class="pied">
-<?php
-
-// Wrapper to show tooltips
-if (!empty($conf->use_javascript_ajax) && empty($conf->dol_no_mouse_hover)) {
-	print "\n<!-- JS CODE TO ENABLE Tooltips on all object with class classfortooltip -->\n";
-	print '<script type="text/javascript">
-    	jQuery(document).ready(function () {
-			jQuery(".classfortooltip").tooltip({
-				show: { collision: "flipfit", effect:\'toggle\', delay:50 },
-				hide: { effect:\'toggle\', delay: 50 },
-				tooltipClass: "mytooltip",
-				content: function () {
-					return $(this).prop(\'title\');		/* To force to get title as is */
-				}
-			});
-		});
-	</script>' . "\n";
-}
-
-printCommonFooter('private');
-?>
-</div>

+ 0 - 144
htdocs/cashdesk/class/Auth.class.php

@@ -1,144 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier      <jeremie.o@laposte.net>
- * Copyright (C) 2008-2011 Laurent Destailleur   <eldy@uers.sourceforge.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-
-/**
- * Class ot manage authentication for pos module (cashdesk)
- */
-class Auth
-{
-	protected $db;
-
-	private $login;
-	private $passwd;
-
-	private $reponse;
-
-	public $sqlQuery;
-
-	/**
-	 * Enter description here ...
-	 *
-	 * @param	DoliDB	$db			Database handler
-	 * @return	void
-	 */
-	public function __construct($db)
-	{
-		$this->db = $db;
-		$this->reponse(null);
-	}
-
-	/**
-	 * Enter description here ...
-	 *
-	 * @param 	string	$aLogin		Login
-	 * @return	void
-	 */
-	public function login($aLogin)
-	{
-		$this->login = $aLogin;
-	}
-
-	/**
-	 * Enter description here ...
-	 *
-	 * @param 	string	$aPasswd	Password
-	 * @return	void
-	 */
-	public function passwd($aPasswd)
-	{
-		$this->passwd = $aPasswd;
-	}
-
-	/**
-	 * Enter description here ...
-	 *
-	 * @param 	string 	$aReponse	Response
-	 * @return	void
-	 */
-	public function reponse($aReponse)
-	{
-		$this->reponse = $aReponse;
-	}
-
-	/**
-	 * Validate login/pass
-	 *
-	 * @param	string	$aLogin		Login
-	 * @param	string	$aPasswd	Password
-	 * @return	int					0 or 1
-	 */
-	public function verif($aLogin, $aPasswd)
-	{
-		global $conf, $langs;
-		global $dolibarr_main_authentication, $dolibarr_auto_user;
-
-		$ret = -1;
-
-		$login = '';
-
-		$test = true;
-
-		// Authentication mode
-		if (empty($dolibarr_main_authentication)) {
-			$dolibarr_main_authentication = 'http,dolibarr';
-		}
-		// Authentication mode: forceuser
-		if ($dolibarr_main_authentication == 'forceuser' && empty($dolibarr_auto_user)) {
-			$dolibarr_auto_user = 'auto';
-		}
-		// Set authmode
-		$authmode = explode(',', $dolibarr_main_authentication);
-
-		// No authentication mode
-		if (!count($authmode)) {
-			$langs->load('main');
-			dol_print_error('', $langs->trans("ErrorConfigParameterNotDefined", 'dolibarr_main_authentication'));
-			exit;
-		}
-
-		$usertotest = $aLogin;
-		$passwordtotest = $aPasswd;
-		$entitytotest = $conf->entity;
-
-		// Validation tests user / password
-		// If ok, the variable will be initialized login
-		// If error, we will put error message in session under the name dol_loginmesg
-		$goontestloop = false;
-		if (isset($_SERVER["REMOTE_USER"]) && in_array('http', $authmode)) {
-			$goontestloop = true;
-		}
-		if (isset($aLogin) || GETPOST('openid_mode', 'alpha', 1)) {
-			$goontestloop = true;
-		}
-
-		if ($test && $goontestloop) {
-			include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php';
-			$login = checkLoginPassEntity($usertotest, $passwordtotest, $entitytotest, $authmode);
-			if ($login) {
-				$this->login($aLogin);
-				$this->passwd($aPasswd);
-				$ret = 0;
-			} else {
-				$ret = -1;
-			}
-		}
-
-		return $ret;
-	}
-}

+ 0 - 558
htdocs/cashdesk/class/Facturation.class.php

@@ -1,558 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- * Copyright (C) 2008-2010 Laurent Destailleur   <eldy@uers.sourceforge.net>
- * Copyright (C) 2010      Juanjo Menent    <jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
-
-
-/**
- * Class to manage invoices for pos module (cashdesk)
- */
-class Facturation
-{
-	/**
-	 * Attributs "volatiles" : reinitialises apres chaque traitement d'un article
-	 * <p>Attributs "volatiles" : reinitialises apres chaque traitement d'un article</p>
-	 * int $id			=> 'rowid' du produit dans llx_product
-	 * string $ref		=> 'ref' du produit dans llx_product
-	 * int $qte			=> Quantite pour le produit en cours de traitement
-	 * int $stock		=> Stock theorique pour le produit en cours de traitement
-	 * int $remise_percent	=> Remise en pourcent sur le produit en cours
-	 * int $montant_remise	=> Remise en pourcent sur le produit en cours
-	 * int $prix		=> Prix HT du produit en cours
-	 * int $tva			=> 'rowid' du taux de tva dans llx_c_tva
-	 */
-
-	/**
-	 * @var int ID
-	 */
-	public $id;
-
-	protected $ref;
-	protected $qte;
-	protected $stock;
-	protected $remise_percent;
-	protected $montant_remise;
-	protected $prix;
-	protected $tva;
-
-	/**
-	 * Attributs persistants : utilises pour toute la duree de la vente (jusqu'a validation ou annulation)
-	 * string $num_facture	=> Numero de la facture (de la forme FAYYMM-XXXX)
-	 * string $mode_reglement	=> Mode de reglement (ESP, CB ou CHQ)
-	 * int $montant_encaisse	=> Montant encaisse en cas de reglement en especes
-	 * int $montant_rendu	=> Monnaie rendue en cas de reglement en especes
-	 * int $paiement_le		=> Date de paiement en cas de paiement differe
-	 *
-	 * int $prix_total_ht	=> Prix total hors taxes
-	 * int $montant_tva		=> Montant total de la TVA, tous taux confondus
-	 * int $prix_total_ttc	=> Prix total TTC
-	 */
-	protected $num_facture;
-	protected $mode_reglement;
-	protected $montant_encaisse;
-	protected $montant_rendu;
-	protected $paiement_le;
-
-	protected $prix_total_ht;
-	protected $montant_tva;
-	protected $prix_total_ttc;
-
-
-	/**
-	 *	Constructor
-	 */
-	public function __construct()
-	{
-		$this->raz();
-		$this->razPers();
-	}
-
-
-	// Data processing methods
-
-
-	/**
-	 *  Add a product into cart
-	 *
-	 *  @return	void
-	 */
-	public function ajoutArticle()
-	{
-		global $conf, $db, $mysoc;
-
-		$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-
-		$societe = new Societe($db);
-		$societe->fetch($thirdpartyid);
-
-		$product = new Product($db);
-		$product->fetch($this->id);
-
-
-		$vatrowid = $this->tva();
-
-		$tmp = getTaxesFromId($vatrowid);
-		$txtva = $tmp['rate'].(empty($tmp['code']) ? '' : ' ('.$tmp['code'].')');
-		$vat_npr = $tmp['npr'];
-
-		$localtaxarray = getLocalTaxesFromRate($vatrowid, 0, $societe, $mysoc, 1);
-
-		// Clean vat code
-		$reg = array();
-		$vat_src_code = '';
-		if (preg_match('/\((.*)\)/', $txtva, $reg)) {
-			$vat_src_code = $reg[1];
-			$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
-		}
-
-		// Define part of HT, VAT, TTC
-		$resultarray = calcul_price_total($this->qte, $this->prix(), $this->remisePercent(), $txtva, -1, -1, 0, 'HT', $vat_npr, $product->type, $mysoc, $localtaxarray);
-
-		// Calculation of total HT without discount
-		$total_ht = $resultarray[0];
-		$total_vat = $resultarray[1];
-		$total_ttc = $resultarray[2];
-		$total_localtax1 = $resultarray[9];
-		$total_localtax2 = $resultarray[10];
-
-		// Calculation of the discount amount
-		if ($this->remisePercent()) {
-			$remise_percent = $this->remisePercent();
-		} else {
-			$remise_percent = 0;
-		}
-		$montant_remise_ht = ($resultarray[6] - $resultarray[0]);
-		$this->amountDiscount($montant_remise_ht);
-
-		$newcartarray = $_SESSION['poscart'];
-
-		$i = 0;
-		if (!is_null($newcartarray) && !empty($newcartarray)) {
-			$i = count($newcartarray);
-		}
-
-		$newcartarray[$i]['id'] = $i;
-		$newcartarray[$i]['ref'] = $product->ref;
-		$newcartarray[$i]['label'] = $product->label;
-		$newcartarray[$i]['price'] = $product->price;
-		$newcartarray[$i]['price_ttc'] = $product->price_ttc;
-
-		if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
-			if (isset($product->multiprices[$societe->price_level])) {
-				$newcartarray[$i]['price'] = $product->multiprices[$societe->price_level];
-				$newcartarray[$i]['price_ttc'] = $product->multiprices_ttc[$societe->price_level];
-			}
-		}
-
-		$newcartarray[$i]['fk_article'] = $this->id;
-		$newcartarray[$i]['qte'] = $this->qte();
-		$newcartarray[$i]['fk_tva'] = $this->tva(); // Vat rowid
-		$newcartarray[$i]['remise_percent'] = $remise_percent;
-		$newcartarray[$i]['remise'] = price2num($montant_remise_ht);
-		$newcartarray[$i]['total_ht'] = price2num($total_ht, 'MT');
-		$newcartarray[$i]['total_ttc'] = price2num($total_ttc, 'MT');
-		$newcartarray[$i]['total_vat'] = price2num($total_vat, 'MT');
-		$newcartarray[$i]['total_localtax1'] = price2num($total_localtax1, 'MT');
-		$newcartarray[$i]['total_localtax2'] = price2num($total_localtax2, 'MT');
-		$_SESSION['poscart'] = $newcartarray;
-
-		$this->raz();
-	}
-
-	/**
-	 *  Remove a product from panel
-	 *
-	 *  @param  int		$aArticle	Id of line into cart to remove
-	 *  @return	void
-	 */
-	public function supprArticle($aArticle)
-	{
-		$poscart = $_SESSION['poscart'];
-
-		$j = 0;
-		$newposcart = array();
-		foreach ($poscart as $key => $val) {
-			if ($poscart[$key]['id'] != $aArticle) {
-				$newposcart[$j] = $poscart[$key];
-				$newposcart[$j]['id'] = $j;
-				$j++;
-			}
-		}
-		unset($poscart);
-		//var_dump($poscart);exit;
-		$_SESSION['poscart'] = $newposcart;
-	}
-
-	/**
-	 * Calculation of total HT, total TTC and VAT amounts
-	 *
-	 * @return	int		Total
-	 */
-	public function calculTotaux()
-	{
-		global $db;
-
-		$total_ht = 0;
-		$total_ttc = 0;
-		$total_vat = 0;
-		$total_localtax1 = 0;
-		$total_localtax2 = 0;
-
-		$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array());
-
-		$tab_size = count($tab);
-		for ($i = 0; $i < $tab_size; $i++) {
-			// Total HT
-			$remise = $tab[$i]['remise'];
-			$total_ht += ($tab[$i]['total_ht']);
-			$total_vat += ($tab[$i]['total_vat']);
-			$total_ttc += ($tab[$i]['total_ttc']);
-			$total_localtax1 += ($tab[$i]['total_localtax1']);
-			$total_localtax2 += ($tab[$i]['total_localtax2']);
-		}
-
-		$this->prix_total_ttc = $total_ttc;
-		$this->prix_total_ht = $total_ht;
-		$this->prix_total_vat = $total_vat;
-		$this->prix_total_localtax1 = $total_localtax1;
-		$this->prix_total_localtax2 = $total_localtax2;
-
-		$this->montant_tva = $total_ttc - $total_ht;
-		//print 'total: '.$this->prix_total_ttc; exit;
-	}
-
-	/**
-	 * Reset attributes
-	 *
-	 * @return	void
-	 */
-	public function raz()
-	{
-		$this->id('RESET');
-		$this->ref('RESET');
-		$this->qte('RESET');
-		$this->stock('RESET');
-		$this->remisePercent('RESET');
-		$this->amountDiscount('RESET');
-		$this->prix('RESET');
-		$this->tva('RESET');
-	}
-
-	/**
-	 * Resetting persistent attributes
-	 *
-	 *  @return	void
-	 */
-	private function razPers()
-	{
-		$this->numInvoice('RESET');
-		$this->getSetPaymentMode('RESET');
-		$this->amountCollected('RESET');
-		$this->amountReturned('RESET');
-		$this->paiementLe('RESET');
-
-		$this->amountWithoutTax('RESET');
-		$this->amountVat('RESET');
-		$this->amountWithTax('RESET');
-	}
-
-
-	// Methods for modifying protected attributes
-
-	/**
-	 * Getter for id
-	 *
-	 * @param	int		$aId	Id
-	 * @return  int             Id
-	 */
-	public function id($aId = null)
-	{
-
-		if (!$aId) {
-			return $this->id;
-		} elseif ($aId == 'RESET') {
-			$this->id = null;
-		} else {
-			$this->id = $aId;
-		}
-	}
-
-	/**
-	 * Getter for ref
-	 *
-	 * @param	string	$aRef	Ref
-	 * @return	string			Ref
-	 */
-	public function ref($aRef = null)
-	{
-
-		if (is_null($aRef)) {
-			return $this->ref;
-		} elseif ($aRef == 'RESET') {
-			$this->ref = null;
-		} else {
-			$this->ref = $aRef;
-		}
-	}
-
-	/**
-	 * Getter for qte
-	 *
-	 * @param	int		$aQte		Qty
-	 * @return	int					Qty
-	 */
-	public function qte($aQte = null)
-	{
-		if (is_null($aQte)) {
-			return $this->qte;
-		} elseif ($aQte == 'RESET') {
-			$this->qte = null;
-		} else {
-			$this->qte = $aQte;
-		}
-	}
-
-	/**
-	 * Getter for stock
-	 *
-	 * @param   string	$aStock		Stock
-	 * @return	string				Stock
-	 */
-	public function stock($aStock = null)
-	{
-
-		if (is_null($aStock)) {
-			return $this->stock;
-		} elseif ($aStock == 'RESET') {
-			$this->stock = null;
-		} else {
-			$this->stock = $aStock;
-		}
-	}
-
-	/**
-	 * Getter for remise_percent
-	 *
-	 * @param	string	$aRemisePercent		Discount
-	 * @return	string						Discount
-	 */
-	public function remisePercent($aRemisePercent = null)
-	{
-
-		if (is_null($aRemisePercent)) {
-			return $this->remise_percent;
-		} elseif ($aRemisePercent == 'RESET') {
-			$this->remise_percent = null;
-		} else {
-			$this->remise_percent = $aRemisePercent;
-		}
-	}
-
-	/**
-	 * Getter for montant_remise
-	 *
-	 * @param	int		$aMontantRemise		Amount
-	 * @return	string						Amount
-	 */
-	public function amountDiscount($aMontantRemise = null)
-	{
-
-		if (is_null($aMontantRemise)) {
-			return $this->montant_remise;
-		} elseif ($aMontantRemise == 'RESET') {
-			$this->montant_remise = null;
-		} else {
-			$this->montant_remise = $aMontantRemise;
-		}
-	}
-
-	/**
-	 * Getter for prix
-	 *
-	 * @param	int		$aPrix		Price
-	 * @return	string				Stock
-	 */
-	public function prix($aPrix = null)
-	{
-
-		if (is_null($aPrix)) {
-			return $this->prix;
-		} elseif ($aPrix == 'RESET') {
-			$this->prix = null;
-		} else {
-			$this->prix = $aPrix;
-		}
-	}
-
-	/**
-	 * Getter for tva
-	 *
-	 * @param	int		$aTva		Vat
-	 * @return	int					Vat
-	 */
-	public function tva($aTva = null)
-	{
-		if (is_null($aTva)) {
-			return $this->tva;
-		} elseif ($aTva == 'RESET') {
-			$this->tva = null;
-		} else {
-			$this->tva = $aTva;
-		}
-	}
-
-	/**
-	 * Get num invoice
-	 *
-	 * @param string	$aNumFacture		Invoice ref
-	 * @return	string						Invoice ref
-	 */
-	public function numInvoice($aNumFacture = null)
-	{
-		if (is_null($aNumFacture)) {
-			return $this->num_facture;
-		} elseif ($aNumFacture == 'RESET') {
-			$this->num_facture = null;
-		} else {
-			$this->num_facture = $aNumFacture;
-		}
-	}
-
-	/**
-	 * Get payment mode
-	 *
-	 * @param	int		$aModeReglement		Payment mode
-	 * @return	int							Payment mode
-	 */
-	public function getSetPaymentMode($aModeReglement = null)
-	{
-
-		if (is_null($aModeReglement)) {
-			return $this->mode_reglement;
-		} elseif ($aModeReglement == 'RESET') {
-			$this->mode_reglement = null;
-		} else {
-			$this->mode_reglement = $aModeReglement;
-		}
-	}
-
-	/**
-	 * Get amount
-	 *
-	 * @param	int		$aMontantEncaisse		Amount
-	 * @return	int								Amount
-	 */
-	public function amountCollected($aMontantEncaisse = null)
-	{
-
-		if (is_null($aMontantEncaisse)) {
-			return $this->montant_encaisse;
-		} elseif ($aMontantEncaisse == 'RESET') {
-			$this->montant_encaisse = null;
-		} else {
-			$this->montant_encaisse = $aMontantEncaisse;
-		}
-	}
-
-	/**
-	 * Get amount
-	 *
-	 * @param	int			$aMontantRendu		Amount
-	 * @return	int								Amount
-	 */
-	public function amountReturned($aMontantRendu = null)
-	{
-
-		if (is_null($aMontantRendu)) {
-			return $this->montant_rendu;
-		} elseif ($aMontantRendu == 'RESET') {
-			$this->montant_rendu = null;
-		} else {
-			$this->montant_rendu = $aMontantRendu;
-		}
-	}
-
-	/**
-	 * Get payment date
-	 *
-	 * @param	integer		$aPaiementLe		Date
-	 * @return	integer							Date
-	 */
-	public function paiementLe($aPaiementLe = null)
-	{
-		if (is_null($aPaiementLe)) {
-			return $this->paiement_le;
-		} elseif ($aPaiementLe == 'RESET') {
-			$this->paiement_le = null;
-		} else {
-			$this->paiement_le = $aPaiementLe;
-		}
-	}
-
-	/**
-	 * Get total HT
-	 *
-	 * @param	int		$aTotalHt		Total amount
-	 * @return	int						Total amount
-	 */
-	public function amountWithoutTax($aTotalHt = null)
-	{
-		if (is_null($aTotalHt)) {
-			return $this->prix_total_ht;
-		} elseif ($aTotalHt == 'RESET') {
-			$this->prix_total_ht = null;
-		} else {
-			$this->prix_total_ht = $aTotalHt;
-		}
-	}
-
-	/**
-	 * Get amount vat
-	 *
-	 * @param	int		$aMontantTva	Amount vat
-	 * @return	int						Amount vat
-	 */
-	public function amountVat($aMontantTva = null)
-	{
-		if (is_null($aMontantTva)) {
-			return $this->montant_tva;
-		} elseif ($aMontantTva == 'RESET') {
-			$this->montant_tva = null;
-		} else {
-			$this->montant_tva = $aMontantTva;
-		}
-	}
-
-	/**
-	 * Get total TTC
-	 *
-	 * @param	int		$aTotalTtc		Amount ttc
-	 * @return	int						Amount ttc
-	 */
-	public function amountWithTax($aTotalTtc = null)
-	{
-		if (is_null($aTotalTtc)) {
-			return $this->prix_total_ttc;
-		} elseif ($aTotalTtc == 'RESET') {
-			$this->prix_total_ttc = null;
-		} else {
-			$this->prix_total_ttc = $aTotalTtc;
-		}
-	}
-}

+ 0 - 455
htdocs/cashdesk/css/style.css

@@ -1,455 +0,0 @@
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-body {
-	background: #fff;
-	color: #333;
-	margin: 0;
-	padding: 0;
-}
-
-p {
-	margin: 0;
-}
-
-.conteneur {
-	background: #fff;
-	text-align: left;
-	/*max-width: 770px;*/
-	/*margin: 10px auto;
-	border: 2px solid #000;*/
-}
-
-.conteneur_img_gauche {
-	/* background: url("../img/bg_conteneur_gauche.png") top left repeat-y; */
-}
-
-.conteneur_img_droite {
-	/* background: url("../img/bg_conteneur_droite.png") top right repeat-y; */
-}
-
-.contenu {
-	width: 100%;
-	text-align: center;
-	padding-top: 20px;
-}
-
-.logo {
-    text-align: center;
-}
-.logopos {
-	padding-top: 20px;
-	max-height: 40px;
-}
-
-/* ------------------- Header ------------------- */
-.entete {
-	height: 15px;
-	margin: 0;
-	/* background: url('../img/bg_entete.png') no-repeat left top; */
-}
-
-.entete span {
-	display: none;
-}
-
-.principal_login td.label1 {
-    width: 50%;
-}
-
-/* ------------------- Menu ------------------- */
-.menu_principal {
-    margin: 0;
-    font-size: 14px;
-	height: 84px;
-	background: #CCCCCC;
-	background-image: linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
-	background-image: -o-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
-	background-image: -moz-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
-	background-image: -webkit-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
-	background-image: -ms-linear-gradient(top, rgba(255,255,255,.3) 0%, rgba(40,40,40,.3) 100%);
-	background-image: -webkit-gradient( linear, left top, left bottom, color-stop(0, rgba(255,255,255,.3)), color-stop(1, rgba(40,40,40,.3)) );
-}
-
-.menu_bloc {
-	margin-left: 12px;
-}
-
-.menu {
-	margin: 0;
-    list-style-type: none;
-    padding: 8px 0 0;
-}
-
-.menu li {
-	float: left;
-	padding-right: 10px;
-}
-
-.menu_choix0 {
-	font-size: 10px;
-	text-align: right;
-	font-style: italic;
-	font-weight: normal;
-	display: block;
-	color: #333;
-	text-decoration: none;
-	padding-right: 5px;
-}
-
-/* Force values for small screen 570 */
-@media only screen and (max-width: 570px)
-{
-	.menu_choix0 {
-		max-width: 180px;
-	}
-}
-
-.menu_choix0 a {
-	font-weight: normal;
-	text-decoration: none;
-}
-li.menu_choix0 {
-		float: right;
-}
-
-/* ------------------- Remind of products ------------------- */
-.liste_articles {
-	min-width: 215px;
-	float: right;
-	margin-top: 8px;
-	margin-right: 20px;
-	border: 1px dotted #5ca64d;
-	padding-bottom: 10px;
-	vertical-align: middle;
-}
-
-p.titre {
-    margin: 0 0 20px;
-    text-align: center;
-	font-weight: bold;
-	font-size: 1.4em;
-	color: #5ca64d;
-	border-bottom: 1px dotted;
-}
-
-.cadre_article {
-    width: 180px;
-	text-align: center;
-    margin: 0 auto 10px;
-    padding-bottom: 10px;
-	border-bottom: 1px solid #eee;
-}
-
-.cadre_article p {
-	color: #5ca64d;
-}
-
-.cadre_article p a {
-	color: #333;
-	font-size: 1.1em;
-	text-decoration: none;
-	padding-right: 25px;
-	background: url('../img/basket_delete.png') top right no-repeat;
-}
-
-.cadre_article p a:hover {
-	color: #6d3f6d;
-}
-
-.cadre_aucun_article {
-	text-align: center;
-	font-style: italic;
-}
-
-.cadre_prix_total {
-	text-align: center;
-	font-weight: bold;
-	font-size: 1.4em;
-	color: #6d3f6d;
-	padding-top: 10px;
-	padding-bottom: 10px;
-	margin-left: 20px;
-	margin-right: 20px;
-	border: 1px dotted #6d3f6d;
-}
-
-/* ------------------- Contenu ------------------- */
-.principal_login {
-	margin: 10px;
-	padding: 0;
-	max-width: 800px;
-	text-align: left;
-}
-
-.formulaire_login {
-	text-align: center;
-}
-
-.formulaire_login table {
-    padding-left: 60px;
-    margin: 0 auto 20px;
-    background: url('../img/login.png') bottom left no-repeat;
-}
-
-.formulaire_login table tr {
-	height: 30px;
-}
-
-.texte_login {
-	padding-left: 2px;
-	padding-right: 2px;
-	background: #fff;
-	border: 1px solid #6d3f6d;
-}
-
-.principal {
-	float: left;
-	margin: 0 15px;
-	padding: 0;
-	max-width: 900px;
-}
-
-.blocksellfinished {
-	min-width: 215px;
-	margin-top: 8px;
-}
-.titre1 {
-	font-weight: bold;
-	color: #ff9900;
-	margin: 0;
-	font-size: 1.4em;
-}
-
-.label1 {
-	color: #333;
-	font-size: 1.1em;
-}
-
-.cadre_facturation {
-	border: 2px solid #ddd;
-	margin-bottom: 15px;
-}
-
-.principal p {
-	padding-left: 10px;
-	padding-right: 10px;
-}
-
-.lien1 {
-	color: #333;
-	font-size: 1.1em;
-	text-decoration: underline;
-}
-
-.lien1:hover {
-	color: #6d3f6d;
-}
-
-/* Formulaires */
-.formulaire1 {
-	padding: 0;
-}
-
-
-/* --------------------- Combo lists ------------------- */
-.select_design {
-	overflow: auto;
-}
-
-.select_design select {
-	border: 1px solid #6d3f6d;
-    font: 12px verdana,arial,helvetica;
-	background: #fff;
-}
-
-.select_tva select {
-	width: 60px;
-	border: 1px solid #6d3f6d;
-	background: #fff;
-}
-
-.top_liste {
-	font-style: italic;
-	text-align: center;
-	color: #aaa;
-}
-
-/* --------------- Champs texte ---------------- */
-.texte_ref,.texte1,.texte1_off,.texte2,.texte2_off,.textarea_note {
-	padding-left: 2px;
-	padding-right: 2px;
-}
-
-.texte_ref,.texte1,.texte2,.textarea_note {
-	background: #fff;
-	border: 1px solid #6d3f6d;
-}
-
-.texte1_off,.texte2_off {
-	color: #000;
-	border: 1px solid #eee;
-	background: #eee;
-}
-
-.texte_ref {
-	min-width: 150px;
-}
-
-.texte1,.texte1_off {
-	width: 60px;
-}
-
-.texte2,.texte2_off {
-	width: 140px;
-}
-
-/* ------------------- */
-.textarea_note {
-	width: 100%;
-	height: 50px;
-	padding: 2px 2px;
-}
-
-/* -------------- Buttons for SimplePOS --------------------- */
-.bouton_ajout_article {
-	margin-top: 10px;
-	width: 60%;
-	height: 40px;
-}
-
-.bouton_mode_reglement, .bouton_mode_reglement_disabled {
-	width: 150px;
-	height: 40px;
-}
-
-.bouton_validation { /* 			width: 80px; */
-	margin-left: 10px;
-	margin-top: 20px;
-	margin-bottom: 10px;
-}
-
-.formulaire2 {
-	padding: 0;
-	width: 100%;
-}
-
-.table_resume {
-	width: 100%;
-}
-
-.table_resume tr {
-	background: #eee;
-}
-
-.table_resume td {
-	padding-left: 8px;
-}
-
-.resume_label,.note_label {
-	min-width: 200px;
-	font-weight: bold;
-	font-size: 1.1em;
-}
-
-.note_label {
-	padding-top: 20px;
-}
-
-/* ------------------- Pied de page ------------------- */
-.pied {
-	clear: both;
-	height: 15px;
-	/* background: url('../img/bg_pied.png') no-repeat bottom left; */
-}
-
-/* ------------------- Param�tres communs (messages d'erreur, informations, etc...) ------------------- */
-.msg_err1 {
-	color: #c00;
-}
-
-/* Messages d'erreur */
-.cadre_err1 {
-	margin-right: 10px;
-	margin-bottom: 10px;
-	padding: 10px 10px;
-	border: 1px solid #c00;
-	background: #feffac;
-	color: #c00;
-}
-
-/* Titre */
-.err_titre {
-	font-weight: bold;
-    margin: 0 0 10px;
-    padding: 0;
-}
-
-/* Description */
-.err_desc {
-	margin: 0;
-	padding: 0;
-}
-
-/* Messages d'information */
-.cadre_msg1 {
-	margin-right: 10px;
-	margin-bottom: 10px;
-	padding: 10px 10px;
-	border: 1px solid #070;
-	background: #e8f8da;
-	color: #070;
-}
-
-/* Titre */
-.msg_titre {
-	font-weight: bold;
-    margin: 0 0 10px;
-    padding: 0;
-}
-
-/* Description */
-.msg_desc {
-	margin: 0;
-	padding: 0;
-}
-
-/* Affichage de la liste des resultats */
-.dhtml_bloc {
-	margin: 0;
-	padding: 3px;
-	font-size: 13px;
-	font-family: arial, sans-serif;
-	border: 1px solid #000;
-	z-index: 1;
-	width: 455px;
-	max-height: 500px;
-	overflow: auto;
-	position: absolute;
-	background-color: white;
-}
-
-.dhtml_defaut {
-	list-style-type: none;
-	display: block;
-	height: 16px;
-	overflow: hidden;
-}
-
-.dhtml_selection {
-	background-color: #3366cc;
-	color: white ! important;
-}

+ 0 - 61
htdocs/cashdesk/css/ticket.css

@@ -1,61 +0,0 @@
-/*
- * TPV ticket.css
- */
-body {
-    font-size: 1.5em;
-    position: relative;
-}
-
-.entete { /* 		position: relative; */
-
-}
-
-.address { /* 			float: left; */
-    font-size: 12px;
-}
-
-.date_heure {
-    position: absolute;
-    top: 0;
-    right: 0;
-    font-size: 16px;
-}
-
-.infos {
-    position: relative;
-}
-
-.liste_articles {
-    width: 100%;
-    border-bottom: 1px solid #000;
-    text-align: center;
-}
-
-.liste_articles tr.titres th {
-    border-bottom: 1px solid #000;
-}
-
-.liste_articles td.total {
-    text-align: right;
-}
-
-.totaux {
-    margin-top: 20px;
-    width: 30%;
-    float: right;
-    text-align: right;
-}
-
-.lien {
-    position: absolute;
-    top: 0;
-    left: 0;
-    display: none;
-}
-
-@media print {
-    .lien {
-            display: none;
-    }
-}
-

+ 0 - 48
htdocs/cashdesk/deconnexion.php

@@ -1,48 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/deconnexion.php
- *	\ingroup    cashdesk
- *	\brief      Manage deconnexion for point of sale module
- */
-
-//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Uncomment creates pb to relogon after a disconnect
-if (!defined('NOREQUIREMENU')) {
-	define('NOREQUIREMENU', '1');
-}
-if (!defined('NOREQUIREHTML')) {
-	define('NOREQUIREHTML', '1');
-}
-if (!defined('NOREQUIREAJAX')) {
-	define('NOREQUIREAJAX', '1');
-}
-if (!defined('NOREQUIRESOC')) {
-	define('NOREQUIRESOC', '1');
-}
-
-require_once '../main.inc.php';
-
-// This destroy tag that say "Point of Sale session is on".
-unset($_SESSION['uid']);
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php');
-exit;

+ 0 - 159
htdocs/cashdesk/facturation.php

@@ -1,159 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- * Copyright (C) 2008-2011 Laurent Destailleur   <eldy@uers.sourceforge.net>
- * Copyright (C) 2011 Juanjo Menent			  	 <jmenent@2byte.es>
- * Copyright (C) 2013 Marcos García					<marcosgdf@gmail.com>
- * Copyright (C) 2013 Adolfo Segura 				<adolfo.segura@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/facturation.php
- *	\ingroup    cashdesk
- *	\brief      Include to show main page for cashdesk module
- */
-
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-
-// Get list of articles (in warehouse '$conf_fkentrepot' if defined and stock module enabled)
-if (GETPOST('filtre', 'alpha')) {
-	// Avec filtre
-	$ret = array(); $i = 0;
-
-	$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx, p.fk_product_type";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= ", ps.reel";
-	}
-	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
-	}
-	$sql .= " WHERE p.entity IN (".getEntity('product').")";
-	$sql .= " AND p.tosell = 1";
-	if (!$conf->global->CASHDESK_SERVICES) {
-		$sql .= " AND p.fk_product_type = 0";
-	}
-	$sql .= " AND (";
-	$sql .= "p.ref LIKE '%".$db->escape(GETPOST('filtre'))."%' OR p.label LIKE '%".$db->escape(GETPOST('filtre'))."%'";
-	if (!empty($conf->barcode->enabled)) {
-		$filtre = GETPOST('filtre', 'alpha');
-
-		//If the barcode looks like an EAN13 format and the last digit is included in it,
-		//then whe look for the 12-digit too
-		//As the twelve-digit string will also hit the 13-digit code, we only look for this one
-		if (strlen($filtre) == 13) {
-			$crit_12digit = substr($filtre, 0, 12);
-			$sql .= " OR p.barcode LIKE '%".$db->escape($crit_12digit)."%'";
-		} else {
-			$sql .= " OR p.barcode LIKE '%".$db->escape($filtre)."%'";
-		}
-	}
-	$sql .= ")";
-	$sql .= " ORDER BY label";
-
-	dol_syslog("facturation.php", LOG_DEBUG);
-	$resql = $db->query($sql);
-	if ($resql) {
-		$nbr_enreg = $db->num_rows($resql);
-
-		while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) {
-			foreach ($tab as $cle => $valeur) {
-				$ret[$i][$cle] = $valeur;
-			}
-			$i++;
-		}
-		$db->free($resql);
-	} else {
-		dol_print_error($db);
-	}
-	$tab_designations = $ret;
-} else {
-	// Sans filtre
-	$ret = array();
-	$i = 0;
-
-	$sql = "SELECT p.rowid, ref, label, tva_tx, p.fk_product_type";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= ", ps.reel";
-	}
-	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
-	}
-	$sql .= " WHERE p.entity IN (".getEntity('product').")";
-	$sql .= " AND p.tosell = 1";
-	if (!$conf->global->CASHDESK_SERVICES) {
-		$sql .= " AND p.fk_product_type = 0";
-	}
-	$sql .= " ORDER BY p.label";
-
-	dol_syslog($sql);
-	$resql = $db->query($sql);
-	if ($resql) {
-		$nbr_enreg = $db->num_rows($resql);
-
-		while ($i < $conf_taille_listes && $tab = $db->fetch_array($resql)) {
-			foreach ($tab as $cle => $valeur) {
-				$ret[$i][$cle] = $valeur;
-			}
-			$i++;
-		}
-		$db->free($resql);
-	} else {
-		dol_print_error($db);
-	}
-	$tab_designations = $ret;
-}
-
-//$nbr_enreg = count($tab_designations);
-
-if ($nbr_enreg > 1) {
-	if ($nbr_enreg > $conf_taille_listes) {
-		$top_liste_produits = '----- '.$conf_taille_listes.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
-	} else {
-		$top_liste_produits = '----- '.$nbr_enreg.' '.$langs->transnoentitiesnoconv("CashDeskProducts").' '.$langs->trans("CashDeskOn").' '.$nbr_enreg.' -----';
-	}
-} elseif ($nbr_enreg == 1) {
-	$top_liste_produits = '----- 1 '.$langs->transnoentitiesnoconv("ProductFound").' -----';
-} else {
-	$top_liste_produits = '----- '.$langs->transnoentitiesnoconv("NoProductFound").' -----';
-}
-
-
-// Recuperation des taux de tva
-global $mysoc;
-
-$ret = array();
-$i = 0;
-
-// Reinitialisation du mode de paiement, en cas de retour aux achats apres validation
-$obj_facturation->getSetPaymentMode('RESET');
-$obj_facturation->amountCollected('RESET');
-$obj_facturation->amountReturned('RESET');
-$obj_facturation->paiementLe('RESET');
-
-
-// Affichage des templates
-require 'tpl/facturation1.tpl.php';

+ 0 - 129
htdocs/cashdesk/facturation_dhtml.php

@@ -1,129 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 	Jeremie Ollivier 	<jeremie.o@laposte.net>
- * Copyright (C) 2008-2009 	Laurent Destailleur <eldy@uers.sourceforge.net>
- * Copyright (C) 2015		Regis Houssin		<regis.houssin@inodbox.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/facturation_dhtml.php
- *	\ingroup    cashdesk
- *	\brief      This page is called each time we press a key in the code search form to show product combo list.
- */
-
-
-if (!defined('NOREQUIRESOC')) {
-	define('NOREQUIRESOC', '1');
-}
-if (!defined('NOCSRFCHECK')) {
-	define('NOCSRFCHECK', '1');
-}
-if (!defined('NOTOKENRENEWAL')) {
-	define('NOTOKENRENEWAL', '1');
-}
-if (!defined('NOREQUIREMENU')) {
-	define('NOREQUIREMENU', '1');
-}
-if (!defined('NOREQUIREHTML')) {
-	define('NOREQUIREHTML', '1');
-}
-if (!defined('NOREQUIREAJAX')) {
-	define('NOREQUIREAJAX', '1');
-}
-
-// Change this following line to use the correct relative path (../, ../../, etc)
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-top_httphead('text/html');
-
-$search = GETPOST("code", "alpha");
-
-// Search from criteria
-if (dol_strlen($search) >= 0) {	// If search criteria is on char length at least
-	$sql = "SELECT p.rowid, p.ref, p.label, p.tva_tx";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= ", ps.reel";
-	}
-	$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-		$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = '".$db->escape($conf_fkentrepot)."'";
-	}
-	$sql .= " WHERE p.entity IN (".getEntity('product').")";
-	$sql .= " AND p.tosell = 1";
-	$sql .= " AND p.fk_product_type = 0";
-	// Add criteria on ref/label
-	if (!empty($conf->global->PRODUCT_DONOTSEARCH_ANYWHERE)) {
-		$sql .= " AND (p.ref LIKE '".$db->escape($search)."%' OR p.label LIKE '".$db->escape($search)."%'";
-		if (!empty($conf->barcode->enabled)) {
-			$sql .= " OR p.barcode LIKE '".$db->escape($search)."%'";
-		}
-		$sql .= ")";
-	} else {
-		$sql .= " AND (p.ref LIKE '%".$db->escape($search)."%' OR p.label LIKE '%".$db->escape($search)."%'";
-		if (!empty($conf->barcode->enabled)) {
-			$sql .= " OR p.barcode LIKE '%".$db->escape($search)."%'";
-		}
-		$sql .= ")";
-	}
-	$sql .= " ORDER BY label";
-
-	dol_syslog("facturation_dhtml.php", LOG_DEBUG);
-	$result = $db->query($sql);
-
-	if ($result) {
-		if ($nbr = $db->num_rows($result)) {
-			$resultat = '<ul class="dhtml_bloc">';
-
-			$ret = array(); $i = 0;
-			while ($tab = $db->fetch_array($result)) {
-				foreach ($tab as $cle => $valeur) {
-					$ret[$i][$cle] = $valeur;
-				}
-				$i++;
-			}
-			$tab = $ret;
-
-			$tab_size = count($tab);
-			for ($i = 0; $i < $tab_size; $i++) {
-				$resultat .= '
-					<li class="dhtml_defaut" title="'.$tab[$i]['ref'].'"
-						onMouseOver="javascript: this.className = \'dhtml_selection\';"
-						onMouseOut="javascript: this.className = \'dhtml_defaut\';"
-					>'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</li>
-				';
-			}
-
-			$resultat .= '</ul>';
-
-			print $resultat;
-		} else {
-			$langs->load("cashdesk");
-
-			print '<ul class="dhtml_bloc">';
-			print '<li class="dhtml_defaut">'.$langs->trans("NoResults").'</li>';
-			print '</ul>';
-		}
-	}
-}

+ 0 - 225
htdocs/cashdesk/facturation_verif.php

@@ -1,225 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier    <jeremie.o@laposte.net>
- * Copyright (C) 2008-2010 Laurent Destailleur <eldy@uers.sourceforge.net>
- * Copyright (C) 2018      Juanjo Menent       <jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/facturation_verif.php
- *	\ingroup    cashdesk
- *	\brief      facturation_verif.php
- */
-
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php';
-require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-
-$action = GETPOST('action', 'aZ09');
-
-$obj_facturation = unserialize($_SESSION['serObjFacturation']);
-unset($_SESSION['serObjFacturation']);
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-switch ($action) {
-	default:
-		if (GETPOST('hdnSource') != 'NULL') {
-			$sql = "SELECT p.rowid, p.ref, p.price, p.tva_tx, p.default_vat_code, p.recuperableonly";
-			if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-				$sql .= ", ps.reel";
-			}
-			$sql .= " FROM ".MAIN_DB_PREFIX."product as p";
-			if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot)) {
-				$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_stock as ps ON p.rowid = ps.fk_product AND ps.fk_entrepot = ".((int) $conf_fkentrepot);
-			}
-			$sql .= " WHERE p.entity IN (".getEntity('product').")";
-
-			// Recuperation des donnees en fonction de la source (liste deroulante ou champ texte) ...
-			if ($_POST['hdnSource'] == 'LISTE') {
-				$sql .= " AND p.rowid = ".((int) GETPOST('selProduit', 'int'));
-			} elseif ($_POST['hdnSource'] == 'REF') {
-				$sql .= " AND p.ref = '".$db->escape(GETPOST('txtRef', 'alpha'))."'";
-			}
-
-			$result = $db->query($sql);
-			if ($result) {
-				// ... et enregistrement dans l'objet
-				if ($db->num_rows($result)) {
-					$ret = array();
-					$tab = $db->fetch_array($result);
-					foreach ($tab as $key => $value) {
-						$ret[$key] = $value;
-					}
-					// Here $ret['tva_tx'] is vat rate of product but we want to not use the one into table but found by function
-
-					$productid = $ret['rowid'];
-					$product = new Product($db);
-					$product->fetch($productid);
-					$prod = $product;
-
-					$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-					$societe = new Societe($db);
-					$societe->fetch($thirdpartyid);
-
-					// Update if prices fields are defined
-					$tva_tx = get_default_tva($mysoc, $societe, $product->id);
-					$tva_npr = get_default_npr($mysoc, $societe, $product->id);
-					if (empty($tva_tx)) {
-						$tva_npr = 0;
-					}
-
-					$pu_ht = $prod->price;
-					$pu_ttc = $prod->price_ttc;
-					$price_min = $prod->price_min;
-					$price_base_type = $prod->price_base_type;
-
-					// multiprix
-					if (!empty($conf->global->PRODUIT_MULTIPRICES) && !empty($societe->price_level)) {
-						$pu_ht = $prod->multiprices[$societe->price_level];
-						$pu_ttc = $prod->multiprices_ttc[$societe->price_level];
-						$price_min = $prod->multiprices_min[$societe->price_level];
-						$price_base_type = $prod->multiprices_base_type[$societe->price_level];
-						if (!empty($conf->global->PRODUIT_MULTIPRICES_USE_VAT_PER_LEVEL)) {  // using this option is a bug. kept for backward compatibility
-							if (isset($prod->multiprices_tva_tx[$societe->price_level])) {
-								$tva_tx = $prod->multiprices_tva_tx[$societe->price_level];
-							}
-							if (isset($prod->multiprices_recuperableonly[$societe->price_level])) {
-								$tva_npr = $prod->multiprices_recuperableonly[$societe->price_level];
-							}
-						}
-					} elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
-						require_once DOL_DOCUMENT_ROOT.'/product/class/productcustomerprice.class.php';
-
-						$prodcustprice = new Productcustomerprice($db);
-
-						$filter = array('t.fk_product' => $prod->id, 't.fk_soc' => $societe->id);
-
-						$result = $prodcustprice->fetch_all('', '', 0, 0, $filter);
-						if ($result >= 0) {
-							if (count($prodcustprice->lines) > 0) {
-								$pu_ht = price($prodcustprice->lines[0]->price);
-								$pu_ttc = price($prodcustprice->lines[0]->price_ttc);
-								$price_base_type = $prodcustprice->lines[0]->price_base_type;
-								$tva_tx = $prodcustprice->lines[0]->tva_tx;
-								if ($prodcustprice->lines[0]->default_vat_code && !preg_match('/\(.*\)/', $tva_tx)) {
-									$tva_tx .= ' ('.$prodcustprice->lines[0]->default_vat_code.')';
-								}
-								$tva_npr = $prodcustprice->lines[0]->recuperableonly;
-								if (empty($tva_tx)) {
-									$tva_npr = 0;
-								}
-							}
-						} else {
-							setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
-						}
-					}
-
-					$tmpvat = price2num(preg_replace('/\s*\(.*\)/', '', $tva_tx));
-					$tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx));
-
-					// if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ?
-					if (!empty($price_ht)) {
-						$pu_ht = price2num($price_ht, 'MU');
-						$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
-					} elseif ($tmpvat != $tmpprodvat) {
-						// On reevalue prix selon taux tva car taux tva transaction peut etre different
-						// de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur).
-						if ($price_base_type != 'HT') {
-							$pu_ht = price2num($pu_ttc / (1 + ($tmpvat / 100)), 'MU');
-						} else {
-							$pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU');
-						}
-					}
-
-					$obj_facturation->id($ret['rowid']);
-					$obj_facturation->ref($ret['ref']);
-					$obj_facturation->stock($ret['reel']);
-					//$obj_facturation->prix($ret['price']);
-					$obj_facturation->prix($pu_ht);
-
-
-					$vatrate = $tva_tx;
-					$obj_facturation->vatrate = $vatrate; // Save vat rate (full text vat with code)
-
-					// Definition du filtre pour n'afficher que le produit concerne
-					if (GETPOST('hdnSource') == 'LISTE') {
-						$filtre = $ret['ref'];
-					} elseif (GETPOST('hdnSource') == 'REF') {
-						$filtre = GETPOST('txtRef');
-					}
-
-					$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode($filtre);
-				} else {
-					$obj_facturation->raz();
-
-					if (GETPOST('hdnSource') == 'REF') {
-						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&filtre='.urlencode(GETPOST('txtRef'));
-					} else {
-						$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
-					}
-				}
-			} else {
-				dol_print_error($db);
-			}
-		} else {
-			$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
-		}
-
-		break;
-
-	case 'change_thirdparty':	// We have clicked on button "Modify" a thirdparty
-		$newthirdpartyid = GETPOST('CASHDESK_ID_THIRDPARTY', 'int');
-		if ($newthirdpartyid > 0) {
-			$_SESSION["CASHDESK_ID_THIRDPARTY"] = $newthirdpartyid;
-		}
-
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
-		break;
-
-	case 'ajout_article':
-		if (!empty($obj_facturation->id)) {	// A product was previously selected and stored in session, so we can add it
-			dol_syslog("facturation_verif save vat ".GETPOST('selTva'));
-			$obj_facturation->qte(GETPOST('txtQte'));
-			$obj_facturation->tva(GETPOST('selTva')); // id of vat. Saved so we can use it for next product
-			$obj_facturation->remisePercent(GETPOST('txtRemise'));
-			$obj_facturation->ajoutArticle(); // This add an entry into $_SESSION['poscart']
-			// We update prixTotalTtc
-		}
-
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
-		break;
-
-	case 'suppr_article':
-		$obj_facturation->supprArticle(GETPOST('suppr_id'));
-
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation';
-		break;
-}
-
-// We saved object obj_facturation
-$_SESSION['serObjFacturation'] = serialize($obj_facturation);
-//var_dump($_SESSION['serObjFacturation']);
-header('Location: '.$redirection);
-exit;

BIN
htdocs/cashdesk/img/basket_delete.png


BIN
htdocs/cashdesk/img/bg_conteneur_droite.png


BIN
htdocs/cashdesk/img/bg_conteneur_gauche.png


BIN
htdocs/cashdesk/img/bg_entete.png


BIN
htdocs/cashdesk/img/bg_pied.png


BIN
htdocs/cashdesk/img/calendrier.png


BIN
htdocs/cashdesk/img/decrypted.png


BIN
htdocs/cashdesk/img/gescom.png


BIN
htdocs/cashdesk/img/lock.png


BIN
htdocs/cashdesk/img/login.png


BIN
htdocs/cashdesk/img/new.png


+ 0 - 50
htdocs/cashdesk/include/environnement.php

@@ -1,50 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier     <jeremie.o@laposte.net>
- * Copyright (C) 2009-2011 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2011      Juanjo Menent 		<jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// This file initializes more variables to already initialized variables with main.inc.php
-// So include of this file must be always done after include to main.inc.php
-
-$conf_db_type = $dolibarr_main_db_type;
-
-// Parametres de connexion a la base
-$conf_db_host = $dolibarr_main_db_host;
-$conf_db_user = $dolibarr_main_db_user;
-$conf_db_pass = $dolibarr_main_db_pass;
-$conf_db_base = $dolibarr_main_db_name;
-
-// Identifiant unique correspondant au tiers generique pour la vente
-$conf_fksoc = (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"])) ? $_SESSION["CASHDESK_ID_THIRDPARTY"] : ($conf->global->CASHDESK_ID_THIRDPARTY > 0 ? $conf->global->CASHDESK_ID_THIRDPARTY : 0);
-// Identifiant unique correspondant a l'entrepot a utiliser
-$conf_fkentrepot = (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"])) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : ($conf->global->CASHDESK_ID_WAREHOUSE > 0 ? $conf->global->CASHDESK_ID_WAREHOUSE : 0);
-if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
-	$conf_fkentrepot = 0; // If option to disable the stock decrease is on, we set warehouse id to 0.
-}
-
-// Identifiant unique correspondant au compte caisse / liquide
-$conf_fkaccount_cash = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CASH : 0);
-// Identifiant unique correspondant au compte cheque
-$conf_fkaccount_cheque = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE : 0);
-// Identifiant unique correspondant au compte cb
-$conf_fkaccount_cb = (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) ? $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"] : ($conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0 ? $conf->global->CASHDESK_ID_BANKACCOUNT_CB : 0);
-//var_dump($_SESSION);
-
-
-// View parameters
-$conf_taille_listes = (empty($conf->global->PRODUIT_LIMIT_SIZE) ? 1000 : $conf->global->PRODUIT_LIMIT_SIZE); // Number max of lines to show in lists
-$conf_nbr_car_listes = 60; // Nombre max de caracteres par ligne dans les listes

+ 0 - 56
htdocs/cashdesk/include/keypad.php

@@ -1,56 +0,0 @@
-<?php
-/* Copyright (C) 2014	Charles-FR BENKE		<charles.fr@benke.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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- * Return a string to output a keypad
- *
- * @param	string		$keypadname		Key pad name
- * @param 	string		$formname		Form name
- * @return	string						HTML code to show a js keypad.
- */
-function genkeypad($keypadname, $formname)
-{
-	global $conf;
-
-	if (empty($conf->global->CASHDESK_SHOW_KEYPAD)) {
-		return '';
-	}
-
-	// défine the font size of button
-	$btnsize = 32;
-	$sz = '<input type="button" id="closekeypad'.$keypadname.'" value="X" style="display:none;" onclick="closekeypad(\''.$keypadname.'\')"/>'."\n";
-	$sz .= '<input type="button" value="..." id="openkeypad'.$keypadname.'" onclick="openkeypad(\''.$keypadname.'\')"/><br>'."\n";
-	$sz .= '<div id="keypad'.$keypadname.'" style="position:absolute;z-index:90;display:none; background:#AAA; vertical-align:top;">'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 7 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',7);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 8 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',8);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 9 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',9);"/><br>'."\n";
-
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 4 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',4);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 5 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',5);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 6 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',6);"/><br>'."\n";
-
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 1 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',1);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 2 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',2);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 3 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',3);"/><br>'."\n";
-
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value=" 0 " onclick="addvalue(\''.$keypadname.'\',\''.$formname.'\',0);"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value="&larr;" ';
-	$sz .= ' onclick="document.getElementById(\''.$keypadname.'\').value=document.getElementById(\''.$keypadname.'\').value.substr(0,document.getElementById(\''.$keypadname.'\').value.length-1);modif();"/>'."\n";
-	$sz .= '<input type="button" style="font-size:'.$btnsize.'px;" value="CE" onclick="document.getElementById(\''.$keypadname.'\').value=0;modif();"/>'."\n";
-	$sz .= '</div>';
-	return $sz;
-}

+ 0 - 232
htdocs/cashdesk/index.php

@@ -1,232 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier    <jeremie.o@laposte.net>
- * Copyright (C) 2011-2017 Juanjo Menent   	   <jmenent@2byte.es>
- * Copyright (C) 2011      Laurent Destailleur <eldy@users.sourceforge.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/index.php
- * 	\ingroup	cashdesk
- *  \brief      File to login to point of sales
- */
-
-// Set and init common variables
-// This include will set: config file variable $dolibarr_xxx, $conf, $langs and $mysoc objects
-require_once '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("admin", "cashdesk"));
-
-// Test if user logged
-if ($_SESSION['uid'] > 0) {
-	header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php');
-	exit;
-}
-
-$usertxt = GETPOST('user', '', 1);
-$err = GETPOST("err");
-
-// Instantiate hooks of thirdparty module only if not already define
-$hookmanager->initHooks(array('cashdeskloginpage'));
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * View
- */
-
-$form = new Form($db);
-$formproduct = new FormProduct($db);
-
-$arrayofcss = array('/cashdesk/css/style.css');
-top_htmlhead('', '', 0, 0, '', $arrayofcss);
-
-// Execute hook getLoginPageOptions (for table)
-$parameters = array('entity' => GETPOST('entity', 'int'));
-$reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks.
-if (is_array($hookmanager->resArray) && !empty($hookmanager->resArray)) {
-	$morelogincontent = $hookmanager->resArray; // (deprecated) For compatibility
-} else {
-	$morelogincontent = $hookmanager->resPrint;
-}
-?>
-
-<body>
-<div class="conteneur">
-<div class="conteneur_img_gauche">
-<div class="conteneur_img_droite">
-
-<div class="menu_principal hideonsmartphone">
-<div class="logo">
-<?php
-if (!empty($mysoc->logo_small)) {
-	print '<img class="logopos" alt="Logo company" src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">';
-} else {
-	print '<div class="logopos">'.$mysoc->name.'</div>';
-}
-?>
-</div>
-</div>
-
-<div class="contenu">
-<div class="inline-block" style="vertical-align: top">
-<div class="principal_login">
-<?php if ($err) {
-	print dol_escape_htmltag($err)."<br><br>\n";
-} ?>
-<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Identification"); ?></legend>
-<form id="frmLogin" method="POST" action="index_verif.php">
-	<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
-
-<table>
-
-	<tr>
-		<td class="label1"><?php echo $langs->trans("Login"); ?></td>
-		<td><input name="txtUsername" class="texte_login maxwidth150onsmartphoneimp" type="text" value="<?php echo $usertxt; ?>" /></td>
-	</tr>
-	<tr>
-		<td class="label1"><?php echo $langs->trans("Password"); ?></td>
-		<td><input name="pwdPassword" class="texte_login maxwidth150onsmartphoneimp" type="password" value="" /></td>
-	</tr>
-
-<?php
-if (!empty($morelogincontent)) {
-	if (is_array($morelogincontent)) {
-		foreach ($morelogincontent as $format => $option) {
-			if ($format == 'table') {
-				echo '<!-- Option by hook -->';
-				echo $option;
-			}
-		}
-	} else {
-		echo '<!-- Option by hook -->';
-		echo $morelogincontent;
-	}
-}
-?>
-
-	<tr>
-		<td colspan="2">
-		&nbsp;
-		</td>
-	</tr>
-
-<?php
-print "<tr>";
-print '<td class="label1">'.$langs->trans("CashDeskThirdPartyForSell").'</td>';
-print '<td>';
-$disabled = 0;
-$langs->load("companies");
-if (!empty($conf->global->CASHDESK_ID_THIRDPARTY)) {
-	$disabled = 1; // If a particular third party is defined, we disable choice
-}
-print $form->select_company(GETPOST('socid', 'int') ?GETPOST('socid', 'int') : $conf->global->CASHDESK_ID_THIRDPARTY, 'socid', '(s.client IN (1,3) AND s.status = 1)', !$disabled, $disabled, 0, array(), 0, 'maxwidth300');
-//print '<input name="warehouse_id" class="texte_login" type="warehouse_id" value="" />';
-print '</td>';
-print "</tr>\n";
-
-if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
-	$langs->load("stocks");
-	print "<tr>";
-	print '<td class="label1">'.$langs->trans("Warehouse").'</td>';
-	print '<td>';
-	$disabled = 0;
-	if ($conf->global->CASHDESK_ID_WAREHOUSE > 0) {
-		$disabled = 1; // If a particular stock is defined, we disable choice
-	}
-	print $formproduct->selectWarehouses((GETPOST('warehouseid') ?GETPOST('warehouseid', 'int') : (empty($conf->global->CASHDESK_ID_WAREHOUSE) ? 'ifone' : $conf->global->CASHDESK_ID_WAREHOUSE)), 'warehouseid', '', !$disabled, $disabled);
-	print '</td>';
-	print "</tr>\n";
-}
-
-print "<tr>";
-print '<td class="label1">'.$langs->trans("CashDeskBankAccountForSell").'</td>';
-print '<td>';
-$defaultknown = 0;
-if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH) && $conf->global->CASHDESK_ID_BANKACCOUNT_CASH > 0) {
-	$defaultknown = 1; // If a particular stock is defined, we disable choice
-}
-$form->select_comptes(((GETPOST('bankid_cash') > 0) ?GETPOST('bankid_cash') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH), 'CASHDESK_ID_BANKACCOUNT_CASH', 0, "courant=2", ($defaultknown ? 0 : 2));
-print '</td>';
-print "</tr>\n";
-
-print "<tr>";
-print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCheque").'</td>';
-print '<td>';
-$defaultknown = 0;
-if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE) && $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE > 0) {
-	$defaultknown = 1; // If a particular stock is defined, we disable choice
-}
-$form->select_comptes(((GETPOST('bankid_cheque') > 0) ?GETPOST('bankid_cheque') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE), 'CASHDESK_ID_BANKACCOUNT_CHEQUE', 0, "courant=1", ($defaultknown ? 0 : 2));
-print '</td>';
-print "</tr>\n";
-
-print "<tr>";
-print '<td class="label1">'.$langs->trans("CashDeskBankAccountForCB").'</td>';
-print '<td>';
-$defaultknown = 0;
-if (!empty($conf->global->CASHDESK_ID_BANKACCOUNT_CB) && $conf->global->CASHDESK_ID_BANKACCOUNT_CB > 0) {
-	$defaultknown = 1; // If a particular stock is defined, we disable choice
-}
-$form->select_comptes(((GETPOST('bankid_cb') > 0) ?GETPOST('bankid_cb') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB), 'CASHDESK_ID_BANKACCOUNT_CB', 0, "courant=1", ($defaultknown ? 0 : 2));
-print '</td>';
-print "</tr>\n";
-
-?>
-
-	<tr>
-		<td colspan="2">
-		&nbsp;
-		</td>
-	</tr>
-
-
-</table>
-<br>
-
-<div align="center"><span class="bouton_login"><input class="button" type="submit" value="<?php echo dol_escape_htmltag($langs->trans("Connection")); ?>" /></span></div>
-
-</form>
-</fieldset>
-
-
-<?php
-if ($_GET['err'] < 0) {
-	echo ('<script type="text/javascript">');
-	echo ('	document.getElementById(\'frmLogin\').pwdPassword.focus();');
-	echo ('</script>');
-} else {
-	echo ('<script type="text/javascript">');
-	echo ('	document.getElementById(\'frmLogin\').txtUsername.focus();');
-	echo ('</script>');
-}
-?>
-
-</div>
-</div>
-</div>
-
-<?php include 'affPied.php'; ?></div>
-</div>
-</div>
-</body>
-
-<?php
-print '</html>';

+ 0 - 126
htdocs/cashdesk/index_verif.php

@@ -1,126 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier    <jeremie.o@laposte.net>
- * Copyright (C) 2008-2010 Laurent Destailleur <eldy@uers.sourceforge.net>
- * Copyright (C) 2011	   Juanjo Menent	   <jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * This page is called after submission of login page.
- * We set here login choices into session.
- */
-
-/**
- *	\file       htdocs/cashdesk/index_verif.php
- *	\ingroup    cashdesk
- *	\brief      index_verif.php
- */
-
-include '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Auth.class.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("admin", "cashdesk"));
-
-$username = GETPOST("txtUsername");
-$password = GETPOST("pwdPassword");
-$thirdpartyid = (GETPOST('socid', 'int') > 0) ?GETPOST('socid', 'int') : $conf->global->CASHDESK_ID_THIRDPARTY;
-$warehouseid = (GETPOST("warehouseid") > 0) ?GETPOST("warehouseid", 'int') : $conf->global->CASHDESK_ID_WAREHOUSE;
-$bankid_cash = (GETPOST("CASHDESK_ID_BANKACCOUNT_CASH") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CASH", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CASH;
-$bankid_cheque = (GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CHEQUE", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CHEQUE;
-$bankid_cb = (GETPOST("CASHDESK_ID_BANKACCOUNT_CB") > 0) ?GETPOST("CASHDESK_ID_BANKACCOUNT_CB", 'int') : $conf->global->CASHDESK_ID_BANKACCOUNT_CB;
-
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-// Check username
-if (empty($username)) {
-	$retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Login"));
-	header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
-	exit;
-}
-// Check third party id
-if (!($thirdpartyid > 0)) {
-	$retour = $langs->trans("ErrorFieldRequired", $langs->transnoentities("CashDeskThirdPartyForSell"));
-	header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
-	exit;
-}
-
-// If we setup stock module to ask movement on invoices, we must not allow access if required setup not finished.
-if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !($warehouseid > 0)) {
-	$retour = $langs->trans("CashDeskYouDidNotDisableStockDecease");
-	header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
-	exit;
-}
-
-// If stock decrease on bill validation, check user has stock edit permissions
-if (!empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK) && !empty($username)) {
-	$testuser = new User($db);
-	$testuser->fetch(0, $username);
-	$testuser->getrights('stock');
-	if (empty($testuser->rights->stock->creer)) {
-		$retour = $langs->trans("UserNeedPermissionToEditStockToUsePos");
-		header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid.'&bankid_cash='.$bankid_cash.'&bankid_cheque='.$bankid_cheque.'&bankid_cb='.$bankid_cb);
-		exit;
-	}
-}
-
-
-// Check password
-$auth = new Auth($db);
-$retour = $auth->verif($username, $password);
-
-if ($retour >= 0) {
-	$return = array();
-
-	$sql = "SELECT rowid, lastname, firstname";
-	$sql .= " FROM ".MAIN_DB_PREFIX."user";
-	$sql .= " WHERE login = '".$db->escape($username)."'";
-	$sql .= " AND entity IN (0,".$conf->entity.")";
-
-	$result = $db->query($sql);
-	if ($result) {
-		$tab = $db->fetch_array($res);
-
-		foreach ($tab as $key => $value) {
-			$return[$key] = $value;
-		}
-
-		$_SESSION['uid'] = $tab['rowid'];
-		$_SESSION['uname'] = $username;
-		$_SESSION['lastname'] = $tab['lastname'];
-		$_SESSION['firstname'] = $tab['firstname'];
-		$_SESSION['CASHDESK_ID_THIRDPARTY'] = ($thirdpartyid > 0 ? $thirdpartyid : '');
-		$_SESSION['CASHDESK_ID_WAREHOUSE'] = ($warehouseid > 0 ? $warehouseid : '');
-
-		$_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] = ($bankid_cash > 0 ? $bankid_cash : '');
-		$_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] = ($bankid_cheque > 0 ? $bankid_cheque : '');
-		$_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] = ($bankid_cb > 0 ? $bankid_cb : '');
-		//var_dump($_SESSION);exit;
-
-		header('Location: '.DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=facturation&id=NOUV');
-		exit;
-	} else {
-		dol_print_error($db);
-	}
-} else {
-	// Load translation files required by the page
-	$langs->loadLangs(array("other", "errors"));
-	$retour = $langs->trans("ErrorBadLoginPassword");
-	header('Location: '.DOL_URL_ROOT.'/cashdesk/index.php?err='.urlencode($retour).'&user='.$username.'&socid='.$thirdpartyid.'&warehouseid='.$warehouseid);
-	exit;
-}

+ 0 - 73
htdocs/cashdesk/javascript/dhtml.js

@@ -1,73 +0,0 @@
-
-/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
- * Copyright (C) 2015		Regis Houssin		<regis.houssin@inodbox.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// Instanciation et initialisation de l'objet xmlhttprequest
-function file(fichier) {
-
-	// Instanciation de l'objet pour Mozilla, Konqueror, Opera, Safari, etc ...
-	if (window.XMLHttpRequest) {
-
-		xhr_object = new XMLHttpRequest ();
-
-	// ... ou pour IE
-	} else if (window.ActiveXObject) {
-
-		xhr_object = new ActiveXObject ("Microsoft.XMLHTTP");
-
-	} else {
-
-		return (false);
-
-	}
-
-	xhr_object.open ("GET", fichier, false);
-	xhr_object.send (null);
-
-	if (xhr_object.readyState == 4) {
-
-		return (xhr_object.responseText);
-
-	} else {
-
-		return (false);
-
-	}
-
-}
-
-
-// aCible : id du bloc de destination; aCode : argument a passer a la page php chargee du traitement et de l'affichage
-function verifResultat(aCible, aCode, iLimit) {
-	if (aCode != '' && aCode.length >= iLimit) {
-
-		if (texte = file('facturation_dhtml.php?code='+escape(aCode))) {
-			document.getElementById(aCible).innerHTML = texte;
-		} else
-			document.getElementById(aCible).innerHTML = '';
-	}
-
-}
-
-
-// Change dynamiquement la classe de l'element ayant l'id aIdElement pour aClasse
-function setStyle(aIdElement, aClasse) {
-
-	aIdElement.className = aClasse;
-
-}
-

+ 0 - 175
htdocs/cashdesk/javascript/facturation1.js

@@ -1,175 +0,0 @@
-
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// Calcul et affichage en temps reel des informations sur le produit en cours
-function modif() {
-
-	var prix_unit = parseFloat ( document.getElementById('frmQte').txtPrixUnit.value );
-	var qte = parseFloat ( document.getElementById('frmQte').txtQte.value );
-	var _index = parseFloat ( document.getElementById('frmQte').selTva.selectedIndex );
-	var tva = parseFloat ( document.getElementById('frmQte').selTva.options[_index].text );
-	var remise = parseInt ( document.getElementById('frmQte').txtRemise.value );
-	var stock = document.getElementById('frmQte').txtStock.value;
-
-// 		// On s'assure que la quantitee tapee ne depasse pas le stock
-// 		if ( qte > stock ) {
-//
-// 			qte = stock;
-// 			document.getElementById('frmQte').txtQte.value = qte;
-//
-// 		}
-//
-// 		if ( qte < 1 ) {
-//
-// 			qte = 1;
-// 			document.getElementById('frmQte').txtQte.value = qte;
-//
-// 		}
-//
-// 		if ( !stock || stock <= 0 ) {
-//
-// 			qte = 0;
-// 			document.getElementById('frmQte').txtQte.value = qte;
-//
-// 		}
-
-	// Calcul du total HT, sans remise
-	var total_ht = Math.round ( (prix_unit * qte) * 100 ) / 100;
-
-	// Calcul du montant de la remise, apres s'etre assure que cette derniere ne soit pas negative
-	if ( remise <= 0 ) {
-
-		document.getElementById('frmQte').txtRemise.value = 0;
-		montant_remise = 0;
-
-	} else {
-
-		var montant_remise = total_ht * remise / 100;
-
-	}
-
-	// Recalcul du montant total, avec la remise
-	var total = Math.round ( (total_ht - montant_remise) *100 ) / 100;
-
-	// Affichage du resultat dans le formulaire
-	document.getElementById('frmQte').txtTotal.value = total.toFixed(2);
-
-}
-
-// Affecte la source de la requete (liste deroulante ou champ texte 'ref') au champ cache
-function setSource(aSrc) {
-
-	document.getElementById('frmFacturation').hdnSource.value = aSrc;
-	document.getElementById('frmFacturation').submit();
-
-}
-
-// Verification de la coherence des informations saisies dans le formulaire de choix du nombre d'articles
-function verifSaisie() {
-
-	if ( document.getElementById('frmQte').txtQte.value ) {
-
-		return true;
-
-	} else {
-
-		document.getElementById('frmQte').txtQte.focus();
-		return false;
-
-	}
-
-}
-
-// Verification de la coherence des informations saisies dans le formulaire de calcul de la difference
-function verifDifference() {
-
-	var du = parseFloat ( document.getElementById('frmDifference').txtDu.value );
-	var encaisse = parseFloat ( document.getElementById('frmDifference').txtEncaisse.value );
-
-	if (encaisse > du) {
-
-		resultat = Math.round ( (encaisse - du) * 100 ) / 100;
-		document.getElementById('frmDifference').txtRendu.value = resultat.toFixed(2);
-
-	} else if (encaisse == du) {
-
-		document.getElementById('frmDifference').txtRendu.value = '0';
-
-	} else {
-
-		document.getElementById('frmDifference').txtRendu.value = '-';
-
-	}
-
-}
-
-// Affecte le moyen de paiement (ESP, CB ou CHQ) au champ cache en fonction du bouton clique
-function verifClic(aChoix) {
-
-	document.getElementById('frmDifference').hdnChoix.value = aChoix;
-
-}
-
-// Determination du moyen de paiement, et validation du formulaire si les donnees sont coherentes
-function verifReglement() {
-
-	var choix = document.getElementById('frmDifference').hdnChoix.value;
-	var du = parseFloat (document.getElementById('frmDifference').txtDu.value);
-	var encaisse = parseFloat (document.getElementById('frmDifference').txtEncaisse.value);
-
-	if ( du > 0 ) {
-
-		if ( choix == 'ESP' ) {
-
-			if ( encaisse != 0 && encaisse >= du ) {
-
-				return true;
-
-			} else {
-
-				document.getElementById('frmDifference').txtEncaisse.select();
-				document.getElementById('frmDifference').txtEncaisse.focus();
-				return false;
-
-			}
-
-		} else if ( choix == 'DIF' ) {
-
-			if ( document.getElementById('frmDifference').txtDatePaiement.value ) {
-
-				return true;
-
-			} else {
-
-				document.getElementById('frmDifference').txtDatePaiement.select();
-				document.getElementById('frmDifference').txtDatePaiement.focus();
-				return false;
-
-			}
-
-		} else {
-
-			return true;
-
-		}
-
-	} else {
-
-		return false;
-
-	}
-}

+ 0 - 36
htdocs/cashdesk/javascript/keypad.js

@@ -1,36 +0,0 @@
-/* Copyright (C) 2014	Charles-FR BENKE		<charles.fr@benke.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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-function closekeypad(keypadname)
-{
-	document.getElementById('keypad'+keypadname).style.display='none';
-	document.getElementById('closekeypad'+keypadname).style.display='none';
-	document.getElementById('openkeypad'+keypadname).style.display='inline-block';
-}
-function openkeypad(keypadname)
-{
-	document.getElementById('keypad'+keypadname).style.display='inline-block';
-	document.getElementById('closekeypad'+keypadname).style.display='inline-block';
-	document.getElementById('openkeypad'+keypadname).style.display='none';
-}
-function addvalue(keypadname, formname, valueToAdd)
-{
-	myform=document.forms[formname];
-	if (myform.elements[keypadname].value=="0")
-		myform.elements[keypadname].value="";
-	myform.elements[keypadname].value+=valueToAdd;
-	modif();
-}

+ 0 - 225
htdocs/cashdesk/tpl/facturation1.tpl.php

@@ -1,225 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
- * Copyright (C) 2011		Laurent Destailleur	<eldy@users.sourceforge.net>
- * Copyright (C) 2011		Juanjo Menent		<jmenent@2byte.es>
- * Copyright (C) 2015		Regis Houssin		<regis.houssin@inodbox.com>
- * Copyright (C) 2018       Frédéric France         <frederic.france@netlogic.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
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "bills", "cashdesk"));
-
-// Object $form must de defined
-
-?>
-
-<script type="text/javascript" src="javascript/facturation1.js"></script>
-<script type="text/javascript" src="javascript/dhtml.js"></script>
-<script type="text/javascript" src="javascript/keypad.js"></script>
-
-<!-- ========================= Cadre "Article" ============================= -->
-<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Article"); ?></legend>
-	<form id="frmFacturation" class="formulaire1" method="post" action="facturation_verif.php" autocomplete="off">
-		<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
-
-		<input type="hidden" name="hdnSource" value="NULL" />
-
-		<table class="center">
-			<tr><th class="label1"><?php echo $langs->trans("FilterRefOrLabelOrBC"); ?></th><th class="label1"><?php echo $langs->trans("Designation"); ?></th></tr>
-			<tr>
-			<!-- Affichage de la reference et de la designation -->
-			<!-- Suppression de l'attribut onkeyup qui causait un probleme d'emulation avec les douchettes -->
-			<td><input class="texte_ref" type="text" id ="txtRef" name="txtRef" value="<?php echo $obj_facturation->ref() ?>"
-				onchange="javascript: setSource('REF');"
-				onfocus="javascript: this.select();" />
-			</td>
-			<td class="select_design maxwidthonsmartphone">
-				<select id="selProduit" class="maxwidthonsmartphone" name="selProduit" onchange="javascript: setSource('LISTE');">
-<?php
-print '<option value="0">'.$top_liste_produits.'</option>'."\n";
-
-$id = $obj_facturation->id();
-
-// Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ...
-
-$nbtoshow = $nbr_enreg;
-if (!empty($conf_taille_listes) && $nbtoshow > $conf_taille_listes) {
-	$nbtoshow = $conf_taille_listes;
-}
-
-for ($i = 0; $i < $nbtoshow; $i++) {
-	if ($id == $tab_designations[$i]['rowid']) {
-		$selected = 'selected';
-	} else {
-		$selected = '';
-	}
-
-	$label = $tab_designations[$i]['label'];
-
-	print '<option '.$selected.' value="'.$tab_designations[$i]['rowid'].'">'.dol_trunc($tab_designations[$i]['ref'], 16).' - '.dol_trunc($label, 35, 'middle');
-	if (!empty($conf->stock->enabled) && !empty($conf_fkentrepot) && $tab_designations[$i]['fk_product_type'] == 0) {
-		print ' ('.$langs->trans("CashDeskStock").': '.(empty($tab_designations[$i]['reel']) ? 0 : $tab_designations[$i]['reel']).')';
-	}
-	print '</option>'."\n";
-}
-?>
-				</select>
-			</td>
-			</tr>
-		</table>
-	</form>
-
-	<form id="frmQte" class="formulaire1" method="post" action="facturation_verif.php?action=ajout_article" onsubmit ="javascript: return verifSaisie();">
-		<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
-		<table class="center">
-			<tr>
-			<th><?php echo $langs->trans("Qty"); ?></th>
-			<th><?php echo $langs->trans("PriceUHT"); ?></th>
-			<th><?php echo $langs->trans("Discount"); ?> (%)</th>
-			<th><?php echo $langs->trans("VATRate"); ?></th>
-			<th></th>
-			</tr>
-			<tr>
-				<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtQte" name="txtQte" value="1" onkeyup="javascript: modif();" onfocus="javascript: this.select();" />
-<?php print genkeypad("txtQte", "frmQte"); ?>
-				</td>
-				<!-- Show unit price -->
-				<?php // TODO Remove the disabled and use this value when adding product into cart ?>
-				<td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtPrixUnit" value="<?php echo price2num($obj_facturation->prix(), 'MU'); ?>" onchange="javascript: modif();" disabled /></td>
-				<!-- Choix de la remise -->
-				<td><input class="texte1 maxwidth50onsmartphone" type="text" id="txtRemise" name="txtRemise" value="0" onkeyup="javascript: modif();" onfocus="javascript: this.select();"/>
-					<?php print genkeypad("txtRemise", "frmQte"); ?>
-				</td>
-				<!-- Choix du taux de TVA -->
-				<td class="select_tva center">
-				<?php
-					$vatrate = $obj_facturation->vatrate; // To get vat rate we just have selected
-
-					$buyer = new Societe($db);
-				if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) {
-					$buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
-				}
-					echo $form->load_tva('selTva', (GETPOSTISSET("selTva") ? GETPOST("selTva", 'alpha', 2) : $vatrate), $mysoc, $buyer, 0, 0, '', false, -1);
-				?>
-				</td>
-				<td></td>
-			</tr>
-			<tr>
-				<!-- Affichage du stock pour l'article courant -->
-			<tr>
-				<td><?php echo $langs->trans("Stock"); ?></td>
-				<td>
-				<input class="texte1_off maxwidth50onsmartphone" type="text" name="txtStock" value="<?php echo $obj_facturation->stock() ?>" disabled />
-				</td>
-				<td><?php echo $langs->trans("TotalHT"); ?></td>
-				<!-- Affichage du total HT -->
-				<td colspan="2"><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td>
-			</tr>
-
-		</table>
-
-		<input class="button bouton_ajout_article" type="submit" id="sbmtEnvoyer" value="<?php echo $langs->trans("AddThisArticle"); ?>" />
-	</form>
-</fieldset>
-
-<!-- ========================= Cadre "Amount" ============================= -->
-<form id="frmDifference"  class="formulaire1" method="post" onsubmit="javascript: return verifReglement()" action="validation_verif.php?action=validate_sell">
-	<input type="hidden" name="hdnChoix" value="" />
-	<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
-<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Amount"); ?></legend>
-		<table class="centpercent">
-			<tr><th class="label1"><?php echo $langs->trans("TotalTicket"); ?></th><th class="label1"><?php echo $langs->trans("Received"); ?></th><th class="label1"><?php echo $langs->trans("Change"); ?></th></tr>
-			<tr>
-			<!-- Affichage du montant du -->
-			<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtDu" value="<?php echo price2num($obj_facturation->amountWithTax(), 'MT'); ?>" disabled /></td>
-			<!-- Choix du montant encaisse -->
-			<td><input class="texte2 maxwidth100onsmartphone" type="text" id="txtEncaisse" name="txtEncaisse" value="" onkeyup="javascript: verifDifference();" onfocus="javascript: this.select();" />
-<?php print genkeypad("txtEncaisse", "frmDifference"); ?>
-			</td>
-			<!-- Affichage du montant rendu -->
-			<td><input class="texte2_off maxwidth100onsmartphone" type="text" name="txtRendu" value="0" disabled /></td>
-			</tr>
-			<tr>
-		</table>
-</fieldset>
-
-<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("PaymentMode"); ?></legend>
-		<div class="inline-block">
-			<?php
-			print '<div class="inline-block" style="margin: 6px;">';
-			if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CASH']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CASH'] < 0) {
-				$langs->load("errors");
-				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("Cash").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
-			} else {
-				print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("Cash").'" onclick="javascript: verifClic(\'ESP\');" />';
-			}
-			print '</div>';
-			print '<div class="inline-block" style="margin: 6px;">';
-			if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CB']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CB'] < 0) {
-				$langs->load("errors");
-				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete", $langs->transnoentitiesnoconv("CashDesk"))).'" />';
-			} else {
-				print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CreditCard").'" onclick="javascript: verifClic(\'CB\');" />';
-			}
-			print '</div>';
-			print '<div class="inline-block" style="margin: 6px;">';
-			if (empty($_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE']) || $_SESSION['CASHDESK_ID_BANKACCOUNT_CHEQUE'] < 0) {
-				$langs->load("errors");
-				print '<input class="bouton_mode_reglement_disabled" type="button" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" title="'.dol_escape_htmltag($langs->trans("ErrorModuleSetupNotComplete"), $langs->transnoentitiesnoconv("CashDesk")).'" />';
-			} else {
-				print '<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="'.$langs->trans("CheckBank").'" onclick="javascript: verifClic(\'CHQ\');" />';
-			}
-			print '</div>';
-			print '<div class="clearboth">';
-			print '<div class="inline-block" style="margin: 6px;">';
-			?>
-				<input class="button bouton_mode_reglement" type="submit" name="btnModeReglement" value="<?php echo $langs->trans("Reported"); ?>" onclick="javascript: verifClic('DIF');" />
-			<?php
-			print $langs->trans("DateDue").' :';
-			print $form->selectDate(-1, 'txtDatePaiement', 0, 0, 0, 'paymentmode', 1, 0);
-			print '</div>';
-			?>
-		</div>
-</fieldset>
-</form>
-
-<script type="text/javascript">
-/*	Calendar.setup ({
-		inputField	: "txtDatePaiement",
-		ifFormat	: "%Y-%m-%d",
-		button		: "btnCalendrier"
-	});
-*/
-	if (document.getElementById('frmFacturation').txtRef.value) {
-
-		modif();
-		document.getElementById('frmQte').txtQte.focus();
-		document.getElementById('frmQte').txtQte.select();
-
-	} else {
-
-		document.getElementById('frmFacturation').txtRef.focus();
-
-	}
-
-</script>

+ 0 - 73
htdocs/cashdesk/tpl/liste_articles.tpl.php

@@ -1,73 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
- * Copyright (C) 2011		Juanjo Menent		<jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-
-require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "bills", "cashdesk"));
-
-?>
-
-<div class="liste_articles_haut">
-<div class="liste_articles_bas">
-
-<p class="titre"><?php echo $langs->trans("ShoppingCart"); ?></p>
-
-<?php
-/** add Ditto for MultiPrix*/
-$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-$societe = new Societe($db);
-$societe->fetch($thirdpartyid);
-/** end add Ditto */
-
-$tab = (!empty($_SESSION['poscart']) ? $_SESSION['poscart'] : array());
-
-$tab_size = count($tab);
-if ($tab_size <= 0) {
-	print '<div class="center">'.$langs->trans("NoArticle").'</div><br>';
-} else {
-	for ($i = 0; $i < $tab_size; $i++) {
-		echo ('<div class="cadre_article">'."\n");
-		echo ('<p><a href="facturation_verif.php?action=suppr_article&suppr_id='.$tab[$i]['id'].'" title="'.$langs->trans("DeleteArticle").'">'.$tab[$i]['ref'].' - '.$tab[$i]['label'].'</a></p>'."\n");
-
-		if ($tab[$i]['remise_percent'] > 0) {
-			$remise_percent = ' -'.$tab[$i]['remise_percent'].'%';
-		} else {
-			$remise_percent = '';
-		}
-
-		$remise = $tab[$i]['remise'];
-
-		echo ('<p>'.$tab[$i]['qte'].' x '.price2num($tab[$i]['price'], 'MT').$remise_percent.' = '.price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("HT").' ('.price(price2num($tab[$i]['total_ttc'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency).' '.$langs->trans("TTC").')</p>'."\n");
-		echo ('</div>'."\n");
-	}
-}
-
-echo ('<p class="cadre_prix_total">'.$langs->trans("Total").' : '.price(price2num($total_ttc, 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'<br></p>'."\n");
-
-?></div>
-</div>

+ 0 - 90
htdocs/cashdesk/tpl/menu.tpl.php

@@ -1,90 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier      <jeremie.o@laposte.net>
- * Copyright (C) 2008-2010 Laurent Destailleur   <eldy@uers.sourceforge.net>
- * Copyright (C) 2009      Regis Houssin         <regis.houssin@inodbox.com>
- * Copyright (C) 2017      Juanjo Menent         <jmenent@2byte.es>
- * Copyright (C) 2012      Marcos García         <marcosgdf@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-
-include_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
-include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-include_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
-
-/*if (!empty($_SESSION["CASHDESK_ID_THIRDPARTY"]))
-{
-	$company=new Societe($db);
-	$company->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
-	$companyLink = $company->getNomUrl(1);
-}*/
-if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) {
-	$bankcash = new Account($db);
-	$bankcash->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"]);
-	$bankcash->label = $bankcash->ref;
-	$bankcashLink = $bankcash->getNomUrl(1);
-}
-if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) {
-	$bankcb = new Account($db);
-	$bankcb->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"]);
-	$bankcbLink = $bankcb->getNomUrl(1);
-}
-if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) {
-	$bankcheque = new Account($db);
-	$bankcheque->fetch($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"]);
-	$bankchequeLink = $bankcheque->getNomUrl(1);
-}
-if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled)) {
-	$warehouse = new Entrepot($db);
-	$warehouse->fetch($_SESSION["CASHDESK_ID_WAREHOUSE"]);
-	$warehouseLink = $warehouse->getNomUrl(1);
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "cashdesk"));
-
-print "\n".'<!-- menu.tpl.php -->'."\n";
-print '<div class="menu_bloc">';
-print '<ul class="menu">';
-// Link to new sell
-print '<li class="menu_choix1"><a href="affIndex.php?menutpl=facturation&id=NOUV"><span class="hideonsmartphone">'.$langs->trans("NewSell").'</span></a></li>';
-// Open new tab on backoffice (this is not a disconnect from POS)
-print '<li class="menu_choix2"><a href=".." target="backoffice"><span class="hideonsmartphone">'.$langs->trans("BackOffice").'</span></a></li>';
-// Disconnect
-print '<li class="menu_choix0"><div class="cashdeskloginuser marginbottomonly valignmiddle"><div class="inline-block valignmiddle">'.$langs->trans("User").': '.$_SESSION['firstname'].' '.$_SESSION['lastname'].'</div>';
-print '<div class="inline-block valignmiddle"> <a href="deconnexion.php">'.img_picto($langs->trans('Logout'), 'logout.png').'</a></div></div>';
-print '<form id="frmThirdparty" class="formulaire1 inline-block" method="post" action="facturation_verif.php?action=change_thirdparty">';
-print $langs->trans("CashDeskThirdParty").': ';
-print $form->select_company($_SESSION["CASHDESK_ID_THIRDPARTY"], 'CASHDESK_ID_THIRDPARTY', '(s.client IN (1,3) AND s.status = 1)', '', 0, 0, null, 0, 'valignmiddle inline-block');
-print '<input class="button bouton_change_thirdparty inline-block valignmiddle" type="submit" id="bouton_change_thirdparty" value="'.$langs->trans("Modify").'">';
-//print $companyLink;
-print '<br>';
-print '</form>';
-/*print $langs->trans("CashDeskBankCash").': '.$bankcashLink.'<br>';
-print $langs->trans("CashDeskBankCB").': '.$bankcbLink.'<br>';
-print $langs->trans("CashDeskBankCheque").': '.$bankchequeLink.'<br>';*/
-print '<div class="clearboth">';
-if (!empty($_SESSION["CASHDESK_ID_WAREHOUSE"]) && !empty($conf->stock->enabled) && empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
-	print $langs->trans("CashDeskWarehouse").': '.$warehouseLink;
-}
-print '</div></li></ul>';
-print '</div>';
-print "\n".'<!-- menu.tpl.php end -->'."\n";

+ 0 - 119
htdocs/cashdesk/tpl/ticket.tpl.php

@@ -1,119 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier    <jeremie.o@laposte.net>
- * Copyright (C) 2011      Laurent Destailleur <eldy@users.sourceforge.net>
- * Copyright (C) 2012      Marcos García       <marcosgdf@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-
-include_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "cashdesk"));
-
-top_httphead('text/html');
-
-$facid = GETPOST('facid', 'int');
-$object = new Facture($db);
-$object->fetch($facid);
-
-?>
-<html>
-	<head>
-	<title><?php echo $langs->trans('PrintTicket') ?></title>
-	<link rel="stylesheet" type="text/css" href="<?php echo DOL_URL_ROOT; ?>/cashdesk/css/ticket.css">
-</head>
-
-<body>
-
-<div class="entete">
-	<div class="logo">
-		<?php print '<img src="'.DOL_URL_ROOT.'/viewimage.php?modulepart=mycompany&amp;file='.urlencode('logos/thumbs/'.$mysoc->logo_small).'">'; ?>
-	</div>
-	<div class="infos">
-		<p class="address"><?php echo $mysoc->name; ?><br>
-		<?php print dol_nl2br(dol_format_address($mysoc)); ?><br>
-		</p>
-
-		<p class="date_heure"><?php
-		// Recuperation et affichage de la date et de l'heure
-		$now = dol_now();
-		print dol_print_date($now, 'dayhourtext').'<br>';
-		print $object->ref;
-		?></p>
-	</div>
-</div>
-
-<br>
-
-<table class="liste_articles">
-	<thead>
-	<tr class="titres">
-			<th><?php print $langs->trans("Code"); ?></th>
-			<th><?php print $langs->trans("Label"); ?></th>
-			<th><?php print $langs->trans("Qty"); ?></th>
-			<th><?php print $langs->trans("Discount").' (%)'; ?></th>
-			<th><?php print $langs->trans("TotalHT"); ?></th>
-	</tr>
-	</thead>
-	<tbody>
-	<?php
-
-	$tab = array();
-	$tab = $_SESSION['poscart'];
-
-	$tab_size = count($tab);
-	for ($i = 0; $i < $tab_size; $i++) {
-		$remise = $tab[$i]['remise'];
-		?>
-	<tr>
-		<td><?php echo $tab[$i]['ref']; ?></td>
-		<td><?php echo $tab[$i]['label']; ?></td>
-		<td><?php echo $tab[$i]['qte']; ?></td>
-		<td><?php echo $tab[$i]['remise_percent']; ?></td>
-		<td class="total"><?php echo price(price2num($tab[$i]['total_ht'], 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td>
-	</tr>
-		<?php
-	}
-	?>
-	</tbody>
-</table>
-
-<table class="totaux">
-<tr>
-	<th class="nowrap"><?php echo $langs->trans("TotalHT"); ?></th>
-	<td class="nowrap"><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
-</tr>
-<tr>
-	<th class="nowrap"><?php echo $langs->trans("TotalVAT").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountVat(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
-</tr>
-<tr>
-	<th class="nowrap"><?php echo ''.$langs->trans("TotalTTC").'</th><td class="nowrap">'.price(price2num($obj_facturation->amountWithTax(), 'MT'), '', $langs, 0, -1, -1, $conf->currency)."\n"; ?></td>
-</tr>
-</table>
-
-<script type="text/javascript">
-	window.print();
-</script>
-
-<a class="lien" href="#" onclick="javascript: window.close(); return(false);"><?php echo $langs->trans("Close"); ?></a>
-</body>
-</html>

+ 0 - 118
htdocs/cashdesk/tpl/validation1.tpl.php

@@ -1,118 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
- * Copyright (C) 2011		Juanjo Menent		<jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "bills", "banks"));
-
-// Object $form must de defined
-
-?>
-
-<fieldset class="cadre_facturation"><legend class="titre1"><?php echo $langs->trans("Summary"); ?></legend>
-
-	<table class="table_resume">
-
-		<tr><td class="resume_label"><?php echo $langs->trans("Invoice"); ?></td><td><?php  echo $obj_facturation->numInvoice(); ?></td></tr>
-		<tr><td class="resume_label"><?php echo $langs->trans("TotalHT"); ?></td><td><?php echo price(price2num($obj_facturation->amountWithoutTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
-<?php
-// Affichage de la tva par taux
-if ($obj_facturation->amountVat()) {
-	echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->amountVat(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
-} else {
-	echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.$langs->trans("NoVAT").'</td></tr>');
-}
-?>
-		<tr><td class="resume_label"><?php echo $langs->trans("TotalTTC"); ?> </td><td><?php echo price(price2num($obj_facturation->amountWithTax(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
-		<tr><td class="resume_label"><?php echo $langs->trans("PaymentMode"); ?> </td><td>
-		<?php
-		switch ($obj_facturation->getSetPaymentMode()) {
-			case 'ESP':
-				echo $langs->trans("Cash");
-				$filtre = 'courant=2';
-				if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"])) {
-					$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CASH"];
-				}
-				break;
-			case 'CB':
-				echo $langs->trans("CreditCard");
-				$filtre = 'courant=1';
-				if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CB"])) {
-					$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CB"];
-				}
-				break;
-			case 'CHQ':
-				echo $langs->trans("Cheque");
-				$filtre = 'courant=1';
-				if (!empty($_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"])) {
-					$selected = $_SESSION["CASHDESK_ID_BANKACCOUNT_CHEQUE"];
-				}
-				break;
-			case 'DIF':
-				echo $langs->trans("Reported");
-				$filtre = 'courant=1 OR courant=2';
-				$selected = '';
-				break;
-			default:
-				$filtre = 'courant=1 OR courant=2';
-				$selected = '';
-		}
-
-		?>
-		</td></tr>
-
-<?php
-// Affichage des infos en fonction du mode de paiement
-if ($obj_facturation->getsetPaymentMode() == 'DIF') {
-	echo ('<tr><td class="resume_label">'.$langs->trans("DateDue").'</td><td>'.$obj_facturation->paiementLe().'</td></tr>');
-} else {
-	echo ('<tr><td class="resume_label">'.$langs->trans("Received").'</td><td>'.price(price2num($obj_facturation->amountCollected(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
-}
-
-// Affichage du montant rendu (reglement en especes)
-if ($obj_facturation->amountReturned()) {
-	echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price(price2num($obj_facturation->amountReturned(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
-}
-
-?>
-
-	</table>
-
-	<form id="frmValidation" class="formulaire2" method="post" action="validation_verif.php?action=validate_invoice">
-		<input type="hidden" name="token" value="<?php echo newToken(); ?>" />
-		<p class="note_label">
-			<?php
-				echo $langs->trans("BankToPay")."<br>";
-				$form->select_comptes($selected, 'cashdeskbank', 0, $filtre);
-			?>
-		</p>
-		<p class="note_label"><?php echo $langs->trans("Notes"); ?><br><textarea class="textarea_note" name="txtaNotes"></textarea></p>
-
-		<div class="center"><input class="button" type="submit" name="btnValider" value="<?php echo $langs->trans("ValidateInvoice"); ?>" /><br>
-		<br><a class="lien1" href="affIndex.php?menutpl=facturation"><?php echo $langs->trans("RestartSelling"); ?></a>
-		</div>
-	</form>
-
-
-
-</fieldset>

+ 0 - 57
htdocs/cashdesk/tpl/validation2.tpl.php

@@ -1,57 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008	Jeremie Ollivier	<jeremie.o@laposte.net>
- * Copyright (C) 2012       Marcos García       <marcosgdf@gmail.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-// Protection to avoid direct call of template
-if (empty($langs) || !is_object($langs)) {
-	print "Error, template page can't be called as URL";
-	exit;
-}
-
-// Load translation files required by the page
-$langs->loadLangs(array("main", "bills"));
-
-?>
-
-<div class="blocksellfinished">
-
-<div class="cadre_facturation">
-<h3 class="titre1"><?php echo $langs->trans("SellFinished"); ?></h3><br>
-
-<script type="text/javascript">
-
-	function popupTicket(id,name)
-	{
-		largeur = 600;
-		hauteur = 500;
-		opt = 'width='+largeur+', height='+hauteur+', left='+(screen.width - largeur)/2+', top='+(screen.height-hauteur)/2+'';
-		window.open('validation_ticket.php?facid='+id,name, opt);
-	}
-
-	popupTicket(<?php echo GETPOST('facid', 'int'); ?>,'<?php echo $langs->trans('PrintTicket') ?>');
-
-</script>
-
-<p><a class="lien1" href="<?php echo DOL_URL_ROOT ?>/compta/facture/card.php?action=builddoc&facid=<?php echo GETPOST('facid', 'int'); ?>" target="_blank"><?php echo $langs->trans("ShowInvoice"); ?></a></p>
-<br>
-<p><a class="lien1" href="#" onclick="Javascript: popupTicket(<?php echo GETPOST('facid', 'int'); ?>,'<?php echo $langs->trans('PrintTicket') ?>'); return(false);"><?php echo $langs->trans("PrintTicket"); ?></a></p>
-
-</div>
-</div>
-<br>
-

+ 0 - 27
htdocs/cashdesk/validation.php

@@ -1,27 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/validation.php
- *	\ingroup    cashdesk
- *	\brief      validation.php
- */
-
-$form = new Form($db);
-
-// Affichage des templates
-require 'tpl/validation1.tpl.php';

+ 0 - 25
htdocs/cashdesk/validation_ok.php

@@ -1,25 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/validation_ok.php
- *	\ingroup    cashdesk
- *	\brief      validation_ok.php
- */
-
-// Affichage des templates
-require 'tpl/validation2.tpl.php';

+ 0 - 50
htdocs/cashdesk/validation_ticket.php

@@ -1,50 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier <jeremie.o@laposte.net>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/validation_ticket.php
- *	\ingroup    cashdesk
- *	\brief      validation_ticket.php
- */
-
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * Actions
- */
-
-$obj_facturation = unserialize($_SESSION['serObjFacturation']);
-unset($_SESSION['serObjFacturation']);
-
-$hookmanager->initHooks(array('cashdeskTplTicket'));
-
-$parameters = array();
-$reshook = $hookmanager->executeHooks('doActions', $parameters, $obj_facturation);
-if (empty($reshook)) {
-	require 'tpl/ticket.tpl.php';
-}
-
-
-$_SESSION['serObjFacturation'] = serialize($obj_facturation);

+ 0 - 361
htdocs/cashdesk/validation_verif.php

@@ -1,361 +0,0 @@
-<?php
-/* Copyright (C) 2007-2008 Jeremie Ollivier    <jeremie.o@laposte.net>
- * Copyright (C) 2008-2009 Laurent Destailleur <eldy@uers.sourceforge.net>
- * Copyright (C) 2011	   Juanjo Menent	   <jmenent@2byte.es>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- */
-
-/**
- *	\file       htdocs/cashdesk/validation_verif.php
- *	\ingroup    cashdesk
- *	\brief      validation_verif.php
- */
-
-require '../main.inc.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/include/environnement.php';
-require_once DOL_DOCUMENT_ROOT.'/cashdesk/class/Facturation.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
-require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
-
-$obj_facturation = unserialize($_SESSION['serObjFacturation']);
-
-$action = GETPOST('action', 'aZ09');
-$bankaccountid = GETPOST('cashdeskbank');
-
-if (empty($user->rights->cashdesk->run)) {
-	accessforbidden();
-}
-
-
-/*
- * Actions
- */
-
-switch ($action) {
-	default:
-		$redirection = DOL_URL_ROOT.'/cashdesk/affIndex.php?menutpl=validation';
-		break;
-
-	case 'validate_sell':
-		$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-
-		$company = new Societe($db);
-		$company->fetch($thirdpartyid);
-
-		$invoice = new Facture($db);
-		$invoice->date = dol_now();
-		$invoice->type = Facture::TYPE_STANDARD;
-
-		// To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here
-		// and restore values just after
-		$sav_FACTURE_ADDON = '';
-		if (!empty($conf->global->POS_ADDON)) {
-			$sav_FACTURE_ADDON = $conf->global->FACTURE_ADDON;
-			$conf->global->FACTURE_ADDON = $conf->global->POS_ADDON;
-
-			// To force prefix only for POS with terre module
-			if (!empty($conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX)) {
-				$conf->global->INVOICE_NUMBERING_TERRE_FORCE_PREFIX = $conf->global->POS_NUMBERING_TERRE_FORCE_PREFIX;
-			}
-			// To force prefix only for POS with mars module
-			if (!empty($conf->global->POS_NUMBERING_MARS_FORCE_PREFIX)) {
-				$conf->global->INVOICE_NUMBERING_MARS_FORCE_PREFIX = $conf->global->POS_NUMBERING_MARS_FORCE_PREFIX;
-			}
-			// To force rule only for POS with mercure
-			//...
-		}
-
-		$num = $invoice->getNextNumRef($company);
-
-		// Restore save values
-		if (!empty($sav_FACTURE_ADDON)) {
-			$conf->global->FACTURE_ADDON = $sav_FACTURE_ADDON;
-		}
-
-		$obj_facturation->numInvoice($num);
-
-		$obj_facturation->getSetPaymentMode($_POST['hdnChoix']);
-
-		// Si paiement autre qu'en especes, montant encaisse = prix total
-		$mode_reglement = $obj_facturation->getSetPaymentMode();
-		if ($mode_reglement != 'ESP') {
-			$montant = $obj_facturation->amountWithTax();
-		} else {
-			$montant = $_POST['txtEncaisse'];
-		}
-
-		if ($mode_reglement != 'DIF') {
-			$obj_facturation->amountCollected($montant);
-
-			//Determination de la somme rendue
-			$total = $obj_facturation->amountWithTax();
-			$encaisse = $obj_facturation->amountCollected();
-
-			$obj_facturation->amountReturned($encaisse - $total);
-		} else {
-			//$txtDatePaiement=$_POST['txtDatePaiement'];
-			$datePaiement = dol_mktime(0, 0, 0, $_POST['txtDatePaiementmonth'], $_POST['txtDatePaiementday'], $_POST['txtDatePaiementyear']);
-			$txtDatePaiement = dol_print_date($datePaiement, 'dayrfc');
-			$obj_facturation->paiementLe($txtDatePaiement);
-		}
-
-		$redirection = 'affIndex.php?menutpl=validation';
-		break;
-
-
-	case 'retour':
-		$redirection = 'affIndex.php?menutpl=facturation';
-		break;
-
-
-	case 'validate_invoice':
-		$now = dol_now();
-
-		// Recuperation de la date et de l'heure
-		$date = dol_print_date($now, 'day');
-		$heure = dol_print_date($now, 'hour');
-
-		$note = '';
-		if (!is_object($obj_facturation)) {
-			dol_print_error('', 'Empty context');
-			exit;
-		}
-
-		switch ($obj_facturation->getSetPaymentMode()) {
-			case 'DIF':
-				$mode_reglement_id = 0;
-				//$cond_reglement_id = dol_getIdFromCode($db,'RECEP','cond_reglement','code','rowid')
-				$cond_reglement_id = 0;
-				break;
-			case 'ESP':
-				$mode_reglement_id = dol_getIdFromCode($db, 'LIQ', 'c_paiement', 'code', 'id', 1);
-				$cond_reglement_id = 0;
-				$note .= $langs->trans("Cash")."\n";
-				$note .= $langs->trans("Received").' : '.$obj_facturation->amountCollected()." ".$conf->currency."\n";
-				$note .= $langs->trans("Rendu").' : '.$obj_facturation->amountReturned()." ".$conf->currency."\n";
-				$note .= "\n";
-				$note .= '--------------------------------------'."\n\n";
-				break;
-			case 'CB':
-				$mode_reglement_id = dol_getIdFromCode($db, 'CB', 'c_paiement', 'code', 'id', 1);
-				$cond_reglement_id = 0;
-				break;
-			case 'CHQ':
-				$mode_reglement_id = dol_getIdFromCode($db, 'CHQ', 'c_paiement', 'code', 'id', 1);
-				$cond_reglement_id = 0;
-				break;
-		}
-		if (empty($mode_reglement_id)) {
-			$mode_reglement_id = 0; // If mode_reglement_id not found
-		}
-		if (empty($cond_reglement_id)) {
-			$cond_reglement_id = 0; // If cond_reglement_id not found
-		}
-		$note .= GETPOST('txtaNotes', 'alphanohtml');
-		dol_syslog("obj_facturation->getSetPaymentMode()=".$obj_facturation->getSetPaymentMode()." mode_reglement_id=".$mode_reglement_id." cond_reglement_id=".$cond_reglement_id);
-
-		$error = 0;
-
-
-		$db->begin();
-
-		$user->fetch($_SESSION['uid']);
-		$user->getrights();
-
-		$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
-		$societe = new Societe($db);
-		$societe->fetch($thirdpartyid);
-
-		$invoice = new Facture($db);
-
-		// Get content of cart
-		$tab_liste = $_SESSION['poscart'];
-
-		// Loop on each line into cart
-		$tab_liste_size = count($tab_liste);
-		for ($i = 0; $i < $tab_liste_size; $i++) {
-			$tmp = getTaxesFromId($tab_liste[$i]['fk_tva']);
-			$vat_rate = $tmp['rate'];
-			$vat_npr = $tmp['npr'];
-			$vat_src_code = $tmp['code'];
-
-			$invoiceline = new FactureLigne($db);
-			$invoiceline->fk_product = $tab_liste[$i]['fk_article'];
-			$invoiceline->desc = $tab_liste[$i]['label'];
-			$invoiceline->qty = $tab_liste[$i]['qte'];
-			$invoiceline->remise_percent = $tab_liste[$i]['remise_percent'];
-			$invoiceline->price = $tab_liste[$i]['price'];
-			$invoiceline->subprice = $tab_liste[$i]['price'];
-
-			$invoiceline->tva_tx = empty($vat_rate) ? 0 : $vat_rate; // works even if vat_rate is ''
-			$invoiceline->info_bits = empty($vat_npr) ? 0 : $vat_npr;
-			$invoiceline->vat_src_code = $vat_src_code;
-
-			$invoiceline->total_ht = $tab_liste[$i]['total_ht'];
-			$invoiceline->total_ttc = $tab_liste[$i]['total_ttc'];
-			$invoiceline->total_tva = $tab_liste[$i]['total_vat'];
-			$invoiceline->total_localtax1 = $tab_liste[$i]['total_localtax1'];
-			$invoiceline->total_localtax2 = $tab_liste[$i]['total_localtax2'];
-
-			$invoice->lines[] = $invoiceline;
-		}
-
-		$invoice->socid = $conf_fksoc;
-		$invoice->date_creation = $now;
-		$invoice->date = $now;
-		$invoice->date_lim_reglement = 0;
-		$invoice->total_ht = $obj_facturation->amountWithoutTax();
-		$invoice->total_tva = $obj_facturation->amountVat();
-		$invoice->total_ttc = $obj_facturation->amountWithTax();
-		$invoice->note_private = $note;
-		$invoice->cond_reglement_id = $cond_reglement_id;
-		$invoice->mode_reglement_id = $mode_reglement_id;
-		$invoice->module_source = 'cashdesk';
-		$invoice->pos_source = '0';
-		//print "c=".$invoice->cond_reglement_id." m=".$invoice->mode_reglement_id; exit;
-
-		// Si paiement differe ...
-		if ($obj_facturation->getSetPaymentMode() == 'DIF') {
-			$resultcreate = $invoice->create($user, 0, dol_stringtotime($obj_facturation->paiementLe()));
-			if ($resultcreate > 0) {
-				$warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0);
-				if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
-					$warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice
-				}
-
-				$resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0);
-
-				if ($warehouseidtodecrease > 0) {
-					// Decrease
-					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
-					$langs->load("agenda");
-					// Loop on each line
-					$cpt = count($invoice->lines);
-					for ($i = 0; $i < $cpt; $i++) {
-						if ($invoice->lines[$i]->fk_product > 0) {
-							$mouvP = new MouvementStock($db);
-							$mouvP->origin = &$invoice;
-							// We decrease stock for product
-							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) {
-								$result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
-							} else {
-								$result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
-							}
-							if ($result < 0) {
-								$error++;
-							}
-						}
-					}
-				}
-			} else {
-				setEventMessages($invoice->error, $invoice->errors, 'errors');
-				$error++;
-			}
-
-			$id = $invoice->id;
-		} else {
-			$resultcreate = $invoice->create($user, 0, 0);
-			if ($resultcreate > 0) {
-				$warehouseidtodecrease = (isset($_SESSION["CASHDESK_ID_WAREHOUSE"]) ? $_SESSION["CASHDESK_ID_WAREHOUSE"] : 0);
-				if (!empty($conf->global->CASHDESK_NO_DECREASE_STOCK)) {
-					$warehouseidtodecrease = 0; // If a particular stock is defined, we disable choice
-				}
-
-				$resultvalid = $invoice->validate($user, $obj_facturation->numInvoice(), 0);
-
-				if ($warehouseidtodecrease > 0) {
-					// Decrease
-					require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
-					$langs->load("agenda");
-					// Loop on each line
-					$cpt = count($invoice->lines);
-					for ($i = 0; $i < $cpt; $i++) {
-						if ($invoice->lines[$i]->fk_product > 0) {
-							$mouvP = new MouvementStock($db);
-							$mouvP->origin = &$invoice;
-							// We decrease stock for product
-							if ($invoice->type == $invoice::TYPE_CREDIT_NOTE) {
-								$result = $mouvP->reception($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
-							} else {
-								$result = $mouvP->livraison($user, $invoice->lines[$i]->fk_product, $warehouseidtodecrease, $invoice->lines[$i]->qty, $invoice->lines[$i]->subprice, $langs->trans("InvoiceValidatedInDolibarrFromPos", $invoice->newref));
-							}
-							if ($result < 0) {
-								setEventMessages($mouvP->error, $mouvP->errors, 'errors');
-								$error++;
-							}
-						}
-					}
-				}
-
-				$id = $invoice->id;
-
-				// Add the payment
-				$payment = new Paiement($db);
-				$payment->datepaye = $now;
-				$payment->amounts[$invoice->id] = $obj_facturation->amountWithTax();
-				$payment->note_public = $langs->trans("Payment").' '.$langs->trans("Invoice").' '.$obj_facturation->numInvoice();
-				$payment->paiementid = $invoice->mode_reglement_id;
-				$payment->num_paiement = '';
-				$payment->num_payment = '';
-
-				$paiement_id = $payment->create($user);
-				if ($paiement_id > 0) {
-					if (!$error) {
-						$result = $payment->addPaymentToBank($user, 'payment', '(CustomerInvoicePayment)', $bankaccountid, '', '');
-						if (!$result > 0) {
-							$errmsg = $paiement->error;
-							$error++;
-						}
-					}
-
-					if (!$error) {
-						if ($invoice->total_ttc == $obj_facturation->amountWithTax()
-							&& $obj_facturation->getSetPaymentMode() != 'DIFF') {
-							// We set status to paid
-							$result = $invoice->setPaid($user);
-							//print 'set paid';exit;
-						}
-					}
-				} else {
-					setEventMessages($invoice->error, $invoice->errors, 'errors');
-					$error++;
-				}
-			} else {
-				setEventMessages($invoice->error, $invoice->errors, 'errors');
-				$error++;
-			}
-		}
-
-
-		if (!$error) {
-			$db->commit();
-			$redirection = 'affIndex.php?menutpl=validation_ok&facid='.$id; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
-		} else {
-			$db->rollback();
-			$redirection = 'affIndex.php?facid='.$id.'&error=1&mesg=ErrorFailedToCreateInvoice'; // Ajout de l'id de la facture, pour l'inclure dans un lien pointant directement vers celle-ci dans Dolibarr
-		}
-		break;
-
-		// End of case: validate_invoice
-}
-
-unset($_SESSION['serObjFacturation']);
-
-$_SESSION['serObjFacturation'] = serialize($obj_facturation);
-
-header('Location: '.$redirection);
-exit;

+ 10 - 3
htdocs/categories/class/categorie.class.php

@@ -34,6 +34,7 @@
 
 require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
 require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
+require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
 require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
 
@@ -56,6 +57,7 @@ class Categorie extends CommonObject
 	const TYPE_WAREHOUSE = 'warehouse';
 	const TYPE_ACTIONCOMM = 'actioncomm';
 	const TYPE_WEBSITE_PAGE = 'website_page';
+	const TYPE_TICKET = 'ticket';
 
 	/**
 	 * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
@@ -78,7 +80,8 @@ class Categorie extends CommonObject
 		'bank_line'    => 8,
 		'warehouse'    => 9,
 		'actioncomm'   => 10,
-		'website_page' => 11
+		'website_page' => 11,
+		'ticket'       => 12
 	);
 
 	/**
@@ -98,7 +101,8 @@ class Categorie extends CommonObject
 		8 => 'bank_line',
 		9 => 'warehouse',
 		10 => 'actioncomm',
-		11 => 'website_page'
+		11 => 'website_page',
+		12 => 'ticket'
 	);
 
 	/**
@@ -141,7 +145,8 @@ class Categorie extends CommonObject
 		'project'  => 'Project',
 		'warehouse'=> 'Entrepot',
 		'actioncomm' => 'ActionComm',
-		'website_page' => 'WebsitePage'
+		'website_page' => 'WebsitePage',
+		'ticket' => 'Ticket'
 	);
 
 	/**
@@ -234,6 +239,8 @@ class Categorie extends CommonObject
 	 * @see Categorie::TYPE_WAREHOUSE
 	 * @see Categorie::TYPE_ACTIONCOMM
 	 * @see Categorie::TYPE_WEBSITE_PAGE
+	 * @see Categorie::TYPE_TICKET
+
 	 */
 	public $type;
 

+ 83 - 1
htdocs/categories/viewcat.php

@@ -142,6 +142,11 @@ if ($id > 0 && $removeelem > 0) {
 		$tmpobject = new User($db);
 		$result = $tmpobject->fetch($removeelem);
 		$elementtype = 'user';
+	} elseif ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write) {
+		require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
+		$tmpobject = new Ticket($db);
+		$result = $tmpobject->fetch($removeelem);
+		$elementtype = 'ticket';
 	}
 
 	$result = $object->del_type($tmpobject, $elementtype);
@@ -167,7 +172,8 @@ if ($user->rights->categorie->supprimer && $action == 'confirm_delete' && $confi
 if ($elemid && $action == 'addintocategory' &&
 	(($type == Categorie::TYPE_PRODUCT && ($user->rights->produit->creer || $user->rights->service->creer)) ||
 	 ($type == Categorie::TYPE_CUSTOMER && $user->rights->societe->creer) ||
-	 ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer)
+	 ($type == Categorie::TYPE_SUPPLIER && $user->rights->societe->creer) ||
+	 ($type == Categorie::TYPE_TICKET && $user->rights->ticket->write)
    )) {
 	if ($type == Categorie::TYPE_PRODUCT) {
 		require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
@@ -181,6 +187,10 @@ if ($elemid && $action == 'addintocategory' &&
 		require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
 		$newobject = new Societe($db);
 		$elementtype = 'supplier';
+	} elseif ($type == Categorie::TYPE_TICKET) {
+		require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
+		$newobject = new Ticket($db);
+		$elementtype = 'ticket';
 	}
 	$result = $newobject->fetch($elemid);
 
@@ -1024,6 +1034,78 @@ if ($type == Categorie::TYPE_WAREHOUSE) {
 	}
 }
 
+if ($type == Categorie::TYPE_TICKET) {
+	$permission = ($user->rights->categorie->creer || $user->rights->categorie->creer);
+
+	$tickets = $object->getObjectsInCateg($type, 0, $limit, $offset);
+	if ($tickets < 0) {
+		dol_print_error($db, $object->error, $object->errors);
+	} else {
+		// Form to add record into a category
+		$showclassifyform = 1;
+		if ($showclassifyform) {
+			print '<br>';
+			print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+			print '<input type="hidden" name="token" value="'.newToken().'">';
+			print '<input type="hidden" name="typeid" value="'.$typeid.'">';
+			print '<input type="hidden" name="type" value="'.$typeid.'">';
+			print '<input type="hidden" name="id" value="'.$object->id.'">';
+			print '<input type="hidden" name="action" value="addintocategory">';
+			print '<table class="noborder centpercent">';
+			print '<tr class="liste_titre"><td>';
+			print $langs->trans("AddTicketIntoCategory").' &nbsp;';
+			$form->selectTickets('', 'elemid');
+			print '<input type="submit" class="button buttongen" value="'.$langs->trans("ClassifyInCategory").'"></td>';
+			print '</tr>';
+			print '</table>';
+			print '</form>';
+		}
+
+		print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
+		print '<input type="hidden" name="token" value="'.newToken().'">';
+		print '<input type="hidden" name="typeid" value="'.$typeid.'">';
+		print '<input type="hidden" name="type" value="'.$typeid.'">';
+		print '<input type="hidden" name="id" value="'.$object->id.'">';
+		print '<input type="hidden" name="action" value="list">';
+
+		print '<br>';
+		$param = '&limit='.$limit.'&id='.$id.'&type='.$type; $num = count($tickets); $nbtotalofrecords = ''; $newcardbutton = '';
+		print_barre_liste($langs->trans("Ticket"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'ticket', 0, $newcardbutton, '', $limit);
+
+
+		print '<table class="noborder centpercent">'."\n";
+		print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("Ref").'</td></tr>'."\n";
+
+		if (count($tickets) > 0) {
+			$i = 0;
+			foreach ($tickets as $ticket) {
+				$i++;
+				if ($i > $limit) break;
+
+				print "\t".'<tr class="oddeven">'."\n";
+				print '<td class="nowrap" valign="top">';
+				print $ticket->getNomUrl(1);
+				print "</td>\n";
+				print '<td class="tdtop">'.$ticket->label."</td>\n";
+				// Link to delete from category
+				print '<td class="right">';
+				if ($permission) {
+					print "<a href= '".$_SERVER['PHP_SELF']."?".(empty($socid) ? 'id' : 'socid')."=".$object->id."&amp;type=".$typeid."&amp;removeelem=".$ticket->id."'>";
+					print $langs->trans("DeleteFromCat");
+					print img_picto($langs->trans("DeleteFromCat"), 'unlink', '', false, 0, 0, '', 'paddingleft');
+					print "</a>";
+				}
+				print '</td>';
+				print "</tr>\n";
+			}
+		} else {
+			print '<tr class="oddeven"><td colspan="2" class="opacitymedium">'.$langs->trans("ThisCategoryHasNoItems").'</td></tr>';
+		}
+		print "</table>\n";
+
+		print '</form>'."\n";
+	}
+}
 
 // End of page
 llxFooter();

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

@@ -261,7 +261,7 @@ class ActionComm extends CommonObject
 	/**
 	 * @var int socpeople id linked to action
 	 */
-	public $contactid;
+	public $contact_id;
 
 	/**
 	 * @var Societe|null Company linked to action (optional)
@@ -273,7 +273,7 @@ class ActionComm extends CommonObject
 	/**
 	 * @var Contact|null Contact linked to action (optional)
 	 * @deprecated
-	 * @see $contactid
+	 * @see $contact_id
 	 */
 	public $contact;
 
@@ -2340,7 +2340,7 @@ class ActionComm extends CommonObject
 						$sendContent = make_substitutions($langs->trans($arraymessage->content), $substitutionarray);
 
 						//Topic
-						$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->trans('EventReminder'));
+						$sendTopic = (!empty($arraymessage->topic)) ? $arraymessage->topic : html_entity_decode($langs->transnoentities('EventReminder'));
 
 						// Recipient
 						$recipient = new User($this->db);

+ 460 - 443
htdocs/comm/action/list.php

@@ -47,7 +47,7 @@ $massaction = GETPOST('massaction', 'alpha');
 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'actioncommlist'; // To manage different context of search
 $resourceid = GETPOST("search_resourceid", "int") ?GETPOST("search_resourceid", "int") : GETPOST("resourceid", "int");
 $pid = GETPOST("search_projectid", 'int', 3) ?GETPOST("search_projectid", 'int', 3) : GETPOST("projectid", 'int', 3);
-$search_status = (GETPOST("search_status", 'alpha') != '') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha');
+$search_status = (GETPOST("search_status", 'aZ09') != '') ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09');
 $type = GETPOST('search_type', 'alphanohtml') ?GETPOST('search_type', 'alphanohtml') : GETPOST('type', 'alphanohtml');
 $optioncss = GETPOST('optioncss', 'alpha');
 $year = GETPOST("year", 'int');
@@ -517,526 +517,543 @@ $parameters = array();
 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
 $sql .= $hookmanager->resPrint;
 
-$sql .= $db->order($sortfield, $sortorder);
-
+// Count total nb of records
 $nbtotalofrecords = '';
 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
-	// TODO Set and use an optimized request in $sqlforcount with no fields and no useless join to caluclate nb of records
-	$result = $db->query($sql);
-	$nbtotalofrecords = $db->num_rows($result);
+	/* This old and fast method to get and count full list returns all record so use a high amount of memory.
+	 $resql = $db->query($sql);
+	 $nbtotalofrecords = $db->num_rows($resql);
+	 */
+	/* The slow method does not consume memory on mysql (not tested on pgsql) */
+	/*$resql = $db->query($sql, 0, 'auto', 1);
+	while ($db->fetch_object($resql)) {
+		$nbtotalofrecords++;
+	}*/
+	/* This fast and low memory method to get and count full list converts the sql into a sql count */
+	$sqlforcount = preg_replace('/^SELECT[a-z0-9\._\s\(\),]+FROM/i', 'SELECT COUNT(*) as nbtotalofrecords FROM', $sql);
+	$resql = $db->query($sqlforcount);
+	$objforcount = $db->fetch_object($resql);
+	$nbtotalofrecords = $objforcount->nbtotalofrecords;
 	if (($page * $limit) > $nbtotalofrecords) {	// if total resultset is smaller then paging size (filtering), goto and load page 0
 		$page = 0;
 		$offset = 0;
 	}
+	$db->free($resql);
 }
 
-$sql .= $db->plimit($limit + 1, $offset);
-//print $sql;
+// Complete request and execute it with limit
+$sql .= $db->order($sortfield, $sortorder);
+if ($limit) {
+	$sql .= $db->plimit($limit + 1, $offset);
+}
 
-dol_syslog("comm/action/list.php", LOG_DEBUG);
 $resql = $db->query($sql);
-if ($resql) {
-	$actionstatic = new ActionComm($db);
-	$societestatic = new Societe($db);
+if (!$resql) {
+	dol_print_error($db);
+	exit;
+}
 
-	$num = $db->num_rows($resql);
+$num = $db->num_rows($resql);
 
-	$arrayofselected = is_array($toselect) ? $toselect : array();
 
-	// Local calendar
-	$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
-	$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
-	$newtitle .= '</div>';
-	//$newtitle=$langs->trans($title);
+$actionstatic = new ActionComm($db);
+$societestatic = new Societe($db);
 
-	$tabactive = 'cardlist';
+$num = $db->num_rows($resql);
 
-	$head = calendars_prepare_head($param);
+$arrayofselected = is_array($toselect) ? $toselect : array();
 
-	print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
+// Local calendar
+$newtitle = '<div class="nowrap clear inline-block minheight30 margintoponly">';
+$newtitle .= '<input type="checkbox" id="check_mytasks" name="check_mytasks" checked disabled> '.$langs->trans("LocalAgenda").' &nbsp; ';
+$newtitle .= '</div>';
+//$newtitle=$langs->trans($title);
 
-	if ($optioncss != '') {
-		print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
-	}
-	print '<input type="hidden" name="token" value="'.newToken().'">';
-	print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
-	print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
-	print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
-	print '<input type="hidden" name="type" value="'.$type.'">';
-	$nav = '';
-
-	if ($filter) {
-		$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
-	}
-	if ($showbirthday) {
-		$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
-	}
-	print $nav;
-
-	//print dol_get_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);
-	//print dol_get_fiche_end();
-
-	// Add link to show birthdays
-	/*
-	$link = '';
-	if (empty($conf->use_javascript_ajax))
-	{
-		$newparam=$param;   // newparam is for birthday links
-		$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
-		if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
-		$link='<a href="'.$_SERVER['PHP_SELF'];
-		$link.='?'.$newparam;
-		$link.='">';
-		if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
-		else $link.=$langs->trans("AgendaHideBirthdayEvents");
-		$link.='</a>';
-	}
-	*/
+$tabactive = 'cardlist';
 
-	$s = $newtitle;
+$head = calendars_prepare_head($param);
 
-	// Calendars from hooks
-	$parameters = array(); $object = null;
-	$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
-	if (empty($reshook)) {
-		$s .= $hookmanager->resPrint;
-	} elseif ($reshook > 1) {
-		$s = $hookmanager->resPrint;
-	}
+print '<form method="POST" id="searchFormList" class="listactionsfilter" action="'.$_SERVER["PHP_SELF"].'">'."\n";
 
-	$viewmode = '';
-	$viewmode .= '<a class="btnTitle btnTitleSelected reposition" href="'.DOL_URL_ROOT.'/comm/action/list.php?action=show_list&restore_lastsearch_values=1'.$paramnoactionodate.'">';
-	//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
-	$viewmode .= img_picto($langs->trans("List"), 'object_list', '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').$paramnoactionodate.'">';
-	//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
-	$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', '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').$paramnoactionodate.'">';
-	//$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').$paramnoactionodate.'">';
-	//$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').$paramnoactionodate.'">';
-	//$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>';
-
-	// Add more views from hooks
-	$parameters = array(); $object = null;
-	$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
-	if (empty($reshook)) {
-		$viewmode .= $hookmanager->resPrint;
-	} elseif ($reshook > 1) {
-		$viewmode = $hookmanager->resPrint;
-	}
+if ($optioncss != '') {
+	print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
+}
+print '<input type="hidden" name="token" value="'.newToken().'">';
+print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
+print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
+print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
+print '<input type="hidden" name="type" value="'.$type.'">';
+$nav = '';
 
-	$tmpforcreatebutton = dol_getdate(dol_now(), true);
+if ($filter) {
+	$nav .= '<input type="hidden" name="search_filter" value="'.$filter.'">';
+}
+if ($showbirthday) {
+	$nav .= '<input type="hidden" name="search_showbirthday" value="1">';
+}
+print $nav;
 
-	$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
+//print dol_get_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);
+//print dol_get_fiche_end();
 
-	//$param='month='.$monthshown.'&year='.$year;
-	$hourminsec = '100000';
+// Add link to show birthdays
+/*
+$link = '';
+if (empty($conf->use_javascript_ajax))
+{
+	$newparam=$param;   // newparam is for birthday links
+	$newparam=preg_replace('/showbirthday=[0-1]/i','showbirthday='.(empty($showbirthday)?1:0),$newparam);
+	if (! preg_match('/showbirthday=/i',$newparam)) $newparam.='&showbirthday=1';
+	$link='<a href="'.$_SERVER['PHP_SELF'];
+	$link.='?'.$newparam;
+	$link.='">';
+	if (empty($showbirthday)) $link.=$langs->trans("AgendaShowBirthdayEvents");
+	else $link.=$langs->trans("AgendaHideBirthdayEvents");
+	$link.='</a>';
+}
+*/
+
+$s = $newtitle;
+
+// Calendars from hooks
+$parameters = array(); $object = null;
+$reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action);
+if (empty($reshook)) {
+	$s .= $hookmanager->resPrint;
+} elseif ($reshook > 1) {
+	$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'.$paramnoactionodate.'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("List"), 'object_list', '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').$paramnoactionodate.'">';
+//$viewmode .= '<span class="fa paddingleft imgforviewmode valignmiddle btnTitle-icon">';
+$viewmode .= img_picto($langs->trans("ViewCal"), 'object_calendarmonth', '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').$paramnoactionodate.'">';
+//$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').$paramnoactionodate.'">';
+//$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').$paramnoactionodate.'">';
+//$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>';
+
+// Add more views from hooks
+$parameters = array(); $object = null;
+$reshook = $hookmanager->executeHooks('addCalendarView', $parameters, $object, $action);
+if (empty($reshook)) {
+	$viewmode .= $hookmanager->resPrint;
+} elseif ($reshook > 1) {
+	$viewmode = $hookmanager->resPrint;
+}
 
-	$url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
-	$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
-	$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
+$tmpforcreatebutton = dol_getdate(dol_now(), true);
 
-	$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
+$newparam .= '&month='.str_pad($month, 2, "0", STR_PAD_LEFT).'&year='.$tmpforcreatebutton['year'];
 
-	$param .= '&action='.$action;
+//$param='month='.$monthshown.'&year='.$year;
+$hourminsec = '100000';
 
-	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);
+$url = DOL_URL_ROOT.'/comm/action/card.php?action=create';
+$url .= '&datep='.sprintf("%04d%02d%02d", $tmpforcreatebutton['year'], $tmpforcreatebutton['mon'], $tmpforcreatebutton['mday']).$hourminsec;
+$url .= '&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam ? '?'.$newparam : ''));
 
-	print $s;
+$newcardbutton = dolGetButtonTitle($langs->trans('AddAction'), '', 'fa fa-plus-circle', $url, '', $user->rights->agenda->myactions->create || $user->rights->agenda->allactions->create);
 
-	$objecttmp = new ActionComm($db);
-	include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
+$param .= '&action='.$action;
 
-	$moreforfilter = '';
+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);
 
-	$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
-	$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
-	if ($massactionbutton) {
-		$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
-	}
-	$i = 0;
+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>';
+$objecttmp = new ActionComm($db);
+include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
 
-	print '<div class="div-table-responsive">';
-	print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
+$moreforfilter = '';
 
-	print '<tr class="liste_titre_filter">';
-	if (!empty($arrayfields['a.id']['checked'])) {
-		print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
-	}
-	if (!empty($arrayfields['owner']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['c.libelle']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['a.label']['checked'])) {
-		print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
-	}
-	if (!empty($arrayfields['a.note']['checked'])) {
-		print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
-	}
-	if (!empty($arrayfields['a.datep']['checked'])) {
-		print '<td class="liste_titre nowraponall" align="center">';
-		print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
-		print '</td>';
-	}
-	if (!empty($arrayfields['a.datep2']['checked'])) {
-		print '<td class="liste_titre nowraponall" align="center">';
-		print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
-		print '</td>';
-	}
-	if (!empty($arrayfields['s.nom']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['a.fk_contact']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['a.fk_element']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
+$varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
+$selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
+if ($massactionbutton) {
+	$selectedfields .= $form->showCheckAddButtons('checkforselect', 1);
+}
+$i = 0;
 
-	// Extra fields
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
+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>';
 
-	// Fields from hook
-	$parameters = array('arrayfields'=>$arrayfields);
-	$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
-	print $hookmanager->resPrint;
+print '<div class="div-table-responsive">';
+print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
 
-	if (!empty($arrayfields['a.datec']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['a.tms']['checked'])) {
-		print '<td class="liste_titre"></td>';
-	}
-	if (!empty($arrayfields['a.percent']['checked'])) {
-		print '<td class="liste_titre center">';
-		$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
-		print ajax_combobox('selectsearch_status');
-		print '</td>';
-	}
-	// Action column
-	print '<td class="liste_titre" align="middle">';
-	$searchpicto = $form->showFilterButtons();
-	print $searchpicto;
+print '<tr class="liste_titre_filter">';
+if (!empty($arrayfields['a.id']['checked'])) {
+	print '<td class="liste_titre"><input type="text" class="maxwidth50" name="search_id" value="'.$search_id.'"></td>';
+}
+if (!empty($arrayfields['owner']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['c.libelle']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['a.label']['checked'])) {
+	print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_title" value="'.$search_title.'"></td>';
+}
+if (!empty($arrayfields['a.note']['checked'])) {
+	print '<td class="liste_titre"><input type="text" class="maxwidth75" name="search_note" value="'.$search_note.'"></td>';
+}
+if (!empty($arrayfields['a.datep']['checked'])) {
+	print '<td class="liste_titre nowraponall" align="center">';
+	print $form->selectDate($datestart, 'datestart', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
 	print '</td>';
-	print "</tr>\n";
+}
+if (!empty($arrayfields['a.datep2']['checked'])) {
+	print '<td class="liste_titre nowraponall" align="center">';
+	print $form->selectDate($dateend, 'dateend', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', '', 'tzuserrel');
+	print '</td>';
+}
+if (!empty($arrayfields['s.nom']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['a.fk_contact']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['a.fk_element']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
 
-	print '<tr class="liste_titre">';
-	if (!empty($arrayfields['a.id']['checked'])) {
-		print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['owner']['checked'])) {
-		print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['c.libelle']['checked'])) {
-		print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.label']['checked'])) {
-		print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.note']['checked'])) {
-		print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
-	}
-	//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
-	if (!empty($arrayfields['a.datep']['checked'])) {
-		print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.datep2']['checked'])) {
-		print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['s.nom']['checked'])) {
-		print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.fk_contact']['checked'])) {
-		print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.fk_element']['checked'])) {
-		print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
-	}
+// Extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php';
 
-	// Extra fields
-	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
+// Fields from hook
+$parameters = array('arrayfields'=>$arrayfields);
+$reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
 
-	// Hook fields
-	$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
-	$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
-	print $hookmanager->resPrint;
+if (!empty($arrayfields['a.datec']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['a.tms']['checked'])) {
+	print '<td class="liste_titre"></td>';
+}
+if (!empty($arrayfields['a.percent']['checked'])) {
+	print '<td class="liste_titre center">';
+	$formactions->form_select_status_action('formaction', $search_status, 1, 'search_status', 1, 2, 'minwidth100imp maxwidth125');
+	print ajax_combobox('selectsearch_status');
+	print '</td>';
+}
+// Action column
+print '<td class="liste_titre" align="middle">';
+$searchpicto = $form->showFilterButtons();
+print $searchpicto;
+print '</td>';
+print "</tr>\n";
 
-	if (!empty($arrayfields['a.datec']['checked'])) {
-		print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
-	}
-	if (!empty($arrayfields['a.tms']['checked'])) {
-		print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
-	}
+print '<tr class="liste_titre">';
+if (!empty($arrayfields['a.id']['checked'])) {
+	print_liste_field_titre($arrayfields['a.id']['label'], $_SERVER["PHP_SELF"], "a.id", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['owner']['checked'])) {
+	print_liste_field_titre($arrayfields['owner']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['c.libelle']['checked'])) {
+	print_liste_field_titre($arrayfields['c.libelle']['label'], $_SERVER["PHP_SELF"], "c.libelle", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.label']['checked'])) {
+	print_liste_field_titre($arrayfields['a.label']['label'], $_SERVER["PHP_SELF"], "a.label", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.note']['checked'])) {
+	print_liste_field_titre($arrayfields['a.note']['label'], $_SERVER["PHP_SELF"], "a.note", $param, "", "", $sortfield, $sortorder);
+}
+//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
+if (!empty($arrayfields['a.datep']['checked'])) {
+	print_liste_field_titre($arrayfields['a.datep']['label'], $_SERVER["PHP_SELF"], "a.datep,a.id", $param, '', 'align="center"', $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.datep2']['checked'])) {
+	print_liste_field_titre($arrayfields['a.datep2']['label'], $_SERVER["PHP_SELF"], "a.datep2", $param, '', 'align="center"', $sortfield, $sortorder);
+}
+if (!empty($arrayfields['s.nom']['checked'])) {
+	print_liste_field_titre($arrayfields['s.nom']['label'], $_SERVER["PHP_SELF"], "s.nom", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.fk_contact']['checked'])) {
+	print_liste_field_titre($arrayfields['a.fk_contact']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.fk_element']['checked'])) {
+	print_liste_field_titre($arrayfields['a.fk_element']['label'], $_SERVER["PHP_SELF"], "", $param, "", "", $sortfield, $sortorder);
+}
 
-	if (!empty($arrayfields['a.percent']['checked'])) {
-		print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
-	}
-	print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
-	print "</tr>\n";
+// Extra fields
+include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php';
 
-	$contactstatic = new Contact($db);
-	$now = dol_now();
-	$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
+// Hook fields
+$parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
+print $hookmanager->resPrint;
 
-	require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
-	$caction = new CActionComm($db);
-	$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
-	$contactListCache = array();
+if (!empty($arrayfields['a.datec']['checked'])) {
+	print_liste_field_titre($arrayfields['a.datec']['label'], $_SERVER["PHP_SELF"], "a.datec,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
+}
+if (!empty($arrayfields['a.tms']['checked'])) {
+	print_liste_field_titre($arrayfields['a.tms']['label'], $_SERVER["PHP_SELF"], "a.tms,a.id", $param, "", 'align="center"', $sortfield, $sortorder);
+}
 
-	while ($i < min($num, $limit)) {
-		$obj = $db->fetch_object($resql);
+if (!empty($arrayfields['a.percent']['checked'])) {
+	print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "a.percent", $param, "", 'align="center"', $sortfield, $sortorder);
+}
+print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="center"', $sortfield, $sortorder, 'maxwidthsearch ');
+print "</tr>\n";
 
-		// Discard auto action if option is on
-		if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
-			$i++;
-			continue;
-		}
+$contactstatic = new Contact($db);
+$now = dol_now();
+$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
 
-		$actionstatic->id = $obj->id;
-		$actionstatic->ref = $obj->id;
-		$actionstatic->code = $obj->code;
-		$actionstatic->type_code = $obj->type_code;
-		$actionstatic->type_label = $obj->type_label;
-		$actionstatic->type_picto = $obj->type_picto;
-		$actionstatic->type_color = $obj->type_color;
-		$actionstatic->label = $obj->label;
-		$actionstatic->location = $obj->location;
-		$actionstatic->note_private = dol_htmlentitiesbr($obj->note);
-
-		// Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
-		// but only if we need it
-		if (!empty($arrayfields['a.fk_contact']['checked'])) {
-			$actionstatic->fetchResources();
-		}
+require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
+$caction = new CActionComm($db);
+$arraylist = $caction->liste_array(1, 'code', '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0), '', 1);
+$contactListCache = array();
 
-		print '<tr class="oddeven">';
+while ($i < min($num, $limit)) {
+	$obj = $db->fetch_object($resql);
 
-		// Ref
-		if (!empty($arrayfields['a.id']['checked'])) {
-			print '<td class="nowraponall">';
-			print $actionstatic->getNomUrl(1, -1);
-			print '</td>';
-		}
+	// Discard auto action if option is on
+	if (!empty($conf->global->AGENDA_ALWAYS_HIDE_AUTO) && $obj->type_code == 'AC_OTH_AUTO') {
+		$i++;
+		continue;
+	}
 
-		// User owner
-		if (!empty($arrayfields['owner']['checked'])) {
-			print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
-			if ($obj->fk_user_action > 0) {
-				$userstatic->fetch($obj->fk_user_action);
-				print $userstatic->getNomUrl(-1);
-			} else {
-				print '&nbsp;';
-			}
-			print '</td>';
+	$actionstatic->id = $obj->id;
+	$actionstatic->ref = $obj->id;
+	$actionstatic->code = $obj->code;
+	$actionstatic->type_code = $obj->type_code;
+	$actionstatic->type_label = $obj->type_label;
+	$actionstatic->type_picto = $obj->type_picto;
+	$actionstatic->type_color = $obj->type_color;
+	$actionstatic->label = $obj->label;
+	$actionstatic->location = $obj->location;
+	$actionstatic->note_private = dol_htmlentitiesbr($obj->note);
+
+	// Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid
+	// but only if we need it
+	if (!empty($arrayfields['a.fk_contact']['checked'])) {
+		$actionstatic->fetchResources();
+	}
+
+	print '<tr class="oddeven">';
+
+	// Ref
+	if (!empty($arrayfields['a.id']['checked'])) {
+		print '<td class="nowraponall">';
+		print $actionstatic->getNomUrl(1, -1);
+		print '</td>';
+	}
+
+	// User owner
+	if (!empty($arrayfields['owner']['checked'])) {
+		print '<td class="tdoverflowmax150">'; // With edge and chrome the td overflow is not supported correctly when content is not full text.
+		if ($obj->fk_user_action > 0) {
+			$userstatic->fetch($obj->fk_user_action);
+			print $userstatic->getNomUrl(-1);
+		} else {
+			print '&nbsp;';
 		}
+		print '</td>';
+	}
 
-		// Type
-		if (!empty($arrayfields['c.libelle']['checked'])) {
-			print '<td class="nowraponall">';
-			print $actionstatic->getTypePicto();
-			$labeltype = $obj->type_code;
-			if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
-				$labeltype = 'AC_OTH';
+	// Type
+	if (!empty($arrayfields['c.libelle']['checked'])) {
+		print '<td class="nowraponall">';
+		print $actionstatic->getTypePicto();
+		$labeltype = $obj->type_code;
+		if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) {
+			$labeltype = 'AC_OTH';
+		}
+		if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
+			$labeltype = $langs->trans("Message");
+		} else {
+			if (!empty($arraylist[$labeltype])) {
+				$labeltype = $arraylist[$labeltype];
 			}
-			if ($actionstatic->type_code == 'AC_OTH' && $actionstatic->code == 'TICKET_MSG') {
-				$labeltype = $langs->trans("Message");
-			} else {
-				if (!empty($arraylist[$labeltype])) {
-					$labeltype = $arraylist[$labeltype];
-				}
-				if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
-					$labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
-				}
+			if ($obj->type_code == 'AC_OTH_AUTO' && ($obj->type_code != $obj->code) && $labeltype && !empty($arraylist[$obj->code])) {
+				$labeltype .= ' - '.$arraylist[$obj->code]; // Use code in priority on type_code
 			}
-			print dol_trunc($labeltype, 28);
-			print '</td>';
 		}
+		print dol_trunc($labeltype, 28);
+		print '</td>';
+	}
 
-		// Label
-		if (!empty($arrayfields['a.label']['checked'])) {
-			print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">';
-			print $actionstatic->label;
-			print '</td>';
-		}
+	// Label
+	if (!empty($arrayfields['a.label']['checked'])) {
+		print '<td class="tdoverflowmax200" title="'.dol_escape_htmltag($actionstatic->label).'">';
+		print $actionstatic->label;
+		print '</td>';
+	}
 
-		// Description
-		if (!empty($arrayfields['a.note']['checked'])) {
-			print '<td class="tdoverflowonsmartphone">';
-			$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0));
-			print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private);
-			print '</td>';
-		}
+	// Description
+	if (!empty($arrayfields['a.note']['checked'])) {
+		print '<td class="tdoverflowonsmartphone">';
+		$text = dolGetFirstLineOfText(dol_string_nohtmltag($actionstatic->note_private, 0));
+		print $form->textwithtooltip(dol_trunc($text, 40), $actionstatic->note_private);
+		print '</td>';
+	}
 
-		$formatToUse = $obj->fulldayevent ? 'day' : 'dayhour';
+	$formatToUse = $obj->fulldayevent ? 'day' : 'dayhour';
 
-		// Start date
-		if (!empty($arrayfields['a.datep']['checked'])) {
-			print '<td class="center nowraponall">';
-			print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser');
-			$late = 0;
-			if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
-				$late = 1;
-			}
-			if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
-				$late = 1;
-			}
-			if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) {
-				$late = 1;
-			}
-			if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
-				$late = 1;
-			}
-			if ($late) {
-				print img_warning($langs->trans("Late")).' ';
-			}
-			print '</td>';
+	// Start date
+	if (!empty($arrayfields['a.datep']['checked'])) {
+		print '<td class="center nowraponall">';
+		print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuser');
+		$late = 0;
+		if ($obj->percent == 0 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
+			$late = 1;
 		}
-
-		// End date
-		if (!empty($arrayfields['a.datep2']['checked'])) {
-			print '<td class="center nowraponall">';
-			print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser');
-			print '</td>';
+		if ($obj->percent == 0 && !$obj->dp && $obj->dp2 && $db->jdate($obj->dp) < ($now - $delay_warning)) {
+			$late = 1;
+		}
+		if ($obj->percent > 0 && $obj->percent < 100 && $obj->dp2 && $db->jdate($obj->dp2) < ($now - $delay_warning)) {
+			$late = 1;
+		}
+		if ($obj->percent > 0 && $obj->percent < 100 && !$obj->dp2 && $obj->dp && $db->jdate($obj->dp) < ($now - $delay_warning)) {
+			$late = 1;
+		}
+		if ($late) {
+			print img_warning($langs->trans("Late")).' ';
 		}
+		print '</td>';
+	}
 
-		// Third party
-		if (!empty($arrayfields['s.nom']['checked'])) {
-			print '<td class="tdoverflowmax150">';
-			if ($obj->socid > 0) {
-				$societestatic->id = $obj->socid;
-				$societestatic->client = $obj->client;
-				$societestatic->name = $obj->societe;
-				$societestatic->email = $obj->socemail;
+	// End date
+	if (!empty($arrayfields['a.datep2']['checked'])) {
+		print '<td class="center nowraponall">';
+		print dol_print_date($db->jdate($obj->dp2), $formatToUse, 'tzuser');
+		print '</td>';
+	}
 
-				print $societestatic->getNomUrl(1, '', 28);
-			} else {
-				print '&nbsp;';
-			}
-			print '</td>';
+	// Third party
+	if (!empty($arrayfields['s.nom']['checked'])) {
+		print '<td class="tdoverflowmax150">';
+		if ($obj->socid > 0) {
+			$societestatic->id = $obj->socid;
+			$societestatic->client = $obj->client;
+			$societestatic->name = $obj->societe;
+			$societestatic->email = $obj->socemail;
+
+			print $societestatic->getNomUrl(1, '', 28);
+		} else {
+			print '&nbsp;';
 		}
+		print '</td>';
+	}
 
-		// Contact
-		if (!empty($arrayfields['a.fk_contact']['checked'])) {
-			print '<td class="tdoverflowmax100">';
-
-			if (!empty($actionstatic->socpeopleassigned)) {
-				$contactList = array();
-				foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
-					if (!isset($contactListCache[$socpeopleassigned['id']])) {
-						// if no cache found we fetch it
-						$contact = new Contact($db);
-						if ($contact->fetch($socpeopleassigned['id']) > 0) {
-							$contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
-							$contactList[] = $contact->getNomUrl(1, '', 0);
-						}
-					} else {
-						// use cache
-						$contactList[] = $contactListCache[$socpeopleassigned['id']];
+	// Contact
+	if (!empty($arrayfields['a.fk_contact']['checked'])) {
+		print '<td class="tdoverflowmax100">';
+
+		if (!empty($actionstatic->socpeopleassigned)) {
+			$contactList = array();
+			foreach ($actionstatic->socpeopleassigned as $socpeopleassigned) {
+				if (!isset($contactListCache[$socpeopleassigned['id']])) {
+					// if no cache found we fetch it
+					$contact = new Contact($db);
+					if ($contact->fetch($socpeopleassigned['id']) > 0) {
+						$contactListCache[$socpeopleassigned['id']] = $contact->getNomUrl(1, '', 0);
+						$contactList[] = $contact->getNomUrl(1, '', 0);
 					}
+				} else {
+					// use cache
+					$contactList[] = $contactListCache[$socpeopleassigned['id']];
 				}
-				if (!empty($contactList)) {
-					print implode(', ', $contactList);
-				}
-			} elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
-				$contactstatic->id = $obj->fk_contact;
-				$contactstatic->email = $obj->email;
-				$contactstatic->lastname = $obj->lastname;
-				$contactstatic->firstname = $obj->firstname;
-				$contactstatic->phone_pro = $obj->phone_pro;
-				$contactstatic->phone_mobile = $obj->phone_mobile;
-				$contactstatic->phone_perso = $obj->phone_perso;
-				$contactstatic->country_id = $obj->country_id;
-				print $contactstatic->getNomUrl(1, '', 0);
-			} else {
-				print "&nbsp;";
 			}
-			print '</td>';
-		}
-
-		// Linked object
-		if (!empty($arrayfields['a.fk_element']['checked'])) {
-			print '<td class="tdoverflowmax150">';
-			//var_dump($obj->fkelement.' '.$obj->elementtype);
-			if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
-				include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
-				print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
-			} else {
-				print "&nbsp;";
+			if (!empty($contactList)) {
+				print implode(', ', $contactList);
 			}
-			print '</td>';
+		} elseif ($obj->fk_contact > 0) { //keep for retrocompatibility with faraway event
+			$contactstatic->id = $obj->fk_contact;
+			$contactstatic->email = $obj->email;
+			$contactstatic->lastname = $obj->lastname;
+			$contactstatic->firstname = $obj->firstname;
+			$contactstatic->phone_pro = $obj->phone_pro;
+			$contactstatic->phone_mobile = $obj->phone_mobile;
+			$contactstatic->phone_perso = $obj->phone_perso;
+			$contactstatic->country_id = $obj->country_id;
+			print $contactstatic->getNomUrl(1, '', 0);
+		} else {
+			print "&nbsp;";
 		}
+		print '</td>';
+	}
 
-		// Extra fields
-		include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
-		// Fields from hook
-		$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
-		$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
-		print $hookmanager->resPrint;
-
-		// Date creation
-		if (!empty($arrayfields['a.datec']['checked'])) {
-			// Status/Percent
-			print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuser').'</td>';
-		}
-		// Date update
-		if (!empty($arrayfields['a.tms']['checked'])) {
-			print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuser').'</td>';
-		}
-		if (!empty($arrayfields['a.percent']['checked'])) {
-			// Status/Percent
-			$datep = $db->jdate($obj->dp);
-			print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
-		}
-		// Action column
-		print '<td class="nowrap center">';
-		if ($massactionbutton || $massaction) {   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
-			$selected = 0;
-			if (in_array($obj->id, $arrayofselected)) {
-				$selected = 1;
-			}
-			print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
+	// Linked object
+	if (!empty($arrayfields['a.fk_element']['checked'])) {
+		print '<td class="tdoverflowmax150">';
+		//var_dump($obj->fkelement.' '.$obj->elementtype);
+		if ($obj->fk_element > 0 && !empty($obj->elementtype)) {
+			include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
+			print dolGetElementUrl($obj->fk_element, $obj->elementtype, 1);
+		} else {
+			print "&nbsp;";
 		}
 		print '</td>';
+	}
 
-		print "</tr>\n";
-		$i++;
+	// Extra fields
+	include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_print_fields.tpl.php';
+	// Fields from hook
+	$parameters = array('arrayfields'=>$arrayfields, 'obj'=>$obj, 'i'=>$i, 'totalarray'=>&$totalarray);
+	$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
+	print $hookmanager->resPrint;
+
+	// Date creation
+	if (!empty($arrayfields['a.datec']['checked'])) {
+		// Status/Percent
+		print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datec), 'dayhour', 'tzuser').'</td>';
 	}
-	print "</table>";
-	print '</div>';
-	print '</form>';
+	// Date update
+	if (!empty($arrayfields['a.tms']['checked'])) {
+		print '<td align="center" class="nowrap">'.dol_print_date($db->jdate($obj->datem), 'dayhour', 'tzuser').'</td>';
+	}
+	if (!empty($arrayfields['a.percent']['checked'])) {
+		// Status/Percent
+		$datep = $db->jdate($obj->dp);
+		print '<td align="center" class="nowrap">'.$actionstatic->LibStatut($obj->percent, 5, 0, $datep).'</td>';
+	}
+	// Action column
+	print '<td class="nowrap center">';
+	if ($massactionbutton || $massaction) {   // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
+		$selected = 0;
+		if (in_array($obj->id, $arrayofselected)) {
+			$selected = 1;
+		}
+		print '<input id="cb'.$obj->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$obj->id.'"'.($selected ? ' checked="checked"' : '').'>';
+	}
+	print '</td>';
 
-	$db->free($resql);
-} else {
-	dol_print_error($db);
+	print "</tr>\n";
+	$i++;
 }
+print "</table>";
+print '</div>';
+print '</form>';
+
+$db->free($resql);
 
 // End of page
 llxFooter();

+ 50 - 6
htdocs/comm/index.php

@@ -182,7 +182,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
 				print '<tr class="oddeven">';
 				print '<td class="nowrap tdoverflowmax100">'.$propalstatic->getNomUrl(1).'</td>';
 				print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
-				print '<td class="nowrap right tdamount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
+				print '<td class="nowrap right tdamount amount">'.price((!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc)).'</td>';
 				print '</tr>';
 
 				$i++;
@@ -278,7 +278,7 @@ if (!empty($conf->supplier_proposal->enabled) && $user->rights->supplier_proposa
 				print '<tr class="oddeven">';
 				print '<td class="nowrap tdoverflowmax100">'.$supplierproposalstatic->getNomUrl(1).'</td>';
 				print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
-				print '<td class="nowrap right tdamount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
+				print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
 				print '</tr>';
 
 				$i++;
@@ -375,7 +375,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
 				print '<tr class="oddeven">';
 				print '<td class="nowrap tdoverflowmax100">'.$orderstatic->getNomUrl(1).'</td>';
 				print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'customer').'</td>';
-				print '<td class="nowrap right tdamount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
+				print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
 				print '</tr>';
 
 				$i++;
@@ -472,7 +472,7 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 				print '<tr class="oddeven">';
 				print '<td class="nowrap tdoverflowmax100">'.$supplierorderstatic->getNomUrl(1).'</td>';
 				print '<td class="nowrap tdoverflowmax100">'.$companystatic->getNomUrl(1, 'supplier').'</td>';
-				print '<td class="nowrap right tdamount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
+				print '<td class="nowrap right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
 				print '</tr>';
 
 				$i++;
@@ -497,6 +497,50 @@ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SU
 	}
 }
 
+
+/*
+ * Draft interventionals
+ */
+if (!empty($conf->ficheinter->enabled)) {
+	$sql = "SELECT f.rowid, f.ref, s.nom as name, s.rowid as socid";
+	$sql .= " FROM ".MAIN_DB_PREFIX."fichinter as f";
+	$sql .= ", ".MAIN_DB_PREFIX."societe as s";
+	if (!$user->rights->societe->client->voir && !$socid) {
+		$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+	}
+	$sql .= " WHERE f.entity IN (".getEntity('intervention').")";
+	$sql .= " AND f.fk_soc = s.rowid";
+	$sql .= " AND f.fk_statut = 0";
+	if ($socid) {
+		$sql .= " AND f.fk_soc = ".((int) $socid);
+	}
+	if (!$user->rights->societe->client->voir && !$socid) {
+		$sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
+	}
+
+	$resql = $db->query($sql);
+	if ($resql) {
+		print '<div class="div-table-responsive-no-min">';
+		print '<table class="noborder centpercent">';
+		print '<tr class="liste_titre">';
+		print '<th colspan="2">'.$langs->trans("DraftFichinter").'</th></tr>';
+		$langs->load("fichinter");
+		$num = $db->num_rows($resql);
+		if ($num) {
+			$i = 0;
+			while ($i < $num) {
+				$obj = $db->fetch_object($resql);
+				print '<tr class="oddeven">';
+				print '<td class="nowrap">';
+				print "<a href=\"card.php?id=".$obj->rowid."\">".img_object($langs->trans("ShowFichinter"), "intervention").' '.$obj->ref."</a></td>";
+				print '<td><a href="'.DOL_URL_ROOT.'/comm/card.php?socid='.$obj->socid.'">'.img_object($langs->trans("ShowCompany"), "company").' '.dol_trunc($obj->name, 24).'</a></td></tr>';
+				$i++;
+			}
+		}
+		print "</table></div>";
+	}
+}
+
 print '</div><div class="fichetwothirdright">';
 print '<div class="ficheaddleft">';
 
@@ -862,7 +906,7 @@ if (!empty($conf->propal->enabled) && $user->rights->propal->lire) {
 
 				print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
 				print '<td class="right tddate">'.dol_print_date($db->jdate($obj->dp), 'day').'</td>';
-				print '<td class="right tdamount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
+				print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
 				print '<td align="center" width="14">'.$propalstatic->LibStatut($obj->fk_statut, 3).'</td>';
 
 				print '</tr>';
@@ -979,7 +1023,7 @@ if (!empty($conf->commande->enabled) && $user->rights->commande->lire) {
 
 				print '<td class="nowrap">'.$companystatic->getNomUrl(1, 'customer', 44).'</td>';
 				print '<td class="right tddate">'.dol_print_date($db->jdate($obj->dv), 'day').'</td>';
-				print '<td class="right tdamount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
+				print '<td class="right tdamount amount">'.price(!empty($conf->global->MAIN_DASHBOARD_USE_TOTAL_HT) ? $obj->total_ht : $obj->total_ttc).'</td>';
 				print '<td align="center" width="14">'.$orderstatic->LibStatut($obj->fk_statut, $obj->billed, 3).'</td>';
 
 				print '</tr>';

+ 4 - 3
htdocs/comm/mailing/cibles.php

@@ -1,6 +1,6 @@
 <?php
 /* Copyright (C) 2004      Rodolphe Quiedeville <rodolphe@quiedeville.org>
- * Copyright (C) 2005-2016 Laurent Destailleur  <eldy@uers.sourceforge.net>
+ * Copyright (C) 2005-2021 Laurent Destailleur  <eldy@uers.sourceforge.net>
  * Copyright (C) 2005-2010 Regis Houssin        <regis.houssin@inodbox.com>
  * Copyright (C) 2014	   Florian Henry        <florian.henry@open-concept.pro>
  *
@@ -337,6 +337,7 @@ if ($object->fetch($id) >= 0) {
 			if (is_resource($handle)) {
 				while (($file = readdir($handle)) !== false) {
 					if (substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS') {
+						$reg = array();
 						if (preg_match("/(.*)\.modules\.php$/i", $file, $reg)) {
 							if ($reg[1] == 'example') {
 								continue;
@@ -534,9 +535,9 @@ if ($object->fetch($id) >= 0) {
 
 		$morehtmlcenter = '';
 		if ($allowaddtarget) {
-			$morehtmlcenter = '<span class="opacitymedium">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition">'.$langs->trans("TargetsReset").'</a>';
+			$morehtmlcenter = '<span class="opacitymedium">'.$langs->trans("ToClearAllRecipientsClickHere").'</span> <a href="'.$_SERVER["PHP_SELF"].'?clearlist=1&id='.$object->id.'" class="button reposition smallpaddingimp">'.$langs->trans("TargetsReset").'</a>';
 		}
-		$morehtmlcenter .= ' <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?exportcsv=1&id='.$object->id.'">'.$langs->trans("Download").'</a>';
+		$morehtmlcenter .= ' &nbsp; <a class="reposition" href="'.$_SERVER["PHP_SELF"].'?exportcsv=1&id='.$object->id.'">'.$langs->trans("Download").'</a>';
 
 		print_barre_liste($langs->trans("MailSelectedRecipients"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $morehtmlcenter, $num, $nbtotalofrecords, 'generic', 0, '', '', $limit);
 

+ 2 - 2
htdocs/comm/propal/card.php

@@ -2529,7 +2529,7 @@ if ($action == 'create') {
 				}
 
 				// ReOpen
-				if (($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED) && $usercanclose) {
+				if ( (( ! empty($conf->global->PROPAL_REOPEN_UNSIGNED_ONLY) && $object->statut == Propal::STATUS_NOTSIGNED) || (empty($conf->global->PROPAL_REOPEN_UNSIGNED_ONLY) && ($object->statut == Propal::STATUS_SIGNED || $object->statut == Propal::STATUS_NOTSIGNED || $object->statut == Propal::STATUS_BILLED))) && $usercanclose) {
 					print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&amp;action=reopen'.(empty($conf->global->MAIN_JUMP_TAG) ? '' : '#reopen').'"';
 					print '>'.$langs->trans('ReOpen').'</a>';
 				}
@@ -2579,7 +2579,7 @@ if ($action == 'create') {
 				}
 
 				// Create an invoice and classify billed
-				if ($object->statut == Propal::STATUS_SIGNED) {
+				if ($object->statut == Propal::STATUS_SIGNED && empty($conf->global->PROPOSAL_ARE_NOT_BILLABLE)) {
 					if (!empty($conf->facture->enabled) && $usercancreateinvoice) {
 						print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture/card.php?action=create&amp;origin='.$object->element.'&amp;originid='.$object->id.'&amp;socid='.$object->socid.'">'.$langs->trans("AddBill").'</a>';
 					}

+ 10 - 4
htdocs/comm/propal/list.php

@@ -220,13 +220,13 @@ $permissiontoread = $user->rights->propal->lire;
 $permissiontoadd = $user->rights->propal->creer;
 $permissiontodelete = $user->rights->propal->supprimer;
 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) {
-	$permissiontovalidate = $user->rights->propale->propal_advance->validate;
-	$permissiontoclose = $user->rights->propale->propal_advance->close;
-	$permissiontosendbymail = $user->rights->propale->propal_advance->send;
+	$permissiontovalidate = $user->rights->propal->propal_advance->validate;
+	$permissiontoclose = $user->rights->propal->propal_advance->close;
+	$permissiontosendbymail = $user->rights->propal->propal_advance->send;
 } else {
 	$permissiontovalidate = $user->rights->propal->creer;
 	$permissiontoclose = $user->rights->propal->creer;
-	$permissiontosendbymail = $user->rights->propal->creer;
+	$permissiontosendbymail = $user->rights->propal->lire;
 }
 
 
@@ -517,6 +517,12 @@ if ($search_user > 0) {
 	$sql .= ", ".MAIN_DB_PREFIX."element_contact as c";
 	$sql .= ", ".MAIN_DB_PREFIX."c_type_contact as tc";
 }
+
+// Add table from hooks
+$parameters = array();
+$reshook = $hookmanager->executeHooks('printFieldListFrom', $parameters, $object); // Note that $action and $object may have been modified by hook
+$sql .= $hookmanager->resPrint;
+
 $sql .= ' WHERE p.fk_soc = s.rowid';
 $sql .= ' AND p.entity IN ('.getEntity('propal').')';
 if (!$user->rights->societe->client->voir && !$socid) { //restriction

Некоторые файлы не были показаны из-за большого количества измененных файлов