浏览代码

Merge branch 'develop' into patch-234

Laurent Destailleur 5 年之前
父节点
当前提交
c63db01d5f
共有 100 个文件被更改,包括 1446 次插入822 次删除
  1. 20 17
      ChangeLog
  2. 2 2
      dev/initdata/generate-product.php
  3. 16 4
      dev/initdata/generate-thirdparty.php
  4. 2 2
      dev/setup/codesniffer/ruleset.xml
  5. 3 3
      dev/translation/sanity_check_en_langfiles.php
  6. 1 1
      htdocs/accountancy/admin/account.php
  7. 1 1
      htdocs/accountancy/admin/accountmodel.php
  8. 1 1
      htdocs/accountancy/admin/fiscalyear.php
  9. 1 1
      htdocs/accountancy/admin/fiscalyear_card.php
  10. 1 1
      htdocs/accountancy/admin/fiscalyear_info.php
  11. 1 1
      htdocs/accountancy/bookkeeping/card.php
  12. 2 2
      htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php
  13. 2 2
      htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php
  14. 14 15
      htdocs/accountancy/class/accountingaccount.class.php
  15. 5 0
      htdocs/accountancy/class/bookkeeping.class.php
  16. 1 1
      htdocs/accountancy/closure/index.php
  17. 1 1
      htdocs/accountancy/closure/validate.php
  18. 1 1
      htdocs/accountancy/customer/card.php
  19. 1 1
      htdocs/accountancy/customer/index.php
  20. 1 1
      htdocs/accountancy/customer/lines.php
  21. 1 1
      htdocs/accountancy/customer/list.php
  22. 1 1
      htdocs/accountancy/expensereport/card.php
  23. 1 1
      htdocs/accountancy/expensereport/index.php
  24. 1 1
      htdocs/accountancy/expensereport/lines.php
  25. 1 1
      htdocs/accountancy/expensereport/list.php
  26. 1 1
      htdocs/accountancy/index.php
  27. 4 4
      htdocs/accountancy/journal/bankjournal.php
  28. 1 1
      htdocs/accountancy/journal/expensereportsjournal.php
  29. 1 1
      htdocs/accountancy/journal/purchasesjournal.php
  30. 1 1
      htdocs/accountancy/journal/sellsjournal.php
  31. 1 1
      htdocs/accountancy/supplier/card.php
  32. 1 1
      htdocs/accountancy/supplier/index.php
  33. 1 1
      htdocs/accountancy/supplier/lines.php
  34. 1 1
      htdocs/accountancy/supplier/list.php
  35. 1 1
      htdocs/adherents/admin/website.php
  36. 1 1
      htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php
  37. 9 9
      htdocs/adherents/card.php
  38. 43 72
      htdocs/adherents/class/adherent.class.php
  39. 4 4
      htdocs/adherents/class/adherentstats.class.php
  40. 2 2
      htdocs/adherents/class/subscription.class.php
  41. 2 2
      htdocs/adherents/htpasswd.php
  42. 23 11
      htdocs/adherents/index.php
  43. 2 2
      htdocs/adherents/ldap.php
  44. 1 0
      htdocs/adherents/list.php
  45. 2 2
      htdocs/adherents/stats/byproperties.php
  46. 2 2
      htdocs/adherents/stats/geo.php
  47. 2 2
      htdocs/adherents/stats/index.php
  48. 1 1
      htdocs/adherents/type_translation.php
  49. 2 2
      htdocs/admin/barcode.php
  50. 181 218
      htdocs/admin/bom.php
  51. 4 50
      htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php
  52. 5 5
      htdocs/admin/emailcollector_card.php
  53. 2 2
      htdocs/admin/emailcollector_list.php
  54. 2 2
      htdocs/admin/mails_senderprofile_list.php
  55. 6 22
      htdocs/admin/modulehelp.php
  56. 522 0
      htdocs/admin/mrp.php
  57. 1 1
      htdocs/admin/notification.php
  58. 2 2
      htdocs/admin/tools/listevents.php
  59. 2 2
      htdocs/admin/tools/listsessions.php
  60. 2 2
      htdocs/admin/translation.php
  61. 1 1
      htdocs/admin/website.php
  62. 10 2
      htdocs/api/class/api.class.php
  63. 1 1
      htdocs/api/class/api_setup.class.php
  64. 8 2
      htdocs/api/index.php
  65. 2 2
      htdocs/asset/card.php
  66. 6 0
      htdocs/asset/class/asset.class.php
  67. 2 2
      htdocs/asset/document.php
  68. 1 1
      htdocs/asset/info.php
  69. 2 2
      htdocs/asset/list.php
  70. 2 2
      htdocs/asset/note.php
  71. 1 1
      htdocs/asset/type.php
  72. 5 0
      htdocs/blockedlog/class/blockedlog.class.php
  73. 2 2
      htdocs/bom/bom_agenda.php
  74. 47 35
      htdocs/bom/bom_card.php
  75. 2 2
      htdocs/bom/bom_document.php
  76. 2 2
      htdocs/bom/bom_list.php
  77. 2 2
      htdocs/bom/bom_note.php
  78. 45 4
      htdocs/bom/class/api_boms.class.php
  79. 25 78
      htdocs/bom/class/bom.class.php
  80. 14 4
      htdocs/bom/tpl/objectline_create.tpl.php
  81. 8 0
      htdocs/bom/tpl/objectline_edit.tpl.php
  82. 7 0
      htdocs/bom/tpl/objectline_title.tpl.php
  83. 10 0
      htdocs/bom/tpl/objectline_view.tpl.php
  84. 4 3
      htdocs/bookmarks/bookmarks.lib.php
  85. 2 2
      htdocs/cashdesk/admin/cashdesk.php
  86. 3 3
      htdocs/cashdesk/class/Facturation.class.php
  87. 21 18
      htdocs/cashdesk/tpl/facturation1.tpl.php
  88. 2 2
      htdocs/cashdesk/tpl/ticket.tpl.php
  89. 23 23
      htdocs/cashdesk/tpl/validation1.tpl.php
  90. 4 4
      htdocs/categories/class/categorie.class.php
  91. 1 1
      htdocs/categories/photos.php
  92. 1 1
      htdocs/categories/traduction.php
  93. 1 1
      htdocs/categories/viewcat.php
  94. 23 22
      htdocs/comm/action/card.php
  95. 187 76
      htdocs/comm/action/class/actioncomm.class.php
  96. 9 0
      htdocs/comm/action/class/api_agendaevents.class.php
  97. 1 1
      htdocs/comm/action/class/ical.class.php
  98. 3 3
      htdocs/comm/action/document.php
  99. 32 19
      htdocs/comm/action/index.php
  100. 4 4
      htdocs/comm/action/info.php

+ 20 - 17
ChangeLog

@@ -25,7 +25,10 @@ Following changes may create regressions for some external modules, but were nec
 * The trigger BON_PRELEVEMENT_CREATE has been renamed into DIRECT_DEBIT_ORDER_CREATE.
 * The constant INVOICE_SHOW_POS_IN_EXPORT has been renamed into INVOICE_SHOW_POS.
 * If your logo was visible on the menu bar, you must upload a new logo into 'Home-Setup-Company/Organization' to have it visible agin in menu. 
-
+* All properties 'libstatut', 'labelstatut', 'labelstatus' were renamed into 'labelStatus'. 
+* All properties 'labelstatusshort' and 'labelstatut_short' were renamed into 'labelStatusShort'. 
+* All properties 'type_libelle' were renamed into 'type_label'.
+* Renamed property of thirdparty "statut_commercial" into "status_prospect_label"
 
 ***** ChangeLog for 10.0.3 compared to 10.0.2 *****
 IMPORTANT : This version fixes a serious bug in saving the units of weight, size, surface and volume on product card.
@@ -42,11 +45,11 @@ FIX: #12041
 FIX: #12054
 FIX: #12083
 FIX: #12088
+FIX: CVE-2019-17578 CVE-2019-17577 CVE-2019-17576
 FIX: Clean the + of categories on the product view only in POS module
 FIX: access to public interface when origin email has an alias.
 FIX: Alias name is not into the email recipient label.
 FIX: allow standalone credit note even if no invoice
-FIX: an admin can not access his own permissions after enabling advanced
 FIX: an admin can not access his own permissions after enabling advanced permissions
 FIX: Attachement of linked files on ticket when sending a message
 FIX: avoid non numeric warning
@@ -115,17 +118,17 @@ FIX: #11752
 FIX: #11789 FIX: #11790
 FIX: #11804 list of tickets from a customer card display ALL tickets
 FIX: #11834
-FIX: Add char $ and ; in sanitizing of filenames.
-FIX: Add comment before protected functions
-FIX: Add log and type of content in dolWebsiteOutput and
-FIX: Add repair.php option 'restore' to restore user picture after v10
+FIX: add char $ and ; in sanitizing of filenames
+FIX: add comment before protected functions
+FIX: add log and type of content in dolWebsiteOutput and
+FIX: add repair.php option 'restore' to restore user picture after v10
 FIX: amount opened on thirdparty card dont care of credit note not converted
-FIX: Api of documents work with value 'thirdparty'
+FIX: API of documents work with value 'thirdparty'
 FIX: author in message / ticket API
-FIX: avoid sql error if fk_project is empty during update
+FIX: avoid SQL error if fk_project is empty during update
 FIX: avoid Warning: A non-numeric value encountered
-FIX: bad consistency in list of invoice for direct debit order.
-FIX: Bad error management in zip compress and web site export
+FIX: bad consistency in list of invoice for direct debit order
+FIX: bad error management in zip compress and web site export
 FIX: bad substitution for extrafields type checkbox
 FIX: better help message with multicompany
 FIX: calculation of $products_dispatched
@@ -134,11 +137,11 @@ FIX: Can't delete a draft leave even if it should
 FIX: Can't save setup of mailman module
 FIX: column jabberid missing
 FIX: Confirmation of deletion
-FIX: Consistency in direct debit order lists.
+FIX: Consistency in direct debit order lists
 FIX: Content send before header warning
 FIX: credit note can be split
 FIX: credit note used on list
-FIX: Css was saved on wrong website.
+FIX: CSS was saved on wrong website
 FIX: delivery extrafields
 FIX: Disabling a website does not put it offline
 FIX: display only stripe sources for customer
@@ -155,13 +158,13 @@ FIX: Fatal situation if payment removed on expense report. Action
 FIX: filepath of generated documents doesn't handle products with special characters
 FIX: for MAIN_MAXTABS_IN_CARD = $i card
 FIX: gzip and bzip2 must use option -f
-FIX: It was possible to create cashfence without entering data.
+FIX: it was possible to create cashfence without entering data
 FIX: javascript error when using dol_use_jmobile=1
 FIX: logout redirect to takepos.php
 FIX: Look and feel v10
 FIX: Make protected all pfd models functions
 FIX: management of extrafields in modulebuilder
-FIX: Missing div for buttons in tax, loan, various payment modules
+FIX: missing div for buttons in tax, loan, various payment modules
 FIX: missing include (dol_convert_file not found)
 FIX: Missing some replacements in website module
 FIX: missing test on permission on button to delete ledger record
@@ -185,13 +188,13 @@ FIX: Return code of pdf_einstein.modules.php and proformat
 FIX: round for application fee in stripe
 FIX: Sens of the balance (Debit - Credit in accountancy not contrary)
 FIX: Several pb in export of documents
-FIX: SQL syntax error and CSRF check on vat reports
+FIX: SQL syntax error and CSRF check on VAT reports
 FIX: takepos layout clear or focus search
-FIX: too many record in sql request. Whena criteria is a filter, we must
+FIX: too many record in sql request. When a criteria is a filter, we must
 FIX: Translation of month
 FIX: USEDOLIBARREDITOR not always set
 FIX: VAT number for Monaco (it uses FR)
-FIX: vulenrability in uploading file found by 美创科技安全实验室
+FIX: vulnerability in uploading file found by 美创科技安全实验室
 FIX: wrong display (and hidden input) for already dispatched quantity
 FIX: wrong parameters (same error in branch 9, 10, develop)
 FIX: Wrong variable. Must be PROJECT_HIDE_UNSELECTABLES

+ 2 - 2
dev/initdata/generate-product.php

@@ -61,8 +61,8 @@ $user->getrights();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
 $resql=$db->query($sql);
 if ($resql) {
-  $num = $db->num_rows($resql); $i = 0;
-  while ($i < $num) {      $row = $db->fetch_row($resql);      $productsid[$i] = $row[0];      $i++; }
+    $num = $db->num_rows($resql); $i = 0;
+    while ($i < $num) {      $row = $db->fetch_row($resql);      $productsid[$i] = $row[0];      $i++; }
 }
 
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();

+ 16 - 4
dev/initdata/generate-thirdparty.php

@@ -64,22 +64,34 @@ $user->getrights();
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."product"; $productsid = array();
 $resql=$db->query($sql);
 if ($resql) {
-  $num = $db->num_rows($resql); $i = 0;
-  while ($i < $num) {      $row = $db->fetch_row($resql);      $productsid[$i] = $row[0];      $i++; }
+    $num = $db->num_rows($resql); $i = 0;
+    while ($i < $num) {
+		$row = $db->fetch_row($resql);
+		$productsid[$i] = $row[0];
+		$i++;
+	}
 }
 
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."societe"; $societesid = array();
 $resql=$db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql); $i = 0;
-    while ($i < $num) { $row = $db->fetch_row($resql);      $societesid[$i] = $row[0];      $i++; }
+    while ($i < $num) {
+		$row = $db->fetch_row($resql);
+		$societesid[$i] = $row[0];
+		$i++;
+	}
 } else { print "err"; }
 
 $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande"; $commandesid = array();
 $resql=$db->query($sql);
 if ($resql) {
 	$num = $db->num_rows($resql); $i = 0;
-    while ($i < $num) { $row = $db->fetch_row($resql);      $commandesid[$i] = $row[0];      $i++; }
+    while ($i < $num) {
+		$row = $db->fetch_row($resql);
+		$commandesid[$i] = $row[0];
+		$i++;
+	}
 } else { print "err"; }
 
 

+ 2 - 2
dev/setup/codesniffer/ruleset.xml

@@ -186,7 +186,7 @@
 	<!-- Check indent are done with spaces and with correct number -->
 	<!-- Disabled as this does not support tab -->
 	<!-- <rule ref="Generic.WhiteSpace.ScopeIndent" /> -->
- 	<!-- TODO Enable this
+
 	<arg name="tab-width" value="4"/>
 	<rule ref="Generic.WhiteSpace.ScopeIndent">
 	  <properties>
@@ -194,7 +194,7 @@
 	    <property name="tabIndent" value="true"/>
 	  </properties>
 	</rule>
-	-->
+
 
     <rule ref="Squiz.WhiteSpace.ScopeClosingBrace.Indent" />
 

+ 3 - 3
dev/translation/sanity_check_en_langfiles.php

@@ -149,9 +149,9 @@ foreach ($langstrings_3d AS $filename => $file)
 		$keys = array_keys($langstrings_full, $value);
 		if (count($keys)>1)
 		{
-				foreach ($keys AS $key) {
-					$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
-				}
+			foreach ($keys AS $key) {
+				$dups[$value][$filename][$linenum] = trim($langstrings_3dtrans[$filename][$linenum]);
+			}
 		}
 	}
 }

+ 1 - 1
htdocs/accountancy/admin/account.php

@@ -46,7 +46,7 @@ $search_pcgtype = GETPOST('search_pcgtype', 'alpha');
 $search_pcgsubtype = GETPOST('search_pcgsubtype', 'alpha');
 
 // Security check
-if ($user->societe_id > 0) accessforbidden();
+if ($user->socid > 0) accessforbidden();
 if (! $user->rights->accounting->chartofaccount) accessforbidden();
 
 // Load variable for pagination

+ 1 - 1
htdocs/accountancy/admin/accountmodel.php

@@ -71,7 +71,7 @@ $search_country_id = GETPOST('search_country_id', 'int');
 
 
 // Security check
-if ($user->societe_id > 0) accessforbidden();
+if ($user->socid > 0) accessforbidden();
 if (! $user->rights->accounting->chartofaccount) accessforbidden();
 
 

+ 1 - 1
htdocs/accountancy/admin/fiscalyear.php

@@ -43,7 +43,7 @@ if (! $sortorder) $sortorder="ASC";
 $langs->loadLangs(array("admin","compta"));
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->fiscalyear->write)              // If we can read accounting records, we should be able to see fiscal year.
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/admin/fiscalyear_card.php

@@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
 $langs->loadLangs(array("admin","compta"));
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (empty($user->rights->accounting->fiscalyear->write))
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/admin/fiscalyear_info.php

@@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/fiscalyear.class.php';
 $langs->loadLangs(array("admin","compta"));
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->fiscalyear->write)
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/bookkeeping/card.php

@@ -45,7 +45,7 @@ $mode = GETPOST('mode', 'aZ09');		 		// '' or 'tmp'
 $piece_num = GETPOST("piece_num", 'int');	// id of transaction (several lines share the same transaction id)
 
 // Security check
-if ($user->societe_id > 0) {
+if ($user->socid > 0) {
 	accessforbidden();
 }
 

+ 2 - 2
htdocs/accountancy/bookkeeping/thirdparty_lettering_customer.php

@@ -83,7 +83,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
 
 // Security check
 $socid = GETPOST("socid", 'int');
-// if ($user->societe_id) $socid=$user->societe_id;
+// if ($user->socid) $socid=$user->socid;
 
 $lettering = new Lettering($db);
 $object = new Societe($db);
@@ -139,7 +139,7 @@ dol_fiche_head($head, 'lettering_customer', $langs->trans("ThirdParty"), 0, 'com
 
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
+dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
 
 dol_fiche_end();
 

+ 2 - 2
htdocs/accountancy/bookkeeping/thirdparty_lettering_supplier.php

@@ -83,7 +83,7 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
 
 // Security check
 $socid = GETPOST("socid", 'int');
-// if ($user->societe_id) $socid=$user->societe_id;
+// if ($user->socid) $socid=$user->socid;
 
 $lettering = new Lettering($db);
 $object = new Societe($db);
@@ -138,7 +138,7 @@ dol_fiche_head($head, 'lettering_supplier', $langs->trans("ThirdParty"), 0, 'com
 
 $linkback = '<a href="'.DOL_URL_ROOT.'/societe/list.php?restore_lastsearch_values=1">'.$langs->trans("BackToList").'</a>';
 
-dol_banner_tab($object, 'socid', $linkback, ($user->societe_id?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
+dol_banner_tab($object, 'socid', $linkback, ($user->socid?0:1), 'rowid', 'nom', '', '', 0, '', '', 'arearefnobottom');
 
 dol_fiche_end();
 

+ 14 - 15
htdocs/accountancy/class/accountingaccount.class.php

@@ -638,11 +638,11 @@ class AccountingAccount extends CommonObject
 	/**
 	 *  Renvoi le libelle d'un statut donne
 	 *
-	 *  @param  int     $statut     Id statut
+	 *  @param  int     $status     Id status
 	 *  @param  int     $mode       0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
 	 *  @return string              Label of status
 	 */
-	public function LibStatut($statut, $mode = 0)
+	public function LibStatut($status, $mode = 0)
 	{
         // phpcs:enable
 		global $langs;
@@ -650,34 +650,33 @@ class AccountingAccount extends CommonObject
 
 		if ($mode == 0)
 		{
-			$prefix='';
-			if ($statut == 1) return $langs->trans('Enabled');
-			elseif ($statut == 0) return $langs->trans('Disabled');
+			if ($status == 1) return $langs->trans('Enabled');
+			elseif ($status == 0) return $langs->trans('Disabled');
 		}
 		elseif ($mode == 1)
 		{
-			if ($statut == 1) return $langs->trans('Enabled');
-			elseif ($statut == 0) return $langs->trans('Disabled');
+			if ($status == 1) return $langs->trans('Enabled');
+			elseif ($status == 0) return $langs->trans('Disabled');
 		}
 		elseif ($mode == 2)
 		{
-			if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 3)
 		{
-			if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4');
-			elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5');
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5');
 		}
 		elseif ($mode == 4)
 		{
-			if ($statut == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
-			elseif ($statut == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
+			if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled');
+			elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled');
 		}
 		elseif ($mode == 5)
 		{
-			if ($statut == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
-			elseif ($statut == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
+			if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4');
+			elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5');
 		}
 	}
 }

+ 5 - 0
htdocs/accountancy/class/bookkeeping.class.php

@@ -1975,7 +1975,12 @@ class BookKeepingLine
 	public $code_journal;
 	public $journal_label;
 	public $piece_num;
+
+	/**
+     * @var integer|string date_creation
+     */
 	public $date_creation;
+
     public $date_modification;
     public $date_export;
 }

+ 1 - 1
htdocs/accountancy/closure/index.php

@@ -34,7 +34,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy"));
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->fiscalyear->write)
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/closure/validate.php

@@ -34,7 +34,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy"));
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 	if (! $user->rights->accounting->fiscalyear->write)
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/customer/card.php

@@ -38,7 +38,7 @@ $codeventil = GETPOST('codeventil');
 $id = GETPOST('id');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 

+ 1 - 1
htdocs/accountancy/customer/index.php

@@ -39,7 +39,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy"));
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -72,7 +72,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -83,7 +83,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/expensereport/card.php

@@ -42,7 +42,7 @@ $codeventil = GETPOST('codeventil');
 $id = GETPOST('id');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 

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

@@ -36,7 +36,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy"));
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -67,7 +67,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -77,7 +77,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

+ 1 - 1
htdocs/accountancy/index.php

@@ -32,7 +32,7 @@ require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php';
 $langs->loadLangs(array("compta","bills","other","accountancy","loans","banks","admin","dict"));
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array of hooks

+ 4 - 4
htdocs/accountancy/journal/bankjournal.php

@@ -80,7 +80,7 @@ $now = dol_now();
 $action = GETPOST('action', 'aZ09');
 
 // Security check
-if ($user->societe_id > 0 && empty($id_journal))
+if ($user->socid > 0 && empty($id_journal))
 	accessforbidden();
 
 
@@ -323,11 +323,11 @@ if ($result) {
 					if (preg_match('/^\((.*)\)$/i', $links[$key]['label'], $reg)) {
 						if ($reg[1] == 'socialcontribution')
 							$reg[1] = 'SocialContribution';
-						$chargestatic->lib = $langs->trans($reg[1]);
+						$chargestatic->label = $langs->trans($reg[1]);
 					} else {
-						$chargestatic->lib = $links[$key]['label'];
+						$chargestatic->label = $links[$key]['label'];
 					}
-					$chargestatic->ref = $chargestatic->lib;
+					$chargestatic->ref = $chargestatic->label;
 					$tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, 30);
 					$tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
 

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

@@ -56,7 +56,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
 $now = dol_now();
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 /*

+ 1 - 1
htdocs/accountancy/journal/purchasesjournal.php

@@ -56,7 +56,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
 $now = dol_now();
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 $hookmanager->initHooks(array('purchasesjournal'));

+ 1 - 1
htdocs/accountancy/journal/sellsjournal.php

@@ -58,7 +58,7 @@ if ($in_bookkeeping == '') $in_bookkeeping = 'notyet';
 $now = dol_now();
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 $hookmanager->initHooks(array('sellsjournal'));

+ 1 - 1
htdocs/accountancy/supplier/card.php

@@ -42,7 +42,7 @@ $codeventil = GETPOST('codeventil');
 $id = GETPOST('id');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 
 

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

@@ -37,7 +37,7 @@ $langs->loadLangs(array("compta","bills","other","main","accountancy"));
 if (empty($conf->accounting->enabled)) {
 	accessforbidden();
 }
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -74,7 +74,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

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

@@ -83,7 +83,7 @@ if (! $sortorder) {
 }
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 	accessforbidden();
 if (! $user->rights->accounting->bind->write)
 	accessforbidden();

+ 1 - 1
htdocs/adherents/admin/website.php

@@ -178,7 +178,7 @@ if (! empty($conf->global->MEMBER_ENABLE_PUBLIC))
 	$listofval = array(-1 => $langs->trans("Undefined"));
 	$listofval += $adht->liste_array();
 	$forcetype = $conf->global->MEMBER_NEWFORM_FORCETYPE ?: -1;
-	print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listetype)>1?1:0);
+	print $form->selectarray("MEMBER_NEWFORM_FORCETYPE", $listofval, $forcetype, count($listofval)>1?1:0);
 	print "</td></tr>\n";
 
 	// Amount

+ 1 - 1
htdocs/adherents/canvas/default/tpl/adherentcard_view.tpl.php

@@ -118,7 +118,7 @@ if (! empty($this->control->tpl['action_delete'])) echo $this->control->tpl['act
 
 <?php echo $this->control->tpl['showend'];
 
-if (empty($user->societe_id)) {
+if (empty($user->socid)) {
     echo '<div class="tabsAction">';
 
     if ($user->rights->adherent->creer) {

+ 9 - 9
htdocs/adherents/card.php

@@ -983,7 +983,7 @@ else
 		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><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOST('member_email', 'alpha')?GETPOST('member_email', 'alpha'):$object->email).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(GETPOST('member_email', 'alpha')?GETPOST('member_email', 'alpha'):$object->email).'"></td></tr>';
 
 		// Address
 		print '<tr><td class="tdtop">'.$langs->trans("Address").'</td><td>';
@@ -1020,13 +1020,13 @@ else
 		}
 
 		// Pro phone
-		print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone', 'alpha')?GETPOST('phone', 'alpha'):$object->phone).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(GETPOST('phone', 'alpha')?GETPOST('phone', 'alpha'):$object->phone).'"></td></tr>';
 
 		// Personal phone
-		print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso', 'alpha')?GETPOST('phone_perso', 'alpha'):$object->phone_perso).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(GETPOST('phone_perso', 'alpha')?GETPOST('phone_perso', 'alpha'):$object->phone_perso).'"></td></tr>';
 
 		// Mobile phone
-		print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile', 'alpha')?GETPOST('phone_mobile', 'alpha'):$object->phone_mobile).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(GETPOST('phone_mobile', 'alpha')?GETPOST('phone_mobile', 'alpha'):$object->phone_mobile).'"></td></tr>';
 
 	    // Skype
 	    if (! empty($conf->socialnetworks->enabled))
@@ -1259,7 +1259,7 @@ else
 		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><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"])?GETPOST("member_email", '', 2):$object->email).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_email').' '.($conf->global->ADHERENT_MAIL_REQUIRED?'<span class="fieldrequired">':'').$langs->trans("EMail").($conf->global->ADHERENT_MAIL_REQUIRED?'</span>':'').'</td><td><input type="text" name="member_email" class="minwidth300" maxlength="255" value="'.(isset($_POST["member_email"])?GETPOST("member_email", '', 2):$object->email).'"></td></tr>';
 
 		// Address
 		print '<tr><td>'.$langs->trans("Address").'</td><td>';
@@ -1289,13 +1289,13 @@ else
 		}
 
 		// Pro phone
-		print '<tr><td>'.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?GETPOST("phone"):$object->phone).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePro").'</td><td><input type="text" name="phone" size="20" value="'.(isset($_POST["phone"])?GETPOST("phone"):$object->phone).'"></td></tr>';
 
 		// Personal phone
-		print '<tr><td>'.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?GETPOST("phone_perso"):$object->phone_perso).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning').' '.$langs->trans("PhonePerso").'</td><td><input type="text" name="phone_perso" size="20" value="'.(isset($_POST["phone_perso"])?GETPOST("phone_perso"):$object->phone_perso).'"></td></tr>';
 
 		// Mobile phone
-		print '<tr><td>'.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?GETPOST("phone_mobile"):$object->phone_mobile).'"></td></tr>';
+		print '<tr><td>'.img_picto('', 'object_phoning_mobile').' '.$langs->trans("PhoneMobile").'</td><td><input type="text" name="phone_mobile" size="20" value="'.(isset($_POST["phone_mobile"])?GETPOST("phone_mobile"):$object->phone_mobile).'"></td></tr>';
 
 	    // Skype
 	    if (! empty($conf->socialnetworks->enabled))
@@ -1885,7 +1885,7 @@ else
 				}
 
 				// Create user
-				if (! $user->societe_id && ! $object->user_id)
+				if (! $user->socid && ! $object->user_id)
 				{
 					if ($user->rights->user->user->creer)
 					{

+ 43 - 72
htdocs/adherents/class/adherent.class.php

@@ -174,7 +174,7 @@ class Adherent extends CommonObject
 
     // -1:brouillon, 0:resilie, >=1:valide,paye
     // def in common object
-    //public $statut;
+    //public $status;
 
     public $photo;
 
@@ -2132,7 +2132,11 @@ class Adherent extends CommonObject
 			// Only picto
 			if ($withpictoimg > 0) $picto='<span class="nopadding'.($morecss?' userimg'.$morecss:'').'">'.img_object('', 'user', $paddafterimage.' '.($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).'</span>';
 			// Picto must be a photo
-			else $picto='<span class="nopadding'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>'.Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1).'</span>';
+			else {
+				$picto='<span class="nopadding'.($morecss?' userimg'.$morecss:'').'"'.($paddafterimage?' '.$paddafterimage:'').'>';
+				$picto.=Form::showphoto('memberphoto', $this, 0, 0, 0, 'userphoto'.($withpictoimg==-3?'small':''), 'mini', 0, 1);
+				$picto.='</span>';
+			}
 			$result.=$picto;
 		}
 		if ($withpictoimg > -2 && $withpictoimg != 2)
@@ -2164,94 +2168,61 @@ class Adherent extends CommonObject
 	/**
 	 *  Renvoi le libelle d'un statut donne
 	 *
-	 *  @param	int			$statut      			Id statut
+	 *  @param	int			$status      			Id status
 	 *	@param	int			$need_subscription		1 if member type need subscription, 0 otherwise
 	 *	@param	int     	$date_end_subscription	Date fin adhesion
 	 *  @param  int		    $mode                   0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto
 	 *  @return string      						Label
 	 */
-	public function LibStatut($statut, $need_subscription, $date_end_subscription, $mode = 0)
+	public function LibStatut($status, $need_subscription, $date_end_subscription, $mode = 0)
 	{
         // phpcs:enable
 		global $langs;
 		$langs->load("members");
-		if ($mode == 0)
-		{
-			if ($statut == -1) return $langs->trans("MemberStatusDraft");
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return $langs->trans("MemberStatusNoSubscription");
-				elseif (! $date_end_subscription)        return $langs->trans("MemberStatusActive");
-				elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate");
-				else                                     return $langs->trans("MemberStatusPaid");
-			}
-			elseif ($statut == 0)  return $langs->trans("MemberStatusResiliated");
-		}
-		elseif ($mode == 1)
+
+        $statusType = '';
+        $labelStatus = '';
+        $labelStatusShort = '';
+
+		if ($status == -1)
 		{
-			if ($statut == -1) return $langs->trans("MemberStatusDraftShort");
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return $langs->trans("MemberStatusNoSubscription");
-				elseif (! $date_end_subscription)        return $langs->trans("MemberStatusActiveShort");
-				elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLateShort");
-				else                                     return $langs->trans("MemberStatusPaidShort");
-			}
-			elseif ($statut == 0)  return $langs->trans("MemberStatusResiliatedShort");
+			$statusType = 'status0';
+			$labelStatus = $langs->trans("MemberStatusDraft");
+			$labelStatusShort = $langs->trans("MemberStatusDraftShort");
 		}
-		elseif ($mode == 2)
-		{
-			if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraftShort");
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscriptionShort");
-				elseif (! $date_end_subscription)        return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActiveShort");
-				elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLateShort");
-				else                                     return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaidShort");
+		elseif ($status >= 1) {
+			if ($need_subscription == 0)
+			{
+				$statusType = 'status4';
+				$labelStatus = $langs->trans("MemberStatusNoSubscription");
+				$labelStatusShort = $langs->trans("MemberStatusNoSubscriptionShort");
 			}
-			elseif ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliatedShort");
-		}
-		elseif ($mode == 3)
-		{
-			if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0');
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4');
-				elseif (! $date_end_subscription)        return img_picto($langs->trans('MemberStatusActive'), 'statut1');
-				elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3');
-				else                                     return img_picto($langs->trans('MemberStatusPaid'), 'statut4');
+			elseif (! $date_end_subscription)
+			{
+				$statusType = 'status1';
+				$labelStatus = $langs->trans("MemberStatusActive");
+				$labelStatusShort = $langs->trans("MemberStatusActiveShort");
 			}
-			elseif ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'), 'statut5');
-		}
-		elseif ($mode == 4)
-		{
-			if ($statut == -1) return img_picto($langs->trans('MemberStatusDraft'), 'statut0').' '.$langs->trans("MemberStatusDraft");
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4').' '.$langs->trans("MemberStatusNoSubscription");
-				elseif (! $date_end_subscription)        return img_picto($langs->trans('MemberStatusActive'), 'statut1').' '.$langs->trans("MemberStatusActive");
-				elseif ($date_end_subscription < time()) return img_picto($langs->trans('MemberStatusActiveLate'), 'statut3').' '.$langs->trans("MemberStatusActiveLate");
-				else                                     return img_picto($langs->trans('MemberStatusPaid'), 'statut4').' '.$langs->trans("MemberStatusPaid");
+			elseif ($date_end_subscription < time())
+			{
+				$statusType = 'status3';
+				$labelStatus = $langs->trans("MemberStatusActiveLate");
+				$labelStatusShort = $langs->trans("MemberStatusActiveLateShort");
 			}
-			if ($statut == 0)  return img_picto($langs->trans('MemberStatusResiliated'), 'statut5').' '.$langs->trans("MemberStatusResiliated");
-		}
-		elseif ($mode == 5)
-		{
-		    if ($statut == -1) return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusDraftShort").'</span> '.img_picto($langs->trans('MemberStatusDraft'), 'statut0');
-			elseif ($statut >= 1) {
-				if ($need_subscription == 0)		 return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusNoSubscriptionShort").' </span>'.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4');
-				elseif (! $date_end_subscription)        return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusActiveShort").' </span>'.img_picto($langs->trans('MemberStatusActive'), 'statut1');
-				elseif ($date_end_subscription < time()) return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusActiveLateShort").' </span>'.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3');
-				else                                     return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusPaidShort").' </span>'.img_picto($langs->trans('MemberStatusPaid'), 'statut4');
+			else {
+				$statusType = 'status4';
+				$labelStatus = $langs->trans("MemberStatusPaid");
+				$labelStatusShort = $langs->trans("MemberStatusPaidShort");
 			}
-			if ($statut == 0)  return '<span class="hideonsmartphone">'.$langs->trans("MemberStatusResiliated").' </span>'.img_picto($langs->trans('MemberStatusResiliated'), 'statut5');
 		}
-		elseif ($mode == 6)
+		elseif ($status == 0)
 		{
-		    if ($statut == -1) return $langs->trans("MemberStatusDraft").' '.img_picto($langs->trans('MemberStatusDraft'), 'statut0');
-			if ($statut >= 1) {
-				if ($need_subscription == 0)		 return $langs->trans("MemberStatusNoSubscription").' '.img_picto($langs->trans('MemberStatusNoSubscription'), 'statut4');
-				elseif (! $date_end_subscription)        return $langs->trans("MemberStatusActive").' '.img_picto($langs->trans('MemberStatusActive'), 'statut1');
-				elseif ($date_end_subscription < time()) return $langs->trans("MemberStatusActiveLate").' '.img_picto($langs->trans('MemberStatusActiveLate'), 'statut3');
-				else                                     return $langs->trans("MemberStatusPaid").' '.img_picto($langs->trans('MemberStatusPaid'), 'statut4');
-			}
-			if ($statut == 0)  return $langs->trans("MemberStatusResiliated").' '.img_picto($langs->trans('MemberStatusResiliated'), 'statut5');
+			$statusType = 'status6';
+			$labelStatus = $langs->trans("MemberStatusResiliated");
+			$labelStatusShort = $langs->trans("MemberStatusResiliatedShort");
 		}
+
+		return dolGetStatus($labelStatus, $labelStatusShort, '', $statusType, $mode);
 	}
 
 

+ 4 - 4
htdocs/adherents/class/adherentstats.class.php

@@ -70,7 +70,7 @@ class AdherentStats extends Stats
 
 		$this->where.= " m.statut != 0";
 		$this->where.= " AND p.fk_adherent = m.rowid AND m.entity IN (".getEntity('adherent').")";
-		//if (!$user->rights->societe->client->voir && !$user->societe_id) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+		//if (!$user->rights->societe->client->voir && !$user->socid) $this->where .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
 		if($this->memberid)
 		{
 			$this->where .= " AND m.rowid = ".$this->memberid;
@@ -92,7 +92,7 @@ class AdherentStats extends Stats
 
 		$sql = "SELECT date_format(p.dateadh,'%m') as dm, count(*)";
 		$sql.= " FROM ".$this->from;
-		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
 		$sql.= " AND ".$this->where;
 		$sql.= " GROUP BY dm";
@@ -112,7 +112,7 @@ class AdherentStats extends Stats
 
 		$sql = "SELECT date_format(p.dateadh,'%Y') as dm, count(*)";
 		$sql.= " FROM ".$this->from;
-		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 		$sql.= " WHERE ".$this->where;
 		$sql.= " GROUP BY dm";
         $sql.= $this->db->order('dm', 'DESC');
@@ -133,7 +133,7 @@ class AdherentStats extends Stats
 
 		$sql = "SELECT date_format(p.dateadh,'%m') as dm, sum(p.".$this->field.")";
 		$sql.= " FROM ".$this->from;
-		//if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
+		//if (!$user->rights->societe->client->voir && !$user->socid) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 		$sql.= " WHERE date_format(p.dateadh,'%Y') = '".$year."'";
 		$sql.= " AND ".$this->where;
 		$sql.= " GROUP BY dm";

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

@@ -431,10 +431,10 @@ class Subscription extends CommonObject
     /**
      *  Renvoi le libelle d'un statut donne
      *
-     *  @param	int			$statut      			Id statut
+     *  @param	int			$status      			Id status
      *  @return string      						Label
      */
-    public function LibStatut($statut)
+    public function LibStatut($status)
     {
         // phpcs:enable
         global $langs;

+ 2 - 2
htdocs/adherents/htpasswd.php

@@ -42,7 +42,7 @@ if (empty($sortorder)) {  $sortorder="ASC"; }
 if (empty($sortfield)) {  $sortfield="d.login"; }
 if (! isset($statut))
 {
-	$statut = 1 ;
+	$statut = 1;
 }
 
 if (! isset($cotis))
@@ -54,7 +54,7 @@ if (! isset($cotis))
 
 $sql = "SELECT d.login, d.pass, d.datefin";
 $sql .= " FROM ".MAIN_DB_PREFIX."adherent as d ";
-$sql .= " WHERE d.statut = $statut ";
+$sql .= " WHERE d.statut = ".$statut;
 if ($cotis==1)
 {
 	$sql .= " AND datefin > '".$db->idate($now)."'";

+ 23 - 11
htdocs/adherents/index.php

@@ -61,7 +61,7 @@ $AdherentsResilies=array();
 
 $AdherentType=array();
 
-// Members list
+// Type of membership
 $sql = "SELECT t.rowid, t.libelle as label, t.subscription,";
 $sql.= " d.statut, count(d.rowid) as somme";
 $sql.= " FROM ".MAIN_DB_PREFIX."adherent_type as t";
@@ -71,7 +71,7 @@ $sql.= " AND d.entity IN (".getEntity('adherent').")";
 $sql.= " WHERE t.entity IN (".getEntity('member_type').")";
 $sql.= " GROUP BY t.rowid, t.libelle, t.subscription, d.statut";
 
-dol_syslog("index.php::select nb of members by type", LOG_DEBUG);
+dol_syslog("index.php::select nb of members per type", LOG_DEBUG);
 $result = $db->query($sql);
 if ($result)
 {
@@ -140,6 +140,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     {
     	print '<form method="post" action="'.DOL_URL_ROOT.'/core/search.php">';
     	print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+        print '<div class="div-table-responsive-no-min">';
     	print '<table class="noborder nohover centpercent">';
     	$i=0;
     	foreach($listofsearchfields as $key => $value)
@@ -152,6 +153,7 @@ if (! empty($conf->global->MAIN_SEARCH_FORM_ON_HOME_AREAS))     // This is usele
     		$i++;
     	}
     	print '</table>';
+        print '</div>';
     	print '</form>';
     	print '<br>';
     }
@@ -227,10 +229,8 @@ $sql = "SELECT c.subscription, c.dateadh as dateh";
 $sql.= " FROM ".MAIN_DB_PREFIX."adherent as d, ".MAIN_DB_PREFIX."subscription as c";
 $sql.= " WHERE d.entity IN (".getEntity('adherent').")";
 $sql.= " AND d.rowid = c.fk_adherent";
-if(isset($date_select) && $date_select != '')
-{
-    $sql .= " AND c.dateadh LIKE '".$date_select."%'";
-}
+
+
 $result = $db->query($sql);
 if ($result)
 {
@@ -251,21 +251,33 @@ if ($result)
 print '<div class="div-table-responsive-no-min">';
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
-print '<th>'.$langs->trans("Subscriptions").'</th>';
-print '<th class="right">'.$langs->trans("Number").'</th>';
+print '<th>'.$langs->trans("Year").'</th>';
+print '<th class="right">'.$langs->trans("Subscriptions").'</th>';
 print '<th class="right">'.$langs->trans("AmountTotal").'</th>';
 print '<th class="right">'.$langs->trans("AmountAverage").'</th>';
 print "</tr>\n";
 
 krsort($Total);
+$i = 0;
 foreach ($Total as $key=>$value)
 {
-    print '<tr class="oddeven">';
+	if ($i >= 8)
+	{
+		print '<tr class="oddeven">';
+		print "<td>...</td>";
+		print "<td class=\"right\"></td>";
+		print "<td class=\"right\"></td>";
+		print "<td class=\"right\"></td>";
+		print "</tr>\n";
+		break;
+	}
+	print '<tr class="oddeven">';
     print "<td><a href=\"./subscription/list.php?date_select=$key\">$key</a></td>";
     print "<td class=\"right\">".$Number[$key]."</td>";
     print "<td class=\"right\">".price($value)."</td>";
     print "<td class=\"right\">".price(price2num($value/$Number[$key], 'MT'))."</td>";
     print "</tr>\n";
+    $i++;
 }
 
 // Total
@@ -282,7 +294,7 @@ print "<br>\n";
 print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
 
 /*
- * Last modified members
+ * Latest modified members
  */
 $max=5;
 
@@ -330,7 +342,7 @@ if ($resql)
 			print '<td>'.$staticmember->getNomUrl(1, 32).'</td>';
 			print '<td>'.$statictype->getNomUrl(1, 32).'</td>';
 			print '<td>'.dol_print_date($db->jdate($obj->datem), 'dayhour').'</td>';
-			print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 5).'</td>';
+			print '<td class="right">'.$staticmember->LibStatut($obj->statut, ($obj->subscription=='yes'?1:0), $db->jdate($obj->date_end_subscription), 3).'</td>';
 			print '</tr>';
 			$i++;
 		}

+ 2 - 2
htdocs/adherents/ldap.php

@@ -37,9 +37,9 @@ $action = GETPOST('action', 'aZ09');
 
 // Protection
 $socid=0;
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
-    $socid = $user->societe_id;
+    $socid = $user->socid;
 }
 
 $object = new Adherent($db);

+ 1 - 0
htdocs/adherents/list.php

@@ -681,6 +681,7 @@ while ($i < min($num, $limit))
 	$memberstatic->datefin= $datefin;
 	$memberstatic->socid = $obj->fk_soc;
 	$memberstatic->photo = $obj->photo;
+	$memberstatic->morphy = $obj->morphy;
 
 	if (! empty($obj->fk_soc)) {
 		$memberstatic->fetch_thirdparty();

+ 2 - 2
htdocs/adherents/stats/byproperties.php

@@ -33,10 +33,10 @@ $mode=GETPOST('mode')?GETPOST('mode'):'';
 
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
     $action = '';
-    $socid = $user->societe_id;
+    $socid = $user->socid;
 }
 $result=restrictedArea($user, 'adherent', '', '', 'cotisation');
 

+ 2 - 2
htdocs/adherents/stats/geo.php

@@ -34,10 +34,10 @@ $mode=GETPOST('mode')?GETPOST('mode'):'';
 
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
     $action = '';
-    $socid = $user->societe_id;
+    $socid = $user->socid;
 }
 $result=restrictedArea($user, 'adherent', '', '', 'cotisation');
 

+ 2 - 2
htdocs/adherents/stats/index.php

@@ -35,10 +35,10 @@ $userid=GETPOST('userid', 'int'); if ($userid < 0) $userid=0;
 $socid=GETPOST('socid', 'int'); if ($socid < 0) $socid=0;
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
     $action = '';
-    $socid = $user->societe_id;
+    $socid = $user->socid;
 }
 $result=restrictedArea($user, 'adherent', '', '', 'cotisation');
 

+ 1 - 1
htdocs/adherents/type_translation.php

@@ -41,7 +41,7 @@ $cancel=GETPOST('cancel', 'alpha');
 // Security check
 $fieldvalue = (! empty($id) ? $id : (! empty($ref) ? $ref : ''));
 $fieldtype = (! empty($ref) ? 'ref' : 'rowid');
-if ($user->societe_id) $socid=$user->societe_id;
+if ($user->socid) $socid=$user->socid;
 // Security check
 $result=restrictedArea($user, 'adherent', $id, 'adherent_type');
 

+ 2 - 2
htdocs/admin/barcode.php

@@ -208,7 +208,7 @@ print '<td width="200" class="center">'.$langs->trans("Example").'</td>';
 print '<td class="center" width="60">'.$langs->trans("CodeBarGenerator").'</td>';
 print "</tr>\n";
 
-$sql = "SELECT rowid, code as encoding, libelle, coder, example";
+$sql = "SELECT rowid, code as encoding, libelle as label, coder, example";
 $sql.= " FROM ".MAIN_DB_PREFIX."c_barcode_type";
 $sql.= " WHERE entity = ".$conf->entity;
 $sql.= " ORDER BY code";
@@ -225,7 +225,7 @@ if ($resql)
 		$obj = $db->fetch_object($resql);
 
 		print '<tr class="oddeven"><td width="100">';
-		print $obj->libelle;
+		print $obj->label;
 		print "</td><td>\n";
 		print $langs->trans('BarcodeDesc'.$obj->encoding);
 		//print "L'EAN se compose de 8 caracteres, 7 chiffres plus une cle de controle.<br>";

+ 181 - 218
htdocs/admin/bom.php

@@ -183,16 +183,6 @@ elseif ($action == 'set_BOM_FREE_TEXT')
     {
         setEventMessages($langs->trans("Error"), null, 'errors');
     }
-} elseif ($action=="setshippableiconinlist") {
-    // Activate Set Shippable Icon In List
-    $setshippableiconinlist = GETPOST('value', 'int');
-    $res = dolibarr_set_const($db, "SHIPPABLE_BOM_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
-    if (! $res > 0) $error++;
-    if (! $error) {
-        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
-    } else {
-        setEventMessages($langs->trans("Error"), null, 'errors');
-    }
 }
 
 
@@ -314,244 +304,217 @@ foreach ($dirmodels as $reldir)
 print "</table><br>\n";
 
 
-if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
+/*
+ * Document templates generators
+ */
+
+print load_fiche_titre($langs->trans("BOMsModelModule"), '', '');
+
+// Load array def with activated templates
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
 {
-    /*
-     * Document templates generators
-     */
-
-    print load_fiche_titre($langs->trans("BOMsModelModule"), '', '');
-
-    // Load array def with activated templates
-    $def = array();
-    $sql = "SELECT nom";
-    $sql.= " FROM ".MAIN_DB_PREFIX."document_model";
-    $sql.= " WHERE type = '".$type."'";
-    $sql.= " AND entity = ".$conf->entity;
-    $resql=$db->query($sql);
-    if ($resql)
-    {
-    	$i = 0;
-    	$num_rows=$db->num_rows($resql);
-    	while ($i < $num_rows)
-    	{
-    		$array = $db->fetch_array($resql);
-    		array_push($def, $array[0]);
-    		$i++;
-    	}
-    }
-    else
-    {
-    	dol_print_error($db);
-    }
+	$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);
+}
 
 
-    print "<table class=\"noborder\" width=\"100%\">\n";
-    print "<tr class=\"liste_titre\">\n";
-    print '<td>'.$langs->trans("Name").'</td>';
-    print '<td>'.$langs->trans("Description").'</td>';
-    print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
-    print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
-    print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
-    print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
-    print "</tr>\n";
+print "<table class=\"noborder\" width=\"100%\">\n";
+print "<tr class=\"liste_titre\">\n";
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
+print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
+print "</tr>\n";
 
-    clearstatcache();
+clearstatcache();
 
-    foreach ($dirmodels as $reldir)
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
     {
-        foreach (array('','/doc') as $valdir)
-        {
-        	$dir = dol_buildpath($reldir."core/modules/bom".$valdir);
+    	$dir = dol_buildpath($reldir."core/modules/bom".$valdir);
 
-            if (is_dir($dir))
+        if (is_dir($dir))
+        {
+            $handle=opendir($dir);
+            if (is_resource($handle))
             {
-                $handle=opendir($dir);
-                if (is_resource($handle))
+                while (($file = readdir($handle))!==false)
                 {
-                    while (($file = readdir($handle))!==false)
-                    {
-                        $filelist[]=$file;
-                    }
-                    closedir($handle);
-                    arsort($filelist);
+                    $filelist[]=$file;
+                }
+                closedir($handle);
+                arsort($filelist);
 
-                    foreach($filelist as $file)
+                foreach($filelist as $file)
+                {
+                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
                     {
-                        if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
-                        {
-                        	if (file_exists($dir.'/'.$file))
-                        	{
-                        		$name = substr($file, 4, dol_strlen($file) -16);
-    	                        $classname = substr($file, 0, dol_strlen($file) -12);
-
-    	                        require_once $dir.'/'.$file;
-    	                        $module = new $classname($db);
-
-    	                        $modulequalified=1;
-    	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
-    	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
-
-    	                        if ($modulequalified)
-    	                        {
-    	                            $var = !$var;
-    	                            print '<tr class="oddeven"><td width="100">';
-    	                            print (empty($module->name)?$name:$module->name);
-    	                            print "</td><td>\n";
-    	                            if (method_exists($module, 'info')) print $module->info($langs);
-    	                            else print $module->description;
-    	                            print '</td>';
-
-    	                            // Active
-    	                            if (in_array($name, $def))
-    	                            {
-    	                            	print '<td class="center">'."\n";
-    	                            	print '<a 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 href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
-    	                                print "</td>";
-    	                            }
-
-    	                            // Default
-    	                            print '<td class="center">';
-    	                            if ($conf->global->BOM_ADDON_PDF == $name)
-    	                            {
-    	                                print img_picto($langs->trans("Default"), 'on');
-    	                            }
-    	                            else
-    	                            {
-    	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
-    	                            }
-    	                            print '</td>';
-
-    	                            // Info
-    		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
-    					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
-    			                    if ($module->type == 'pdf')
-    			                    {
-    			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
-    			                    }
-    					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
-    					    		$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
-    					    		$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
-    					    		$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
-    					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
-    					    		//$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
-    					    		//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
-    					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
-
-
-    	                            print '<td class="center">';
-    	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
-    	                            print '</td>';
-
-    	                            // Preview
-    	                            print '<td class="center">';
-    	                            if ($module->type == 'pdf')
-    	                            {
-    	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
-    	                            }
-    	                            else
-    	                            {
-    	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
-    	                            }
-    	                            print '</td>';
-
-    	                            print "</tr>\n";
-    	                        }
-                        	}
-                        }
+                    	if (file_exists($dir.'/'.$file))
+                    	{
+                    		$name = substr($file, 4, dol_strlen($file) -16);
+	                        $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                        require_once $dir.'/'.$file;
+	                        $module = new $classname($db);
+
+	                        $modulequalified=1;
+	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+
+	                        if ($modulequalified)
+	                        {
+	                            $var = !$var;
+	                            print '<tr class="oddeven"><td width="100">';
+	                            print (empty($module->name)?$name:$module->name);
+	                            print "</td><td>\n";
+	                            if (method_exists($module, 'info')) print $module->info($langs);
+	                            else print $module->description;
+	                            print '</td>';
+
+	                            // Active
+	                            if (in_array($name, $def))
+	                            {
+	                            	print '<td class="center">'."\n";
+	                            	print '<a 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 href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Default
+	                            print '<td class="center">';
+	                            if ($conf->global->BOM_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"), 'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	                            }
+	                            print '</td>';
+
+	                            // Info
+		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+			                    if ($module->type == 'pdf')
+			                    {
+			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+			                    }
+					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+	                            print '<td class="center">';
+	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td class="center">';
+	                            if ($module->type == 'pdf')
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+	                            }
+	                            else
+	                            {
+	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+	                            }
+	                            print '</td>';
+
+	                            print "</tr>\n";
+	                        }
+                    	}
                     }
                 }
             }
         }
     }
-
-    print '</table>';
-    print "<br>";
-
-    /*
-     * Other options
-     */
-
-    print load_fiche_titre($langs->trans("OtherOptions"), '', '');
-    print '<table class="noborder" width="100%">';
-    print '<tr class="liste_titre">';
-    print '<td>'.$langs->trans("Parameter").'</td>';
-    print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
-    print "<td>&nbsp;</td>\n";
-    print "</tr>\n";
-
-    $substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
-    $substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
-    $htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
-    foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
-    $htmltext.='</i>';
-
-    print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
-    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
-    print '<tr class="oddeven"><td colspan="2">';
-    print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
-    $variablename='BOM_FREE_TEXT';
-    if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
-    {
-        print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
-    }
-    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><td class="right">';
-    print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
-    print "</td></tr>\n";
-    print '</form>';
-
-    //Use draft Watermark
-
-    print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
-    print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-    print "<input type=\"hidden\" name=\"action\" value=\"set_BOM_DRAFT_WATERMARK\">";
-    print '<tr class="oddeven"><td>';
-    print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
-    print '</td><td>';
-    print '<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.$conf->global->BOM_DRAFT_WATERMARK.'">';
-    print '</td><td class="right">';
-    print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
-    print "</td></tr>\n";
-    print '</form>';
-
-    print '</table>';
-    print '<br>';
 }
 
+print '</table>';
+print "<br>";
+
 /*
- * Notifications
+ * Other options
  */
-/*
-print load_fiche_titre($langs->trans("Notifications"), '', '');
+
+print load_fiche_titre($langs->trans("OtherOptions"), '', '');
 print '<table class="noborder" width="100%">';
 print '<tr class="liste_titre">';
 print '<td>'.$langs->trans("Parameter").'</td>';
-print '<td class="center" width="60"></td>';
-print '<td width="80">&nbsp;</td>';
+print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
+print "<td>&nbsp;</td>\n";
 print "</tr>\n";
 
+$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
+$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
+$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
+foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
+$htmltext.='</i>';
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="set_BOM_FREE_TEXT">';
 print '<tr class="oddeven"><td colspan="2">';
-print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
+print $form->textwithpicto($langs->trans("FreeLegalTextOnBOMs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
+$variablename='BOM_FREE_TEXT';
+if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
+{
+    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+}
+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><td class="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+//Use draft Watermark
+
+print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print "<input type=\"hidden\" name=\"action\" value=\"set_BOM_DRAFT_WATERMARK\">";
+print '<tr class="oddeven"><td>';
+print $form->textwithpicto($langs->trans("WatermarkOnDraftBOMs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
+print '</td><td>';
+print '<input class="flat minwidth200" type="text" name="BOM_DRAFT_WATERMARK" value="'.$conf->global->BOM_DRAFT_WATERMARK.'">';
 print '</td><td class="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
 print "</td></tr>\n";
+print '</form>';
 
 print '</table>';
-*/
+print '<br>';
+
 
 // End of page
 llxFooter();

+ 4 - 50
htdocs/admin/dolistore/class/PSWebServiceLibrary.class.php

@@ -18,10 +18,10 @@
 * versions in the future. If you wish to customize PrestaShop for your
 * needs please refer to http://www.prestashop.com for more information.
 *
-*  @author PrestaShop SA <contact@prestashop.com>
-*  @copyright  2007-2013 PrestaShop SA
-*  @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
-*  International Registered Trademark & Property of PrestaShop SA
+* @author PrestaShop SA <contact@prestashop.com>
+* @copyright  2007-2013 PrestaShop SA
+* @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
+* International Registered Trademark & Property of PrestaShop SA
 * PrestaShop Webservice Library
 * @package PrestaShopWebservice
 */
@@ -395,52 +395,6 @@ class PrestaShopWebservice
 		self::checkStatusCode($request['status_code']);// check the response validity
 		return self::parseXML($request['response']);
 	}
-
-	/**
-	 * Delete (DELETE) a resource.
-	 * Unique parameter must take : <br><br>
-	 * 'resource' => Resource name<br>
-	 * 'id' => ID or array which contains IDs of a resource(s) you want to delete<br><br>
-	 * <code>
-	 * <?php
-	 * require_once('./PrestaShopWebservice.php');
-	 * try
-	 * {
-	 * $ws = new PrestaShopWebservice('http://mystore.com/', 'ZQ88PRJX5VWQHCWE4EE7SQ7HPNX00RAJ', false);
-	 * $xml = $ws->delete(array('resource' => 'orders', 'id' => 1));
-	 *	// Following code will not be executed if an exception is thrown.
-	 * 	echo 'Successfully deleted.';
-	 * }
-	 * catch (PrestaShopWebserviceException $ex)
-	 * {
-	 * 	echo 'Error : '.$ex->getMessage();
-	 * }
-	 * ?>
-	 * </code>
-	 *
-	 * @param  array       $options        Array representing resource to delete.
-	 * @return boolean                     True
-	 */
-	public function delete($options)
-	{
-	    if (isset($options['url'])) {
-	        $url = $options['url'];
-		} elseif (isset($options['resource']) && isset($options['id'])) {
-    	    if (is_array($options['id']))
-    	        $url = $this->url.'/api/'.$options['resource'].'/?id=['.implode(',', $options['id']).']';
-    	    else
-				$url = $this->url.'/api/'.$options['resource'].'/'.$options['id'];
-		}
-	    if (isset($options['id_shop'])) {
-			$url .= '&id_shop='.$options['id_shop'];
-		}
-	    if (isset($options['id_group_shop'])) {
-			$url .= '&id_group_shop='.$options['id_group_shop'];
-		}
-	    $request = self::executeRequest($url, array(CURLOPT_CUSTOMREQUEST => 'DELETE'));
-	    self::checkStatusCode($request['status_code']);// check the response validity
-	    return true;
-	}
 }
 
 /**

+ 5 - 5
htdocs/admin/emailcollector_card.php

@@ -75,8 +75,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php';  // Must be include, not include_once.
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$isdraft = (($object->statut == MyObject::STATUS_DRAFT) ? 1 : 0);
 //$result = restrictedArea($user, 'mymodule', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
 
@@ -260,7 +260,7 @@ if ($action == 'create') {
 
 	dol_fiche_head(array(), '');
 
-	print '<table class="border centpercent">'."\n";
+	print '<table class="border centpercent tableforfield">'."\n";
 
 	//unset($fields[]);
 
@@ -296,7 +296,7 @@ if (($id || $ref) && $action == 'edit')
 
 	dol_fiche_head();
 
-	print '<table class="border centpercent">' . "\n";
+	print '<table class="border centpercent tableforfield">' . "\n";
 
 	// Common attributes
 	include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_edit.tpl.php';
@@ -448,7 +448,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	print '<div class="fichecenter">';
 	print '<div class="fichehalfleft">';
 	print '<div class="underbanner clearboth"></div>';
-	print '<table class="border centpercent">'."\n";
+	print '<table class="border centpercent tableforfield">'."\n";
 
 	// Common attributes
 	//$keyforbreak='fieldkeytoswithonsecondcolumn';

+ 2 - 2
htdocs/admin/emailcollector_list.php

@@ -78,9 +78,9 @@ if (! $sortorder) $sortorder="ASC";
 
 // Security check
 $socid=0;
-if ($user->societe_id > 0)	// Protection if external user
+if ($user->socid > 0)	// Protection if external user
 {
-	//$socid = $user->societe_id;
+	//$socid = $user->socid;
 	accessforbidden();
 }
 //$result = restrictedArea($user, 'emailcollector', $id, '');

+ 2 - 2
htdocs/admin/mails_senderprofile_list.php

@@ -71,9 +71,9 @@ if (! $sortorder) $sortorder="ASC";
 
 // Protection if external user
 $socid=0;
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
-	//$socid = $user->societe_id;
+	//$socid = $user->socid;
 	accessforbidden();
 }
 

+ 6 - 22
htdocs/admin/modulehelp.php

@@ -129,7 +129,7 @@ foreach ($modulesdir as $dir)
 								if (preg_match('/deprecated/', $objMod->version) && (empty($conf->global->$const_name) && ($conf->global->MAIN_FEATURES_LEVEL >= 0))) $modulequalified=0;
 
 		    					// We discard modules according to property disabled
-		    					if (! empty($objMod->hidden)) $modulequalified=0;
+		    					//if (! empty($objMod->hidden)) $modulequalified=0;
 
 		    					if ($modulequalified > 0)
 		    					{
@@ -214,15 +214,17 @@ asort($orders);
 //var_dump($modules);
 
 
+unset($objMod);
 $i=0;
 foreach($orders as $tmpkey => $tmpvalue)
 {
-    $objMod  = $modules[$tmpkey];
-    if ($objMod->numero == $id)
+    $tmpMod  = $modules[$tmpkey];
+    if ($tmpMod->numero == $id)
     {
         $key = $i;
         $modName = $filename[$tmpkey];
         $dirofmodule = $dirmod[$tmpkey];
+        $objMod = $tmpMod;
         break;
     }
     $i++;
@@ -233,25 +235,7 @@ $familyposition=$tab[0]; $familykey=$tab[1]; $module_position=$tab[2]; $numero=$
 
 
 
-$h = 0;
-
-$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=desc';
-$head[$h][1] = $langs->trans("Description");
-$head[$h][2] = 'desc';
-$h++;
-
-$head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=feature';
-$head[$h][1] = $langs->trans("TechnicalServicesProvided");
-$head[$h][2] = 'feature';
-$h++;
-
-if ($objMod->isCoreOrExternalModule() == 'external')
-{
-    $head[$h][0] = DOL_URL_ROOT."/admin/modulehelp.php?id=".$id.'&mode=changelog';
-    $head[$h][1] = $langs->trans("ChangeLog");
-    $head[$h][2] = 'changelog';
-    $h++;
-}
+$head = modulehelp_prepare_head($objMod);
 
 // Check filters
 $modulename=$objMod->getName();

+ 522 - 0
htdocs/admin/mrp.php

@@ -0,0 +1,522 @@
+<?php
+/* Copyright (C) 2019 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/admin/mrp.php
+ *	\ingroup    mrp
+ *	\brief      Setup page of module MRP
+ */
+
+require '../main.inc.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/mrp/class/mo.class.php';
+require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp_mo.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/mrp/lib/mrp.lib.php';
+
+// Load translation files required by the page
+$langs->loadLangs(array('admin', 'errors', 'mrp', 'other'));
+
+if (! $user->admin) accessforbidden();
+
+$action = GETPOST('action', 'alpha');
+$value = GETPOST('value', 'alpha');
+$label = GETPOST('label', 'alpha');
+$scandir = GETPOST('scan_dir', 'alpha');
+$type = 'mrp';
+
+
+/*
+ * Actions
+ */
+
+include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
+
+if ($action == 'updateMask')
+{
+	$maskconstmrp=GETPOST('maskconstMo', 'alpha');
+	$maskmrp=GETPOST('maskMo', 'alpha');
+
+	if ($maskconstmrp) $res = dolibarr_set_const($db, $maskconstmrp, $maskmrp, 'chaine', 0, '', $conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        setEventMessages($langs->trans("Error"), null, 'errors');
+    }
+}
+
+elseif ($action == 'specimen')
+{
+	$modele=GETPOST('module', 'alpha');
+
+	$mo = new MO($db);
+	$mrp->initAsSpecimen();
+
+	// Search template files
+	$file=''; $classname=''; $filefound=0;
+	$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+	foreach($dirmodels as $reldir)
+	{
+	    $file=dol_buildpath($reldir."core/modules/mrp/doc/pdf_".$modele.".modules.php", 0);
+		if (file_exists($file))
+		{
+			$filefound=1;
+			$classname = "pdf_".$modele;
+			break;
+		}
+	}
+
+	if ($filefound)
+	{
+		require_once $file;
+
+		$module = new $classname($db);
+
+		if ($module->write_file($mrp, $langs) > 0)
+		{
+			header("Location: ".DOL_URL_ROOT."/document.php?modulepart=mrp&file=SPECIMEN.pdf");
+			return;
+		}
+		else
+		{
+			setEventMessages($module->error, null, 'errors');
+			dol_syslog($module->error, LOG_ERR);
+		}
+	}
+	else
+	{
+		setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
+		dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
+	}
+}
+
+// Activate a model
+elseif ($action == 'set')
+{
+	$ret = addDocumentModel($value, $type, $label, $scandir);
+}
+
+elseif ($action == 'del')
+{
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+        if ($conf->global->MRP_MO_ADDON_PDF == "$value") dolibarr_del_const($db, 'MRP_MO_ADDON_PDF', $conf->entity);
+	}
+}
+
+// Set default model
+elseif ($action == 'setdoc')
+{
+	if (dolibarr_set_const($db, "MRP_MO_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity))
+	{
+		// The constant that was read before the new set
+		// We therefore requires a variable to have a coherent view
+		$conf->global->MRP_MO_ADDON_PDF = $value;
+	}
+
+	// On active le modele
+	$ret = delDocumentModel($value, $type);
+	if ($ret > 0)
+	{
+		$ret = addDocumentModel($value, $type, $label, $scandir);
+	}
+}
+
+elseif ($action == 'setmod')
+{
+	// TODO Check if numbering module chosen can be activated
+	// by calling method canBeActivated
+
+	dolibarr_set_const($db, "MRP_MO_ADDON", $value, 'chaine', 0, '', $conf->entity);
+}
+
+elseif ($action == 'set_MRP_MO_DRAFT_WATERMARK')
+{
+	$draft = GETPOST("MRP_MO_DRAFT_WATERMARK");
+	$res = dolibarr_set_const($db, "MRP_MO_DRAFT_WATERMARK", trim($draft), 'chaine', 0, '', $conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        setEventMessages($langs->trans("Error"), null, 'errors');
+    }
+}
+
+elseif ($action == 'set_MRP_MO_FREE_TEXT')
+{
+	$freetext = GETPOST("MRP_MO_FREE_TEXT", 'none');	// No alpha here, we want exact string
+
+	$res = dolibarr_set_const($db, "MRP_MO_FREE_TEXT", $freetext, 'chaine', 0, '', $conf->entity);
+
+	if (! $res > 0) $error++;
+
+ 	if (! $error)
+    {
+        setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
+    }
+    else
+    {
+        setEventMessages($langs->trans("Error"), null, 'errors');
+    }
+}
+
+
+/*
+ * View
+ */
+
+$form=new Form($db);
+
+$dirmodels=array_merge(array('/'), (array) $conf->modules_parts['models']);
+
+llxHeader("", $langs->trans("MrpSetupPage"));
+
+$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
+print load_fiche_titre($langs->trans("MrpSetupPage"), $linkback, 'title_setup');
+
+$head = mrpAdminPrepareHead();
+
+dol_fiche_head($head, 'settings', $langs->trans("MOs"), -1, 'mrp');
+
+/*
+ * MOs Numbering model
+ */
+
+print load_fiche_titre($langs->trans("MOsNumberingModules"), '', '');
+
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td class="nowrap">'.$langs->trans("Example").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status").'</td>';
+print '<td class="center" width="16">'.$langs->trans("ShortInfo").'</td>';
+print '</tr>'."\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+	$dir = dol_buildpath($reldir."core/modules/mrp/");
+
+	if (is_dir($dir))
+	{
+		$handle = opendir($dir);
+		if (is_resource($handle))
+		{
+			while (($file = readdir($handle))!==false)
+			{
+			    if (substr($file, 0, 7) == 'mod_mo_' && substr($file, dol_strlen($file)-3, 3) == 'php')
+				{
+					$file = substr($file, 0, dol_strlen($file)-4);
+
+					require_once $dir.$file.'.php';
+
+					$module = new $file($db);
+
+					// Show modules according to features level
+					if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) continue;
+					if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue;
+
+					if ($module->isEnabled())
+					{
+						print '<tr class="oddeven"><td>'.$module->name."</td><td>\n";
+						print $module->info();
+						print '</td>';
+
+                        // Show example of numbering model
+                        print '<td class="nowrap">';
+                        $tmp=$module->getExample();
+                        if (preg_match('/^Error/', $tmp)) print '<div class="error">'.$langs->trans($tmp).'</div>';
+                        elseif ($tmp=='NotConfigured') print $langs->trans($tmp);
+                        else print $tmp;
+                        print '</td>'."\n";
+
+						print '<td class="center">';
+						if ($conf->global->MRP_MO_ADDON == $file)
+						{
+							print img_picto($langs->trans("Activated"), 'switch_on');
+						}
+						else
+						{
+							print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'">';
+							print img_picto($langs->trans("Disabled"), 'switch_off');
+							print '</a>';
+						}
+						print '</td>';
+
+						$mrp=new MO($db);
+						$mrp->initAsSpecimen();
+
+						// Info
+						$htmltooltip='';
+						$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
+						$mrp->type=0;
+						$nextval=$module->getNextValue($mysoc, $mrp);
+                        if ("$nextval" != $langs->trans("NotAvailable")) {  // Keep " on nextval
+                            $htmltooltip.=''.$langs->trans("NextValue").': ';
+                            if ($nextval) {
+                                if (preg_match('/^Error/', $nextval) || $nextval=='NotConfigured')
+                                    $nextval = $langs->trans($nextval);
+                                $htmltooltip.=$nextval.'<br>';
+                            } else {
+                                $htmltooltip.=$langs->trans($module->error).'<br>';
+                            }
+                        }
+
+						print '<td class="center">';
+						print $form->textwithpicto('', $htmltooltip, 1, 0);
+						print '</td>';
+
+						print "</tr>\n";
+					}
+				}
+			}
+			closedir($handle);
+		}
+	}
+}
+print "</table><br>\n";
+
+
+/*
+ * Document templates generators
+ */
+
+print load_fiche_titre($langs->trans("MOsModelModule"), '', '');
+
+// Load array def with activated templates
+$def = array();
+$sql = "SELECT nom";
+$sql.= " FROM ".MAIN_DB_PREFIX."document_model";
+$sql.= " WHERE type = '".$type."'";
+$sql.= " AND entity = ".$conf->entity;
+$resql=$db->query($sql);
+if ($resql)
+{
+	$i = 0;
+	$num_rows=$db->num_rows($resql);
+	while ($i < $num_rows)
+	{
+		$array = $db->fetch_array($resql);
+		array_push($def, $array[0]);
+		$i++;
+	}
+}
+else
+{
+	dol_print_error($db);
+}
+
+
+print "<table class=\"noborder\" width=\"100%\">\n";
+print "<tr class=\"liste_titre\">\n";
+print '<td>'.$langs->trans("Name").'</td>';
+print '<td>'.$langs->trans("Description").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Status")."</td>\n";
+print '<td class="center" width="60">'.$langs->trans("Default")."</td>\n";
+print '<td class="center" width="38">'.$langs->trans("ShortInfo").'</td>';
+print '<td class="center" width="38">'.$langs->trans("Preview").'</td>';
+print "</tr>\n";
+
+clearstatcache();
+
+foreach ($dirmodels as $reldir)
+{
+    foreach (array('','/doc') as $valdir)
+    {
+    	$dir = dol_buildpath($reldir."core/modules/mrp".$valdir);
+
+        if (is_dir($dir))
+        {
+            $handle=opendir($dir);
+            if (is_resource($handle))
+            {
+                while (($file = readdir($handle))!==false)
+                {
+                    $filelist[]=$file;
+                }
+                closedir($handle);
+                arsort($filelist);
+
+                foreach($filelist as $file)
+                {
+                    if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file))
+                    {
+                    	if (file_exists($dir.'/'.$file))
+                    	{
+                    		$name = substr($file, 4, dol_strlen($file) -16);
+	                        $classname = substr($file, 0, dol_strlen($file) -12);
+
+	                        require_once $dir.'/'.$file;
+	                        $module = new $classname($db);
+
+	                        $modulequalified=1;
+	                        if ($module->version == 'development'  && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0;
+	                        if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0;
+
+	                        if ($modulequalified)
+	                        {
+	                            $var = !$var;
+	                            print '<tr class="oddeven"><td width="100">';
+	                            print (empty($module->name)?$name:$module->name);
+	                            print "</td><td>\n";
+	                            if (method_exists($module, 'info')) print $module->info($langs);
+	                            else print $module->description;
+	                            print '</td>';
+
+	                            // Active
+	                            if (in_array($name, $def))
+	                            {
+	                            	print '<td class="center">'."\n";
+	                            	print '<a 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 href="'.$_SERVER["PHP_SELF"].'?action=set&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"), 'switch_off').'</a>';
+	                                print "</td>";
+	                            }
+
+	                            // Default
+	                            print '<td class="center">';
+	                            if ($conf->global->MRP_MO_ADDON_PDF == $name)
+	                            {
+	                                print img_picto($langs->trans("Default"), 'on');
+	                            }
+	                            else
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&value='.$name.'&amp;scan_dir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"), 'off').'</a>';
+	                            }
+	                            print '</td>';
+
+	                            // Info
+		    					$htmltooltip =    ''.$langs->trans("Name").': '.$module->name;
+					    		$htmltooltip.='<br>'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown"));
+			                    if ($module->type == 'pdf')
+			                    {
+			                        $htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
+			                    }
+					    		$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
+					    		$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
+					    		$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftMOs").': '.yn($module->option_draft_watermark, 1, 1);
+
+
+	                            print '<td class="center">';
+	                            print $form->textwithpicto('', $htmltooltip, 1, 0);
+	                            print '</td>';
+
+	                            // Preview
+	                            print '<td class="center">';
+	                            if ($module->type == 'pdf')
+	                            {
+	                                print '<a href="'.$_SERVER["PHP_SELF"].'?action=specimen&module='.$name.'">'.img_object($langs->trans("Preview"), 'bill').'</a>';
+	                            }
+	                            else
+	                            {
+	                                print img_object($langs->trans("PreviewNotAvailable"), 'generic');
+	                            }
+	                            print '</td>';
+
+	                            print "</tr>\n";
+	                        }
+                    	}
+                    }
+                }
+            }
+        }
+    }
+}
+
+print '</table>';
+print "<br>";
+
+/*
+ * Other options
+ */
+
+print load_fiche_titre($langs->trans("OtherOptions"), '', '');
+print '<table class="noborder" width="100%">';
+print '<tr class="liste_titre">';
+print '<td>'.$langs->trans("Parameter").'</td>';
+print '<td class="center" width="60">'.$langs->trans("Value").'</td>';
+print "<td>&nbsp;</td>\n";
+print "</tr>\n";
+
+$substitutionarray=pdf_getSubstitutionArray($langs, null, null, 2);
+$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation");
+$htmltext = '<i>'.$langs->trans("AvailableVariables").':<br>';
+foreach($substitutionarray as $key => $val)	$htmltext.=$key.'<br>';
+$htmltext.='</i>';
+
+print '<form action="'.$_SERVER["PHP_SELF"].'" method="post">';
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print '<input type="hidden" name="action" value="set_MRP_MO_FREE_TEXT">';
+print '<tr class="oddeven"><td colspan="2">';
+print $form->textwithpicto($langs->trans("FreeLegalTextOnMOs"), $langs->trans("AddCRIfTooLong").'<br><br>'.$htmltext, 1, 'help', '', 0, 2, 'freetexttooltip').'<br>';
+$variablename='MRP_MO_FREE_TEXT';
+if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT))
+{
+    print '<textarea name="'.$variablename.'" class="flat" cols="120">'.$conf->global->$variablename.'</textarea>';
+}
+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><td class="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+//Use draft Watermark
+
+print "<form method=\"post\" action=\"".$_SERVER["PHP_SELF"]."\">";
+print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+print "<input type=\"hidden\" name=\"action\" value=\"set_MRP_MO_DRAFT_WATERMARK\">";
+print '<tr class="oddeven"><td>';
+print $form->textwithpicto($langs->trans("WatermarkOnDraftMOs"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'<br>';
+print '</td><td>';
+print '<input class="flat minwidth200" type="text" name="MRP_MO_DRAFT_WATERMARK" value="'.$conf->global->MRP_MO_DRAFT_WATERMARK.'">';
+print '</td><td class="right">';
+print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
+print "</td></tr>\n";
+print '</form>';
+
+print '</table>';
+print '<br>';
+
+
+// End of page
+llxFooter();
+$db->close();

+ 1 - 1
htdocs/admin/notification.php

@@ -236,7 +236,7 @@ foreach($listofnotifiedevents as $notifiedevent)
     	$s='<input type="text" size="32" name="NOTIF_'.$notifiedevent['code'].'_old_'.$reg[1].'_key" value="'.dol_escape_htmltag($value).'">';		// Do not use type="email" here, we must be able to enter a list of email with , separator.
 	    $arrayemail=explode(',', $value);
 		$showwarning=0;
-		foreach($arrayemail as $key=>$valuedet)
+		foreach($arrayemail as $keydet => $valuedet)
 		{
 			$valuedet=trim($valuedet);
 			if (! empty($valuedet) && ! isValidEmail($valuedet, 1)) $showwarning++;

+ 2 - 2
htdocs/admin/tools/listevents.php

@@ -35,10 +35,10 @@ $action=GETPOST('action', 'alpha');
 $confirm=GETPOST('confirm', 'alpha');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
 	$action = '';
-	$socid = $user->societe_id;
+	$socid = $user->socid;
 }
 
 // Load translation files required by the page

+ 2 - 2
htdocs/admin/tools/listsessions.php

@@ -35,10 +35,10 @@ $action=GETPOST('action', 'alpha');
 $confirm=GETPOST('confirm', 'alpha');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
     $action = '';
-    $socid = $user->societe_id;
+    $socid = $user->socid;
 }
 
 $sortfield = GETPOST("sortfield", 'alpha');

+ 2 - 2
htdocs/admin/translation.php

@@ -458,7 +458,7 @@ if ($mode == 'searchkey')
     //print 'param='.$param.' $_SERVER["PHP_SELF"]='.$_SERVER["PHP_SELF"].' num='.$num.' page='.$page.' nbtotalofrecords='.$nbtotalofrecords." sortfield=".$sortfield." sortorder=".$sortorder;
     $title = $langs->trans("TranslationKeySearch");
     if ($nbtotalofrecords > 0) $title.=' ('.$nbtotalofrecords.' / '.$nbtotalofrecordswithoutfilters.' - '.$nbtotaloffiles.' '.$langs->trans("Files").')';
-    print print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit)."\n";
+    print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, -1 * $nbtotalofrecords, '', 0, '', '', $limit);
 
     print '<input type="hidden" id="action" name="action" value="search">';
     print '<input type="hidden" id="mode" name="mode" value="'.$mode.'">';
@@ -466,7 +466,7 @@ if ($mode == 'searchkey')
 	print '<div class="div-table-responsive-no-min">';
     print '<table class="noborder" width="100%">';
     print '<tr class="liste_titre">';
-    print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder).'</td>';
+    print_liste_field_titre("Language_en_US_es_MX_etc", $_SERVER["PHP_SELF"], 'lang,transkey', '', $param, '', $sortfield, $sortorder);
     print_liste_field_titre("Key", $_SERVER["PHP_SELF"], 'transkey', '', $param, '', $sortfield, $sortorder);
     print_liste_field_titre("CurrentTranslationString", $_SERVER["PHP_SELF"], 'transvalue', '', $param, '', $sortfield, $sortorder);
     //if (! empty($conf->multicompany->enabled) && !$user->entity) print_liste_field_titre("Entity", $_SERVER["PHP_SELF"], 'entity,transkey', '', $param, '', $sortfield, $sortorder);

+ 1 - 1
htdocs/admin/website.php

@@ -421,7 +421,7 @@ $h++;
 dol_fiche_head($head, 'website', '', -1);
 
 
-print $langs->trans("WebsiteSetupDesc").'<br>';
+print '<span class="opacitymedium">'.$langs->trans("WebsiteSetupDesc").'</span><br>';
 print "<br>\n";
 
 

+ 10 - 2
htdocs/api/class/api.class.php

@@ -102,6 +102,7 @@ class DolibarrApi
         unset($object->isextrafieldmanaged);
 		unset($object->ismultientitymanaged);
 		unset($object->restrictiononfksoc);
+		unset($object->table_rowid);
 
         // Remove linkedObjects. We should already have linkedObjectIds that avoid huge responses
         unset($object->linkedObjects);
@@ -127,13 +128,14 @@ class DolibarrApi
         unset($object->timespent_withhour);
         unset($object->timespent_fk_user);
         unset($object->timespent_note);
+        unset($object->fk_delivery_address);
 
         unset($object->statuts);
         unset($object->statuts_short);
         unset($object->statuts_logo);
         unset($object->statuts_long);
-        unset($object->labelstatut);
-        unset($object->labelstatut_short);
+        unset($object->labelStatus);
+        unset($object->labelStatusShort);
 
         unset($object->element);
         unset($object->fk_element);
@@ -146,6 +148,11 @@ class DolibarrApi
 
         unset($object->skip_update_total);
         unset($object->context);
+        unset($object->next_prev_filter);
+
+        if ($object->table_element != 'ticket') {
+        	unset($object->comments);
+        }
 
         // Remove the $oldcopy property because it is not supported by the JSON
         // encoder. The following error is generated when trying to serialize
@@ -178,6 +185,7 @@ class DolibarrApi
                 unset($object->lines[$i]->cond_reglement);
                 unset($object->lines[$i]->fk_delivery_address);
                 unset($object->lines[$i]->fk_projet);
+                unset($object->lines[$i]->fk_project);
                 unset($object->lines[$i]->thirdparty);
                 unset($object->lines[$i]->user);
                 unset($object->lines[$i]->model_pdf);

+ 1 - 1
htdocs/api/class/api_setup.class.php

@@ -390,7 +390,7 @@ class Setup extends DolibarrApi
     public function getListOfShipmentMethods($sortfield = "rowid", $sortorder = 'ASC', $limit = 100, $page = 0, $active = 1, $sqlfilters = '')
     {
         $list = array();
-        $sql = "SELECT t.code, t.libelle, t.description, t.tracking";
+        $sql = "SELECT t.rowid, t.code, t.libelle, t.description, t.tracking";
         $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as t";
         $sql.= " WHERE t.active = ".$active;
         // Add sql filters

+ 8 - 2
htdocs/api/index.php

@@ -55,6 +55,12 @@ require_once DOL_DOCUMENT_ROOT.'/api/class/api_access.class.php';
 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
 
 
+$url = $_SERVER['PHP_SELF'];
+// Fix for some NGINX setups (this should not be required even with NGINX, however setup of NGINX are often mysterious and this may help is such cases)
+if (! empty($conf->global->MAIN_NGINX_FIX))
+{
+	$url = (isset($_SERVER['SCRIPT_URI']) && $_SERVER["SCRIPT_URI"] !== null) ? $_SERVER["SCRIPT_URI"] : $_SERVER['PHP_SELF'];
+}
 
 // Enable and test if module Api is enabled
 if (empty($conf->global->MAIN_MODULE_API))
@@ -67,7 +73,7 @@ if (empty($conf->global->MAIN_MODULE_API))
 }
 
 // Test if explorer is not disabled
-if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($conf->global->API_EXPLORER_DISABLED))
+if (preg_match('/api\/index\.php\/explorer/', $url) && ! empty($conf->global->API_EXPLORER_DISABLED))
 {
     $langs->load("admin");
     dol_syslog("Call Dolibarr API interfaces with module REST disabled");
@@ -91,7 +97,7 @@ if (preg_match('/api\/index\.php\/explorer/', $_SERVER["PHP_SELF"]) && ! empty($
 
 
 $reg=array();
-preg_match('/index\.php\/([^\/]+)(.*)$/', $_SERVER["PHP_SELF"], $reg);
+preg_match('/index\.php\/([^\/]+)(.*)$/', $url, $reg);
 // .../index.php/categories?sortfield=t.rowid&sortorder=ASC
 
 

+ 2 - 2
htdocs/asset/card.php

@@ -60,8 +60,8 @@ foreach($object->fields as $key => $val)
 if (empty($action) && empty($id) && empty($ref)) $action='view';
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'asset', $id);
 
 // Load object

+ 6 - 0
htdocs/asset/class/asset.class.php

@@ -128,7 +128,13 @@ class Asset extends CommonObject
 
 	public $note_public;
 	public $note_private;
+
+	/**
+     * @var integer|string date_creation
+     */
 	public $date_creation;
+
+
 	public $tms;
 
 	/**

+ 2 - 2
htdocs/asset/document.php

@@ -40,8 +40,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
 $ref = GETPOST('ref', 'alpha');
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'asset', $id);
 
 // Get parameters

+ 1 - 1
htdocs/asset/info.php

@@ -34,7 +34,7 @@ $ref=GETPOST('ref', 'alpha');
 $action=GETPOST('action', 'alpha');
 
 // Security check
-if ($user->societe_id) $socid=$user->societe_id;
+if ($user->socid) $socid=$user->socid;
 $result = restrictedArea($user, 'asset', $id, '');
 
 $object = new Asset($db);

+ 2 - 2
htdocs/asset/list.php

@@ -72,9 +72,9 @@ if (! $sortorder) $sortorder="ASC";
 
 // Protection if external user
 $socid=0;
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
-	//$socid = $user->societe_id;
+	//$socid = $user->socid;
 	accessforbidden();
 }
 //$result = restrictedArea($user, 'asset', $id,'');

+ 2 - 2
htdocs/asset/note.php

@@ -46,8 +46,8 @@ $hookmanager->initHooks(array('assetnote'));     // Note that conf->hooks_module
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'asset', $id);
 
 // Load object

+ 1 - 1
htdocs/asset/type.php

@@ -615,7 +615,7 @@ if ($rowid > 0)
 		if (empty($reshook))
 		{
 			print '<br><br><table class="border" width="100%">';
-			foreach($extrafields->attribute_label as $key=>$label)
+			foreach($extrafields->attributes[$object->element]['label'] as $key=>$label)
 			{
 				if (isset($_POST["options_" . $key])) {
 					if (is_array($_POST["options_" . $key])) {

+ 5 - 0
htdocs/blockedlog/class/blockedlog.class.php

@@ -100,7 +100,12 @@ class BlockedLog
 	 */
 	public $fk_user = 0;
 
+	/**
+     * @var integer|string date_creation
+     */
 	public $date_creation;
+
+
 	public $date_modification;
 
 	public $date_object = 0;

+ 2 - 2
htdocs/bom/bom_agenda.php

@@ -53,8 +53,8 @@ else
 $search_agenda_label=GETPOST('search_agenda_label');
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'bom', $id);
 
 $limit = GETPOST('limit', 'int')?GETPOST('limit', 'int'):$conf->liste_limit;

+ 47 - 35
htdocs/bom/bom_card.php

@@ -70,8 +70,8 @@ if (empty($action) && empty($id) && empty($ref)) $action='view';
 include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php';  // Must be include, not include_once.
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$isdraft = (($object->statut == BillOfMaterials::STATUS_DRAFT) ? 1 : 0);
 //$result = restrictedArea($user, 'bom', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
 
@@ -125,9 +125,11 @@ if (empty($reshook))
 		$error = 0;
 
 		// Set if we used free entry or predefined product
-		$idprod=GETPOST('idprod', 'int');
-		$qty=GETPOST('qty', 'int');
-		$efficiency=GETPOST('efficiency', 'int');
+		$idprod = GETPOST('idprod', 'int');
+		$qty = GETPOST('qty', 'int');
+		$qty_frozen = GETPOST('qty_frozen', 'int');
+		$disable_stock_change = GETPOST('disable_stock_change', 'int');
+		$efficiency = GETPOST('efficiency', 'int');
 
 		if ($qty == '') {
 			setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), null, 'errors');
@@ -138,17 +140,27 @@ if (empty($reshook))
 			$error++;
 		}
 
-		$bomline = new BOMLine($db);
-		$bomline->fk_bom = $id;
-		$bomline->fk_product = $idprod;
-		$bomline->qty = $qty;
-		$bomline->efficiency = $efficiency;
-
-		$result = $bomline->create($user);
-		if ($result <= 0)
+		if (! $error)
 		{
-			setEventMessages($bomline->error, $bomline->errors, 'errors');
-			$action = '';
+    		$bomline = new BOMLine($db);
+    		$bomline->fk_bom = $id;
+    		$bomline->fk_product = $idprod;
+    		$bomline->qty = $qty;
+    		$bomline->qty_frozen = $qty_frozen;
+    		$bomline->disable_stock_change = $disable_stock_change;
+    		$bomline->efficiency = $efficiency;
+
+    		$result = $bomline->create($user);
+    		if ($result <= 0)
+    		{
+    			setEventMessages($bomline->error, $bomline->errors, 'errors');
+    			$action = '';
+    		}
+    		else
+    		{
+    		    unset($_POST['qty_frozen']);
+    		    unset($_POST['disable_stock_change']);
+    		}
 		}
 	}
 
@@ -160,6 +172,8 @@ if (empty($reshook))
 
 		// Set if we used free entry or predefined product
 		$qty=GETPOST('qty', 'int');
+		$qty_frozen = GETPOST('qty_frozen', 'int');
+		$disable_stock_change = GETPOST('disable_stock_change', 'int');
 		$efficiency=GETPOST('efficiency', 'int');
 
 		if ($qty == '') {
@@ -170,6 +184,8 @@ if (empty($reshook))
 		$bomline = new BOMLine($db);
 		$bomline->fetch($lineid);
 		$bomline->qty = $qty;
+		$bomline->qty_frozen = $qty_frozen;
+		$bomline->disable_stock_change = $disable_stock_change;
 		$bomline->efficiency = $efficiency;
 
 		$result = $bomline->update($user);
@@ -178,6 +194,11 @@ if (empty($reshook))
 			setEventMessages($bomline->error, $bomline->errors, 'errors');
 			$action = '';
 		}
+		else
+		{
+		    unset($_POST['qty_frozen']);
+		    unset($_POST['disable_stock_change']);
+		}
 	}
 }
 
@@ -294,12 +315,6 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	{
 		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteLine'), $langs->trans('ConfirmDeleteLine'), 'confirm_deleteline', '', 0, 1);
 	}
-	$formconfirm = '';
-
-	// Confirmation to delete
-	if ($action == 'delete') {
-		$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteOrder'), $langs->trans('ConfirmDeleteOrder'), 'confirm_delete', '', 0, 1);
-	}
 
 	// Confirmation of validation
 	if ($action == 'validate')
@@ -647,14 +662,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	    print '<a name="builddoc"></a>'; // ancre
 
 	    // Documents
-	    /*$objref = dol_sanitizeFileName($object->ref);
-	    $relativepath = $comref . '/' . $comref . '.pdf';
+	    $objref = dol_sanitizeFileName($object->ref);
+	    $relativepath = $objref . '/' . $objref . '.pdf';
 	    $filedir = $conf->bom->dir_output . '/' . $objref;
 	    $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
 	    $genallowed = $user->rights->bom->read;	// If you can read, you can build the PDF to read content
-	    $delallowed = $user->rights->bom->create;	// If you can create/edit, you can remove a file on card
-	    print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
-		*/
+	    $delallowed = $user->rights->bom->write;	// If you can create/edit, you can remove a file on card
+	    print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang);
 
 	    // Show links to link elements
 	    $linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
@@ -678,17 +692,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
 	}
 
 	//Select mail models is same action as presend
-	/*
-	 if (GETPOST('modelselected')) $action = 'presend';
+    if (GETPOST('modelselected')) $action = 'presend';
 
-	 // Presend form
-	 $modelmail='inventory';
-	 $defaulttopic='InformationMessage';
-	 $diroutput = $conf->product->dir_output.'/inventory';
-	 $trackid = 'stockinv'.$object->id;
+	// Presend form
+	$modelmail='bom';
+	$defaulttopic='InformationMessage';
+	$diroutput = $conf->bom->dir_output;
+	$trackid = 'bom'.$object->id;
 
-	 include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
-	 */
+	include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
 }
 
 // End of page

+ 2 - 2
htdocs/bom/bom_document.php

@@ -41,8 +41,8 @@ $id=(GETPOST('socid', 'int') ? GETPOST('socid', 'int') : GETPOST('id', 'int'));
 $ref = GETPOST('ref', 'alpha');
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'bom', $id);
 
 // Get parameters

+ 2 - 2
htdocs/bom/bom_list.php

@@ -73,9 +73,9 @@ if (! $sortorder) $sortorder="ASC";
 
 // Security check
 $socid=0;
-if ($user->societe_id > 0)	// Protection if external user
+if ($user->socid > 0)	// Protection if external user
 {
-	//$socid = $user->societe_id;
+	//$socid = $user->socid;
 	accessforbidden();
 }
 //$result = restrictedArea($user, 'bom', $id, '');

+ 2 - 2
htdocs/bom/bom_note.php

@@ -47,8 +47,8 @@ $hookmanager->initHooks(array('bomnote','globalcard'));     // Note that conf->h
 $extrafields->fetch_name_optionals_label($object->table_element);
 
 // Security check - Protection if external user
-//if ($user->societe_id > 0) access_forbidden();
-//if ($user->societe_id > 0) $socid = $user->societe_id;
+//if ($user->socid > 0) access_forbidden();
+//if ($user->socid > 0) $socid = $user->socid;
 //$result = restrictedArea($user, 'bom', $id);
 
 // Load object

+ 45 - 4
htdocs/bom/class/api_boms.class.php

@@ -260,7 +260,7 @@ class Boms extends DolibarrApi
             throw new RestException(500, 'Error when deleting BOM : '.$this->bom->error);
         }
 
-         return array(
+        return array(
             'success' => array(
                 'code' => 200,
                 'message' => 'BOM deleted'
@@ -281,12 +281,53 @@ class Boms extends DolibarrApi
         // phpcs:enable
     	$object = parent::_cleanObjectDatas($object);
 
-    	/*unset($object->note);
-    	unset($object->address);
+    	unset($object->rowid);
+    	unset($object->canvas);
+
+    	unset($object->name);
+    	unset($object->lastname);
+    	unset($object->firstname);
+    	unset($object->civility_id);
+    	unset($object->statut);
+    	unset($object->state);
+    	unset($object->state_id);
+    	unset($object->state_code);
+    	unset($object->region);
+    	unset($object->region_code);
+    	unset($object->country);
+    	unset($object->country_id);
+    	unset($object->country_code);
     	unset($object->barcode_type);
     	unset($object->barcode_type_code);
     	unset($object->barcode_type_label);
-    	unset($object->barcode_type_coder);*/
+    	unset($object->barcode_type_coder);
+    	unset($object->total_ht);
+    	unset($object->total_tva);
+    	unset($object->total_localtax1);
+    	unset($object->total_localtax2);
+    	unset($object->total_ttc);
+    	unset($object->fk_account);
+    	unset($object->comments);
+    	unset($object->note);
+    	unset($object->mode_reglement_id);
+    	unset($object->cond_reglement_id);
+    	unset($object->cond_reglement);
+    	unset($object->shipping_method_id);
+    	unset($object->fk_incoterms);
+    	unset($object->label_incoterms);
+    	unset($object->location_incoterms);
+
+    	// If object has lines, remove $db property
+    	if (isset($object->lines) && is_array($object->lines) && count($object->lines) > 0)  {
+    		$nboflines = count($object->lines);
+    		for ($i=0; $i < $nboflines; $i++)
+    		{
+    			$this->_cleanObjectDatas($object->lines[$i]);
+
+    			unset($object->lines[$i]->lines);
+    			unset($object->lines[$i]->note);
+    		}
+    	}
 
     	return $object;
     }

+ 25 - 78
htdocs/bom/class/bom.class.php

@@ -112,7 +112,13 @@ class BOM extends CommonObject
 	public $description;
 	public $note_public;
 	public $note_private;
+
+	/**
+     * @var integer|string date_creation
+     */
 	public $date_creation;
+
+
 	public $tms;
 	public $fk_user_creat;
 	public $fk_user_modif;
@@ -240,9 +246,10 @@ class BOM extends CommonObject
 	    unset($object->import_key);
 
 	    // Clear fields
-	    $object->ref = "copy_of_".$object->ref;
-	    $object->title = $langs->trans("CopyOf")." ".$object->title;
-
+	    $object->ref = empty($this->fields['ref']['default']) ? $langs->trans("copy_of_").$object->ref: $this->fields['ref']['default'];
+	    $object->label = empty($this->fields['label']['default']) ? $langs->trans("CopyOf")." ".$object->label: $this->fields['label']['default'];
+	    $object->status = self::STATUS_DRAFT;
+	    // ...
 	    // Clear extrafields that are unique
 	    if (is_array($object->array_options) && count($object->array_options) > 0)
 	    {
@@ -808,43 +815,19 @@ class BOM extends CommonObject
 	public function LibStatut($status, $mode = 0)
 	{
 		// phpcs:enable
-		if (empty($this->labelstatus))
+		if (empty($this->labelStatus))
 		{
 			global $langs;
 			//$langs->load("mrp");
-			$this->labelstatus[self::STATUS_DRAFT] = $langs->trans('Draft');
-			$this->labelstatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
-			$this->labelstatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
+			$this->labelStatus[self::STATUS_DRAFT] = $langs->trans('Draft');
+			$this->labelStatus[self::STATUS_VALIDATED] = $langs->trans('Enabled');
+			$this->labelStatus[self::STATUS_CANCELED] = $langs->trans('Disabled');
 		}
 
-		if ($mode == 0)
-		{
-			return $this->labelstatus[$status];
-		}
-		elseif ($mode == 1)
-		{
-			return $this->labelstatus[$status];
-		}
-		elseif ($mode == 2)
-		{
-			return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-		}
-		elseif ($mode == 3)
-		{
-			return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle');
-		}
-		elseif ($mode == 4)
-		{
-			return img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-		}
-		elseif ($mode == 5)
-		{
-			return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle');
-		}
-		elseif ($mode == 6)
-		{
-			return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut'.($status == self::STATUS_VALIDATED ? 4 : $status), '', false, 0, 0, '', 'valignmiddle');
-		}
+		$statusType = 'status'.$status;
+		if ($status == self::STATUS_VALIDATED) $statusType = 'status4';
+
+		return dolGetStatus($this->labelStatus[$status], $this->labelStatus[$status], '', $statusType, $mode);
 	}
 
 	/**
@@ -1059,12 +1042,14 @@ class BOMLine extends CommonObject
 	 * @var array  Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
 	 */
 	public $fields=array(
-		'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
+		'rowid' => array('type'=>'integer', 'label'=>'LineID', 'enabled'=>1, 'visible'=>-1, 'position'=>1, 'notnull'=>1, 'index'=>1, 'comment'=>"Id",),
 		'fk_bom' => array('type'=>'integer:BillOfMaterials:societe/class/bom.class.php', 'label'=>'BillOfMaterials', 'enabled'=>1, 'visible'=>1, 'position'=>10, 'notnull'=>1, 'index'=>1,),
 		'fk_product' => array('type'=>'integer:Product:product/class/product.class.php', 'label'=>'Product', 'enabled'=>1, 'visible'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,),
 		'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>1, 'visible'=>-1, 'position'=>60, 'notnull'=>-1,),
 		'qty' => array('type'=>'double(24,8)', 'label'=>'Quantity', 'enabled'=>1, 'visible'=>1, 'position'=>100, 'notnull'=>1, 'isameasure'=>'1',),
-		'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
+		'qty_frozen' => array('type'=>'smallint', 'label'=>'QuantityFrozen', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>105, 'css'=>'maxwidth50imp', 'help'=>'QuantityConsumedInvariable'),
+	    'disable_stock_change' => array('type'=>'smallint', 'label'=>'DisableStockChange', 'enabled'=>1, 'visible'=>1, 'default'=>0, 'position'=>108, 'css'=>'maxwidth50imp', 'help'=>'DisableStockChangeHelp'),
+	    'efficiency' => array('type'=>'double(8,4)', 'label'=>'ManufacturingEfficiency', 'enabled'=>1, 'visible'=>1, 'default'=>1, 'position'=>110, 'notnull'=>1, 'css'=>'maxwidth50imp', 'help'=>'ValueOfMeansLoss'),
 		'position' => array('type'=>'integer', 'label'=>'Rank', 'enabled'=>1, 'visible'=>0, 'default'=>0, 'position'=>200, 'notnull'=>1,),
 		'import_key' => array('type'=>'varchar(14)', 'label'=>'ImportId', 'enabled'=>1, 'visible'=>-2, 'position'=>1000, 'notnull'=>-1,),
 	);
@@ -1073,6 +1058,8 @@ class BOMLine extends CommonObject
 	public $fk_product;
 	public $description;
 	public $qty;
+	public $qty_frozen;
+	public $disable_stock_change;
 	public $efficiency;
 	public $position;
 	public $import_key;
@@ -1339,47 +1326,7 @@ class BOMLine extends CommonObject
 	public function LibStatut($status, $mode = 0)
 	{
 		// phpcs:enable
-		if (empty($this->labelstatus))
-		{
-			global $langs;
-			//$langs->load("mrp");
-			$this->labelstatus[1] = $langs->trans('Enabled');
-			$this->labelstatus[0] = $langs->trans('Disabled');
-		}
-
-		if ($mode == 0)
-		{
-			return $this->labelstatus[$status];
-		}
-		elseif ($mode == 1)
-		{
-			return $this->labelstatus[$status];
-		}
-		elseif ($mode == 2)
-		{
-			if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-			elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-		}
-		elseif ($mode == 3)
-		{
-			if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
-			elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
-		}
-		elseif ($mode == 4)
-		{
-			if ($status == 1) return img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-			elseif ($status == 0) return img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle').' '.$this->labelstatus[$status];
-		}
-		elseif ($mode == 5)
-		{
-			if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
-			elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
-		}
-		elseif ($mode == 6)
-		{
-			if ($status == 1) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut4', '', false, 0, 0, '', 'valignmiddle');
-			elseif ($status == 0) return $this->labelstatus[$status].' '.img_picto($this->labelstatus[$status], 'statut5', '', false, 0, 0, '', 'valignmiddle');
-		}
+		return '';
 	}
 
 	/**

+ 14 - 4
htdocs/bom/tpl/objectline_create.tpl.php

@@ -63,11 +63,13 @@ if ($nolinesbefore) {
 	print '<td class="linecolqty right">'.$langs->trans('Qty').'</td>';
 	if ($conf->global->PRODUCT_USE_UNITS)
 	{
-		print '<td class="linecoluseunit left">';
-		print '<span id="title_units">';
-		print $langs->trans('Unit');
-		print '</span></td>';
+	    print '<td class="linecoluseunit left">';
+	    print '<span id="title_units">';
+	    print $langs->trans('Unit');
+	    print '</span></td>';
 	}
+	print '<td class="linecolqtyfrozen right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
+	print '<td class="linecoldisablestockchange right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
 	print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
 	print '<td class="linecoledit" colspan="'.$colspan.'">&nbsp;</td>';
     print '</tr>';
@@ -109,6 +111,7 @@ if (! empty($conf->product->enabled) || ! empty($conf->service->enabled))
 $coldisplay++;
 print '<td class="nobottom linecolqty right"><input type="text" size="2" name="qty" id="qty" class="flat right" value="'.(isset($_POST["qty"])?GETPOST("qty", 'alpha', 2):1).'">';
 print '</td>';
+
 if($conf->global->PRODUCT_USE_UNITS)
 {
     $coldisplay++;
@@ -118,7 +121,14 @@ if($conf->global->PRODUCT_USE_UNITS)
 }
 
 $coldisplay++;
+print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOST("qty_frozen", 'alpha')?' checked="checked"':'').'>';
+print '</td>';
+
+$coldisplay++;
+print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOST("disable_stock_change", 'alpha')?' checked="checked"':'').'">';
+print '</td>';
 
+$coldisplay++;
 print '<td class="nobottom nowrap linecollost right">';
 print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.(GETPOSTISSET("efficiency")?GETPOST("efficiency", 'alpha'):1).'">';
 print '</td>';

+ 8 - 0
htdocs/bom/tpl/objectline_edit.tpl.php

@@ -116,6 +116,14 @@ if ($conf->global->PRODUCT_USE_UNITS)
 	print '</td>';
 }
 
+$coldisplay++;
+print '<td class="nobottom linecolqtyfrozen right"><input type="checkbox" name="qty_frozen" id="qty_frozen" class="flat right" value="1"'.(GETPOSTISSET("qty_frozen")?(GETPOST('qty_frozen', 'int')?' checked="checked"':''):($line->qty_frozen?' checked="checked"':'')).'>';
+print '</td>';
+
+$coldisplay++;
+print '<td class="nobottom linecoldisablestockchange right"><input type="checkbox" name="disable_stock_change" id="disable_stock_change" class="flat right" value="1"'.(GETPOSTISSET('disablestockchange')?(GETPOST("disable_stock_change", 'int')?' checked="checked"':''):($line->disable_stock_change?' checked="checked"':'')).'">';
+print '</td>';
+
 $coldisplay++;
 print '<td class="nobottom nowrap linecollost right">';
 print '<input type="text" size="1" name="efficiency" id="efficiency" class="flat right" value="'.$line->efficiency.'"></td>';

+ 7 - 0
htdocs/bom/tpl/objectline_title.tpl.php

@@ -59,6 +59,13 @@ if ($conf->global->PRODUCT_USE_UNITS)
 	print '<td class="linecoluseunit left">'.$langs->trans('Unit').'</td>';
 }
 
+// Qty frozen
+print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('QtyFrozen'), $langs->trans("QuantityConsumedInvariable")).'</td>';
+
+// Disable stock change
+print '<td class="linecolqty right">'.$form->textwithpicto($langs->trans('DisableStockChange'), $langs->trans('DisableStockChangeHelp')).'</td>';
+
+// Efficiency
 print '<td class="linecollost right">'.$form->textwithpicto($langs->trans('ManufacturingEfficiency'), $langs->trans('ValueOfMeansLoss')).'</td>';
 
 print '<td class="linecoledit"></td>';  // No width to allow autodim

+ 10 - 0
htdocs/bom/tpl/objectline_view.tpl.php

@@ -87,6 +87,16 @@ if($conf->global->PRODUCT_USE_UNITS)
 	}
 	print '</td>';
 }
+
+print '<td class="linecolqtyfrozen nowrap right">';
+$coldisplay++;
+echo $line->qty_frozen ? yn($line->qty_frozen) : '';
+print '</td>';
+print '<td class="linecoldisablestockchange nowrap right">';
+$coldisplay++;
+echo $line->disable_stock_change ? yn($line->disable_stock_change) : '';  // Yes, it is a quantity, not a price, but we just want the formating role of function price
+print '</td>';
+
 print '<td class="linecolqty nowrap right">';
 $coldisplay++;
 echo $line->efficiency;

+ 4 - 3
htdocs/bookmarks/bookmarks.lib.php

@@ -66,10 +66,11 @@ function printBookmarksList()
 
 		$ret.= '<!-- form with POST method by default, will be replaced with GET for external link by js -->'."\n";
 		$ret.= '<form id="actionbookmark" name="actionbookmark" method="POST" action="">';
+        $ret.= '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 		$ret.= '<select name="bookmark" id="boxbookmark" class="flat boxcombo vmenusearchselectcombo" alt="Bookmarks">';
 		$ret.= '<option hidden value="listbookmarks" class="optiongrey" selected rel="'.DOL_URL_ROOT.'/bookmarks/list.php">'.$langs->trans('Bookmarks').'</option>';
 	    $ret.= '<option value="listbookmark" class="optionblue" rel="'.dol_escape_htmltag(DOL_URL_ROOT.'/bookmarks/list.php').'" ';
-	    $ret.= ' data-html="'.dol_escape_htmltag('<span class="fa fa-star-o"></span> '.dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">';
+	    $ret.= ' data-html="'.dol_escape_htmltag('<span class="fas fa-star"></span> '.dol_escape_htmltag($user->rights->bookmark->creer ? $langs->trans('EditBookmarks') : $langs->trans('ListOfBookmarks')).'...').'">';
 	    $ret.= 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))
@@ -77,7 +78,7 @@ function printBookmarksList()
 	    	//$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);
 	    	$ret.= '<option value="newbookmark" class="optionblue" rel="'.dol_escape_htmltag($urltoadd).'"';
-	    	$ret.= ' data-html="'.dol_escape_htmltag('<span class="fa fa-star-o"></span> '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
+	    	$ret.= ' data-html="'.dol_escape_htmltag('<span class="fas fa-star"></span> '.$langs->trans('AddThisPageToBookmarks').'...').'">'.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks').'...').'</option>';
 		}
 		// Menu with all bookmarks
 		if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU))
@@ -200,7 +201,7 @@ function printDropdownBookmarksList()
         //$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.= '<span class="fa fa-star-o"></span> '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
+        $newbtn.= '<span class="fas fa-star"></span> '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).'</a>';
     }
 
 

+ 2 - 2
htdocs/cashdesk/admin/cashdesk.php

@@ -148,12 +148,12 @@ 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);
+	    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);
+	        $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>';

+ 3 - 3
htdocs/cashdesk/class/Facturation.class.php

@@ -194,9 +194,9 @@ class Facturation
         {
             if ($poscart[$key]['id'] != $aArticle)
             {
-               $newposcart[$j]=$poscart[$key];
-               $newposcart[$j]['id']=$j;
-               $j++;
+                $newposcart[$j]=$poscart[$key];
+                $newposcart[$j]['id']=$j;
+                $j++;
             }
         }
         unset($poscart);

+ 21 - 18
htdocs/cashdesk/tpl/facturation1.tpl.php

@@ -56,30 +56,33 @@ $langs->loadLangs(array("main","bills","cashdesk"));
 			</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";
+<?php
+print '<option value="0">'.$top_liste_produits.'</option>'."\n";
 
-						$id = $obj_facturation->id();
+$id = $obj_facturation->id();
 
-						// Si trop d'articles ont ete trouves, on n'affiche que les X premiers (defini dans le fichier de configuration) ...
+// 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;
+$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 = '';
+for ($i = 0; $i < $nbtoshow; $i++)
+{
+	if ($id == $tab_designations[$i]['rowid']) {
+		$selected = 'selected';
+	} else {
+		$selected = '';
+	}
 
-							$label = $tab_designations[$i]['label'];
+	$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";
-						}
-					?>
+	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>

+ 2 - 2
htdocs/cashdesk/tpl/ticket.tpl.php

@@ -85,7 +85,7 @@ $object->fetch($facid);
     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>
@@ -93,7 +93,7 @@ $object->fetch($facid);
         <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
+        <?php
     }
     ?>
     </tbody>

+ 23 - 23
htdocs/cashdesk/tpl/validation1.tpl.php

@@ -36,16 +36,16 @@ $langs->loadLangs(array("main","bills","banks"));
 
 		<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->prixTotalHt(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
-		<?php
-			// Affichage de la tva par taux
-			if ( $obj_facturation->montantTva() ) {
-				echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->montantTva(), '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>');
-			}
-		?>
+<?php
+// Affichage de la tva par taux
+if ( $obj_facturation->montantTva() ) {
+	echo ('<tr><td class="resume_label">'.$langs->trans("VAT").'</td><td>'.price(price2num($obj_facturation->montantTva(), '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->prixTotalTtc(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency); ?></td></tr>
 		<tr><td class="resume_label"><?php echo $langs->trans("PaymentMode"); ?> </td><td>
 		<?php
@@ -82,20 +82,20 @@ $langs->loadLangs(array("main","bills","banks"));
 		?>
 		</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->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
-			}
-
-			// Affichage du montant rendu (reglement en especes)
-			if ( $obj_facturation->montantRendu() ) {
-				echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</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->montantEncaisse(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
+}
 
-		?>
+// Affichage du montant rendu (reglement en especes)
+if ( $obj_facturation->montantRendu() ) {
+	echo ('<tr><td class="resume_label">'.$langs->trans("Change").'</td><td>'.price(price2num($obj_facturation->montantRendu(), 'MT'), 0, $langs, 0, 0, -1, $conf->currency).'</td></tr>');
+}
+
+?>
 
 	</table>
 

+ 4 - 4
htdocs/categories/class/categorie.class.php

@@ -779,9 +779,9 @@ class Categorie extends CommonObject
 		$sql .= " AND c.fk_categorie = ".$this->id;
 		$sql .= " AND c.fk_" . $this->MAP_CAT_FK[$type] . " = o.rowid";
 		// Protection for external users
-		if (($type == 'customer' || $type == 'supplier') && $user->societe_id > 0)
+		if (($type == 'customer' || $type == 'supplier') && $user->socid > 0)
 		{
-			$sql.= " AND o.rowid = ".$user->societe_id;
+			$sql.= " AND o.rowid = ".$user->socid;
 		}
 		if ($limit > 0 || $offset > 0)  $sql .= $this->db->plimit($limit + 1, $offset);
 		$sql .= $this->db->order($sortfield, $sortorder);
@@ -1018,11 +1018,11 @@ class Categorie extends CommonObject
 	 *                fulllabel = nom avec chemin complet de la categorie
 	 *                fullpath = chemin complet compose des id
 	 *
-	 * @param   string                  $type                   Type of categories ('customer', 'supplier', 'contact', 'product', 'member') or (0, 1, 2, ...).
+	 * @param   string                  $type                   Type of categories ('customer', 'supplier', 'contact', 'product', 'member', ...)
 	 * @param   int|string|array        $markafterid            Keep only or removed all categories including the leaf $markafterid in category tree (exclude) or Keep only of category is inside the leaf starting with this id.
      *                                                          $markafterid can be an :
      *                                                          - int (id of category)
-     *                                                          - string (categories ids seprated by comma)
+     *                                                          - string (categories ids separated by comma)
      *                                                          - array (list of categories ids)
      * @param   int                     $include                [=0] Removed or 1=Keep only
 	 * @return  array|int               Array of categories. this->cats and this->motherof are set, -1 on error

+ 1 - 1
htdocs/categories/photos.php

@@ -136,7 +136,7 @@ if ($object->id)
 	}
 	$morehtmlref.='</div>';
 
-	dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
+	dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
 
 	/*
 	 * Confirmation de la suppression de photo

+ 1 - 1
htdocs/categories/traduction.php

@@ -207,7 +207,7 @@ foreach ($ways as $way)
 }
 $morehtmlref.='</div>';
 
-dol_banner_tab($object, 'ref', $linkback, ($user->societe_id?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
+dol_banner_tab($object, 'ref', $linkback, ($user->socid?0:1), 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
 
 print '<br>';
 

+ 1 - 1
htdocs/categories/viewcat.php

@@ -226,7 +226,7 @@ foreach ($ways as $way)
 }
 $morehtmlref.='</div>';
 
-dol_banner_tab($object, 'label', $linkback, ($user->societe_id?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1);
+dol_banner_tab($object, 'label', $linkback, ($user->socid?0:1), 'label', 'label', $morehtmlref, '', 0, '', '', 1);
 
 
 /*

+ 23 - 22
htdocs/comm/action/card.php

@@ -69,9 +69,9 @@ $datef=dol_mktime($fulldayevent?'23':$p2hour, $fulldayevent?'59':$p2min, $fullda
 // Security check
 $socid = GETPOST('socid', 'int');
 $id = GETPOST('id', 'int');
-if ($user->societe_id) $socid=$user->societe_id;
+if ($user->socid) $socid=$user->socid;
 $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
-if ($user->societe_id && $socid) $result = restrictedArea($user, 'societe', $socid);
+if ($user->socid && $socid) $result = restrictedArea($user, 'societe', $socid);
 
 $error=GETPOST("error");
 $donotclearsession=GETPOST('donotclearsession')?GETPOST('donotclearsession'):0;
@@ -94,7 +94,7 @@ if ($id > 0 && $action!='add') {
         $ret1 = $object->fetch_userassigned();
     }
     if ($ret < 0 || $ret1 < 0) {
-       dol_print_error('', $object->error);
+        dol_print_error('', $object->error);
     }
 }
 
@@ -861,11 +861,11 @@ if ($action == 'create')
 	if (GETPOST('datep', 'int', 1)) $datep=dol_stringtotime(GETPOST('datep', 'int', 1), 0);
 	print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").'</span></td><td>';
 	if (GETPOST("afaire") == 1) {
-        print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 1, 0, 'fulldayend');
+        print $form->selectDate($datep, 'ap', 1, 1, 0, "action", 1, 2, 0, 'fulldayend');
     } elseif (GETPOST("afaire") == 2) {
-        print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldayend');
+        print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldayend');
     } else {
-        print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 1, 0, 'fulldaystart');
+        print $form->selectDate($datep, 'ap', 1, 1, 1, "action", 1, 2, 0, 'fulldaystart');
     }
 	print '</td></tr>';
 
@@ -1024,8 +1024,8 @@ if ($action == 'create')
 			$events=array();
 			$events[]=array('method' => 'getContacts', 'url' => dol_buildpath('/core/ajax/contacts.php?showempty=1', 1), 'htmlname' => 'contactid', 'params' => array('add-customer-contact' => 'disabled'));
 			//For external user force the company to user company
-			if (!empty($user->societe_id)) {
-				print $form->select_company($user->societe_id, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
+			if (!empty($user->socid)) {
+				print $form->select_company($user->socid, 'socid', '', 1, 1, 0, $events, 0, 'minwidth300');
 			} else {
 				print $form->select_company('', 'socid', '', 'SelectThirdParty', 1, 0, $events, 0, 'minwidth300');
 			}
@@ -1582,19 +1582,20 @@ if ($id > 0)
     		if ($user->rights->agenda->allactions->create ||
 	       	    (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create))
 		    {
-		        if ($action != 'classify')
-		            $morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
-		            if ($action == 'classify') {
-		                //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
-		                $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
-		                $morehtmlref.='<input type="hidden" name="action" value="classin">';
-		                $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-		                $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
-		                $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
-		                $morehtmlref.='</form>';
-		            } else {
-		                $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
-		            }
+		        if ($action != 'classify') {
+					$morehtmlref.='<a class="editfielda" href="' . $_SERVER['PHP_SELF'] . '?action=classify&amp;id=' . $object->id . '">' . img_edit($langs->transnoentitiesnoconv('SetProject')) . '</a> : ';
+                }
+                if ($action == 'classify') {
+                    //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1);
+                    $morehtmlref.='<form method="post" action="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'">';
+                    $morehtmlref.='<input type="hidden" name="action" value="classin">';
+                    $morehtmlref.='<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
+                    $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1);
+                    $morehtmlref.='<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
+                    $morehtmlref.='</form>';
+                } else {
+                    $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1);
+                }
 		    } else {
 		        if (! empty($object->fk_project)) {
 		            $proj = new Project($db);
@@ -1611,7 +1612,7 @@ if ($id > 0)
 		$morehtmlref.='</div>';
 
 
-		dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
+		dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref);
 
 	    print '<div class="fichecenter">';
 

+ 187 - 76
htdocs/comm/action/class/actioncomm.class.php

@@ -45,43 +45,67 @@ class ActionComm extends CommonObject
      */
     public $table_element = 'actioncomm';
 
+    /**
+     * @var string Name of id column
+     */
     public $table_rowid = 'id';
 
     /**
-     * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+     * @var string Name of icon for actioncomm object. Filename of icon is object_action.png
      */
     public $picto = 'action';
 
     /**
-     * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
-     * @var int
+     * @var int 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
      */
     public $ismultientitymanaged = 1;
 
     /**
-     * 0=Default, 1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user, 2=Same than 1 but accept record if fksoc is empty
-     * @var integer
+     * @var integer 0=Default
+     *              1=View may be restricted to sales representative only if no permission to see all or to company of external user if external user
+     *              2=Same than 1 but accept record if fksoc is empty
      */
     public $restrictiononfksoc = 2;
 
     /**
-     * Id of the event
-     * @var int
+     * @var int Id of the event
      */
     public $id;
 
     /**
-     * Id of the event. Use $id as possible
-     * @var int
+     * @var int Id of the event. Use $id as possible
      */
     public $ref;
 
-    public $type_id;		// Id into parent table llx_c_actioncomm (used only if option to use type is set)
-    public $type_code;		// Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH.
+    /**
+     * @var int Id into parent table llx_c_actioncomm (used only if option to use type is set)
+     */
+    public $type_id;
+
+    /**
+     * @var string Code into parent table llx_c_actioncomm (used only if option to use type is set). With default setup, should be AC_OTH_AUTO or AC_OTH.
+     */
+    public $type_code;
+
+    /**
+     * @var string Type label
+     */
     public $type_label;
-    public $type;			// Label into parent table llx_c_actioncomm (used only if option to use type is set)
-    public $type_color;	// Color into parent table llx_c_actioncomm (used only if option to use type is set)
-    public $code;			// Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...)
+
+    /**
+     * @var string Label into parent table llx_c_actioncomm (used only if option to use type is set)
+     */
+    public $type;
+
+    /**
+     * @var string Color into parent table llx_c_actioncomm (used only if option to use type is set)
+     */
+    public $type_color;
+
+    /**
+     * @var string Free code to identify action. Ie: Agenda trigger add here AC_TRIGGERNAME ('AC_COMPANY_CREATE', 'AC_PROPAL_VALIDATE', ...)
+     */
+    public $code;
 
     /**
      * @var string Agenda event label
@@ -89,72 +113,56 @@ class ActionComm extends CommonObject
     public $label;
 
     /**
-     * Date creation record (datec)
-     *
-     * @var integer
+     * @var integer Date creation record (datec)
      */
     public $datec;
 
     /**
-     * Date end record (datef)
-     *
-     * @var integer
+     * @var integer Date end record (datef)
      */
     public $datef;
 
     /**
-     * Duration (duree)
-     *
-     * @var integer
+     * @var integer Duration (duree)
      */
     public $duree;
 
     /**
-     * Date modification record (tms)
-     *
-     * @var integer
+     * @var integer Date modification record (tms)
      */
     public $datem;
 
     /**
-     * Object user that create action
-     * @var User
+     * @var User Object user that create action
      * @deprecated
      * @see $authorid
      */
     public $author;
 
     /**
-     * Object user that modified action
-     * @var User
+     * @var User Object user that modified action
      * @deprecated
      * @see $usermodid
      */
     public $usermod;
 
     /**
-     * Id user that create action
-     * @var int
+     * @var int Id user that create action
      */
     public $authorid;
 
     /**
-     * Id user that modified action
-     * @var int
+     * @var int Id user that modified action
      */
     public $usermodid;
 
     /**
-     * Date action start (datep)
-     *
-     * @var integer
+     * @var integer Date action start (datep)
      */
     public $datep;
 
     /**
-     * Date action end (datep2)
-     *
-     * @var integer
+     * @var integer Date action end (datep2)
      */
     public $datep2;
 
@@ -163,90 +171,178 @@ class ActionComm extends CommonObject
      * @deprecated
      */
     public $durationp = -1;
-    public $fulldayevent = 0;    // 1=Event on full day
 
     /**
-     * Milestone
-     * @var int
+     * @var int 1=Event on full day
+     */
+    public $fulldayevent = 0;
+
+    /**
+     * @var int Milestone
      * @deprecated Milestone is already event with end date = start date
      */
     public $punctual = 1;
-    public $percentage;    // Percentage
-    public $location;      // Location
 
-	public $transparency;	// Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events)
-    public $priority;      // Small int (0 By default)
+    /**
+     * @var integer Percentage
+     */
+    public $percentage;
 
-	public $userassigned = array();	// Array of user ids
-    public $userownerid;	// Id of user owner = fk_user_action into table
-    public $userdoneid;	// Id of user done (deprecated)
+    /**
+     * @var string Location
+     */
+    public $location;
 
-    public $socpeopleassigned = array(); // Array of contact ids
+    /**
+     * @var int Transparency (ical standard). Used to say if people assigned to event are busy or not by event. 0=available, 1=busy, 2=busy (refused events)
+     */
+    public $transparency;
 
-    public $otherassigned = array(); // Array of other contact emails (not user, not contact)
+    /**
+     * @var int (0 By default)
+     */
+    public $priority;
 
+    /**
+     * @var int[] Array of user ids
+     */
+    public $userassigned = array();
 
-	/**
-     * Object user of owner
-     * @var User
+    /**
+     * @var int Id of user owner = fk_user_action into table
+     */
+    public $userownerid;
+
+    /**
+     * @var int Id of user done (deprecated)
+     * @deprecated
+     */
+    public $userdoneid;
+
+    /**
+     * @var int[] Array of contact ids
+     */
+    public $socpeopleassigned = array();
+
+    /**
+     * @var int[] Array of other contact emails (not user, not contact)
+     */
+    public $otherassigned = array();
+
+
+    /**
+     * @var User Object user of owner
      * @deprecated
      * @see userownerid
      */
     public $usertodo;
 
     /**
-     * Object user that did action
-     * @var User
+     * @var User Object user that did action
      * @deprecated
      * @see userdoneid
      */
     public $userdone;
 
+    /**
+     * @var int thirdparty id linked to action
+     */
     public $socid;
+
+    /**
+     * @var int socpeople id linked to action
+     */
     public $contactid;
 
     /**
-     * Company linked to action (optional)
-     * @var Societe|null
+     * @var Societe|null Company linked to action (optional)
      * @deprecated
      * @see socid
      */
     public $societe;
 
     /**
-     * Contact linked to action (optional)
-     * @var Contact|null
+     * @var Contact|null Contact linked to action (optional)
      * @deprecated
      * @see contactid
      */
     public $contact;
 
     // Properties for links to other objects
+    /**
+     * @var int Id of linked object
+     */
     public $fk_element;    // Id of record
-    public $elementid;    // Id of record alternative for API
-    public $elementtype;   // Type of record. This if property ->element of object linked to.
 
-    // Ical
+    /**
+     * @var int Id of record alternative for API
+     */
+    public $elementid;
+
+    /**
+     * @var string Type of record. This if property ->element of object linked to.
+     */
+    public $elementtype;
+
+    /**
+     * @var string Ical name
+     */
     public $icalname;
+
+    /**
+     * @var string Ical color
+     */
     public $icalcolor;
 
+    /**
+     * @var array Actions
+     */
     public $actions=array();
 
-    // Fields for emails
+    /**
+     * @var string Email msgid
+     */
     public $email_msgid;
+
+    /**
+     * @var string Email from
+     */
     public $email_from;
+
+    /**
+     * @var string Email sender
+     */
     public $email_sender;
+
+    /**
+     * @var string Email to
+     */
     public $email_to;
+
+    /**
+     * @var string Email tocc
+     */
     public $email_tocc;
+    /**
+     * @var string Email tobcc
+     */
     public $email_tobcc;
+
+    /**
+     * @var string Email subject
+     */
     public $email_subject;
+
+    /**
+     * @var string Email errors to
+     */
     public $errors_to;
 
 
     /**
      *      Constructor
      *
-     *      @param		DoliDB		$db      Database handler
+     *      @param      DoliDB		$db      Database handler
      */
     public function __construct(DoliDB $db)
     {
@@ -484,9 +580,9 @@ class ActionComm extends CommonObject
             	return $this->id;
             }
             else
-           {
-	           	$this->db->rollback();
-	           	return -1;
+            {
+                $this->db->rollback();
+                return -1;
             }
         }
         else
@@ -1043,7 +1139,7 @@ class ActionComm extends CommonObject
             return $resarray;
         }
         else
-       {
+        {
             return $db->lasterror();
         }
     }
@@ -1067,13 +1163,13 @@ class ActionComm extends CommonObject
     		$sql = "SELECT count(a.id) as nb";
     	}
     	$sql.= " FROM ".MAIN_DB_PREFIX."actioncomm as a";
-    	if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
+    	if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON a.fk_soc = sc.fk_soc";
     	$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid";
     	$sql.= " WHERE 1 = 1";
     	if(empty($load_state_board)) $sql.= " AND a.percent >= 0 AND a.percent < 100";
     	$sql.= " AND a.entity IN (".getEntity('agenda').")";
-    	if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
-    	if ($user->societe_id) $sql.=" AND a.fk_soc = ".$user->societe_id;
+    	if (! $user->rights->societe->client->voir && ! $user->socid) $sql.= " AND (a.fk_soc IS NULL OR sc.fk_user = " .$user->id . ")";
+    	if ($user->socid) $sql.=" AND a.fk_soc = ".$user->socid;
     	if (! $user->rights->agenda->allactions->read) $sql.= " AND (a.fk_user_author = ".$user->id . " OR a.fk_user_action = ".$user->id . " OR a.fk_user_done = ".$user->id . ")";
 
     	$resql=$this->db->query($sql);
@@ -1344,7 +1440,6 @@ class ActionComm extends CommonObject
 			$linkstart = '';
 			$linkend = '';
 		}
-		//print 'rrr'.$this->libelle.'rrr'.$this->label.'rrr'.$withpicto;
 
         if ($withpicto == 2)
         {
@@ -1463,7 +1558,7 @@ class ActionComm extends CommonObject
             $sql.= " a.priority, a.fulldayevent, a.location, a.punctual, a.transparency,";
             $sql.= " u.firstname, u.lastname, u.email,";
             $sql.= " s.nom as socname,";
-            $sql.= " c.id as type_id, c.code as type_code, c.libelle";
+            $sql.= " c.id as type_id, c.code as type_code, c.libelle as type_label";
             $sql.= " FROM (".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."actioncomm as a)";
             $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on u.rowid = a.fk_user_author";	// Link to get author of event for export
             $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on s.rowid = a.fk_soc";
@@ -1568,7 +1663,7 @@ class ActionComm extends CommonObject
                     $event['location']=$obj->location;
                     $event['transparency']=(($obj->transparency > 0)?'OPAQUE':'TRANSPARENT');		// OPAQUE (busy) or TRANSPARENT (not busy)
                     $event['punctual']=$obj->punctual;
-                    $event['category']=$obj->libelle;	// libelle type action
+                    $event['category']=$obj->type_label;
                     $event['email']=$obj->email;
 					// Define $urlwithroot
 					$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
@@ -1579,6 +1674,22 @@ class ActionComm extends CommonObject
                     $event['created']=$this->db->jdate($obj->datec)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600));
                     $event['modified']=$this->db->jdate($obj->datem)-(empty($conf->global->AGENDA_EXPORT_FIX_TZ)?0:($conf->global->AGENDA_EXPORT_FIX_TZ*3600));
 
+                    // TODO: find a way to call "$this->fetch_userassigned();" without override "$this" properties
+                    $this->id = $obj->id;
+                    $this->fetch_userassigned();
+
+                    $assignedUserArray = array();
+
+                    foreach($this->userassigned as $key => $value)
+                    {
+                        $assignedUser = new User($this->db);
+                        $assignedUser->fetch($value['id']);
+
+                        $assignedUserArray[$key]=$assignedUser;
+                    }
+
+                    $event['assignedUsers']=$assignedUserArray;
+
                     if ($qualified && $datestart)
                     {
                         $eventarray[]=$event;

+ 9 - 0
htdocs/comm/action/class/api_agendaevents.class.php

@@ -338,6 +338,7 @@ class AgendaEvents extends DolibarrApi
         // phpcs:enable
         $object = parent::_cleanObjectDatas($object);
 
+        unset($object->note);		// alreaydy into note_private
         unset($object->usermod);
         unset($object->libelle);
         unset($object->context);
@@ -350,6 +351,11 @@ class AgendaEvents extends DolibarrApi
         unset($object->origin_id);
         unset($object->ref_ext);
         unset($object->statut);
+        unset($object->state_code);
+        unset($object->state_id);
+        unset($object->state);
+        unset($object->region);
+        unset($object->region_code);
         unset($object->country);
         unset($object->country_id);
         unset($object->country_code);
@@ -378,6 +384,9 @@ class AgendaEvents extends DolibarrApi
         unset($object->contact);
         unset($object->societe);
 
+        unset($object->actions);
+        unset($object->lines);
+
         return $object;
     }
 }

+ 1 - 1
htdocs/comm/action/class/ical.class.php

@@ -379,7 +379,7 @@ class ICal
             return $temp;
         }
         else
-       {
+        {
             return false;
         }
     }

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

@@ -45,8 +45,8 @@ $confirm = GETPOST('confirm', 'alpha');
 
 // Security check
 $socid = GETPOST('socid', 'int');
-if ($user->societe_id) $socid=$user->societe_id;
-if ($user->societe_id > 0)
+if ($user->socid) $socid=$user->socid;
+if ($user->socid > 0)
 {
 	unset($_GET["action"]);
 	$action='';
@@ -159,7 +159,7 @@ if ($object->id > 0)
 	}
 	$morehtmlref.='</div>';
 
-	dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
+	dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref);
 
 	print '<div class="fichecenter">';
 

+ 32 - 19
htdocs/comm/action/index.php

@@ -67,7 +67,7 @@ if (! $sortfield) $sortfield="a.datec";
 
 // Security check
 $socid = GETPOST("search_socid", "int")?GETPOST("search_socid", "int"):GETPOST("socid", "int");
-if ($user->societe_id) $socid=$user->societe_id;
+if ($user->socid) $socid=$user->socid;
 $result = restrictedArea($user, 'agenda', 0, '', 'myactions');
 if ($socid < 0) $socid='';
 
@@ -519,14 +519,14 @@ if (! empty($actioncode))
         elseif ($actioncode == 'AC_ALL_AUTO') $sql.= " AND ca.type = 'systemauto'";
         else
         {
-		if (is_array($actioncode))
-		{
+            if (is_array($actioncode))
+            {
 	        	$sql.=" AND ca.code IN ('".implode("','", $actioncode)."')";
-		}
-		else
-		{
+            }
+            else
+            {
 	        	$sql.=" AND ca.code IN ('".implode("','", explode(',', $actioncode))."')";
-		}
+            }
         }
     }
 }
@@ -614,7 +614,7 @@ if ($resql)
         $event->type_label=$obj->type_label;
         $event->type_color=$obj->type_color;
 
-        $event->libelle=$obj->label;
+        $event->libelle=$obj->label;				// deprecated
         $event->label=$obj->label;
         $event->percentage=$obj->percent;
         $event->authorid=$obj->fk_user_author;		// user id of creator
@@ -720,7 +720,7 @@ if ($showbirthday)
             $event->datep=dol_mktime(0, 0, 0, $datearray['mon'], $datearray['mday'], $year, true);    // For full day events, date are also GMT but they wont but converted during output
             $event->datef=$event->datep;
             $event->type_code='BIRTHDAY';
-            $event->libelle=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
+            $event->label=$langs->trans("Birthday").' '.dolGetFirstLastname($obj->firstname, $obj->lastname);
             $event->percentage=100;
             $event->fulldayevent=1;
 
@@ -949,9 +949,9 @@ if (count($listofextcals))
                     $event->datef=$dateend+$usertime;
                     $event->type_code="ICALEVENT";
 
-                    if($icalevent['SUMMARY']) $event->libelle=$icalevent['SUMMARY'];
-                    elseif($icalevent['DESCRIPTION']) $event->libelle=dol_nl2br($icalevent['DESCRIPTION'], 1);
-                    else $event->libelle = $langs->trans("ExtSiteNoLabel");
+                    if($icalevent['SUMMARY']) $event->label=$icalevent['SUMMARY'];
+                    elseif($icalevent['DESCRIPTION']) $event->label=dol_nl2br($icalevent['DESCRIPTION'], 1);
+                    else $event->label = $langs->trans("ExtSiteNoLabel");
 
                     $event->date_start_in_calendar=$event->datep;
 
@@ -1554,7 +1554,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa
 
                         // Show title
                         $titletoshow = $daterange;
-                        $titletoshow.=($titletoshow?' ':'').$event->libelle;
+                        $titletoshow.=($titletoshow?' ':'').($event->label?$event->label:$event->libelle);
 
                         if ($event->type_code == 'ICALEVENT') print $titletoshow;
                         else
@@ -1729,11 +1729,24 @@ function dol_color_minus($color, $minus, $minusunit = 16)
  */
 function sort_events_by_date($a, $b)
 {
-	if($a->datep != $b->datep)
-	{
-		return $a->datep - $b->datep;
-	}
+    if($a->datep != $b->datep)
+    {
+        return $a->datep - $b->datep;
+    }
+
+    // If both events have the same start time, longest first
+
+    if(! is_numeric($b->datef))
+    {
+        // when event B have no end timestamp, event B should sort be before event A (All day events on top)
+        return 1;
+    }
+
+    if(! is_numeric($a->datef))
+    {
+        // when event A have no end timestamp , event A should sort be before event B (All day events on top)
+        return -1;
+    }
 
-	// If both events have the same start time, longest first
-	return $b->datef - $a->datef;
+    return $b->datef - $a->datef;
 }

+ 4 - 4
htdocs/comm/action/info.php

@@ -39,10 +39,10 @@ $langs->load("commercial");
 $id = GETPOST('id', 'int');
 
 // Security check
-if ($user->societe_id > 0)
+if ($user->socid > 0)
 {
-  $action = '';
-  $socid = $user->societe_id;
+    $action = '';
+    $socid = $user->socid;
 }
 
 $result = restrictedArea($user, 'agenda', $id, 'actioncomm&societe', 'myactions|allactions', 'fk_soc', 'id');
@@ -102,7 +102,7 @@ if (! empty($conf->projet->enabled))
 }
 $morehtmlref.='</div>';
 
-dol_banner_tab($object, 'id', $linkback, ($user->societe_id?0:1), 'id', 'ref', $morehtmlref);
+dol_banner_tab($object, 'id', $linkback, ($user->socid?0:1), 'id', 'ref', $morehtmlref);
 
 print '<div class="underbanner clearboth"></div>';
 

部分文件因为文件数量过多而无法显示